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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp

Issue 2427773002: Fixing superscript and subscript baseline for tiny fonts in SVG
Patch Set: Addressing comments. Created 4 years, 2 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
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
(...skipping 16 matching lines...) Expand all
27 27
28 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font, 28 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font,
29 float effectiveZoom) 29 float effectiveZoom)
30 : m_font(font), m_effectiveZoom(effectiveZoom) { 30 : m_font(font), m_effectiveZoom(effectiveZoom) {
31 ASSERT(m_effectiveZoom); 31 ASSERT(m_effectiveZoom);
32 } 32 }
33 33
34 float SVGTextLayoutEngineBaseline::calculateBaselineShift( 34 float SVGTextLayoutEngineBaseline::calculateBaselineShift(
35 const ComputedStyle& style) const { 35 const ComputedStyle& style) const {
36 const SVGComputedStyle& svgStyle = style.svgStyle(); 36 const SVGComputedStyle& svgStyle = style.svgStyle();
37 const SimpleFontData* fontData = m_font.primaryFont(); 37 // If font size is smaller than 3, rounding ascent and descent values in
38 // SimpleFontData sets the baseline shifts for superscript and subscript to
39 // zero. In this case, we use subpixel ascent and descent.
40 const SimpleFontData* fontData =
41 m_font.getFontDescription().getSize().value < 3.0
42 ? m_font.primaryFont()->subpixelAscentDescentFontData().get()
43 : m_font.primaryFont();
38 DCHECK(fontData); 44 DCHECK(fontData);
39 if (!fontData) 45 if (!fontData)
40 return 0; 46 return 0;
41 47
42 DCHECK(m_effectiveZoom); 48 DCHECK(m_effectiveZoom);
43 switch (svgStyle.baselineShift()) { 49 switch (svgStyle.baselineShift()) {
44 case BS_LENGTH: 50 case BS_LENGTH:
45 return SVGLengthContext::valueForLength( 51 return SVGLengthContext::valueForLength(
46 svgStyle.baselineShiftValue(), style, 52 svgStyle.baselineShiftValue(), style,
47 m_font.getFontDescription().computedPixelSize() / m_effectiveZoom); 53 m_font.getFontDescription().computedPixelSize() / m_effectiveZoom);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 case AB_MATHEMATICAL: 162 case AB_MATHEMATICAL:
157 return ascent / 2; 163 return ascent / 2;
158 case AB_BASELINE: 164 case AB_BASELINE:
159 default: 165 default:
160 ASSERT_NOT_REACHED(); 166 ASSERT_NOT_REACHED();
161 return 0; 167 return 0;
162 } 168 }
163 } 169 }
164 170
165 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698