From 21323d4d13f1592c56aa0f5f7f2f474044d8ec9d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 30 Mar 2006 07:35:02 +0000 Subject: Fix blurred underlines on Win32 (#332656): 2006-03-30 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. --- ChangeLog | 9 +++++++++ pango/pangocairo-win32font.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4831f4c9..0c783ee2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-03-30 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. + 2006-02-26 Behdad Esfahbod * === Released 1.10.4 === diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c index e5d8dc0d..69a7f4b6 100644 --- a/pango/pangocairo-win32font.c +++ b/pango/pangocairo-win32font.c @@ -264,6 +264,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) @@ -298,6 +320,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