From fd3c2ca4ef69e7c4b3677b399ae04d0d6f82bffa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 30 May 2006 04:23:40 +0000 Subject: =?UTF-8?q?Bug=20125378=20=E2=80=93=20Better=20underline=20thickne?= =?UTF-8?q?ss=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-05-30 Behdad Esfahbod Bug 125378 – Better underline thickness handling * pango/pango-layout.c (pango_layout_run_get_extents): Include underline in ink extents. --- ChangeLog | 7 +++++ pango/pango-layout.c | 75 ++++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index f45aeb03..691c4acc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-05-30 Behdad Esfahbod + + Bug 125378 – Better underline thickness handling + + * pango/pango-layout.c (pango_layout_run_get_extents): Include + underline in ink extents. + 2006-05-30 Behdad Esfahbod * pango/pangocairo-render.c (draw_error_underline): Fix offset to diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 7b4b5c4e..c95b6390 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3920,57 +3920,52 @@ pango_layout_run_get_extents (PangoLayoutRun *run, PangoRectangle *run_logical) { ItemProperties properties; - PangoRectangle tmp_ink; - gboolean need_ink; pango_layout_get_item_properties (run->item, &properties); - need_ink = run_ink || properties.uline == PANGO_UNDERLINE_LOW; - if (properties.shape_set) imposed_extents (run->item->num_chars, properties.shape_ink_rect, properties.shape_logical_rect, - need_ink ? &tmp_ink : NULL, run_logical); + run_ink, run_logical); else pango_glyph_string_extents (run->glyphs, run->item->analysis.font, - need_ink ? &tmp_ink : NULL, - run_logical); - - if (run_ink) - *run_ink = tmp_ink; + run_ink, run_logical); - switch (properties.uline) + if (properties.uline != PANGO_UNDERLINE_NONE) { - case PANGO_UNDERLINE_NONE: - break; - case PANGO_UNDERLINE_ERROR: - if (run_ink) - run_ink->height = MAX (run_ink->height, 3 * PANGO_SCALE - run_ink->y); - if (run_logical) - run_logical->height = MAX (run_logical->height, 3 * PANGO_SCALE - run_logical->y); - break; - case PANGO_UNDERLINE_SINGLE: - if (run_ink) - run_ink->height = MAX (run_ink->height, 2 * PANGO_SCALE - run_ink->y); - if (run_logical) - run_logical->height = MAX (run_logical->height, 2 * PANGO_SCALE - run_logical->y); - break; - case PANGO_UNDERLINE_DOUBLE: - if (run_ink) - run_ink->height = MAX (run_ink->height, 4 * PANGO_SCALE - run_ink->y); - if (run_logical) - run_logical->height = MAX (run_logical->height, 4 * PANGO_SCALE - run_logical->y); - break; - case PANGO_UNDERLINE_LOW: - /* FIXME: Should this simply be run_logical->height += 2 * PANGO_SCALE instead? - */ - if (run_ink) - run_ink->height += 2 * PANGO_SCALE; - if (run_logical) - run_logical->height = MAX (run_logical->height, - tmp_ink.y + tmp_ink.height + 2 * PANGO_SCALE - run_logical->y); - break; + PangoFontMetrics *metrics = pango_font_get_metrics (run->item->analysis.font, + run->item->analysis.language); + int underline_thickness = pango_font_metrics_get_underline_thickness (metrics); + int underline_position = pango_font_metrics_get_underline_position (metrics); + + switch (properties.uline) + { + case PANGO_UNDERLINE_ERROR: + if (run_ink) + run_ink->height = MAX (run_ink->height, + 3 * underline_thickness - underline_position - run_ink->y); + break; + case PANGO_UNDERLINE_SINGLE: + if (run_ink) + run_ink->height = MAX (run_ink->height, + underline_thickness - underline_position - run_ink->y); + break; + case PANGO_UNDERLINE_DOUBLE: + if (run_ink) + run_ink->height = MAX (run_ink->height, + 3 * underline_thickness - underline_position - run_ink->y); + break; + case PANGO_UNDERLINE_LOW: + if (run_ink) + run_ink->height += 2 * underline_thickness; + break; + default: + g_critical ("unknown underline mode"); + break; + } + + pango_font_metrics_unref (metrics); } if (properties.rise != 0) -- cgit v1.2.1