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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp
index 560d971671948399be37b02732835171d124d411..bd2f11ecec252e1ef9dc36921a8c15e8d4fefbf2 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp
@@ -34,7 +34,13 @@ SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font,
float SVGTextLayoutEngineBaseline::calculateBaselineShift(
const ComputedStyle& style) const {
const SVGComputedStyle& svgStyle = style.svgStyle();
- const SimpleFontData* fontData = m_font.primaryFont();
+ // If font size is smaller than 3, rounding ascent and descent values in
+ // SimpleFontData sets the baseline shifts for superscript and subscript to
+ // zero. In this case, we use subpixel ascent and descent.
+ const SimpleFontData* fontData =
+ m_font.getFontDescription().getSize().value < 3.0
+ ? m_font.primaryFont()->subpixelAscentDescentFontData().get()
+ : m_font.primaryFont();
DCHECK(fontData);
if (!fontData)
return 0;

Powered by Google App Engine
This is Rietveld 408576698