Changeset 182898 in webkit
- Timestamp:
- Apr 16, 2015, 11:47:53 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/cocoa/FontCascadeCocoa.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r182894 r182898 1 2015-04-15 Simon Fraser <simon.fraser@apple.com> 2 3 Pull emoji-position adjustment code into its own function 4 https://bugs.webkit.org/show_bug.cgi?id=143592 5 6 Reviewed by Myles C. Maxfield. 7 8 First step to cleaning up FontCascade::drawGlyphs(). Pull iOS-only code related to 9 emoji positioning into its own function. 10 11 * platform/graphics/cocoa/FontCascadeCocoa.mm: 12 (WebCore::pointAdjustedForEmoji): 13 (WebCore::FontCascade::drawGlyphs): 14 1 15 2015-04-16 Myles C. Maxfield <mmaxfield@apple.com> 2 16 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
r182824 r182898 224 224 #endif 225 225 226 static FloatPoint pointAdjustedForEmoji(const FontPlatformData& platformData, FloatPoint point) 227 { 228 #if PLATFORM(IOS) 229 if (!platformData.m_isEmoji) 230 return point; 231 232 // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned. 233 point.setY(ceilf(point.y())); 234 235 // Emoji glyphs snap to the CSS pixel grid. 236 point.setX(floorf(point.x())); 237 238 // Emoji glyphs are offset one CSS pixel to the right. 239 point.move(1, 0); 240 241 // Emoji glyphs are offset vertically based on font size. 242 float fontSize = platformData.size(); 243 float y = point.y(); 244 if (fontSize <= 15) { 245 // Undo Core Text's y adjustment. 246 static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1; 247 point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2)); 248 } else { 249 if (fontSize < 26) 250 y -= .35f * fontSize - 10; 251 252 // Undo Core Text's y adjustment. 253 static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2; 254 point.setY(floorf(y - yAdjustment)); 255 } 256 #else 257 UNUSED_PARAM(platformData); 258 #endif 259 return point; 260 } 261 226 262 void FontCascade::drawGlyphs(GraphicsContext* context, const Font* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const 227 263 { … … 298 334 299 335 bool useLetterpressEffect = shouldUseLetterpressEffect(*context); 300 FloatPoint point = anchorPoint; 336 FloatPoint point = pointAdjustedForEmoji(platformData, anchorPoint); 337 301 338 #if PLATFORM(IOS) 302 339 float fontSize = platformData.size(); 303 340 CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize); 304 if (platformData.m_isEmoji) {305 // Mimic the positioining of non-bitmap glyphs, which are not subpixel-positioned.306 point.setY(ceilf(point.y()));307 308 // Emoji glyphs snap to the CSS pixel grid.309 point.setX(floorf(point.x()));310 311 // Emoji glyphs are offset one CSS pixel to the right.312 point.move(1, 0);313 314 // Emoji glyphs are offset vertically based on font size.315 float y = point.y();316 if (fontSize <= 15) {317 // Undo Core Text's y adjustment.318 static float yAdjustmentFactor = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? .19 : .1;319 point.setY(floorf(y - yAdjustmentFactor * (fontSize + 2) + 2));320 } else {321 if (fontSize < 26)322 y -= .35f * fontSize - 10;323 324 // Undo Core Text's y adjustment.325 static float yAdjustment = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_6_0) ? 3.8 : 2;326 point.setY(floorf(y - yAdjustment));327 }328 }329 341 #else 330 342 CGAffineTransform matrix = CGAffineTransformIdentity;
Note:
See TracChangeset
for help on using the changeset viewer.