From f4864b10a11b203347d7fa7ed41a499b76d62d88 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 1 Apr 2006 19:20:57 +0000 Subject: Fix blurred underlines on Win32 (#332656): 2006-04-01 Tor Lillqvist Fix blurred underlines on Win32 (#332656): * pango/pangocairo-win32font.c (quantize_position): New function, copy from pangofc-font.c. (create_metrics_for_context): Call quantize_position() for underline and strikethrough position and thickness. --- pango/pangocairo-win32font.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'pango') diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c index 40e5be85..d4df0d6f 100644 --- a/pango/pangocairo-win32font.c +++ b/pango/pangocairo-win32font.c @@ -268,6 +268,28 @@ pango_cairo_win32_font_get_glyph_extents (PangoFont *font, *logical_rect = info->logical_rect; } +static void +quantize_position (int *thickness, + int *position) +{ + int thickness_pixels = (*thickness + PANGO_SCALE / 2) / PANGO_SCALE; + if (thickness_pixels == 0) + thickness_pixels = 1; + + if (thickness_pixels & 1) + { + int new_center = ((*position - *thickness / 2) & ~(PANGO_SCALE - 1)) + PANGO_SCALE / 2; + *position = new_center + (PANGO_SCALE * thickness_pixels) / 2; + } + else + { + int new_center = ((*position - *thickness / 2 + PANGO_SCALE / 2) & ~(PANGO_SCALE - 1)); + *position = new_center + (PANGO_SCALE * thickness_pixels) / 2; + } + + *thickness = thickness_pixels * PANGO_SCALE; +} + static PangoFontMetrics * create_metrics_for_context (PangoFont *font, PangoContext *context) @@ -302,6 +324,9 @@ create_metrics_for_context (PangoFont *font, metrics->strikethrough_thickness = metrics->underline_thickness; metrics->strikethrough_position = height / 4; + quantize_position (&metrics->underline_thickness, &metrics->underline_position); + quantize_position (&metrics->strikethrough_thickness, &metrics->strikethrough_position); + layout = pango_layout_new (context); font_desc = pango_font_describe (font); pango_layout_set_font_description (layout, font_desc); -- cgit v1.2.1