Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: Source/platform/fonts/shaping/HarfBuzzFace.cpp

Issue 1316843005: Round glyph width and bounds if !SkPaint.isSubpixelText() in complex path (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Split SimpleFontData change to a separate CL Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/complex-path-with-no-subpixel-fonts-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint , hb_position_t* width, hb_glyph_extents_t* extents) 139 static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint , hb_position_t* width, hb_glyph_extents_t* extents)
140 { 140 {
141 ASSERT(codepoint <= 0xFFFF); 141 ASSERT(codepoint <= 0xFFFF);
142 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); 142 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
143 143
144 SkScalar skWidth; 144 SkScalar skWidth;
145 SkRect skBounds; 145 SkRect skBounds;
146 uint16_t glyph = codepoint; 146 uint16_t glyph = codepoint;
147 147
148 paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds); 148 paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds);
149 if (width) 149 if (width) {
150 if (!paint->isSubpixelText())
151 skWidth = SkScalarRoundToInt(skWidth);
150 *width = SkiaScalarToHarfBuzzPosition(skWidth); 152 *width = SkiaScalarToHarfBuzzPosition(skWidth);
153 }
151 if (extents) { 154 if (extents) {
155 if (!paint->isSubpixelText()) {
eae 2015/09/01 16:24:38 Would you mind adding a comment here as to why we'
156 SkIRect ir;
157 skBounds.roundOut(&ir);
158 skBounds.set(ir);
159 }
152 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up. 160 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up.
153 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); 161 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft);
154 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); 162 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop);
155 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); 163 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width());
156 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); 164 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height());
157 } 165 }
158 } 166 }
159 167
160 #if !defined(HB_VERSION_ATLEAST) 168 #if !defined(HB_VERSION_ATLEAST)
161 #define HB_VERSION_ATLEAST(major, minor, micro) 0 169 #define HB_VERSION_ATLEAST(major, minor, micro) 0
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 hb_font_t* font = hb_font_create(m_face); 345 hb_font_t* font = hb_font_create(m_face);
338 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB uzzFontData); 346 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB uzzFontData);
339 float size = m_platformData->size(); 347 float size = m_platformData->size();
340 int scale = SkiaScalarToHarfBuzzPosition(size); 348 int scale = SkiaScalarToHarfBuzzPosition(size);
341 hb_font_set_scale(font, scale, scale); 349 hb_font_set_scale(font, scale, scale);
342 hb_font_make_immutable(font); 350 hb_font_make_immutable(font);
343 return font; 351 return font;
344 } 352 }
345 353
346 } // namespace blink 354 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/complex-path-with-no-subpixel-fonts-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698