- Revision
- 183153
- Author
- [email protected]
- Date
- 2015-04-22 16:22:50 -0700 (Wed, 22 Apr 2015)
Log Message
[iOS] Caret does not line up with text when using the system font
https://bugs.webkit.org/show_bug.cgi?id=144076
<rdar://problem/20578301>
Reviewed by Enrica Casucci.
Determining caret locations often uses the complex text codepath, which means
the complex text codepath must know about custom tracking.
This regression is due to r182512.
Note that this patch is a short-term solution until I can solve the bigger issue of
having two CTFontRefs and using each in their proper place.
No new tests because there is no way to robustly test the system font.
* platform/graphics/Font.h:
(WebCore::Font::hasCustomTracking):
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::canUseFastGlyphAdvanceGetter):
(WebCore::Font::platformWidthForGlyph):
(WebCore::hasCustomTracking): Deleted.
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::Font::getCFStringAttributes):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183152 => 183153)
--- trunk/Source/WebCore/ChangeLog 2015-04-22 23:19:22 UTC (rev 183152)
+++ trunk/Source/WebCore/ChangeLog 2015-04-22 23:22:50 UTC (rev 183153)
@@ -1,3 +1,30 @@
+2015-04-22 Myles C. Maxfield <[email protected]>
+
+ [iOS] Caret does not line up with text when using the system font
+ https://bugs.webkit.org/show_bug.cgi?id=144076
+ <rdar://problem/20578301>
+
+ Reviewed by Enrica Casucci.
+
+ Determining caret locations often uses the complex text codepath, which means
+ the complex text codepath must know about custom tracking.
+
+ This regression is due to r182512.
+
+ Note that this patch is a short-term solution until I can solve the bigger issue of
+ having two CTFontRefs and using each in their proper place.
+
+ No new tests because there is no way to robustly test the system font.
+
+ * platform/graphics/Font.h:
+ (WebCore::Font::hasCustomTracking):
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::canUseFastGlyphAdvanceGetter):
+ (WebCore::Font::platformWidthForGlyph):
+ (WebCore::hasCustomTracking): Deleted.
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::getCFStringAttributes):
+
2015-04-22 Brent Fulgham <[email protected]>
Context menu doesn't account for selection semantics
Modified: trunk/Source/WebCore/platform/graphics/Font.h (183152 => 183153)
--- trunk/Source/WebCore/platform/graphics/Font.h 2015-04-22 23:19:22 UTC (rev 183152)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2015-04-22 23:22:50 UTC (rev 183153)
@@ -195,6 +195,7 @@
#endif
#if PLATFORM(COCOA)
CFDictionaryRef getCFStringAttributes(TypesettingFeatures, FontOrientation) const;
+ bool hasCustomTracking() const { return isSystemFont(); }
#endif
#if PLATFORM(COCOA) || USE(HARFBUZZ)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (183152 => 183153)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-04-22 23:19:22 UTC (rev 183152)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-04-22 23:22:50 UTC (rev 183153)
@@ -455,11 +455,6 @@
#endif
}
-static inline bool hasCustomTracking(const Font& font)
-{
- return font.isSystemFont();
-}
-
static inline bool isEmoji(const FontPlatformData& platformData)
{
#if PLATFORM(IOS)
@@ -474,7 +469,7 @@
{
const FontPlatformData& platformData = font.platformData();
// Fast getter doesn't take custom tracking into account
- if (hasCustomTracking(font))
+ if (font.hasCustomTracking())
return false;
// Fast getter doesn't work for emoji
if (isEmoji(platformData))
@@ -501,13 +496,10 @@
advance.width = 0;
}
} else if (!populatedAdvance) {
- // m_platformData.font() returns the original font that was passed into the FontPlatformData constructor. In the case of fonts that have custom tracking,
+ // m_platformData.font() returns the original font that was passed into the FontPlatformData constructor. In the case of fonts that have custom tracking,
// the custom tracking does not survive the transformation to either m_platformData.cgFont() nor m_platformData.ctFont(), so we must use the original
// font() that was passed in. However, for web fonts, m_platformData.font() is null, so we must use m_platformData.ctFont() for those cases.
- if (hasCustomTracking(*this))
- CTFontGetAdvancesForGlyphs(m_platformData.font(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
- else
- CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
+ CTFontGetAdvancesForGlyphs(hasCustomTracking() ? m_platformData.font() : m_platformData.ctFont(), horizontal ? kCTFontOrientationHorizontal : kCTFontOrientationVertical, &glyph, &advance, 1);
}
return advance.width + m_syntheticBoldOffset;
Modified: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp (183152 => 183153)
--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp 2015-04-22 23:19:22 UTC (rev 183152)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp 2015-04-22 23:22:50 UTC (rev 183153)
@@ -46,7 +46,10 @@
attributesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CFMutableDictionaryRef mutableAttributes = (CFMutableDictionaryRef)attributesDictionary.get();
- CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());
+ // m_platformData.font() returns the original font that was passed into the FontPlatformData constructor. In the case of fonts that have custom tracking,
+ // the custom tracking does not survive the transformation to either m_platformData.cgFont() nor m_platformData.ctFont(), so we must use the original
+ // font() that was passed in. However, for web fonts, m_platformData.font() is null, so we must use m_platformData.ctFont() for those cases.
+ CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, hasCustomTracking() ? platformData().font() : platformData().ctFont());
if (!(typesettingFeatures & Kerning)) {
const float zero = 0;