summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/font_pango.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gtk/font_pango.c b/gtk/font_pango.c
index 00131b416..2c77f3015 100644
--- a/gtk/font_pango.c
+++ b/gtk/font_pango.c
@@ -196,7 +196,7 @@ bool nsfont_split(const plot_font_style_t *fstyle,
if (line != NULL) {
/* Pango split the text. The line's start_index indicates the
* start of the character after the line break. */
- index = line->start_index;
+ int orig = index = line->start_index;
/* We must ensure that the split character is a space so that
* we meet the API postcondition. Therefore, scan backwards
@@ -206,6 +206,12 @@ bool nsfont_split(const plot_font_style_t *fstyle,
if (string[--index] == ' ')
break;
}
+
+ if (index == 0) {
+ index = orig;
+ while (index != (int)length && string[index] != ' ')
+ index++;
+ }
}
g_object_unref(layout);