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 12 matching lines...) Expand all Loading... |
23 #include "config.h" | 23 #include "config.h" |
24 #include "platform/fonts/shaping/SimpleShaper.h" | 24 #include "platform/fonts/shaping/SimpleShaper.h" |
25 | 25 |
26 #include "platform/fonts/Character.h" | 26 #include "platform/fonts/Character.h" |
27 #include "platform/fonts/Font.h" | 27 #include "platform/fonts/Font.h" |
28 #include "platform/fonts/GlyphBuffer.h" | 28 #include "platform/fonts/GlyphBuffer.h" |
29 #include "platform/fonts/Latin1TextIterator.h" | 29 #include "platform/fonts/Latin1TextIterator.h" |
30 #include "platform/fonts/SimpleFontData.h" | 30 #include "platform/fonts/SimpleFontData.h" |
31 #include "platform/text/SurrogatePairAwareTextIterator.h" | 31 #include "platform/text/SurrogatePairAwareTextIterator.h" |
32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
| 33 #include "wtf/unicode/CharacterNames.h" |
33 | 34 |
34 using namespace WTF; | 35 using namespace WTF; |
35 using namespace Unicode; | 36 using namespace Unicode; |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 SimpleShaper::SimpleShaper(const Font* font, const TextRun& run, | 40 SimpleShaper::SimpleShaper(const Font* font, const TextRun& run, |
40 HashSet<const SimpleFontData*>* fallbackFonts, GlyphBounds* bounds, | 41 HashSet<const SimpleFontData*>* fallbackFonts, GlyphBounds* bounds, |
41 bool forTextEmphasis) | 42 bool forTextEmphasis) |
42 : m_font(font) | 43 : m_font(font) |
(...skipping 27 matching lines...) Expand all Loading... |
70 { | 71 { |
71 ASSERT(m_font); | 72 ASSERT(m_font); |
72 return m_font->glyphDataForCharacter(charData.character, m_run.rtl(), normal
izeSpace); | 73 return m_font->glyphDataForCharacter(charData.character, m_run.rtl(), normal
izeSpace); |
73 } | 74 } |
74 | 75 |
75 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData
) const | 76 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData
) const |
76 { | 77 { |
77 const SimpleFontData* fontData = glyphData.fontData; | 78 const SimpleFontData* fontData = glyphData.fontData; |
78 ASSERT(fontData); | 79 ASSERT(fontData); |
79 | 80 |
80 if (UNLIKELY(character == '\t' && m_run.allowTabs())) | 81 if (UNLIKELY(character == characterTabulation && m_run.allowTabs())) |
81 return m_font->tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_run
WidthSoFar); | 82 return m_font->tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_run
WidthSoFar); |
82 | 83 |
83 float width = fontData->widthForGlyph(glyphData.glyph); | 84 float width = fontData->widthForGlyph(glyphData.glyph); |
84 | 85 |
85 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ
eeze text. | 86 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ
eeze text. |
86 if (UNLIKELY(m_run.horizontalGlyphStretch() != 1)) | 87 if (UNLIKELY(m_run.horizontalGlyphStretch() != 1)) |
87 width *= m_run.horizontalGlyphStretch(); | 88 width *= m_run.horizontalGlyphStretch(); |
88 | 89 |
89 return width; | 90 return width; |
90 } | 91 } |
(...skipping 28 matching lines...) Expand all Loading... |
119 m_expansion -= m_expansionPerOpportunity; | 120 m_expansion -= m_expansionPerOpportunity; |
120 width += m_expansionPerOpportunity; | 121 width += m_expansionPerOpportunity; |
121 m_isAfterExpansion = true; | 122 m_isAfterExpansion = true; |
122 } | 123 } |
123 } else { | 124 } else { |
124 m_isAfterExpansion = false; | 125 m_isAfterExpansion = false; |
125 } | 126 } |
126 | 127 |
127 // Account for word spacing. | 128 // Account for word spacing. |
128 // We apply additional space between "words" by adding width to the spac
e character. | 129 // We apply additional space between "words" by adding width to the spac
e character. |
129 if (isExpansionOpportunity && (charData.character != '\t' || !m_run.allo
wTabs()) | 130 if (isExpansionOpportunity && (charData.character != characterTabulation
|| !m_run.allowTabs()) |
130 && (charData.characterOffset || charData.character == noBreakSpace) | 131 && (charData.characterOffset || charData.character == noBreakSpace) |
131 && m_font->fontDescription().wordSpacing()) { | 132 && m_font->fontDescription().wordSpacing()) { |
132 width += m_font->fontDescription().wordSpacing(); | 133 width += m_font->fontDescription().wordSpacing(); |
133 } | 134 } |
134 } else { | 135 } else { |
135 m_isAfterExpansion = false; | 136 m_isAfterExpansion = false; |
136 } | 137 } |
137 | 138 |
138 return width; | 139 return width; |
139 } | 140 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 float initialWidth = m_runWidthSoFar; | 243 float initialWidth = m_runWidthSoFar; |
243 | 244 |
244 if (!advance(m_currentCharacter + 1)) | 245 if (!advance(m_currentCharacter + 1)) |
245 return false; | 246 return false; |
246 | 247 |
247 width = m_runWidthSoFar - initialWidth; | 248 width = m_runWidthSoFar - initialWidth; |
248 return true; | 249 return true; |
249 } | 250 } |
250 | 251 |
251 } // namespace blink | 252 } // namespace blink |
OLD | NEW |