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

Side by Side Diff: Source/platform/fonts/shaping/SimpleShaper.cpp

Issue 648293003: Handle missing glyphs when adjusting spacing in SimpleShaper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/soft-hyphen-simple-text-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2014 Google Inc. All rights reserved. 4 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 CharacterData charData; 184 CharacterData charData;
185 while (textIterator.consume(charData.character, charData.clusterLength)) { 185 while (textIterator.consume(charData.character, charData.clusterLength)) {
186 charData.characterOffset = textIterator.currentCharacter(); 186 charData.characterOffset = textIterator.currentCharacter();
187 187
188 GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace); 188 GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace);
189 189
190 // Some fonts do not have a glyph for zero-width-space, 190 // Some fonts do not have a glyph for zero-width-space,
191 // in that case use the space character and override the width. 191 // in that case use the space character and override the width.
192 float width; 192 float width;
193 bool spaceUsedAsZeroWidthSpace = false;
193 if (!glyphData.glyph && Character::treatAsZeroWidthSpaceInComplexScript( charData.character)) { 194 if (!glyphData.glyph && Character::treatAsZeroWidthSpaceInComplexScript( charData.character)) {
194 charData.character = space; 195 charData.character = space;
195 glyphData = glyphDataForCharacter(charData); 196 glyphData = glyphDataForCharacter(charData);
196 width = 0; 197 width = 0;
198 spaceUsedAsZeroWidthSpace = true;
197 } else { 199 } else {
198 width = characterWidth(charData.character, glyphData); 200 width = characterWidth(charData.character, glyphData);
pdr. 2014/10/14 00:28:36 Would it make sense to add ASSERT(!fontData.isZero
eae 2014/10/14 00:30:36 Not really, we only go down the fallback-path abov
199 } 201 }
200 202
201 Glyph glyph = glyphData.glyph; 203 Glyph glyph = glyphData.glyph;
202 const SimpleFontData* fontData = glyphData.fontData; 204 const SimpleFontData* fontData = glyphData.fontData;
203 ASSERT(fontData); 205 ASSERT(fontData);
204 206
205 if (m_fallbackFonts && lastFontData != fontData && width) { 207 if (m_fallbackFonts && lastFontData != fontData && width) {
206 lastFontData = fontData; 208 lastFontData = fontData;
207 cacheFallbackFont(fontData, primaryFont); 209 cacheFallbackFont(fontData, primaryFont);
208 } 210 }
209 211
210 if (hasExtraSpacing) 212 if (hasExtraSpacing && !spaceUsedAsZeroWidthSpace)
211 width = adjustSpacing(width, charData, *fontData, glyphBuffer); 213 width = adjustSpacing(width, charData, *fontData, glyphBuffer);
212 214
213 if (m_bounds) 215 if (m_bounds)
214 updateGlyphBounds(glyphData, width, !charData.characterOffset); 216 updateGlyphBounds(glyphData, width, !charData.characterOffset);
215 217
216 if (m_forTextEmphasis && !Character::canReceiveTextEmphasis(charData.cha racter)) 218 if (m_forTextEmphasis && !Character::canReceiveTextEmphasis(charData.cha racter))
217 glyph = 0; 219 glyph = 0;
218 220
219 // Advance past the character we just dealt with. 221 // Advance past the character we just dealt with.
220 textIterator.advance(charData.clusterLength); 222 textIterator.advance(charData.clusterLength);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 float initialWidth = m_runWidthSoFar; 256 float initialWidth = m_runWidthSoFar;
255 257
256 if (!advance(m_currentCharacter + 1)) 258 if (!advance(m_currentCharacter + 1))
257 return false; 259 return false;
258 260
259 width = m_runWidthSoFar - initialWidth; 261 width = m_runWidthSoFar - initialWidth;
260 return true; 262 return true;
261 } 263 }
262 264
263 } // namespace blink 265 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/soft-hyphen-simple-text-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698