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

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

Issue 676523003: Offset-only GlyphBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review nit Created 6 years, 2 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
Index: Source/platform/fonts/shaping/SimpleShaper.cpp
diff --git a/Source/platform/fonts/shaping/SimpleShaper.cpp b/Source/platform/fonts/shaping/SimpleShaper.cpp
index ee12b709cfb8020bdb73e5735468ba8620f7a145..f4dce5d62f90c7a548ed231ada8e19ae7b733152 100644
--- a/Source/platform/fonts/shaping/SimpleShaper.cpp
+++ b/Source/platform/fonts/shaping/SimpleShaper.cpp
@@ -98,8 +98,7 @@ void SimpleShaper::cacheFallbackFont(const SimpleFontData* fontData,
m_fallbackFonts->add(fontData);
}
-float SimpleShaper::adjustSpacing(float width, const CharacterData& charData,
- const SimpleFontData& fontData, GlyphBuffer* glyphBuffer)
+float SimpleShaper::adjustSpacing(float width, const CharacterData& charData)
{
// Account for letter-spacing.
if (width)
@@ -112,18 +111,7 @@ float SimpleShaper::adjustSpacing(float width, const CharacterData& charData,
if (!treatAsSpace && !m_isAfterExpansion) {
// Take the expansion opportunity before this ideograph.
m_expansion -= m_expansionPerOpportunity;
- float expansionAtThisOpportunity = m_expansionPerOpportunity;
- m_runWidthSoFar += expansionAtThisOpportunity;
- if (glyphBuffer) {
- if (glyphBuffer->isEmpty()) {
- if (m_forTextEmphasis)
- glyphBuffer->add(fontData.zeroWidthSpaceGlyph(), &fontData, m_expansionPerOpportunity);
- else
- glyphBuffer->add(fontData.spaceGlyph(), &fontData, expansionAtThisOpportunity);
- } else {
- glyphBuffer->expandLastAdvance(expansionAtThisOpportunity);
- }
- }
+ m_runWidthSoFar += m_expansionPerOpportunity;
}
if (m_run.allowsTrailingExpansion()
|| (m_run.ltr() && charData.characterOffset + charData.clusterLength < static_cast<size_t>(m_run.length()))
@@ -202,20 +190,26 @@ unsigned SimpleShaper::advanceInternal(TextIterator& textIterator, GlyphBuffer*
}
if (hasExtraSpacing && !spaceUsedAsZeroWidthSpace)
- width = adjustSpacing(width, charData, *fontData, glyphBuffer);
+ width = adjustSpacing(width, charData);
if (m_bounds)
updateGlyphBounds(glyphData, width, !charData.characterOffset);
- if (m_forTextEmphasis && !Character::canReceiveTextEmphasis(charData.character))
- glyph = 0;
+ if (m_forTextEmphasis) {
+ if (!Character::canReceiveTextEmphasis(charData.character))
+ glyph = 0;
+
+ // The emphasis code expects mid-glyph offsets.
+ width /= 2;
+ m_runWidthSoFar += width;
+ }
+
+ if (glyphBuffer)
+ glyphBuffer->add(glyph, fontData, m_runWidthSoFar);
// Advance past the character we just dealt with.
textIterator.advance(charData.clusterLength);
m_runWidthSoFar += width;
-
- if (glyphBuffer)
- glyphBuffer->add(glyph, fontData, width);
}
unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCharacter;
« Source/platform/fonts/GlyphBuffer.h ('K') | « Source/platform/fonts/shaping/SimpleShaper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698