diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-09-11 16:22:33 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-09-11 16:22:33 +0000 |
commit | b8fac1bfdd04bd0daa078c15e24116efca14f616 (patch) | |
tree | b36b67abd7743e900e1c377295b8a24a295a719d /pango/pango-renderer.c | |
parent | 0e89584a6683c8b9c929ccbac28e43838a3085f5 (diff) | |
download | pango-b8fac1bfdd04bd0daa078c15e24116efca14f616.tar.gz |
Bug 347146 – underline/overstrike spaces
2006-09-11 Behdad Esfahbod <behdad@gnome.org>
Bug 347146 – underline/overstrike spaces
* pango/pango-renderer.c (add_underline), (add_strikethrough),
(pango_renderer_draw_layout_line): Use logical extents for
x and width of underline/strikethrough, such that trailing spaces are
correctly handled.
* pango/pango-layout.c (pango_layout_run_get_extents): Use logical
rect for underline/strikethrough, and reflect that in run ink extents.
* pango/pango-layout.c (pango_layout_line_get_extents): Don't
let runs with empty ink extents affect total ink extents.
Diffstat (limited to 'pango/pango-renderer.c')
-rw-r--r-- | pango/pango-renderer.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index f54e1282..7d165f82 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -289,7 +289,8 @@ add_underline (PangoRenderer *renderer, PangoFontMetrics *metrics, int base_x, int base_y, - PangoRectangle *ink_rect) + PangoRectangle *ink_rect, + PangoRectangle *logical_rect) { PangoRectangle *current_rect = &state->underline_rect; PangoRectangle new_rect; @@ -297,8 +298,8 @@ add_underline (PangoRenderer *renderer, int underline_thickness = pango_font_metrics_get_underline_thickness (metrics); int underline_position = pango_font_metrics_get_underline_position (metrics); - new_rect.x = base_x + ink_rect->x; - new_rect.width = ink_rect->width; + new_rect.x = base_x + logical_rect->x; + new_rect.width = logical_rect->width; new_rect.height = underline_thickness; new_rect.y = base_y; @@ -316,14 +317,13 @@ add_underline (PangoRenderer *renderer, new_rect.y += ink_rect->y + ink_rect->height + underline_thickness; break; } + int new_pos; if (renderer->underline == state->underline && new_rect.y == current_rect->y && new_rect.height == current_rect->height) { - current_rect->y = new_rect.y; current_rect->width = new_rect.x + new_rect.width - current_rect->x; - current_rect->height = new_rect.height; } else { @@ -340,7 +340,8 @@ add_strikethrough (PangoRenderer *renderer, PangoFontMetrics *metrics, int base_x, int base_y, - PangoRectangle *ink_rect) + PangoRectangle *ink_rect, + PangoRectangle *logical_rect) { PangoRectangle *current_rect = &state->strikethrough_rect; PangoRectangle new_rect; @@ -348,8 +349,8 @@ add_strikethrough (PangoRenderer *renderer, int strikethrough_thickness = pango_font_metrics_get_strikethrough_thickness (metrics); int strikethrough_position = pango_font_metrics_get_strikethrough_position (metrics); - new_rect.x = base_x + ink_rect->x; - new_rect.width = ink_rect->width; + new_rect.x = base_x + logical_rect->x; + new_rect.width = logical_rect->width; new_rect.y = base_y - strikethrough_position; new_rect.height = strikethrough_thickness; @@ -357,9 +358,7 @@ add_strikethrough (PangoRenderer *renderer, new_rect.y == current_rect->y && new_rect.height == current_rect->height) { - current_rect->y = new_rect.y; current_rect->width = new_rect.x + new_rect.width - current_rect->x; - current_rect->height = new_rect.height; } else { @@ -493,13 +492,18 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer, { ink_rect = shape_attr->ink_rect; logical_rect = shape_attr->logical_rect; + ink = &ink_rect; + logical = &logical_rect; glyph_string_width = shape_attr->logical_rect.width; } else { if (renderer->underline != PANGO_UNDERLINE_NONE || renderer->strikethrough) - ink = &ink_rect; + { + ink = &ink_rect; + logical = &logical_rect; + } pango_glyph_string_extents (run->glyphs, run->item->analysis.font, ink, logical); if (logical) @@ -550,12 +554,12 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer, if (renderer->underline != PANGO_UNDERLINE_NONE) add_underline (renderer, &state,metrics, x + x_off, y - rise, - &ink_rect); + ink, logical); if (renderer->strikethrough) add_strikethrough (renderer, &state, metrics, x + x_off, y - rise, - &ink_rect); + ink, logical); pango_font_metrics_unref (metrics); } |