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

Unified Diff: Source/core/rendering/RenderText.cpp

Issue 593673003: Different fonts selected for width calculation and actual painting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@ellipsis_not_present
Patch Set: Created 6 years, 3 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/core/rendering/RenderBlockLineLayout.cpp ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderText.cpp
diff --git a/Source/core/rendering/RenderText.cpp b/Source/core/rendering/RenderText.cpp
index cb7448b64b0a2a9e302e3736e581a6e6ea389a6f..ba42533173e087c19fae55f7e91296484e337f47 100644
--- a/Source/core/rendering/RenderText.cpp
+++ b/Source/core/rendering/RenderText.cpp
@@ -720,23 +720,29 @@ ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len
}
if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal && m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
+ int i = 0;
float monospaceCharacterWidth = f.spaceWidth();
float w = 0;
bool isSpace;
ASSERT(m_text);
StringImpl& text = *m_text.impl();
- for (int i = start; i < start + len; i++) {
+ RenderStyle * renderStyle = style();
+ for (i = start; i < start + len; i++) {
char c = text[i];
+ // If glyph is not present in primary font then we cannot calculate width based on primary
+ // font property, we need to call "width" method of Font Object.
+ if (!f.primaryFontHasGlyphForCharacter(text[i]))
+ break;
if (c <= space) {
if (c == space || c == newlineCharacter) {
w += monospaceCharacterWidth;
isSpace = true;
} else if (c == characterTabulation) {
- if (style()->collapseWhiteSpace()) {
+ if (renderStyle->collapseWhiteSpace()) {
w += monospaceCharacterWidth;
isSpace = true;
} else {
- w += f.tabWidth(style()->tabSize(), xPos + w);
+ w += f.tabWidth(renderStyle->tabSize(), xPos + w);
isSpace = false;
}
} else
@@ -748,7 +754,8 @@ ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len
if (isSpace && i > start)
w += f.fontDescription().wordSpacing();
}
- return w;
+ if (i == start + len)
eae 2014/09/24 11:35:39 Instead of reusing i like this why not add a new b
h.joshi 2014/09/24 20:25:58 Okey, done.
+ return w;
}
TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start, len, style(), textDirection);
« no previous file with comments | « Source/core/rendering/RenderBlockLineLayout.cpp ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698