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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 FontDescription description = originalFont().fontDescription(); | 109 FontDescription description = originalFont().fontDescription(); |
110 float emWidth = description.computedSize(); | 110 float emWidth = description.computedSize(); |
111 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) | 111 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) |
112 emWidth *= textCombineMargin; | 112 emWidth *= textCombineMargin; |
113 | 113 |
114 description.setOrientation(Horizontal); // We are going to draw combined tex
t horizontally. | 114 description.setOrientation(Horizontal); // We are going to draw combined tex
t horizontally. |
115 m_combinedTextWidth = originalFont().width(run); | 115 m_combinedTextWidth = originalFont().width(run); |
116 | 116 |
117 FontSelector* fontSelector = style()->font().fontSelector(); | 117 FontSelector* fontSelector = style()->font().fontSelector(); |
118 | 118 |
119 bool shouldUpdateFont = style()->setFontDescription(description); // Need to
change font orientation to horizontal. | 119 bool shouldUpdateFont = mutableStyleRef().setFontDescription(description); /
/ Need to change font orientation to horizontal. |
120 | 120 |
121 if (m_combinedTextWidth <= emWidth) { | 121 if (m_combinedTextWidth <= emWidth) { |
122 m_scaleX = 1.0f; | 122 m_scaleX = 1.0f; |
123 } else { | 123 } else { |
124 // Need to try compressed glyphs. | 124 // Need to try compressed glyphs. |
125 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; | 125 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; |
126 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { | 126 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { |
127 description.setWidthVariant(widthVariants[i]); | 127 description.setWidthVariant(widthVariants[i]); |
128 Font compressedFont = Font(description); | 128 Font compressedFont = Font(description); |
129 compressedFont.update(fontSelector); | 129 compressedFont.update(fontSelector); |
130 float runWidth = compressedFont.width(run); | 130 float runWidth = compressedFont.width(run); |
131 if (runWidth <= emWidth) { | 131 if (runWidth <= emWidth) { |
132 m_combinedTextWidth = runWidth; | 132 m_combinedTextWidth = runWidth; |
133 | 133 |
134 // Replace my font with the new one. | 134 // Replace my font with the new one. |
135 shouldUpdateFont = style()->setFontDescription(description); | 135 shouldUpdateFont = mutableStyleRef().setFontDescription(descript
ion); |
136 break; | 136 break; |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 // If width > ~1em, shrink to fit within ~1em, otherwise render without
scaling (no expansion) | 140 // If width > ~1em, shrink to fit within ~1em, otherwise render without
scaling (no expansion) |
141 // http://dev.w3.org/csswg/css-writing-modes-3/#text-combine-compression | 141 // http://dev.w3.org/csswg/css-writing-modes-3/#text-combine-compression |
142 if (m_combinedTextWidth > emWidth) { | 142 if (m_combinedTextWidth > emWidth) { |
143 m_scaleX = emWidth / m_combinedTextWidth; | 143 m_scaleX = emWidth / m_combinedTextWidth; |
144 m_combinedTextWidth = emWidth; | 144 m_combinedTextWidth = emWidth; |
145 } else { | 145 } else { |
146 m_scaleX = 1.0f; | 146 m_scaleX = 1.0f; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 if (shouldUpdateFont) | 150 if (shouldUpdateFont) |
151 style()->font().update(fontSelector); | 151 style()->font().update(fontSelector); |
152 } | 152 } |
153 | 153 |
154 } // namespace blink | 154 } // namespace blink |
OLD | NEW |