summaryrefslogtreecommitdiff
path: root/pango/pango-markup.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-20 10:34:15 -0700
committerMatthias Clasen <mclasen@redhat.com>2019-07-20 11:56:18 -0700
commit62580f2fa5e46d51bb2377d4028471926108bab3 (patch)
tree7472f8a4fb33d6822b4cb853e43e0b38124af542 /pango/pango-markup.c
parente8f20b6116cca605115b42d5e0a15112193a3bad (diff)
downloadpango-62580f2fa5e46d51bb2377d4028471926108bab3.tar.gz
Add an allow-breaks attribute
Add a new attribute type, and parse allow_breaks="false" in markup. This is useful to prevent hyphenation of words.
Diffstat (limited to 'pango/pango-markup.c')
-rw-r--r--pango/pango-markup.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 2c509dac..2b871584 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -153,6 +153,11 @@
* Fallback is enabled by default. Most applications should not
* disable fallback.
*
+ * allow_breaks
+ * : 'true' or 'false' whether to allow line breaks or not. If
+ * not allowed, the range will be kept in a single run as far
+ * as possible. Breaks are allowed by default.
+ *
* lang
* : A language code, indicating the text language
*
@@ -1297,6 +1302,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
const char *font_features = NULL;
const char *alpha = NULL;
const char *background_alpha = NULL;
+ const char *allow_breaks = NULL;
g_markup_parse_context_get_position (context,
&line_number, &char_number);
@@ -1326,6 +1332,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
switch (names[i][0]) {
case 'a':
+ CHECK_ATTRIBUTE (allow_breaks);
CHECK_ATTRIBUTE (alpha);
break;
case 'b':
@@ -1707,6 +1714,16 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
add_attribute (tag, pango_attr_font_features_new (font_features));
}
+ if (G_UNLIKELY (allow_breaks))
+ {
+ gboolean b = FALSE;
+
+ if (!span_parse_boolean ("allow_breaks", allow_breaks, &b, line_number, error))
+ goto error;
+
+ add_attribute (tag, pango_attr_allow_breaks_new (b));
+ }
+
return TRUE;
error: