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

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
« ui/gfx/render_text.cc ('K') | « 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 140345)
+++ ui/gfx/render_text_linux.cc (working copy)
@@ -70,6 +70,18 @@
return subpixel_enabled;
}
+// Sets underline metrics on |renderer| according to Pango font |desc|.
+void SetPangoUnderlineMetrics(PangoFontDescription *desc,
+ internal::SkiaTextRenderer* renderer) {
+ PangoFontMetrics* metrics = GetPangoFontMetrics(desc);
+ const int underline_thickness =
msw 2012/06/06 01:12:51 nit: nix "underline_" from the names to fit each o
Alexei Svitkine (slow) 2012/06/06 14:46:27 Done.
+ pango_font_metrics_get_underline_thickness(metrics);
+ const int underline_position =
+ pango_font_metrics_get_underline_position(metrics);
+ renderer->SetUnderlineMetrics(pango_units_to_double(underline_thickness),
+ pango_units_to_double(underline_position));
+}
+
} // namespace
// TODO(xji): index saved in upper layer is utf16 index. Pango uses utf8 index.
@@ -445,6 +457,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 +475,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;
}
« ui/gfx/render_text.cc ('K') | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698