Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: Source/core/rendering/svg/SVGTextLayoutEngineSpacing.cpp

Issue 234453002: Remove SVG1.1 kerning property (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More TestExpectations updates Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "config.h" 20 #include "config.h"
21 21
22 #include "core/rendering/svg/SVGTextLayoutEngineSpacing.h" 22 #include "core/rendering/svg/SVGTextLayoutEngineSpacing.h"
23 23
24 #include "core/rendering/style/SVGRenderStyle.h"
25 #include "core/svg/SVGLengthContext.h" 24 #include "core/svg/SVGLengthContext.h"
26 #include "platform/fonts/Character.h" 25 #include "platform/fonts/Character.h"
27 #include "platform/fonts/Font.h" 26 #include "platform/fonts/Font.h"
28 27
29 #if ENABLE(SVG_FONTS) 28 #if ENABLE(SVG_FONTS)
30 #include "core/svg/SVGFontData.h" 29 #include "core/svg/SVGFontData.h"
31 #include "core/svg/SVGFontElement.h" 30 #include "core/svg/SVGFontElement.h"
32 #include "core/svg/SVGFontFaceElement.h" 31 #include "core/svg/SVGFontFaceElement.h"
33 #endif 32 #endif
34 33
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kerning *= m_font.fontDescription().computedSize() / m_font.fontMetrics( ).unitsPerEm(); 75 kerning *= m_font.fontDescription().computedSize() / m_font.fontMetrics( ).unitsPerEm();
77 } 76 }
78 77
79 m_lastGlyph = currentGlyph; 78 m_lastGlyph = currentGlyph;
80 return kerning; 79 return kerning;
81 #else 80 #else
82 return 0; 81 return 0;
83 #endif 82 #endif
84 } 83 }
85 84
86 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS tyle* style, SVGElement* contextElement, UChar currentCharacter) 85 float SVGTextLayoutEngineSpacing::calculateCSSSpacing(UChar currentCharacter)
87 { 86 {
88 float kerning = 0;
89 RefPtr<SVGLength> kerningLength = style->kerning();
90 if (kerningLength->unitType() == LengthTypePercentage)
91 kerning = kerningLength->valueAsPercentage() * m_font.fontDescription(). computedPixelSize();
92 else {
93 SVGLengthContext lengthContext(contextElement);
94 kerning = kerningLength->value(lengthContext);
95 }
96
97 UChar lastCharacter = m_lastCharacter; 87 UChar lastCharacter = m_lastCharacter;
98 m_lastCharacter = currentCharacter; 88 m_lastCharacter = currentCharacter;
99 89
100 if (!kerning && !m_font.fontDescription().letterSpacing() && !m_font.fontDes cription().wordSpacing()) 90 if (!m_font.fontDescription().letterSpacing() && !m_font.fontDescription().w ordSpacing())
101 return 0; 91 return 0;
102 92
103 float spacing = m_font.fontDescription().letterSpacing() + kerning; 93 float spacing = m_font.fontDescription().letterSpacing();
104 if (currentCharacter && lastCharacter && m_font.fontDescription().wordSpacin g()) { 94 if (currentCharacter && lastCharacter && m_font.fontDescription().wordSpacin g()) {
105 if (Character::treatAsSpace(currentCharacter) && !Character::treatAsSpac e(lastCharacter)) 95 if (Character::treatAsSpace(currentCharacter) && !Character::treatAsSpac e(lastCharacter))
106 spacing += m_font.fontDescription().wordSpacing(); 96 spacing += m_font.fontDescription().wordSpacing();
107 } 97 }
108 98
109 return spacing; 99 return spacing;
110 } 100 }
111 101
112 } 102 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGTextLayoutEngineSpacing.h ('k') | Source/core/svg/SVGAttributeNames.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698