diff options
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp')
-rw-r--r-- | Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp index f0107c4ab..48d80ae99 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp @@ -18,73 +18,29 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGTextLayoutEngineSpacing.h" -#include "Font.h" +#include "FontCascade.h" #include "SVGLengthContext.h" #include "SVGRenderStyle.h" #if ENABLE(SVG_FONTS) -#include "SVGFontData.h" #include "SVGFontElement.h" #include "SVGFontFaceElement.h" #endif namespace WebCore { -SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const Font& font) +SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const FontCascade& font) : m_font(font) , m_lastCharacter(0) { } -float SVGTextLayoutEngineSpacing::calculateSVGKerning(bool isVerticalText, const SVGTextMetrics::Glyph& currentGlyph) -{ -#if ENABLE(SVG_FONTS) - const SimpleFontData* fontData = m_font.primaryFont(); - if (!fontData->isSVGFont()) { - m_lastGlyph.isValid = false; - return 0; - } - - ASSERT(fontData->isCustomFont()); - ASSERT(fontData->isSVGFont()); - - const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->fontData()); - SVGFontFaceElement* svgFontFace = svgFontData->svgFontFaceElement(); - ASSERT(svgFontFace); - - SVGFontElement* svgFont = svgFontFace->associatedFontElement(); - if (!svgFont) { - m_lastGlyph.isValid = false; - return 0; - } - - float kerning = 0; - if (m_lastGlyph.isValid) { - if (isVerticalText) - kerning = svgFont->verticalKerningForPairOfStringsAndGlyphs(m_lastGlyph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.name); - else - kerning = svgFont->horizontalKerningForPairOfStringsAndGlyphs(m_lastGlyph.unicodeString, m_lastGlyph.name, currentGlyph.unicodeString, currentGlyph.name); - } - - m_lastGlyph = currentGlyph; - m_lastGlyph.isValid = true; - kerning *= m_font.size() / m_font.fontMetrics().unitsPerEm(); - return kerning; -#else - UNUSED_PARAM(isVerticalText); - UNUSED_PARAM(currentGlyph); - return false; -#endif -} - float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* contextElement, const UChar* currentCharacter) { float kerning = 0; - SVGLength kerningLength = style->kerning(); + auto kerningLength = style->kerning(); if (kerningLength.unitType() == LengthTypePercentage) kerning = kerningLength.valueAsPercentage() * m_font.pixelSize(); else { @@ -100,7 +56,7 @@ float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS float spacing = m_font.letterSpacing() + kerning; if (currentCharacter && lastCharacter && m_font.wordSpacing()) { - if (Font::treatAsSpace(*currentCharacter) && !Font::treatAsSpace(*lastCharacter)) + if (FontCascade::treatAsSpace(*currentCharacter) && !FontCascade::treatAsSpace(*lastCharacter)) spacing += m_font.wordSpacing(); } @@ -108,5 +64,3 @@ float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS } } - -#endif // ENABLE(SVG) |