[pango/soft-hyphen: 2/5] wip: identify hyphen breaks



commit d81c80ab2467dd32cb129e8a78032bea78212886
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 6 16:42:39 2019 -0400

    wip: identify hyphen breaks

 pango/break.c       | 8 +++++++-
 pango/pango-break.h | 2 +-
 tests/test-break.c  | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index 11f4079e..3f00f7d2 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -1364,9 +1364,15 @@ pango_default_break (const gchar   *text,
 
            case BREAK_ALLOWED:
              attrs[i].is_line_break = TRUE;
-             break;
+              /* fall through */
 
            case BREAK_ALREADY_HANDLED:
+              if (attrs[i].is_line_break)
+                {
+                  /* After Soft Hyphen or Hyphen-Minus */
+                  if (prev_wc == 0x00AD || prev_wc == 0x002D)
+                    attrs[i].is_hyphen = TRUE;
+                }
              break;
 
            default:
diff --git a/pango/pango-break.h b/pango/pango-break.h
index 92af390b..0924eeab 100644
--- a/pango/pango-break.h
+++ b/pango/pango-break.h
@@ -86,7 +86,6 @@ G_BEGIN_DECLS
 struct _PangoLogAttr
 {
   guint is_line_break : 1;      /* Can break line in front of character */
-
   guint is_mandatory_break : 1; /* Must break line in front of character */
 
   guint is_char_break : 1;      /* Can break here when doing char wrap */
@@ -130,6 +129,7 @@ struct _PangoLogAttr
 
   /* Word boundary as defined by UAX#29 */
   guint is_word_boundary : 1;  /* is NOT in the middle of a word */
+  guint is_hyphen : 1;         /* line break due to hyphen */
 };
 
 /* Determine information about cluster/word/line breaks in a string
diff --git a/tests/test-break.c b/tests/test-break.c
index a77a7f34..552b7c87 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -76,6 +76,11 @@ test_file (const gchar *filename, GString *string)
           g_string_append (string, " ");
           g_string_append (s2, "l");
         }
+      if (log.is_hyphen)
+        {
+          g_string_append (string, " ");
+          g_string_append (s2, "h");
+        }
       if (log.is_char_break)
         {
           g_string_append (string, " ");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]