summaryrefslogtreecommitdiff
path: root/gtk/font_pango.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-02-10 18:23:34 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-02-10 18:23:34 +0000
commit484365874292b4c70abf91642cce83898c9a2d3a (patch)
tree73692b1bc732bc683ecb888a1570bbcdd70de656 /gtk/font_pango.c
parent285a7ca6c3b7a0964f24165dd929f4003b026309 (diff)
downloadnetsurf-484365874292b4c70abf91642cce83898c9a2d3a.tar.gz
netsurf-484365874292b4c70abf91642cce83898c9a2d3a.tar.bz2
Don't need to break on space any more. This gives us unicode line breaking from pango.
Diffstat (limited to 'gtk/font_pango.c')
-rw-r--r--gtk/font_pango.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/gtk/font_pango.c b/gtk/font_pango.c
index 00131b416..de115fa64 100644
--- a/gtk/font_pango.c
+++ b/gtk/font_pango.c
@@ -153,17 +153,24 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
/**
* Find where to split a string to make it fit a width.
*
- * \param fstyle plot style for this text
- * \param string UTF-8 string to measure
- * \param length length of string
- * \param x width available
- * \param char_offset updated to offset in string of actual_x, [0..length]
- * \param actual_x updated to x coordinate of character closest to x
+ * \param fstyle style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string, in bytes
+ * \param x width available
+ * \param char_offset updated to offset in string of actual_x, [1..length]
+ * \param actual_x updated to x coordinate of character closest to x
* \return true on success, false on error and error reported
*
- * On exit, [char_offset == 0 ||
- * string[char_offset] == ' ' ||
- * char_offset == length]
+ * On exit, char_offset indicates first character after split point.
+ *
+ * Note: char_offset of 0 should never be returned.
+ *
+ * Returns:
+ * char_offset giving split point closest to x, where actual_x <= x
+ * else
+ * char_offset giving split point closest to x, where actual_x > x
+ *
+ * Returning char_offset == length means no split possible
*/
bool nsfont_split(const plot_font_style_t *fstyle,
@@ -197,15 +204,6 @@ bool nsfont_split(const plot_font_style_t *fstyle,
/* Pango split the text. The line's start_index indicates the
* start of the character after the line break. */
index = line->start_index;
-
- /* We must ensure that the split character is a space so that
- * we meet the API postcondition. Therefore, scan backwards
- * through the string and stop when we hit the start of
- * the string or find a space. */
- while (index > 0) {
- if (string[--index] == ' ')
- break;
- }
}
g_object_unref(layout);