diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-06-04 22:48:45 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-06-04 22:48:45 +0000 |
commit | d74d5c26553f0ad8af369680f4f4468d4d57bb6f (patch) | |
tree | 033caeb0799c8d5c721c70785a589851dd1b2a7d | |
parent | dda364c26eeacac0a6a41d89cf291d3671fc570d (diff) | |
download | pango-d74d5c26553f0ad8af369680f4f4468d4d57bb6f.tar.gz |
Improve handling of empty ink rectangles; rework for simplicity.
Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com>
* pango/glyphstring.c (pango_glyph_string_extents_range):
Improve handling of empty ink rectangles; rework for
simplicity.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 8 | ||||
-rw-r--r-- | pango/glyphstring.c | 104 |
6 files changed, 90 insertions, 54 deletions
@@ -1,3 +1,9 @@ +Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com> + + * pango/glyphstring.c (pango_glyph_string_extents_range): + Improve handling of empty ink rectangles; rework for + simplicity. + Mon Jun 2 12:10:11 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-glyph-item.c (pango_glyph_item_apply_attrs): @@ -50,7 +56,7 @@ Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com> Tue May 27 18:37:44 2003 Owen Taylor <otaylor@redhat.com> * pango/mini-fribidi/fribidi.c (fribidi_analyse_string): - Limit the size of the buffers we alloca(). (#104238) + Limit the size of the buffers we alloca(). (#104328) Tue May 27 16:51:32 2003 Owen Taylor <otaylor@redhat.com> diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 50b3044d..f331575a 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,9 @@ +Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com> + + * pango/glyphstring.c (pango_glyph_string_extents_range): + Improve handling of empty ink rectangles; rework for + simplicity. + Mon Jun 2 12:10:11 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-glyph-item.c (pango_glyph_item_apply_attrs): @@ -50,7 +56,7 @@ Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com> Tue May 27 18:37:44 2003 Owen Taylor <otaylor@redhat.com> * pango/mini-fribidi/fribidi.c (fribidi_analyse_string): - Limit the size of the buffers we alloca(). (#104238) + Limit the size of the buffers we alloca(). (#104328) Tue May 27 16:51:32 2003 Owen Taylor <otaylor@redhat.com> diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 50b3044d..f331575a 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,9 @@ +Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com> + + * pango/glyphstring.c (pango_glyph_string_extents_range): + Improve handling of empty ink rectangles; rework for + simplicity. + Mon Jun 2 12:10:11 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-glyph-item.c (pango_glyph_item_apply_attrs): @@ -50,7 +56,7 @@ Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com> Tue May 27 18:37:44 2003 Owen Taylor <otaylor@redhat.com> * pango/mini-fribidi/fribidi.c (fribidi_analyse_string): - Limit the size of the buffers we alloca(). (#104238) + Limit the size of the buffers we alloca(). (#104328) Tue May 27 16:51:32 2003 Owen Taylor <otaylor@redhat.com> diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 50b3044d..f331575a 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,9 @@ +Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com> + + * pango/glyphstring.c (pango_glyph_string_extents_range): + Improve handling of empty ink rectangles; rework for + simplicity. + Mon Jun 2 12:10:11 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-glyph-item.c (pango_glyph_item_apply_attrs): @@ -50,7 +56,7 @@ Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com> Tue May 27 18:37:44 2003 Owen Taylor <otaylor@redhat.com> * pango/mini-fribidi/fribidi.c (fribidi_analyse_string): - Limit the size of the buffers we alloca(). (#104238) + Limit the size of the buffers we alloca(). (#104328) Tue May 27 16:51:32 2003 Owen Taylor <otaylor@redhat.com> diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 50b3044d..f331575a 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,9 @@ +Wed Jun 4 14:32:47 2003 Owen Taylor <otaylor@redhat.com> + + * pango/glyphstring.c (pango_glyph_string_extents_range): + Improve handling of empty ink rectangles; rework for + simplicity. + Mon Jun 2 12:10:11 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-glyph-item.c (pango_glyph_item_apply_attrs): @@ -50,7 +56,7 @@ Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com> Tue May 27 18:37:44 2003 Owen Taylor <otaylor@redhat.com> * pango/mini-fribidi/fribidi.c (fribidi_analyse_string): - Limit the size of the buffers we alloca(). (#104238) + Limit the size of the buffers we alloca(). (#104328) Tue May 27 16:51:32 2003 Owen Taylor <otaylor@redhat.com> diff --git a/pango/glyphstring.c b/pango/glyphstring.c index f4766191..6fad2a35 100644 --- a/pango/glyphstring.c +++ b/pango/glyphstring.c @@ -149,27 +149,30 @@ pango_glyph_string_extents_range (PangoGlyphString *glyphs, int x_pos = 0; int i; + /* Note that the handling of empty rectangles for ink + * and logical rectangles is different. A zero-height ink + * rectangle makes no contribution to the overall ink rect, + * while a zero-height logical rect still reserves horizontal + * width. Also, we may return zero-width, positive height + * logical rectangles, while we'll never do that for the + * ink rect. + */ g_return_if_fail (start <= end); - if (end - start == 0) + if (ink_rect) { - if (ink_rect) - { - ink_rect->x = 0; - ink_rect->y = 0; - ink_rect->width = 0; - ink_rect->height = 0; - } - - if (logical_rect) - { - logical_rect->x = 0; - logical_rect->y = 0; - logical_rect->width = 0; - logical_rect->height = 0; - } - - return; + ink_rect->x = 0; + ink_rect->y = 0; + ink_rect->width = 0; + ink_rect->height = 0; + } + + if (logical_rect) + { + logical_rect->x = 0; + logical_rect->y = 0; + logical_rect->width = 0; + logical_rect->height = 0; } for (i = start; i < end; i++) @@ -179,52 +182,55 @@ pango_glyph_string_extents_range (PangoGlyphString *glyphs, PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry; - if (i == start) - { - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, - ink_rect, logical_rect); + pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, + ink_rect ? &glyph_ink : NULL, + logical_rect ? &glyph_logical : NULL); - if (logical_rect) + if (ink_rect && glyph_ink.width != 0 && glyph_ink.height != 0) + { + if (ink_rect->width == 0 || ink_rect->height == 0) { - logical_rect->x = 0; - logical_rect->width = geometry->width; + ink_rect->x = x_pos + glyph_ink.x; + ink_rect->width = glyph_ink.width; + ink_rect->y = glyph_ink.y; + ink_rect->height = glyph_ink.height; } - } - else - { - int new_pos; - - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, - ink_rect ? &glyph_ink : NULL, - logical_rect ? &glyph_logical : NULL); - - if (ink_rect) + else { - new_pos = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset); + int new_x, new_y; + + new_x = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset); ink_rect->width = MAX (ink_rect->x + ink_rect->width, - x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_pos; - ink_rect->x = new_pos; - - new_pos = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset); + x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_x; + ink_rect->x = new_x; + + new_y = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset); ink_rect->height = MAX (ink_rect->y + ink_rect->height, - glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_pos; - ink_rect->y = new_pos; + glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_y; + ink_rect->y = new_y; } + } - if (logical_rect) - { - logical_rect->width += geometry->width; + if (logical_rect) + { + logical_rect->width += geometry->width; - new_pos = MIN (logical_rect->y, glyph_logical.y); + if (i == start) + { + logical_rect->y = glyph_logical.y; + logical_rect->height = glyph_logical.height; + } + else + { + int new_y = MIN (logical_rect->y, glyph_logical.y); logical_rect->height = MAX (logical_rect->y + logical_rect->height, - glyph_logical.y + glyph_logical.height) - new_pos; - logical_rect->y = new_pos; + glyph_logical.y + glyph_logical.height) - new_y; + logical_rect->y = new_y; } } x_pos += geometry->width; } - } /** |