[pango/item-offset: 6/6] layout: Use char_offset in a few places




commit 523bacd47a5f0dba4ee9df238c277e685f2646ba
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 28 11:28:45 2021 -0400

    layout: Use char_offset in a few places
    
    There is more we can do here, but this is a start.

 pango/pango-layout.c | 30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index ac396ba0..de1dc19d 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -76,7 +76,7 @@
 #include "config.h"
 #include "pango-glyph.h"                /* For pango_shape() */
 #include "pango-break.h"
-#include "pango-item.h"
+#include "pango-item-private.h"
 #include "pango-engine.h"
 #include "pango-impl-utils.h"
 #include "pango-glyph-item.h"
@@ -5932,18 +5932,8 @@ justify_clusters (PangoLayoutLine *line,
 
           dir = run->item->analysis.level % 2 == 0 ? +1 : -1;
 
-          /* We need character offset of the start of the run.  We don't have this.
-           * Compute by counting from the beginning of the line.  The naming is
-           * confusing.  Note that:
-           *
-           * run->item->offset        is byte offset of start of run in layout->text.
-           * state->line_start_index  is byte offset of start of line in layout->text.
-           * state->line_start_offset is character offset of start of line in layout->text.
-           */
-          g_assert (run->item->offset >= state->line_start_index);
-          offset = state->line_start_offset
-                 + pango_utf8_strlen (text + state->line_start_index,
-                                      run->item->offset - state->line_start_index);
+          g_assert (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET);
+          offset = ((PangoItemPrivate *)run->item)->char_offset;
 
           for (have_cluster = dir > 0 ?
                  pango_glyph_item_iter_init_start (&cluster_iter, run, text) :
@@ -6077,18 +6067,8 @@ justify_words (PangoLayoutLine *line,
           gboolean have_cluster;
           int offset;
 
-          /* We need character offset of the start of the run.  We don't have this.
-           * Compute by counting from the beginning of the line.  The naming is
-           * confusing.  Note that:
-           *
-           * run->item->offset        is byte offset of start of run in layout->text.
-           * state->line_start_index  is byte offset of start of line in layout->text.
-           * state->line_start_offset is character offset of start of line in layout->text.
-           */
-          g_assert (run->item->offset >= state->line_start_index);
-          offset = state->line_start_offset
-                 + pango_utf8_strlen (text + state->line_start_index,
-                                      run->item->offset - state->line_start_index);
+          g_assert (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET);
+          offset = ((PangoItemPrivate *)run->item)->char_offset;
 
           for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter, run, text);
                have_cluster;


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