OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 FontDescription description = originalFont().fontDescription(); | 118 FontDescription description = originalFont().fontDescription(); |
119 float emWidth = description.computedSize(); | 119 float emWidth = description.computedSize(); |
120 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) | 120 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) |
121 emWidth *= textCombineMargin; | 121 emWidth *= textCombineMargin; |
122 | 122 |
123 description.setOrientation(Horizontal); // We are going to draw combined tex
t horizontally. | 123 description.setOrientation(Horizontal); // We are going to draw combined tex
t horizontally. |
124 m_combinedTextWidth = originalFont().width(run); | 124 m_combinedTextWidth = originalFont().width(run); |
125 | 125 |
126 FontSelector* fontSelector = style()->font().fontSelector(); | 126 FontSelector* fontSelector = style()->font().fontSelector(); |
127 | 127 |
128 bool shouldUpdateFont = style()->setFontDescription(description); // Need to
change font orientation to horizontal. | 128 bool shouldUpdateFont = mutableStyleRef().setFontDescription(description); /
/ Need to change font orientation to horizontal. |
129 | 129 |
130 if (m_combinedTextWidth <= emWidth) { | 130 if (m_combinedTextWidth <= emWidth) { |
131 m_scaleX = 1.0f; | 131 m_scaleX = 1.0f; |
132 } else { | 132 } else { |
133 // Need to try compressed glyphs. | 133 // Need to try compressed glyphs. |
134 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; | 134 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; |
135 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { | 135 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { |
136 description.setWidthVariant(widthVariants[i]); | 136 description.setWidthVariant(widthVariants[i]); |
137 Font compressedFont = Font(description); | 137 Font compressedFont = Font(description); |
138 compressedFont.update(fontSelector); | 138 compressedFont.update(fontSelector); |
139 float runWidth = compressedFont.width(run); | 139 float runWidth = compressedFont.width(run); |
140 if (runWidth <= emWidth) { | 140 if (runWidth <= emWidth) { |
141 m_combinedTextWidth = runWidth; | 141 m_combinedTextWidth = runWidth; |
142 | 142 |
143 // Replace my font with the new one. | 143 // Replace my font with the new one. |
144 shouldUpdateFont = style()->setFontDescription(description); | 144 shouldUpdateFont = mutableStyleRef().setFontDescription(descript
ion); |
145 break; | 145 break; |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 // If width > ~1em, shrink to fit within ~1em, otherwise render without
scaling (no expansion) | 149 // If width > ~1em, shrink to fit within ~1em, otherwise render without
scaling (no expansion) |
150 // http://dev.w3.org/csswg/css-writing-modes-3/#text-combine-compression | 150 // http://dev.w3.org/csswg/css-writing-modes-3/#text-combine-compression |
151 if (m_combinedTextWidth > emWidth) { | 151 if (m_combinedTextWidth > emWidth) { |
152 m_scaleX = emWidth / m_combinedTextWidth; | 152 m_scaleX = emWidth / m_combinedTextWidth; |
153 m_combinedTextWidth = emWidth; | 153 m_combinedTextWidth = emWidth; |
154 } else { | 154 } else { |
155 m_scaleX = 1.0f; | 155 m_scaleX = 1.0f; |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 if (shouldUpdateFont) | 159 if (shouldUpdateFont) |
160 style()->font().update(fontSelector); | 160 style()->font().update(fontSelector); |
161 } | 161 } |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
OLD | NEW |