Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • P pango
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 169
    • Issues 169
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 23
    • Merge requests 23
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • pango
  • Issues
  • #438
Closed
Open
Issue created Nov 29, 2019 by Iain Lane@iainlDeveloper

Gtk reftests broken with pango 1.44 [hyphenation changes]

Compare the "button-wrapping" reftest from gtk3

what gtk created:

button-wrapping.out

the reference image:

button-wrapping.ref

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).

Edited Aug 27, 2020 by Khaled Hosny
Assignee
Assign to
Time tracking