diff options
author | Owen Taylor <otaylor@redhat.com> | 2004-12-17 17:47:48 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2004-12-17 17:47:48 +0000 |
commit | 9c03716c09258556049be6ec8055b927f3bafb5b (patch) | |
tree | ca53d52c35a7168c70bac4606bb90fc18093d1a7 /pango | |
parent | 72672341918128556cc486afcd6e9af0f1507379 (diff) | |
download | pango-9c03716c09258556049be6ec8055b927f3bafb5b.tar.gz |
Fix bug in computing logical_rect.x when layout->width == -1. (#161510,
Fri Dec 17 12:28:56 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_get_extents_internal): Fix
bug in computing logical_rect.x when layout->width == -1.
(#161510, Morten Welinder)
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-layout.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 6b46812e..53106f20 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -2037,6 +2037,14 @@ pango_layout_get_extents_internal (PangoLayout *layout, pango_layout_get_extents (layout, NULL, &overall_logical); width = overall_logical.width; } + + if (logical_rect) + { + logical_rect->x = 0; + logical_rect->y = 0; + logical_rect->width = 0; + logical_rect->height = 0; + } line_list = layout->lines; while (line_list) @@ -2096,24 +2104,35 @@ pango_layout_get_extents_internal (PangoLayout *layout, if (logical_rect) { - /* Compute union of line_logical_layout with - * current logical_rect - */ - - if (line_list == layout->lines) + if (layout->width == -1) { - *logical_rect = line_logical_layout; + /* When no width is set on layout, we can just compute the max of the + * line lengths to get the horizontal extents ... logical_rect.x = 0. + */ + logical_rect->width = MAX (logical_rect->width, line_logical_layout.width); } else { - new_pos = MIN (logical_rect->x, line_logical_layout.x); - logical_rect->width = - MAX (logical_rect->x + logical_rect->width, - line_logical_layout.x + line_logical_layout.width) - new_pos; - logical_rect->x = new_pos; - - logical_rect->height += line_logical_layout.height; + /* When a width is set, we have to compute the union of the horizontal + * extents of all the lines. + */ + if (line_list == layout->lines) + { + logical_rect->x = line_logical_layout.x; + logical_rect->width = line_logical_layout.width; + } + else + { + new_pos = MIN (logical_rect->x, line_logical_layout.x); + logical_rect->width = + MAX (logical_rect->x + logical_rect->width, + line_logical_layout.x + line_logical_layout.width) - new_pos; + logical_rect->x = new_pos; + + } } + + logical_rect->height += line_logical_layout.height; /* No space after the last line, of course. */ if (line_list->next != NULL) |