summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp')
-rw-r--r--Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
index 3863322..4221f26 100644
--- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
+++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
@@ -49,9 +49,9 @@ float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle*
case BS_BASELINE:
return 0;
case BS_SUB:
- return -m_font.height() / 2;
+ return -m_font.fontMetrics().floatHeight() / 2;
case BS_SUPER:
- return m_font.height() / 2;
+ return m_font.fontMetrics().floatHeight() / 2;
default:
ASSERT_NOT_REACHED();
return 0;
@@ -122,27 +122,29 @@ float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic
ASSERT(baseline != AB_AUTO);
}
+ const FontMetrics& fontMetrics = m_font.fontMetrics();
+
// Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling
switch (baseline) {
case AB_BASELINE:
return dominantBaselineToAlignmentBaseline(isVerticalText, textRendererParent);
case AB_BEFORE_EDGE:
case AB_TEXT_BEFORE_EDGE:
- return m_font.ascent();
+ return fontMetrics.floatAscent();
case AB_MIDDLE:
- return m_font.xHeight() / 2;
+ return fontMetrics.xHeight() / 2;
case AB_CENTRAL:
- return (m_font.ascent() - m_font.descent()) / 2;
+ return (fontMetrics.floatAscent() - fontMetrics.floatDescent()) / 2;
case AB_AFTER_EDGE:
case AB_TEXT_AFTER_EDGE:
case AB_IDEOGRAPHIC:
- return m_font.descent();
+ return fontMetrics.floatDescent();
case AB_ALPHABETIC:
return 0;
case AB_HANGING:
- return m_font.ascent() * 8 / 10.f;
+ return fontMetrics.floatAscent() * 8 / 10.f;
case AB_MATHEMATICAL:
- return m_font.ascent() / 2;
+ return fontMetrics.floatAscent() / 2;
default:
ASSERT_NOT_REACHED();
return 0;
@@ -192,12 +194,14 @@ float SVGTextLayoutEngineBaseline::calculateGlyphAdvanceAndOrientation(bool isVe
// Spec: If if the 'glyph-orientation-vertical' results in an orientation angle that is not a multiple of
// 180 degrees, then the current text position is incremented according to the horizontal metrics of the glyph.
+ const FontMetrics& fontMetrics = m_font.fontMetrics();
+
// Vertical orientation handling.
if (isVerticalText) {
- float ascentMinusDescent = m_font.ascent() - m_font.descent();
+ float ascentMinusDescent = fontMetrics.floatAscent() - fontMetrics.floatDescent();
if (!angle) {
xOrientationShift = (ascentMinusDescent - metrics.width()) / 2;
- yOrientationShift = m_font.ascent();
+ yOrientationShift = fontMetrics.floatAscent();
} else if (angle == 180)
xOrientationShift = (ascentMinusDescent + metrics.width()) / 2;
else if (angle == 270) {
@@ -217,7 +221,7 @@ float SVGTextLayoutEngineBaseline::calculateGlyphAdvanceAndOrientation(bool isVe
yOrientationShift = -metrics.width();
else if (angle == 180) {
xOrientationShift = metrics.width();
- yOrientationShift = -m_font.ascent();
+ yOrientationShift = -fontMetrics.floatAscent();
} else if (angle == 270)
xOrientationShift = metrics.width();