[pango/ignore-width-in-horizontal2] itemize: Ignore width in horizontal context
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/ignore-width-in-horizontal2] itemize: Ignore width in horizontal context
- Date: Wed, 4 Aug 2021 03:55:31 +0000 (UTC)
commit 90777d89aa15fb2be260dc442d5cf4ce5a15234d
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Aug 3 23:41:27 2021 -0400
itemize: Ignore width in horizontal context
Changes in width only need to break runs in
vertical context.
Update tests and add a new test.
Fixes: #503
pango/pango-context.c | 3 +++
tests/layouts/valid-14.expected | 17 ++++++++---------
tests/layouts/valid-14.markup | 2 +-
tests/layouts/valid-19.expected | 32 ++++++++++++++------------------
tests/layouts/valid-21.expected | 36 ++++++++++++++++++++++++++++++++++++
tests/layouts/valid-21.markup | 2 ++
tests/test-layout.c | 14 ++++++++++++++
7 files changed, 78 insertions(+), 28 deletions(-)
---
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 4f15dd61..2cb3304c 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1083,6 +1083,9 @@ itemize_state_init (ItemizeState *state,
width_iter_init (&state->width_iter, text + start_index, length);
_pango_emoji_iter_init (&state->emoji_iter, text + start_index, length);
+ if (!PANGO_GRAVITY_IS_VERTICAL (state->context->resolved_gravity))
+ state->width_iter.end = state->end;
+ else
if (state->emoji_iter.is_emoji)
state->width_iter.end = MAX (state->width_iter.end, state->emoji_iter.end);
diff --git a/tests/layouts/valid-14.expected b/tests/layouts/valid-14.expected
index 9c4d5111..0ab5dcb8 100644
--- a/tests/layouts/valid-14.expected
+++ b/tests/layouts/valid-14.expected
@@ -5,7 +5,7 @@
wrapped: 0
ellipsized: 1
lines: 2
-width: 166912
+width: 161792
--- attributes
@@ -29,11 +29,10 @@ i=2, index=38, paragraph-start=1, dir=ltr ''
i=1, index=0, chars=1, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, '你'
[0,2147483647]fallback=1
-i=2, index=3, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, '好'
-i=3, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, ' '
-i=4, index=7, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
-i=5, index=19, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
-i=6, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
-i=7, index=22, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας'
-i=8, index=37, no run, line end
-i=9, index=38, no run, line end
+i=2, index=3, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, '好 '
+i=3, index=7, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
+i=4, index=19, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
+i=5, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
+i=6, index=22, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας'
+i=7, index=37, no run, line end
+i=8, index=38, no run, line end
diff --git a/tests/layouts/valid-14.markup b/tests/layouts/valid-14.markup
index 48412c04..1d556d26 100644
--- a/tests/layouts/valid-14.markup
+++ b/tests/layouts/valid-14.markup
@@ -1,2 +1,2 @@
-line_spacing=1.5,width=163,ellipsize=start
+line_spacing=1.5,width=158,ellipsize=start
你好 Hello שלום Γειά σας
diff --git a/tests/layouts/valid-19.expected b/tests/layouts/valid-19.expected
index 1efc1d54..5e115e47 100644
--- a/tests/layouts/valid-19.expected
+++ b/tests/layouts/valid-19.expected
@@ -26,21 +26,17 @@ i=2, index=75, paragraph-start=1, dir=ltr ''
--- runs
-i=1, index=0, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' a'
-i=2, index=2, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '⃠'
-i=3, index=5, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=4, index=6, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊︎'
-i=5, index=13, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=6, index=14, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊️'
-i=7, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=8, index=22, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '🇩🇪'
-i=9, index=30, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=10, index=31, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✊'
-i=11, index=34, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=12, index=35, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✋🏾'
-i=13, index=42, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' 0 # '
-i=14, index=47, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us,
'🏴'
-i=15, index=71, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
-i=16, index=72, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '©'
-i=17, index=74, no run, line end
-i=18, index=75, no run, line end
+i=1, index=0, chars=4, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' a⃠ '
+i=2, index=6, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊︎ '
+i=3, index=14, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊️'
+i=4, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=5, index=22, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '🇩🇪'
+i=6, index=30, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=7, index=31, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✊'
+i=8, index=34, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=9, index=35, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✋🏾'
+i=10, index=42, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' 0 # '
+i=11, index=47, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us,
'🏴'
+i=12, index=71, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' ©'
+i=13, index=74, no run, line end
+i=14, index=75, no run, line end
diff --git a/tests/layouts/valid-21.expected b/tests/layouts/valid-21.expected
new file mode 100644
index 00000000..5999056f
--- /dev/null
+++ b/tests/layouts/valid-21.expected
@@ -0,0 +1,36 @@
+有一位住在石室裏的詩人叫施氏,abc, 愛吃獅子,決心要吃十隻獅子。
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 2
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 3(0) 6(0) 9(0) 12(0) 15(0) 18(0) 21(0) 24(0) 27(0) 30(0) 33(0) 36(0) 39(0) 42(0) 45(0) 46(0) 47(0)
48(0) 49(0) 50(0) 53(0) 56(0) 59(0) 62(0) 65(0) 68(0) 71(0) 74(0) 77(0) 80(0) 83(0) 86(0) 89(0) 89(1) 93(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr '有一位住在石室裏的詩人叫施氏,abc, 愛吃獅子,決心要吃十隻獅子。
+'
+i=2, index=93, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=14, level=0, gravity=east, flags=1, font=OMITTED, script=han, language=xx,
'有一位住在石室裏的詩人叫施氏'
+i=2, index=42, chars=1, level=0, gravity=east, flags=1, font=OMITTED, script=han, language=xx, ','
+i=3, index=45, chars=5, level=0, gravity=south, flags=1, font=OMITTED, script=latin, language=en-us, 'abc, '
+i=4, index=50, chars=4, level=0, gravity=east, flags=1, font=OMITTED, script=han, language=xx, '愛吃獅子'
+i=5, index=62, chars=1, level=0, gravity=east, flags=1, font=OMITTED, script=han, language=xx, ','
+i=6, index=65, chars=9, level=0, gravity=east, flags=1, font=OMITTED, script=han, language=xx, '決心要吃十隻獅子。'
+i=7, index=92, no run, line end
+i=8, index=93, no run, line end
diff --git a/tests/layouts/valid-21.markup b/tests/layouts/valid-21.markup
new file mode 100644
index 00000000..676a5e56
--- /dev/null
+++ b/tests/layouts/valid-21.markup
@@ -0,0 +1,2 @@
+gravity=east
+有一位住在石室裏的詩人叫施氏,abc, 愛吃獅子,決心要吃十隻獅子。
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 8a1054b4..f35d839e 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -221,6 +221,7 @@ typedef struct {
gboolean auto_dir;
gboolean single_paragraph;
PangoTabArray *tabs;
+ PangoGravity gravity;
} LayoutParams;
static void
@@ -238,6 +239,7 @@ init_params (LayoutParams *params)
params->auto_dir = TRUE;
params->single_paragraph = FALSE;
params->tabs = NULL;
+ params->gravity = PANGO_GRAVITY_AUTO;
}
static void
@@ -326,6 +328,16 @@ parse_params (const char *str,
}
g_strfreev (str3);
}
+ else if (strcmp (str2[0], "gravity") == 0)
+ {
+ eclass = g_type_class_ref (PANGO_TYPE_GRAVITY);
+ ev = g_enum_get_value_by_name (eclass, str2[1]);
+ if (!ev)
+ ev = g_enum_get_value_by_nick (eclass, str2[1]);
+ if (ev)
+ params->gravity = ev->value;
+ g_type_class_unref (eclass);
+ }
g_strfreev (str2);
}
@@ -425,6 +437,8 @@ test_file (const char *filename, GString *string)
parse_params (contents, ¶ms);
+ pango_context_set_base_gravity (context, params.gravity);
+
pango_layout_set_width (layout, params.width > 0 ? params.width * PANGO_SCALE : -1);
pango_layout_set_height (layout, params.height > 0 ? params.height * PANGO_SCALE : params.height);
pango_layout_set_indent (layout, params.indent * PANGO_SCALE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]