From d476d2a944500f8553a2c1d1054df37363f47460 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 8 May 2021 15:09:45 -0400 Subject: layout: Don't insert hyphens at word boundaries We only want to insert hyphens when we are breaking inside a word. Update affected tests (hyphen-or-not shows up in the analysis flags in the output of test-layout). Fixes: #558 --- pango/pango-layout.c | 3 +++ tests/layouts/valid-4.expected | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pango/pango-layout.c b/pango/pango-layout.c index fa499ef3..e847e789 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3611,6 +3611,9 @@ break_needs_hyphen (PangoLayout *layout, if (state->log_widths_offset + pos == 0) return FALSE; + if (layout->log_attrs[state->start_offset + pos].is_line_break) + return FALSE; + if (state->need_hyphen[state->log_widths_offset + pos - 1]) return TRUE; diff --git a/tests/layouts/valid-4.expected b/tests/layouts/valid-4.expected index 66796cb5..2534b6fc 100644 --- a/tests/layouts/valid-4.expected +++ b/tests/layouts/valid-4.expected @@ -23,11 +23,11 @@ i=6, index=152, paragraph-start=1, dir=ltr '' --- runs -i=1, index=0, chars=30, level=0, gravity=south, flags=4, font=OMITTED, script=latin, language=en-us, 'This paragraph should ac­tual­' +i=1, index=0, chars=30, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This paragraph should ac­tual­' i=2, index=32, no run, line end i=3, index=32, chars=31, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ly have multiple lines, unlike ' i=4, index=63, no run, line end -i=5, index=63, chars=29, level=0, gravity=south, flags=4, font=OMITTED, script=latin, language=en-us, 'all the other wannabe äöü pa­' +i=5, index=63, chars=29, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'all the other wannabe äöü pa­' i=6, index=96, no run, line end i=7, index=96, chars=27, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ra­graph tests in this ugh ' i=8, index=124, no run, line end -- cgit v1.2.1