diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 5 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 5 | ||||
-rw-r--r-- | pango/pango-layout.c | 40 |
8 files changed, 72 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index c1ac1cff..be2709e8 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,8 @@ +2000-07-03 Havoc Pennington <hp@redhat.com> + + * pango/pango-layout.c (pango_layout_index_to_pos): Handle the + case where the byte offset is outside the layout. + Sun Jul 2 18:06:01 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (get_tab_pos): Fix up set_font_description() diff --git a/pango/pango-layout.c b/pango/pango-layout.c index c622873a..21ab041f 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -961,10 +961,12 @@ pango_layout_index_to_pos (PangoLayout *layout, GSList *tmp_list; int bytes_seen = 0; int width; + PangoDirection base_dir; + int x_offset; g_return_if_fail (layout != NULL); - g_return_if_fail (index >= 0 && index < layout->length); - + g_return_if_fail (index >= 0); + pos->y = 0; pango_layout_check_lines (layout); @@ -986,7 +988,6 @@ pango_layout_index_to_pos (PangoLayout *layout, if (bytes_seen + layout_line->length > index) { int x_pos; - int x_offset; if (layout->alignment == PANGO_ALIGN_RIGHT) x_offset = width - logical_rect.width; @@ -1012,6 +1013,39 @@ pango_layout_index_to_pos (PangoLayout *layout, bytes_seen += layout_line->length; pos->y += logical_rect.height; } + + /* Return a zero-width rectangle on the left or right side of the + * last line. + */ + g_assert (index >= layout->length); + + pos->y -= logical_rect.height; + pos->height = logical_rect.height; + pos->width = 0; + + base_dir = pango_context_get_base_dir (layout->context); + + if (layout->alignment == PANGO_ALIGN_RIGHT) + x_offset = width - logical_rect.width; + else if (layout->alignment == PANGO_ALIGN_CENTER) + x_offset = (width - logical_rect.width) / 2; + else + x_offset = 0; + + switch (base_dir) + { + case PANGO_DIRECTION_LTR: + pos->x = x_offset + logical_rect.width; + break; + + case PANGO_DIRECTION_RTL: + pos->x = x_offset; + break; + + default: + g_assert_not_reached (); + break; + } } static void |