summaryrefslogtreecommitdiff
path: root/pango/pango-markup.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-04 09:43:08 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-08-04 10:37:44 -0400
commit2e6f2eb8148220b09d4834065d53c73a3ac2427b (patch)
tree9fce36e84330531009328f2054262a4f3eddd68f /pango/pango-markup.c
parent1284511871dd80592ef862fcc5ccb5639ac9fe0e (diff)
downloadpango-2e6f2eb8148220b09d4834065d53c73a3ac2427b.tar.gz
Add an insert-hyphens attribute
Add a text attribute that allows to suppress insertion of hyphens at intra-word line breaks. This is useful for non-paragraph-like contexts, where line breaks are needed, but hyphens are not expected.
Diffstat (limited to 'pango/pango-markup.c')
-rw-r--r--pango/pango-markup.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index e39730e4..6dce1b2e 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -158,6 +158,10 @@
* not allowed, the range will be kept in a single run as far
* as possible. Breaks are allowed by default.
*
+ * insert_hyphens
+ * : 'true' or 'false' whether to insert hyphens when breaking
+ * lines in the middle of a word. Hyphens are inserted by default.
+ *
* show
* : A value determining how invisible characters are treated.
* Possible values are 'spaces', 'line-breaks', 'ignorables'
@@ -1334,6 +1338,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
const char *alpha = NULL;
const char *background_alpha = NULL;
const char *allow_breaks = NULL;
+ const char *insert_hyphens = NULL;
const char *show = NULL;
g_markup_parse_context_get_position (context,
@@ -1407,6 +1412,9 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
CHECK_ATTRIBUTE (gravity);
CHECK_ATTRIBUTE (gravity_hint);
break;
+ case 'i':
+ CHECK_ATTRIBUTE (insert_hyphens);
+ break;
case 'l':
CHECK_ATTRIBUTE (lang);
CHECK_ATTRIBUTE (letter_spacing);
@@ -1767,6 +1775,16 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
add_attribute (tag, pango_attr_allow_breaks_new (b));
}
+ if (G_UNLIKELY (insert_hyphens))
+ {
+ gboolean b = FALSE;
+
+ if (!span_parse_boolean ("insert_hyphens", insert_hyphens, &b, line_number, error))
+ goto error;
+
+ add_attribute (tag, pango_attr_insert_hyphens_new (b));
+ }
+
return TRUE;
error: