summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-07-03 21:32:39 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-07-03 21:32:39 +0000
commit29295c64ab846ad40d6c9d0faeb1810a3a65e948 (patch)
tree98470d36b55c3a6566f1e9171fe543746d9ebbd4
parent38dcbb203cb855b435301c8e27c4427213b75a14 (diff)
downloadpango-29295c64ab846ad40d6c9d0faeb1810a3a65e948.tar.gz
Handle the case where the byte offset is outside the layout.
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.
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.pre-1-05
-rw-r--r--ChangeLog.pre-1-105
-rw-r--r--ChangeLog.pre-1-25
-rw-r--r--ChangeLog.pre-1-45
-rw-r--r--ChangeLog.pre-1-65
-rw-r--r--ChangeLog.pre-1-85
-rw-r--r--pango/pango-layout.c40
8 files changed, 72 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c1ac1cff..be2709e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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