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

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

Issue 613193002: Avoid drawing emphasis marks over ellipsis glyphs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to not add in glyph buffer ellipsis character 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/harfbuzz/HarfBuzzShaper.cpp
diff --git a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
index 9869c5c081b9a9faa24b6a667c06ffe3bfe94d93..762674418c904c55c4d94dc5bbbd7241c2ed5de0 100644
--- a/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
+++ b/Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp
@@ -986,6 +986,8 @@ void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha
unsigned graphemesInCluster = 1;
float clusterAdvance = 0;
uint16_t clusterStart;
+ bool isRTL = m_run.rtl();
Dominik Röttsches 2014/11/14 10:10:47 I wouldn't create a redundant copy here.
Habib Virji 2014/11/24 11:52:31 Reason was it is used quite a lot below. Would rem
+ float glyphAdv = 0;
Dominik Röttsches 2014/11/14 10:10:47 Please do not use abbreviations in variable naming
Habib Virji 2014/11/24 11:52:30 Will update to initialAdvance.
// A "cluster" in this context means a cluster as it is used by HarfBuzz:
// The minimal group of characters and corresponding glyphs, that cannot be broken
@@ -995,23 +997,28 @@ void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha
// then linearly split the sum of corresponding glyph advances by the number of
// grapheme clusters in order to find positions for emphasis mark drawing.
- if (m_run.rtl())
- clusterStart = currentRun->startIndex() + currentRun->numCharacters();
- else
- clusterStart = currentRun->startIndex() + glyphToCharacterIndexes[0];
+ clusterStart = currentRun->startIndex() + (isRTL ? currentRun->numCharacters() : glyphToCharacterIndexes[0]);
Dominik Röttsches 2014/11/14 10:10:47 As far as I can see, this is functionally equivale
Habib Virji 2014/11/24 11:52:31 Agreed. The change was to ease in following code,
for (unsigned i = 0; i < numGlyphs; ++i) {
uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToCharacterIndexes[i];
bool isRunEnd = (i + 1 == numGlyphs);
- bool isClusterEnd = isRunEnd || (currentRun->startIndex() + glyphToCharacterIndexes[i + 1] != currentCharacterIndex);
- clusterAdvance += advances[i];
+ bool isClusterEnd = isRunEnd || (currentRun->startIndex() + glyphToCharacterIndexes[i + 1] != currentCharacterIndex);
+ if ((isRTL && currentCharacterIndex >= m_toIndex) || (!isRTL && currentCharacterIndex < m_fromIndex)) {
+ glyphAdv += advances[i];
+ isRTL ? --clusterStart : ++clusterStart;
+ continue;
+ }
+
+ if (glyphAdv) {
+ glyphBuffer->add(0, currentRun->fontData(), glyphAdv);
Dominik Röttsches 2014/11/14 10:10:47 Instead of already adding a glyph here, the first
Habib Virji 2014/11/24 11:52:30 That's the issue I struggled with. Adding initialA
+ glyphAdv = 0;
+ }
+
+ clusterAdvance += advances[i];
if (isClusterEnd) {
- uint16_t clusterEnd;
- if (m_run.rtl())
- clusterEnd = currentCharacterIndex;
- else
- clusterEnd = isRunEnd ? currentRun->startIndex() + currentRun->numCharacters() : currentRun->startIndex() + glyphToCharacterIndexes[i + 1];
+ uint16_t clusterEnd = isRTL ? currentCharacterIndex :
Dominik Röttsches 2014/11/14 10:10:47 Same as above, code is functionally identical to t
Habib Virji 2014/11/24 11:52:30 Acknowledged.
+ currentRun->startIndex() + (isRunEnd ? currentRun->numCharacters() : glyphToCharacterIndexes[i + 1]);
graphemesInCluster = countGraphemesInCluster(m_normalizedBuffer.get(), m_normalizedBufferLength, clusterStart, clusterEnd);
if (!graphemesInCluster || !clusterAdvance)
« LayoutTests/fast/text/emphasis-ellipsis-complextext.html ('K') | « Source/platform/fonts/Font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698