summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorJody Goldberg <jody@gnome.org>2004-05-28 04:32:04 +0000
committerJody Goldberg <jody@src.gnome.org>2004-05-28 04:32:04 +0000
commitc4ee717810300dde325af4fd818b787dcc25316a (patch)
tree4da8293dbbee3a2c7c489bdb1cb07f57e956ac05 /pango
parent2b0569285270c365f74d36fde991d193e7d82462 (diff)
downloadpango-c4ee717810300dde325af4fd818b787dcc25316a.tar.gz
Backport to 1.4.x
2004-04-29 Jody Goldberg <jody@gnome.org> * pango/pango-layout.c (get_alignment) : only invert if the layout and the context really disagree, not if they are WEAK_LTR vs LTR 2004-03-11 Jody Goldberg <jody@gnome.org> * pango/pango-attributes.h : Add a comment clarifying that PangoAttribute::end_index is _exclusive_. The range is [start..end) Additionally clarify that that the indicies are in _bytes_ not characters.
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-attributes.h4
-rw-r--r--pango/pango-layout.c21
2 files changed, 22 insertions, 3 deletions
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index b3dd3fa3..4488d3e9 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -95,8 +95,8 @@ typedef enum {
struct _PangoAttribute
{
const PangoAttrClass *klass;
- guint start_index;
- guint end_index;
+ guint start_index; /* in bytes */
+ guint end_index; /* the character containing this byte is not included */
};
typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute,
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index ae5580b3..cf070263 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1833,6 +1833,24 @@ pango_layout_get_cursor_pos (PangoLayout *layout,
}
}
+static inline int
+direction_simple (PangoDirection d)
+{
+ switch (d)
+ {
+ case PANGO_DIRECTION_LTR : return 1;
+ case PANGO_DIRECTION_RTL : return -1;
+ case PANGO_DIRECTION_TTB_LTR : return 1;
+ case PANGO_DIRECTION_TTB_RTL : return -1;
+ case PANGO_DIRECTION_WEAK_LTR : return 1;
+ case PANGO_DIRECTION_WEAK_RTL : return -1;
+ case PANGO_DIRECTION_NEUTRAL : return 0;
+ /* no default compiler should complain if a new values is added */
+ }
+ /* not reached */
+ return 0;
+}
+
static PangoAlignment
get_alignment (PangoLayout *layout,
PangoLayoutLine *line)
@@ -1840,7 +1858,8 @@ get_alignment (PangoLayout *layout,
PangoAlignment alignment = layout->alignment;
if (line->layout->auto_dir &&
- line->resolved_dir != pango_context_get_base_dir (layout->context))
+ direction_simple (line->resolved_dir) ==
+ -direction_simple (pango_context_get_base_dir (layout->context)))
{
if (alignment == PANGO_ALIGN_LEFT)
alignment = PANGO_ALIGN_RIGHT;