Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |