Title: [182898] trunk/Source/WebCore
- Revision
- 182898
- Author
- simon.fra...@apple.com
- Date
- 2015-04-16 11:47:53 -0700 (Thu, 16 Apr 2015)
Log Message
Pull emoji-position adjustment code into its own function
https://bugs.webkit.org/show_bug.cgi?id=143592
Reviewed by Myles C. Maxfield.
First step to cleaning up FontCascade::drawGlyphs(). Pull iOS-only code related to
emoji positioning into its own function.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::pointAdjustedForEmoji):
(WebCore::FontCascade::drawGlyphs):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (182897 => 182898)
--- trunk/Source/WebCore/ChangeLog 2015-04-16 18:31:00 UTC (rev 182897)
+++ trunk/Source/WebCore/ChangeLog 2015-04-16 18:47:53 UTC (rev 182898)
@@ -1,3 +1,17 @@
+2015-04-15 Simon Fraser <simon.fra...@apple.com>
+
+ Pull emoji-position adjustment code into its own function
+ https://bugs.webkit.org/show_bug.cgi?id=143592
+
+ Reviewed by Myles C. Maxfield.
+
+ First step to cleaning up FontCascade::drawGlyphs(). Pull iOS-only code related to
+ emoji positioning into its own function.
+
+ * platform/graphics/cocoa/FontCascadeCocoa.mm:
+ (WebCore::pointAdjustedForEmoji):
+ (WebCore::FontCascade::drawGlyphs):
+
2015-04-16 Myles C. Maxfield <mmaxfi...@apple.com>
[iOS] Delete hardcoded font fallback tables
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (182897 => 182898)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2015-04-16 18:31:00 UTC (rev 182897)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2015-04-16 18:47:53 UTC (rev 182898)
@@ -223,6 +223,42 @@
}
#endif
+static FloatPoint pointAdjustedForEmoji(const FontPlatformData& platformData, FloatPoint point)
+{
+#if PLATFORM(IOS)
+ if (!platformData.m_isEmoji)
+ return point;
+
+ // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned.
+ point.setY(ceilf(point.y()));
+
+ // Emoji glyphs snap to the CSS pixel grid.
+ point.setX(floorf(point.x()));
+
+ // Emoji glyphs are offset one CSS pixel to the right.
+ point.move(1, 0);
+
+ // Emoji glyphs are offset vertically based on font size.
+ float fontSize = platformData.size();
+ float y = point.y();
+ if (fontSize <= 15) {
+ // Undo Core Text's y adjustment.
+ static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1;
+ point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2));
+ } else {
+ if (fontSize < 26)
+ y -= .35f * fontSize - 10;
+
+ // Undo Core Text's y adjustment.
+ static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2;
+ point.setY(floorf(y - yAdjustment));
+ }
+#else
+ UNUSED_PARAM(platformData);
+#endif
+ return point;
+}
+
void FontCascade::drawGlyphs(GraphicsContext* context, const Font* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
{
const FontPlatformData& platformData = font->platformData();
@@ -297,35 +333,11 @@
CGContextSetFont(cgContext, platformData.cgFont());
bool useLetterpressEffect = shouldUseLetterpressEffect(*context);
- FloatPoint point = anchorPoint;
+ FloatPoint point = pointAdjustedForEmoji(platformData, anchorPoint);
+
#if PLATFORM(IOS)
float fontSize = platformData.size();
CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize);
- if (platformData.m_isEmoji) {
- // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned.
- point.setY(ceilf(point.y()));
-
- // Emoji glyphs snap to the CSS pixel grid.
- point.setX(floorf(point.x()));
-
- // Emoji glyphs are offset one CSS pixel to the right.
- point.move(1, 0);
-
- // Emoji glyphs are offset vertically based on font size.
- float y = point.y();
- if (fontSize <= 15) {
- // Undo Core Text's y adjustment.
- static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1;
- point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2));
- } else {
- if (fontSize < 26)
- y -= .35f * fontSize - 10;
-
- // Undo Core Text's y adjustment.
- static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2;
- point.setY(floorf(y - yAdjustment));
- }
- }
#else
CGAffineTransform matrix = CGAffineTransformIdentity;
if (drawFont && !platformData.isColorBitmapFont())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes