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

Unified Diff: ui/gfx/render_text_pango.cc

Issue 509093004: linux: Make RenderTextPango avoid clipping underlines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/platform_font_pango.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_pango.cc
diff --git a/ui/gfx/render_text_pango.cc b/ui/gfx/render_text_pango.cc
index 86a52425a00e60ce9a66a538f61b9a4139fc9be9..07cbfb93cdf5c0e71d09261b618bd009028ba17c 100644
--- a/ui/gfx/render_text_pango.cc
+++ b/ui/gfx/render_text_pango.cc
@@ -55,11 +55,20 @@ void SetPangoUnderlineMetrics(PangoFontDescription *desc,
// 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));
+ pango_quantize_line_geometry(&thickness, &position);
+ int thickness_pixels = PANGO_PIXELS(thickness);
+ int position_pixels = PANGO_PIXELS(position);
+
+ // Ugly hack: make sure that underlines don't get clipped. See
+ // http://crbug.com/393117.
+ int descent_pixels = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
Daniel Erat 2014/08/28 20:37:23 it's also possible that this isn't the right fix a
msw 2014/08/29 00:41:55 I honestly don't know the Pango underline code tha
+ position_pixels = std::min(position_pixels,
+ descent_pixels - thickness_pixels);
+
+ renderer->SetUnderlineMetrics(thickness_pixels, position_pixels);
}
} // namespace
« no previous file with comments | « ui/gfx/platform_font_pango.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698