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

Unified Diff: src/core/SkTextBlob.cpp

Issue 1284693002: [TextBlob] Fall back to TightRunBounds when the font bounds are empty (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTextBlob.cpp
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index d1a77e74f7efdcc831a6768f8314abc426e9e4e1..4ba7df8a7da222f832f90eb4dd1d741181015e7a 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -382,7 +382,16 @@ SkRect SkTextBlobBuilder::ConservativeRunBounds(const SkTextBlob::RunRecord& run
SkASSERT(SkTextBlob::kFull_Positioning == run.positioning() ||
SkTextBlob::kHorizontal_Positioning == run.positioning());
- // First, compute the glyph position bbox.
+ SkPaint paint;
+ run.font().applyToPaint(&paint);
+ const SkRect fontBounds = paint.getFontBounds();
+ if (fontBounds.isEmpty()) {
+ // Empty font bounds are likely a font bug. TightBounds has a better chance of
+ // producing useful results in this case.
+ return TightRunBounds(run);
+ }
+
+ // Compute the glyph position bbox.
SkRect bounds;
switch (run.positioning()) {
case SkTextBlob::kHorizontal_Positioning: {
@@ -410,9 +419,6 @@ SkRect SkTextBlobBuilder::ConservativeRunBounds(const SkTextBlob::RunRecord& run
}
// Expand by typeface glyph bounds.
- SkPaint paint;
- run.font().applyToPaint(&paint);
- const SkRect fontBounds = paint.getFontBounds();
bounds.fLeft += fontBounds.left();
bounds.fTop += fontBounds.top();
bounds.fRight += fontBounds.right();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698