Gtk reftests broken with pango 1.44 [hyphenation changes]
Compare the "button-wrapping" reftest from gtk3
what gtk created:
the reference image:
there's some extra spacing now. The test fails. I bisected pango and this commit was the one to break it
commit eb4882cada397268948ec24da046ff75615dfb9e (HEAD, refs/bisect/bad)
Author: Matthias Clasen <mclasen@redhat.com>
Date: Mon Jul 15 23:15:35 2019 -0400
Insert hyphens in more places
Look for whether the char before the break
is not whitespace and doesn't look like a
hyphen.
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 2387e1cd..255fe90a 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3405,8 +3405,37 @@ get_need_hyphen (PangoItem *item,
for (i = 0, p = text + item->offset; i < item->num_chars; i++, p = g_utf8_next_char (p))
{
- gunichar ch = g_utf8_get_char (p);
- need_hyphen[i] = ch == 0xad;
+ gunichar wc = g_utf8_get_char (p);
+ switch (g_unichar_type(wc))
+ {
+ case G_UNICODE_SPACE_SEPARATOR:
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ need_hyphen[i] = FALSE;
+ break;
+ case G_UNICODE_CONTROL:
+ if (wc == '\t' || wc == '\n' || wc == '\r' || wc == '\f')
+ need_hyphen[i] = FALSE;
+ else
+ need_hyphen[i] = TRUE;
+ break;
+ default:
+ if (wc == '-' || /* Hyphen-minus */
+ wc == 0x058a || /* Armenian hyphen */
+ wc == 0x1400 || /* Canadian syllabics hyphen */
+ wc == 0x1806 || /* Mongolian todo hyphen */
+ wc == 0x2010 || /* Hyphen */
+ wc == 0x2027 || /* Hyphenation point */
+ wc == 0x2e17 || /* Double oblique hyphen */
+ wc == 0x2e40 || /* Double hyphen */
+ wc == 0x30a0 || /* Katakana-Hiragana double hyphen */
+ wc == 0xfe63 || /* Small hyphen-minus */
+ wc == 0xff0d) /* Fullwidth hyphen-minus */
+ need_hyphen[i] = FALSE;
+ else
+ need_hyphen[i] = TRUE;
+ break;
+ }
}
}
at first glance it seems that need_hyphen
would be set for anything which was a 0xad
hyphen before, and now it is set for anything which is not a hyphen. And this somehow results in the extra space being allocated.
Is the problem that we are doing this at the end of the text? This fixes it:
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 255fe90a..2a23ceb0 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3612,6 +3612,8 @@ process_item (PangoLayout *layout,
pango_glyph_item_get_logical_widths (&glyph_item, layout->text, state->log_widths);
state->need_hyphen = g_new (int, item->num_chars);
get_need_hyphen (item, layout->text, state->need_hyphen);
+ if (item->num_chars > 0)
+ state->need_hyphen[item->num_chars - 1] = FALSE;
}
retry_break:
but I don't really understand what's going on here, that's probably wrong for some reason (e.g. I just checked this one reftest, not all of them).