Fix split implementation.

This commit is contained in:
Michael Drake 2013-02-06 22:27:51 +00:00
parent 79301e423c
commit 2260152ebf
1 changed files with 7 additions and 1 deletions

View File

@ -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);