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

Unified Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 986493002: Simplify text emphasis painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 5 years, 9 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 | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | Source/platform/fonts/shaping/Shaper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp
diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
index deb02afd8292bb8aa21aefb4f018f1b47794ab3b..52a0a739811e07785df2019f2e3a65beb138ed64 100644
--- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
+++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
@@ -347,8 +347,9 @@ float HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset)
}
-HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, ForTextEmphasisOrNot forTextEmphasis, HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds)
- : Shaper(font, run, forTextEmphasis, fallbackFonts, bounds)
+HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, const GlyphData* emphasisData,
+ HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds)
+ : Shaper(font, run, emphasisData, fallbackFonts, bounds)
, m_wordSpacingAdjustment(font->fontDescription().wordSpacing())
, m_letterSpacing(font->fontDescription().letterSpacing())
, m_expansionOpportunityCount(0)
@@ -1163,9 +1164,6 @@ float HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer,
float HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, HarfBuzzRun* currentRun, float initialAdvance)
{
- // FIXME: Instead of generating a synthetic GlyphBuffer here which is then used by the
- // drawEmphasisMarks method of FontFastPath, we should roll our own emphasis mark drawing function.
-
float* advances = currentRun->advances();
unsigned numGlyphs = currentRun->numGlyphs();
uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
@@ -1214,9 +1212,9 @@ float HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, H
float glyphAdvanceX = clusterAdvance / graphemesInCluster;
for (unsigned j = 0; j < graphemesInCluster; ++j) {
// Do not put emphasis marks on space, separator, and control characters.
- Glyph glyphToAdd = Character::canReceiveTextEmphasis(m_run[currentCharacterIndex]) ? 1 : 0;
- // The emphasis code expects mid-glyph offsets.
- glyphBuffer->add(glyphToAdd, currentRun->fontData(), advanceSoFar + glyphAdvanceX / 2);
+ if (Character::canReceiveTextEmphasis(m_run[currentCharacterIndex]))
+ addEmphasisMark(glyphBuffer, advanceSoFar + glyphAdvanceX / 2);
+
advanceSoFar += glyphAdvanceX;
}
clusterStart = clusterEnd;
@@ -1238,7 +1236,7 @@ bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
// Skip runs that only contain control characters.
if (!currentRun->numGlyphs())
continue;
- advanceSoFar += (m_forTextEmphasis == ForTextEmphasis)
+ advanceSoFar += forTextEmphasis()
? fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun, advanceSoFar)
: fillGlyphBufferFromHarfBuzzRun(glyphBuffer, currentRun, advanceSoFar);
}
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | Source/platform/fonts/shaping/Shaper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698