[pango/matthiasc/for-main] Be more forgiving about attribute ordering




commit dd21621c1bba8121151c6828abbb68ef403c7d76
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 1 12:52:48 2021 -0400

    Be more forgiving about attribute ordering
    
    We don't really have firm control over the way
    attributes are ordered in the list, so the
    assumtion that we see proper nesting for baseline
    shifts was a bit optimistic.
    
    Just look through all open stack items for a match,
    and remove that.
    
    Test included.

 pango/pango-layout.c            |  26 ++++++----
 tests/layouts/valid-22.expected | 111 ++++++++++++++++++++++++++++++++++++++++
 tests/layouts/valid-22.markup   |   2 +
 3 files changed, 129 insertions(+), 10 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 098e3a3e..21e2c9c6 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -6248,20 +6248,26 @@ collect_baseline_shift (ParaBreakState *state,
 
           if (attr->end_index == item->offset + item->length)
             {
-              BaselineItem *entry = state->baseline_shifts->data;
+              GList *t;
 
-              if (attr->start_index == entry->attr->start_index &&
-                  attr->end_index == entry->attr->end_index &&
-                  ((PangoAttrInt *)attr)->value == ((PangoAttrInt *)entry->attr)->value)
+              for (t = state->baseline_shifts; t; t = t->next)
                 {
-                  *end_x_offset -= entry->x_offset;
-                  *end_y_offset -= entry->y_offset;
+                  BaselineItem *entry = t->data;
+
+                  if (attr->start_index == entry->attr->start_index &&
+                      attr->end_index == entry->attr->end_index &&
+                      ((PangoAttrInt *)attr)->value == ((PangoAttrInt *)entry->attr)->value)
+                    {
+                      *end_x_offset -= entry->x_offset;
+                      *end_y_offset -= entry->y_offset;
+                    }
+
+                  state->baseline_shifts = g_list_remove (state->baseline_shifts, entry);
+                  g_free (entry);
+                  break;
                 }
-              else
+              if (t == NULL)
                 g_warning ("Baseline attributes mismatch\n");
-
-              state->baseline_shifts = g_list_remove (state->baseline_shifts, entry);
-              g_free (entry);
             }
         }
     }
diff --git a/tests/layouts/valid-22.expected b/tests/layouts/valid-22.expected
new file mode 100644
index 00000000..69c09b04
--- /dev/null
+++ b/tests/layouts/valid-22.expected
@@ -0,0 +1,111 @@
+e0 = ooo...
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 2
+
+--- attributes
+
+range 0 1
+range 1 2
+[1,2]font-desc=Italic
+[1,2]font-scale=2
+[1,2]baseline-shift=2
+range 2 6
+range 6 7
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+range 7 8
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+range 8 9
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+range 9 10
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+[9,11]font-scale=1
+[9,11]baseline-shift=1
+range 10 11
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+[9,11]font-scale=1
+[9,11]baseline-shift=1
+[10,11]font-scale=1
+[10,11]baseline-shift=1
+range 11 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(1) 12(0) 
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'e0 = ooo...
+'
+i=2, index=12, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e'
+i=2, index=1, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '0'
+[1,2]font-scale=2
+[1,2]baseline-shift=2
+i=3, index=2, chars=4, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' = o'
+i=4, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'o'
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+i=5, index=7, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'o'
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+i=6, index=8, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+i=7, index=9, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+[9,11]font-scale=1
+[9,11]baseline-shift=1
+i=8, index=10, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
+[6,11]font-scale=1
+[6,11]baseline-shift=1
+[7,11]font-scale=1
+[7,11]baseline-shift=1
+[8,11]font-scale=1
+[8,11]baseline-shift=1
+[9,11]font-scale=1
+[9,11]baseline-shift=1
+[10,11]font-scale=1
+[10,11]baseline-shift=1
+i=9, index=11, no run, line end
+i=10, index=12, no run, line end
diff --git a/tests/layouts/valid-22.markup b/tests/layouts/valid-22.markup
new file mode 100644
index 00000000..d761749a
--- /dev/null
+++ b/tests/layouts/valid-22.markup
@@ -0,0 +1,2 @@
+
+e<span font_desc="italic"><sub>0</sub></span> = o<sup>o<sup>o<sup>.<sup>.<sup>.</sup></sup></sup></sup></sup>


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