Author: vince
Date: Mon Feb 23 10:51:31 2009
New Revision: 6609
URL:
http://source.netsurf-browser.org?rev=6609&view=rev
Log:
fix splitting on spaces
Modified:
trunk/netsurf/framebuffer/fb_font_freetype.c
Modified: trunk/netsurf/framebuffer/fb_font_freetype.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_font_freet...
==============================================================================
--- trunk/netsurf/framebuffer/fb_font_freetype.c (original)
+++ trunk/netsurf/framebuffer/fb_font_freetype.c Mon Feb 23 10:51:31 2009
@@ -70,7 +70,7 @@
}
/* set the default render mode */
- // ft_load_type = FT_LOAD_MONOCHROME;
+ //ft_load_type = FT_LOAD_MONOCHROME; /* faster but less pretty */
ft_load_type = 0;
return true;
@@ -217,37 +217,40 @@
FT_UInt glyph_index;
FT_Face face = fb_get_face(style);
FT_Error error;
- int last_space_x = -1;
- int last_space_idx = -1;
+ int last_space_x = 0;
+ int last_space_idx = 0;
*actual_x = 0;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
+
+
+ glyph_index = FT_Get_Char_Index(face, ucs4);
+
+ error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
+ if (error)
+ continue;
if (ucs4 == 0x20) {
last_space_x = *actual_x;
last_space_idx = nxtchr;
}
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
- if (error)
- continue;
-
*actual_x += face->glyph->advance.x >> 6;
- if (*actual_x > x)
- break;
+ if (*actual_x > x) {
+ /* string has exceeded available width return previous
+ * space
+ */
+ *actual_x = last_space_x;
+ *char_offset = last_space_idx;
+ return true;
+ }
nxtchr = utf8_next(string, length, nxtchr);
}
- if (last_space_x == -1) {
- *char_offset = nxtchr;
- } else {
- *actual_x = last_space_x;
- *char_offset = last_space_idx;
- }
+ *char_offset = nxtchr;
+
return true;
}