aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-08-10 09:24:31 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-10 09:24:31 -0700
commitd6b99cc6b84b3ec864221cbe9945d203bd9eb072 (patch)
tree8745b53beb7060133cb1f4050087536d6efc5b08 /src/core
parent9ff6425ce4a8deeb23b1c706b340d7d4e09f3f9b (diff)
[TextBlob] Fall back to TightRunBounds when the font bounds are empty
Empty font bounds are likely an indication of a font bug. As a best effort, we can use TightRunBounds in this easily detectable case. BUG=507022 R=reed@google.com,bungeman@google.com Review URL: https://codereview.chromium.org/1284693002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkTextBlob.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index d1a77e74f7..4ba7df8a7d 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();