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 11 matching lines...) Expand all Loading... |
22 #include "core/rendering/svg/SVGTextLayoutEngineSpacing.h" | 22 #include "core/rendering/svg/SVGTextLayoutEngineSpacing.h" |
23 | 23 |
24 #include "core/rendering/style/SVGRenderStyle.h" | 24 #include "core/rendering/style/SVGRenderStyle.h" |
25 #include "core/svg/SVGLengthContext.h" | 25 #include "core/svg/SVGLengthContext.h" |
26 #include "platform/fonts/Font.h" | 26 #include "platform/fonts/Font.h" |
27 | 27 |
28 #if ENABLE(SVG_FONTS) | 28 #if ENABLE(SVG_FONTS) |
29 #include "core/svg/SVGFontData.h" | 29 #include "core/svg/SVGFontData.h" |
30 #include "core/svg/SVGFontElement.h" | 30 #include "core/svg/SVGFontElement.h" |
31 #include "core/svg/SVGFontFaceElement.h" | 31 #include "core/svg/SVGFontFaceElement.h" |
32 #else | |
33 #include "wtf/UnusedParam.h" | |
34 #endif | 32 #endif |
35 | 33 |
36 namespace WebCore { | 34 namespace WebCore { |
37 | 35 |
38 SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const Font& font) | 36 SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const Font& font) |
39 : m_font(font) | 37 : m_font(font) |
40 , m_lastCharacter(0) | 38 , m_lastCharacter(0) |
41 { | 39 { |
42 } | 40 } |
43 | 41 |
(...skipping 26 matching lines...) Expand all Loading... |
70 kerning = svgFont->verticalKerningForPairOfStringsAndGlyphs(m_lastGl
yph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.na
me); | 68 kerning = svgFont->verticalKerningForPairOfStringsAndGlyphs(m_lastGl
yph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.na
me); |
71 else | 69 else |
72 kerning = svgFont->horizontalKerningForPairOfStringsAndGlyphs(m_last
Glyph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.
name); | 70 kerning = svgFont->horizontalKerningForPairOfStringsAndGlyphs(m_last
Glyph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.
name); |
73 } | 71 } |
74 | 72 |
75 m_lastGlyph = currentGlyph; | 73 m_lastGlyph = currentGlyph; |
76 m_lastGlyph.isValid = true; | 74 m_lastGlyph.isValid = true; |
77 kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); | 75 kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); |
78 return kerning; | 76 return kerning; |
79 #else | 77 #else |
80 UNUSED_PARAM(isVerticalText); | |
81 UNUSED_PARAM(currentGlyph); | |
82 return false; | 78 return false; |
83 #endif | 79 #endif |
84 } | 80 } |
85 | 81 |
86 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS
tyle* style, SVGElement* contextElement, UChar currentCharacter) | 82 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS
tyle* style, SVGElement* contextElement, UChar currentCharacter) |
87 { | 83 { |
88 float kerning = 0; | 84 float kerning = 0; |
89 SVGLength kerningLength = style->kerning(); | 85 SVGLength kerningLength = style->kerning(); |
90 if (kerningLength.unitType() == LengthTypePercentage) | 86 if (kerningLength.unitType() == LengthTypePercentage) |
91 kerning = kerningLength.valueAsPercentage() * m_font.pixelSize(); | 87 kerning = kerningLength.valueAsPercentage() * m_font.pixelSize(); |
(...skipping 11 matching lines...) Expand all Loading... |
103 float spacing = m_font.letterSpacing() + kerning; | 99 float spacing = m_font.letterSpacing() + kerning; |
104 if (currentCharacter && lastCharacter && m_font.wordSpacing()) { | 100 if (currentCharacter && lastCharacter && m_font.wordSpacing()) { |
105 if (Font::treatAsSpace(currentCharacter) && !Font::treatAsSpace(lastChar
acter)) | 101 if (Font::treatAsSpace(currentCharacter) && !Font::treatAsSpace(lastChar
acter)) |
106 spacing += m_font.wordSpacing(); | 102 spacing += m_font.wordSpacing(); |
107 } | 103 } |
108 | 104 |
109 return spacing; | 105 return spacing; |
110 } | 106 } |
111 | 107 |
112 } | 108 } |
OLD | NEW |