diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-02 05:49:23 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-02 05:49:23 +0000 |
commit | e2c1cdbec788875fe02d63d801ba022ee6d75db5 (patch) | |
tree | 17b032d705eeeb5ae527d91d0eda4d2bdf523356 | |
parent | fc9057e3a5b73dffb7761d00a9324ea8903a26bf (diff) | |
parent | 91687742f61d4b74572f3176fa3d8442438df504 (diff) | |
download | pango-e2c1cdbec788875fe02d63d801ba022ee6d75db5.tar.gz |
Merge branch 'gravity-fix' into 'main'
gravity: Remove redundant code
See merge request GNOME/pango!384
-rw-r--r-- | pango/pango-context.c | 9 | ||||
-rw-r--r-- | pango/pango-gravity.c | 18 | ||||
-rw-r--r-- | tests/layouts/valid-20.expected | 40 | ||||
-rw-r--r-- | tests/layouts/valid-20.markup | 2 |
4 files changed, 54 insertions, 15 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c index ac59f3d8..4f15dd61 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -1031,6 +1031,11 @@ itemize_state_init (ItemizeState *state, state->embedding_end = text + start_index; update_embedding_end (state); + state->gravity = PANGO_GRAVITY_AUTO; + state->centered_baseline = PANGO_GRAVITY_IS_VERTICAL (state->context->resolved_gravity); + state->gravity_hint = state->context->gravity_hint; + state->resolved_gravity = PANGO_GRAVITY_AUTO; + /* Initialize the attribute iterator */ if (cached_iter) @@ -1088,10 +1093,6 @@ itemize_state_init (ItemizeState *state, else state->font_desc_gravity = PANGO_GRAVITY_AUTO; - state->gravity = PANGO_GRAVITY_AUTO; - state->centered_baseline = PANGO_GRAVITY_IS_VERTICAL (state->context->resolved_gravity); - state->gravity_hint = state->context->gravity_hint; - state->resolved_gravity = PANGO_GRAVITY_AUTO; state->derived_lang = NULL; state->current_fonts = NULL; state->cache = NULL; diff --git a/pango/pango-gravity.c b/pango/pango-gravity.c index 30e99eb0..0eb3cfe2 100644 --- a/pango/pango-gravity.c +++ b/pango/pango-gravity.c @@ -362,16 +362,13 @@ get_script_properties (PangoScript script) */ PangoGravity pango_gravity_get_for_script (PangoScript script, - PangoGravity base_gravity, - PangoGravityHint hint) + PangoGravity base_gravity, + PangoGravityHint hint) { PangoScriptProperties props = get_script_properties (script); - if (G_UNLIKELY (base_gravity == PANGO_GRAVITY_AUTO)) - base_gravity = props.preferred_gravity; - return pango_gravity_get_for_script_and_width (script, props.wide, - base_gravity, hint); + base_gravity, hint); } /** @@ -403,15 +400,14 @@ pango_gravity_get_for_script (PangoScript script, * Since: 1.26 */ PangoGravity -pango_gravity_get_for_script_and_width (PangoScript script, - gboolean wide, - PangoGravity base_gravity, - PangoGravityHint hint) +pango_gravity_get_for_script_and_width (PangoScript script, + gboolean wide, + PangoGravity base_gravity, + PangoGravityHint hint) { PangoScriptProperties props = get_script_properties (script); gboolean vertical; - if (G_UNLIKELY (base_gravity == PANGO_GRAVITY_AUTO)) base_gravity = props.preferred_gravity; diff --git a/tests/layouts/valid-20.expected b/tests/layouts/valid-20.expected new file mode 100644 index 00000000..6939260b --- /dev/null +++ b/tests/layouts/valid-20.expected @@ -0,0 +1,40 @@ +abcdef + +--- parameters + +wrapped: 0 +ellipsized: 0 +lines: 2 + +--- attributes + +range 0 3 +[0,3]gravity=1 +[0,3]gravity-hint=1 +range 3 6 +[3,6]gravity=0 +range 6 2147483647 + +--- directions + +0 0 0 0 0 0 0 + +--- cursor positions + +0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 5(1) 7(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'abcdef +' +i=2, index=7, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=3, level=0, gravity=east, flags=0, font=OMITTED, script=latin, language=en-us, 'abc' +[0,3]gravity=1 +[0,3]gravity-hint=1 +i=2, index=3, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'def' +[3,6]gravity=0 +i=3, index=6, no run, line end +i=4, index=7, no run, line end diff --git a/tests/layouts/valid-20.markup b/tests/layouts/valid-20.markup new file mode 100644 index 00000000..fe6480d7 --- /dev/null +++ b/tests/layouts/valid-20.markup @@ -0,0 +1,2 @@ +# exercise gravity handling +<span gravity='east' gravity_hint='strong'>abc</span><span gravity='south'>def</span> |