Fixing font calculations and warnings about invalid glyph indices.

svn path=/trunk/netsurf/; revision=11504
This commit is contained in:
Sven Weidauer 2011-01-27 07:55:06 +00:00
parent f5ef7c71e7
commit 14404769cc

View File

@ -62,8 +62,11 @@ static bool nsfont_position_in_string(const plot_font_style_t *style,
NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
*char_offset = cocoa_bytes_for_characters( string, chars );
*actual_x = [layout locationForGlyphAtIndex: glyphIndex].x;
if (chars >= [cocoa_text_storage length]) *char_offset = length;
else *char_offset = cocoa_bytes_for_characters( string, chars );
*actual_x = NSMaxX( [layout boundingRectForGlyphRange: NSMakeRange( glyphIndex - 1, 1 )
inTextContainer: cocoa_text_container] );
return true;
}
@ -78,7 +81,7 @@ static bool nsfont_split(const plot_font_style_t *style,
NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
if (chars == [cocoa_text_storage length] - 1) {
if (chars >= [cocoa_text_storage length]) {
*char_offset = length;
*actual_x = cocoa_layout_width( layout );
return true;