Chromium Code Reviews| Index: Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp |
| diff --git a/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp b/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp |
| index 6a89201f7ecd4b705889b84d74bc73286b2b883e..766a4b79313add34b5761ab987e8b8d7484de435 100644 |
| --- a/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp |
| +++ b/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp |
| @@ -33,6 +33,7 @@ |
| #include <unicode/normlzr.h> |
| #include "SkPaint.h" |
| +#include "SkPath.h" |
| #include "SkTypeface.h" |
| #include "SkTypes.h" |
| #include "core/platform/graphics/FloatRect.h" |
| @@ -213,6 +214,27 @@ void SimpleFontData::determinePitch() |
| m_treatAsFixedPitch = platformData().isFixedPitch(); |
| } |
| +static inline void getSkiaBoundsForGlyph(SkPaint& paint, Glyph glyph, SkRect& bounds) |
| +{ |
| + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| + |
| + SkPath path; |
| + paint.getTextPath(&glyph, sizeof(glyph), 0, 0, &path); |
| + bounds = path.getBounds(); |
| + |
| + // FIXME(eae): getBounds currently returns an empty rect for bitmap |
| + // fonts so fall back on the old behavior. Once fixed in Skia this |
| + // fallback can go away. |
|
leviw_travelin_and_unemployed
2013/09/30 22:47:00
Is there a crbug for this? If not please file.
|
| + if (bounds.isEmpty()) |
| + paint.measureText(&glyph, 2, &bounds); |
| + |
| + if (!paint.isSubpixelText()) { |
| + SkIRect ir; |
| + bounds.round(&ir); |
| + bounds.set(ir); |
| + } |
| +} |
| + |
| FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const |
| { |
| if (!m_platformData.size()) |
| @@ -221,17 +243,10 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const |
| SkASSERT(sizeof(glyph) == 2); // compile-time assert |
| SkPaint paint; |
| - |
| m_platformData.setupPaint(&paint); |
| - paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| SkRect bounds; |
| - paint.measureText(&glyph, 2, &bounds); |
| - if (!paint.isSubpixelText()) { |
| - SkIRect ir; |
| - bounds.round(&ir); |
| - bounds.set(ir); |
| - } |
| + getSkiaBoundsForGlyph(paint, glyph, bounds); |
| return FloatRect(bounds); |
| } |