summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-12-17 17:48:05 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-12-17 17:48:05 +0000
commit4be3b4d6eade1ff38975e50853575adbfe60a04a (patch)
tree624b0d90619a9f6ad7a5b8358c171c7608244247 /pango
parent3f151baaecdb9e5c860c06a17767e2016bca1289 (diff)
downloadpango-4be3b4d6eade1ff38975e50853575adbfe60a04a.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.c45
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)