OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 && !m_run.spacingDisabled(); | 181 && !m_run.spacingDisabled(); |
182 | 182 |
183 const SimpleFontData* primaryFont = m_font->primaryFont(); | 183 const SimpleFontData* primaryFont = m_font->primaryFont(); |
184 const SimpleFontData* lastFontData = primaryFont; | 184 const SimpleFontData* lastFontData = primaryFont; |
185 bool normalizeSpace = m_run.normalizeSpace(); | 185 bool normalizeSpace = m_run.normalizeSpace(); |
186 | 186 |
187 CharacterData charData; | 187 CharacterData charData; |
188 while (textIterator.consume(charData.character, charData.clusterLength)) { | 188 while (textIterator.consume(charData.character, charData.clusterLength)) { |
189 charData.characterOffset = textIterator.currentCharacter(); | 189 charData.characterOffset = textIterator.currentCharacter(); |
190 | 190 |
191 const GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpa
ce); | 191 GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace); |
| 192 |
| 193 // Some fonts do not have a glyph for zero-width-space, |
| 194 // in that case use the space character and override the width. |
| 195 float width; |
| 196 if (!glyphData.glyph && Character::treatAsZeroWidthSpaceInComplexScript(
charData.character)) { |
| 197 charData.character = space; |
| 198 glyphData = glyphDataForCharacter(charData); |
| 199 width = 0; |
| 200 } else { |
| 201 width = characterWidth(charData.character, glyphData); |
| 202 } |
| 203 |
192 Glyph glyph = glyphData.glyph; | 204 Glyph glyph = glyphData.glyph; |
193 const SimpleFontData* fontData = glyphData.fontData; | 205 const SimpleFontData* fontData = glyphData.fontData; |
194 ASSERT(fontData); | 206 ASSERT(fontData); |
195 | 207 |
196 // Now that we have a glyph and font data, get its width. | |
197 float width = characterWidth(charData.character, glyphData); | |
198 | |
199 if (m_fallbackFonts && lastFontData != fontData && width) { | 208 if (m_fallbackFonts && lastFontData != fontData && width) { |
200 lastFontData = fontData; | 209 lastFontData = fontData; |
201 cacheFallbackFont(fontData, primaryFont); | 210 cacheFallbackFont(fontData, primaryFont); |
202 } | 211 } |
203 | 212 |
204 if (hasExtraSpacing) | 213 if (hasExtraSpacing) |
205 width = adjustSpacing(width, charData, *fontData, glyphBuffer); | 214 width = adjustSpacing(width, charData, *fontData, glyphBuffer); |
206 | 215 |
207 if (m_accountForGlyphBounds) | 216 if (m_accountForGlyphBounds) |
208 updateGlyphBounds(glyphData, width, !charData.characterOffset); | 217 updateGlyphBounds(glyphData, width, !charData.characterOffset); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 float initialWidth = m_runWidthSoFar; | 257 float initialWidth = m_runWidthSoFar; |
249 | 258 |
250 if (!advance(m_currentCharacter + 1)) | 259 if (!advance(m_currentCharacter + 1)) |
251 return false; | 260 return false; |
252 | 261 |
253 width = m_runWidthSoFar - initialWidth; | 262 width = m_runWidthSoFar - initialWidth; |
254 return true; | 263 return true; |
255 } | 264 } |
256 | 265 |
257 } // namespace blink | 266 } // namespace blink |
OLD | NEW |