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

Unified Diff: Source/platform/fonts/Font.cpp

Issue 778233002: TextBlob: Use deferred bounds if negative letter or word spacing exists. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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: Source/platform/fonts/Font.cpp
diff --git a/Source/platform/fonts/Font.cpp b/Source/platform/fonts/Font.cpp
index ba3f7245f074d19ea37819d58d269d39dd731aee..1f31b6d0252201f6ffe36113f16d1595182a77a0 100644
--- a/Source/platform/fonts/Font.cpp
+++ b/Source/platform/fonts/Font.cpp
@@ -259,6 +259,12 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo
return result;
}
+static bool requiresRecomputingBounds(const Font& font)
+{
+ const FontDescription& fontDescription = font.fontDescription();
+ return fontDescription.letterSpacing() < 0 || fontDescription.wordSpacing() < 0;
+}
+
PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatRect& bounds,
bool couldUseLCD) const
{
@@ -266,6 +272,9 @@ PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR
SkTextBlobBuilder builder;
SkRect skBounds = bounds;
+ // FIXME: Identify these cases earlier on and avoid using bounds that are
+ // not visually correct in other places.
+ const SkRect* skBoundsPtr = requiresRecomputingBounds(*this) ? nullptr : &skBounds;
bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets();
unsigned i = 0;
@@ -292,8 +301,8 @@ PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR
unsigned count = i - start;
const SkTextBlobBuilder::RunBuffer& buffer = hasVerticalOffsets
- ? builder.allocRunPos(paint, count, &skBounds)
- : builder.allocRunPosH(paint, count, 0, &skBounds);
+ ? builder.allocRunPos(paint, count, skBoundsPtr)
+ : builder.allocRunPosH(paint, count, 0, skBoundsPtr);
const uint16_t* glyphs = glyphBuffer.glyphs(start);
const float* offsets = glyphBuffer.offsets(start);
« 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