diff options
author | Tor Lillqvist <tml@novell.com> | 2006-03-30 07:35:02 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2006-03-30 07:35:02 +0000 |
commit | 21323d4d13f1592c56aa0f5f7f2f474044d8ec9d (patch) | |
tree | 572ce9762fd05bc6154add28319c2eb8c92398b1 | |
parent | b1e008021705e2e7f78750618f7a72a4e9c54516 (diff) | |
download | pango-1-10.tar.gz |
Fix blurred underlines on Win32 (#332656):pango-1-10
2006-03-30 Tor Lillqvist <tml@novell.com>
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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | pango/pangocairo-win32font.c | 25 |
2 files changed, 34 insertions, 0 deletions
@@ -1,3 +1,12 @@ +2006-03-30 Tor Lillqvist <tml@novell.com> + + 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 <behdad@gnome.org> * === 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); |