OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 m_lastGlyph.isValid = true; | 75 m_lastGlyph.isValid = true; |
76 kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); | 76 kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); |
77 return kerning; | 77 return kerning; |
78 #else | 78 #else |
79 UNUSED_PARAM(isVerticalText); | 79 UNUSED_PARAM(isVerticalText); |
80 UNUSED_PARAM(currentGlyph); | 80 UNUSED_PARAM(currentGlyph); |
81 return false; | 81 return false; |
82 #endif | 82 #endif |
83 } | 83 } |
84 | 84 |
85 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS
tyle* style, SVGElement* contextElement, const UChar* currentCharacter) | 85 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS
tyle* style, SVGElement* contextElement, UChar currentCharacter) |
86 { | 86 { |
87 float kerning = 0; | 87 float kerning = 0; |
88 SVGLength kerningLength = style->kerning(); | 88 SVGLength kerningLength = style->kerning(); |
89 if (kerningLength.unitType() == LengthTypePercentage) | 89 if (kerningLength.unitType() == LengthTypePercentage) |
90 kerning = kerningLength.valueAsPercentage() * m_font.pixelSize(); | 90 kerning = kerningLength.valueAsPercentage() * m_font.pixelSize(); |
91 else { | 91 else { |
92 SVGLengthContext lengthContext(contextElement); | 92 SVGLengthContext lengthContext(contextElement); |
93 kerning = kerningLength.value(lengthContext); | 93 kerning = kerningLength.value(lengthContext); |
94 } | 94 } |
95 | 95 |
96 const UChar* lastCharacter = m_lastCharacter; | 96 UChar lastCharacter = m_lastCharacter; |
97 m_lastCharacter = currentCharacter; | 97 m_lastCharacter = currentCharacter; |
98 | 98 |
99 if (!kerning && !m_font.letterSpacing() && !m_font.wordSpacing()) | 99 if (!kerning && !m_font.letterSpacing() && !m_font.wordSpacing()) |
100 return 0; | 100 return 0; |
101 | 101 |
102 float spacing = m_font.letterSpacing() + kerning; | 102 float spacing = m_font.letterSpacing() + kerning; |
103 if (currentCharacter && lastCharacter && m_font.wordSpacing()) { | 103 if (currentCharacter && lastCharacter && m_font.wordSpacing()) { |
104 if (Font::treatAsSpace(*currentCharacter) && !Font::treatAsSpace(*lastCh
aracter)) | 104 if (Font::treatAsSpace(currentCharacter) && !Font::treatAsSpace(lastChar
acter)) |
105 spacing += m_font.wordSpacing(); | 105 spacing += m_font.wordSpacing(); |
106 } | 106 } |
107 | 107 |
108 return spacing; | 108 return spacing; |
109 } | 109 } |
110 | 110 |
111 } | 111 } |
OLD | NEW |