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

Unified Diff: ui/gfx/render_text_linux.cc

Issue 10520017: Use pango underline metrics in RenderTextLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_linux.cc
===================================================================
--- ui/gfx/render_text_linux.cc (revision 141008)
+++ ui/gfx/render_text_linux.cc (working copy)
@@ -70,6 +70,21 @@
return subpixel_enabled;
}
+// Sets underline metrics on |renderer| according to Pango font |desc|.
+void SetPangoUnderlineMetrics(PangoFontDescription *desc,
+ internal::SkiaTextRenderer* renderer) {
+ PangoFontMetrics* metrics = GetPangoFontMetrics(desc);
+ int thickness = pango_font_metrics_get_underline_thickness(metrics);
+ // Pango returns the position "above the baseline". Change its sign to convert
+ // it to a vertical offset from the baseline.
+ int position = -pango_font_metrics_get_underline_position(metrics);
+ pango_quantize_line_geometry(&thickness, &position);
+ // Note: pango_quantize_line_geometry() guarantees pixel boundaries, so
+ // PANGO_PIXELS() is safe to use.
+ renderer->SetUnderlineMetrics(PANGO_PIXELS(thickness),
+ PANGO_PIXELS(position));
+}
+
} // namespace
// TODO(xji): index saved in upper layer is utf16 index. Pango uses utf8 index.
@@ -445,6 +460,8 @@
renderer.SetForegroundColor(styles[style].foreground);
renderer.SetFontFamilyWithStyle(family_name, styles[style].font_style);
renderer.DrawPosText(&pos[start], &glyphs[start], i - start);
+ if (styles[style].underline)
+ SetPangoUnderlineMetrics(desc.get(), &renderer);
renderer.DrawDecorations(start_x, y, glyph_x - start_x, styles[style]);
start = i;
@@ -461,6 +478,8 @@
renderer.SetForegroundColor(styles[style].foreground);
renderer.SetFontFamilyWithStyle(family_name, styles[style].font_style);
renderer.DrawPosText(&pos[start], &glyphs[start], glyph_count - start);
+ if (styles[style].underline)
+ SetPangoUnderlineMetrics(desc.get(), &renderer);
renderer.DrawDecorations(start_x, y, glyph_x - start_x, styles[style]);
x = glyph_x;
}
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698