[pango/get-direction: 3/3] Add pango_layout_get_direction



commit d1f82d61341e9d24a7aa06fe20e0e780729ab779
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 16 08:30:51 2019 -0400

    Add pango_layout_get_direction
    
    This lets callers access to resolved text direction
    of a layout. GTK needs this.
    
    Closes: https://gitlab.gnome.org/GNOME/pango/issues/14

 docs/pango-sections.txt |  1 +
 pango/pango-layout.c    | 26 ++++++++++++++++++++++++++
 pango/pango-layout.h    |  5 ++++-
 3 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index c179633b..52d54a5c 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -530,6 +530,7 @@ pango_layout_set_justify
 pango_layout_get_justify
 pango_layout_set_auto_dir
 pango_layout_get_auto_dir
+pango_layout_get_direction
 pango_layout_set_alignment
 pango_layout_get_alignment
 pango_layout_set_tabs
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 67db57bb..47b55f92 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2344,6 +2344,32 @@ pango_layout_line_get_char_direction (PangoLayoutLine *layout_line,
   return PANGO_DIRECTION_LTR;
 }
 
+/**
+ * pango_layout_get_direction:
+ * @layout: a #PangoLayout
+ * @index: the byte index of the char
+ *
+ * Gets the text direction at the given character
+ * position in @layout.
+ *
+ * Returns: the text direction at @index
+ *
+ * Since: 1.45
+ */
+PangoDirection
+pango_layout_get_direction (PangoLayout *layout,
+                            int          index)
+{
+  PangoLayoutLine *line;
+
+  line = pango_layout_index_to_line_and_extents (layout, index, NULL);
+
+  if (line)
+    return pango_layout_line_get_char_direction (line, index);
+
+  return PANGO_DIRECTION_LTR;
+}
+
 /**
  * pango_layout_get_cursor_pos:
  * @layout: a #PangoLayout
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index 0639b1b4..6e7d8380 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -230,7 +230,6 @@ PangoAlignment pango_layout_get_alignment        (PangoLayout                *la
 PANGO_AVAILABLE_IN_ALL
 void           pango_layout_set_tabs             (PangoLayout                *layout,
                                                  PangoTabArray              *tabs);
-
 PANGO_AVAILABLE_IN_ALL
 PangoTabArray* pango_layout_get_tabs             (PangoLayout                *layout);
 
@@ -251,6 +250,10 @@ gboolean           pango_layout_is_ellipsized (PangoLayout        *layout);
 PANGO_AVAILABLE_IN_1_16
 int      pango_layout_get_unknown_glyphs_count (PangoLayout    *layout);
 
+PANGO_AVAILABLE_IN_1_45
+PangoDirection pango_layout_get_direction (PangoLayout *layout,
+                                           int          index);
+
 PANGO_AVAILABLE_IN_ALL
 void     pango_layout_context_changed (PangoLayout    *layout);
 PANGO_AVAILABLE_IN_1_32


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]