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,19 @@ |
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); |
msw
2012/06/06 18:35:25
Does this work ok with DIP / high dpi?
Alexei Svitkine (slow)
2012/06/06 18:46:23
It shouldn't cause any problems - though it will s
|
+ renderer->SetUnderlineMetrics(PANGO_PIXELS(thickness), |
msw
2012/06/06 18:35:25
Should these still use pango_units_to_double as a
Alexei Svitkine (slow)
2012/06/06 18:46:23
Since pango_quantize_line_geometry() guarantees pi
msw
2012/06/06 18:51:52
I guess my point was why not use pango_units_to_do
Alexei Svitkine (slow)
2012/06/06 19:03:05
I've added a comment about it.
|
+ PANGO_PIXELS(position)); |
+} |
+ |
} // namespace |
// TODO(xji): index saved in upper layer is utf16 index. Pango uses utf8 index. |
@@ -445,6 +458,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 +476,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; |
} |