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

Unified Diff: Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp

Issue 25045010: Change SimpleFontData::platformBoundsForGlyph to use getTextPath (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/linux/fast/text/emphasis-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « LayoutTests/platform/linux/fast/text/emphasis-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698