diff options
author | Elliot Lee <sopwith@redhat.com> | 2000-08-04 03:22:08 +0000 |
---|---|---|
committer | Elliot Lee <sopwith@src.gnome.org> | 2000-08-04 03:22:08 +0000 |
commit | b8a07999404dae9364733ba956e8c5eccbaed341 (patch) | |
tree | f7814daaee67bf009b0d170f2e62144542d9d02c /pango/pango-layout.c | |
parent | b77b31c48f62191054c57e2b0696aef3f8654d1a (diff) | |
download | pango-b8a07999404dae9364733ba956e8c5eccbaed341.tar.gz |
Fix segfault when tmp_list has no 'prev' pointer. Infinite loops do not
2000-08-03 Elliot Lee <sopwith@redhat.com>
* pango/modules.c: Fix segfault when tmp_list has no 'prev' pointer.
* pango/pango-attributes.c (pango_attr_list_insert_internal): Infinite loops do not fast programs make.
* pango/pango-context.c: Set a default font size so that things don't go boom if someone forgets to set it themselves.
* pango/pango-layout.c (pango_layout_index_to_pos): Exclude newlines from consideration.
(pango_layout_line_index_to_x): Take shape attributes into consideration when determining position.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 2c10c41b..84acc12e 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -19,8 +19,8 @@ * Boston, MA 02111-1307, USA. */ -#include <pango/pango-layout.h> #include <pango/pango.h> /* For pango_shape() */ +#include <pango/pango-layout.h> #include <string.h> #define LINE_IS_VALID(line) ((line)->layout != NULL) @@ -642,27 +642,43 @@ pango_layout_line_index_to_x (PangoLayoutLine *line, { PangoRectangle logical_rect; PangoLayoutRun *run = run_list->data; + gboolean shape_set; + pango_layout_get_item_properties (run->item, NULL, NULL, &logical_rect, &shape_set); + if (run->item->offset <= index && run->item->offset + run->item->length > index) { - pango_glyph_string_index_to_x (run->glyphs, - line->layout->text + run->item->offset, - run->item->length, - &run->item->analysis, - index - run->item->offset, trailing, x_pos); - - if (x_pos) - *x_pos += width; + if (shape_set) + { + if (x_pos) + *x_pos = width + (trailing ? logical_rect.width : 0); + } + else + { + pango_glyph_string_index_to_x (run->glyphs, + line->layout->text + run->item->offset, + run->item->length, + &run->item->analysis, + index - run->item->offset, trailing, x_pos); + + if (x_pos) + *x_pos += width; + } return; } - pango_glyph_string_extents (run->glyphs, run->item->analysis.font, - NULL, &logical_rect); + if (!shape_set) + pango_glyph_string_extents (run->glyphs, run->item->analysis.font, + NULL, &logical_rect); + width += logical_rect.width; run_list = run_list->next; } + + if(x_pos) + *x_pos = width; } /** @@ -1017,6 +1033,8 @@ pango_layout_index_to_pos (PangoLayout *layout, tmp_list = tmp_list->next; bytes_seen += layout_line->length; + if (tmp_list && layout->text[bytes_seen] == '\n') + bytes_seen++; pos->y += logical_rect.height; } |