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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (UNLIKELY(m_textRun.horizontalGlyphStretch() != 1)) | 80 if (UNLIKELY(m_textRun.horizontalGlyphStretch() != 1)) |
81 width *= m_textRun.horizontalGlyphStretch(); | 81 width *= m_textRun.horizontalGlyphStretch(); |
82 | 82 |
83 return width; | 83 return width; |
84 } | 84 } |
85 | 85 |
86 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData) | 86 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData) |
87 { | 87 { |
88 // Account for letter-spacing. | 88 // Account for letter-spacing. |
89 if (width) | 89 if (width) |
90 width += m_font->fontDescription().letterSpacing(); | 90 width += m_font->getFontDescription().letterSpacing(); |
91 | 91 |
92 bool isExpansionOpportunity = Character::treatAsSpace(charData.character) ||
(m_textRun.getTextJustify() == TextJustifyDistribute); | 92 bool isExpansionOpportunity = Character::treatAsSpace(charData.character) ||
(m_textRun.getTextJustify() == TextJustifyDistribute); |
93 if (isExpansionOpportunity || (m_textRun.getTextJustify() == TextJustifyAuto
&& Character::isCJKIdeographOrSymbol(charData.character))) { | 93 if (isExpansionOpportunity || (m_textRun.getTextJustify() == TextJustifyAuto
&& Character::isCJKIdeographOrSymbol(charData.character))) { |
94 // Distribute the run's total expansion evenly over all expansion opport
unities in the run. | 94 // Distribute the run's total expansion evenly over all expansion opport
unities in the run. |
95 if (m_expansion) { | 95 if (m_expansion) { |
96 if (!isExpansionOpportunity && !m_isAfterExpansion) { | 96 if (!isExpansionOpportunity && !m_isAfterExpansion) { |
97 // Take the expansion opportunity before this ideograph. | 97 // Take the expansion opportunity before this ideograph. |
98 m_expansion -= m_expansionPerOpportunity; | 98 m_expansion -= m_expansionPerOpportunity; |
99 m_runWidthSoFar += m_expansionPerOpportunity; | 99 m_runWidthSoFar += m_expansionPerOpportunity; |
100 } | 100 } |
101 if (m_textRun.allowsTrailingExpansion() | 101 if (m_textRun.allowsTrailingExpansion() |
102 || (m_textRun.ltr() && charData.characterOffset + charData.clust
erLength < static_cast<size_t>(m_textRun.length())) | 102 || (m_textRun.ltr() && charData.characterOffset + charData.clust
erLength < static_cast<size_t>(m_textRun.length())) |
103 || (m_textRun.rtl() && charData.characterOffset)) { | 103 || (m_textRun.rtl() && charData.characterOffset)) { |
104 m_expansion -= m_expansionPerOpportunity; | 104 m_expansion -= m_expansionPerOpportunity; |
105 width += m_expansionPerOpportunity; | 105 width += m_expansionPerOpportunity; |
106 m_isAfterExpansion = true; | 106 m_isAfterExpansion = true; |
107 } | 107 } |
108 } else { | 108 } else { |
109 m_isAfterExpansion = false; | 109 m_isAfterExpansion = false; |
110 } | 110 } |
111 | 111 |
112 // Account for word spacing. | 112 // Account for word spacing. |
113 // We apply additional space between "words" by adding width to the spac
e character. | 113 // We apply additional space between "words" by adding width to the spac
e character. |
114 if (isExpansionOpportunity && (charData.character != tabulationCharacter
|| !m_textRun.allowTabs()) | 114 if (isExpansionOpportunity && (charData.character != tabulationCharacter
|| !m_textRun.allowTabs()) |
115 && (charData.characterOffset || charData.character == noBreakSpaceCh
aracter) | 115 && (charData.characterOffset || charData.character == noBreakSpaceCh
aracter) |
116 && m_font->fontDescription().wordSpacing()) { | 116 && m_font->getFontDescription().wordSpacing()) { |
117 width += m_font->fontDescription().wordSpacing(); | 117 width += m_font->getFontDescription().wordSpacing(); |
118 } | 118 } |
119 } else { | 119 } else { |
120 m_isAfterExpansion = false; | 120 m_isAfterExpansion = false; |
121 } | 121 } |
122 | 122 |
123 return width; | 123 return width; |
124 } | 124 } |
125 | 125 |
126 template <typename TextIterator> | 126 template <typename TextIterator> |
127 unsigned SimpleShaper::advanceInternal(TextIterator& textIterator, GlyphBuffer*
glyphBuffer) | 127 unsigned SimpleShaper::advanceInternal(TextIterator& textIterator, GlyphBuffer*
glyphBuffer) |
128 { | 128 { |
129 bool hasExtraSpacing = (m_font->fontDescription().letterSpacing() || m_font-
>fontDescription().wordSpacing() || m_expansion) | 129 bool hasExtraSpacing = (m_font->getFontDescription().letterSpacing() || m_fo
nt->getFontDescription().wordSpacing() || m_expansion) |
130 && !m_textRun.spacingDisabled(); | 130 && !m_textRun.spacingDisabled(); |
131 | 131 |
132 const SimpleFontData* lastFontData = m_font->primaryFont(); | 132 const SimpleFontData* lastFontData = m_font->primaryFont(); |
133 bool normalizeSpace = m_textRun.normalizeSpace(); | 133 bool normalizeSpace = m_textRun.normalizeSpace(); |
134 const float initialRunWidth = m_runWidthSoFar; | 134 const float initialRunWidth = m_runWidthSoFar; |
135 | 135 |
136 CharacterData charData; | 136 CharacterData charData; |
137 while (textIterator.consume(charData.character)) { | 137 while (textIterator.consume(charData.character)) { |
138 charData.characterOffset = textIterator.offset(); | 138 charData.characterOffset = textIterator.offset(); |
139 charData.clusterLength = textIterator.glyphLength(); | 139 charData.clusterLength = textIterator.glyphLength(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 float initialWidth = m_runWidthSoFar; | 218 float initialWidth = m_runWidthSoFar; |
219 | 219 |
220 if (!advance(m_currentCharacter + 1)) | 220 if (!advance(m_currentCharacter + 1)) |
221 return false; | 221 return false; |
222 | 222 |
223 width = m_runWidthSoFar - initialWidth; | 223 width = m_runWidthSoFar - initialWidth; |
224 return true; | 224 return true; |
225 } | 225 } |
226 | 226 |
227 } // namespace blink | 227 } // namespace blink |
OLD | NEW |