mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-12 13:59:20 +03:00
More font-related fixes.
svn path=/trunk/netsurf/; revision=11516
This commit is contained in:
parent
ccac2289cf
commit
b2482982dd
14
cocoa/font.m
14
cocoa/font.m
@ -149,7 +149,7 @@ static inline NSUInteger cocoa_glyph_for_location( NSLayoutManager *layout, CGFl
|
|||||||
NSUInteger glyphIndex = [layout glyphIndexForPoint: NSMakePoint( cocoa_px_to_pt( x ), 0 )
|
NSUInteger glyphIndex = [layout glyphIndexForPoint: NSMakePoint( cocoa_px_to_pt( x ), 0 )
|
||||||
inTextContainer: cocoa_text_container
|
inTextContainer: cocoa_text_container
|
||||||
fractionOfDistanceThroughGlyph: &fraction];
|
fractionOfDistanceThroughGlyph: &fraction];
|
||||||
if (fraction > 0) ++glyphIndex;
|
if (fraction >= 1.0) ++glyphIndex;
|
||||||
return glyphIndex;
|
return glyphIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,9 +171,11 @@ static NSLayoutManager *cocoa_prepare_layout_manager( const char *bytes, size_t
|
|||||||
const plot_font_style_t *style )
|
const plot_font_style_t *style )
|
||||||
{
|
{
|
||||||
if (NULL == bytes || 0 == length) return nil;
|
if (NULL == bytes || 0 == length) return nil;
|
||||||
|
|
||||||
|
NSString *string = [[[NSString alloc] initWithBytes: bytes length:length encoding:NSUTF8StringEncoding] autorelease];
|
||||||
|
if (string == nil) return nil;
|
||||||
|
|
||||||
static NSLayoutManager *layout = nil;
|
static NSLayoutManager *layout = nil;
|
||||||
|
|
||||||
if (nil == layout) {
|
if (nil == layout) {
|
||||||
cocoa_text_container = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize( CGFLOAT_MAX, CGFLOAT_MAX )];
|
cocoa_text_container = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize( CGFLOAT_MAX, CGFLOAT_MAX )];
|
||||||
[cocoa_text_container setLineFragmentPadding: 0];
|
[cocoa_text_container setLineFragmentPadding: 0];
|
||||||
@ -182,9 +184,6 @@ static NSLayoutManager *cocoa_prepare_layout_manager( const char *bytes, size_t
|
|||||||
[layout addTextContainer: cocoa_text_container];
|
[layout addTextContainer: cocoa_text_container];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NSString *string = [[[NSString alloc] initWithBytes: bytes length:length encoding:NSUTF8StringEncoding] autorelease];
|
|
||||||
|
|
||||||
static NSString *oldString = 0;
|
static NSString *oldString = 0;
|
||||||
static plot_font_style_t oldStyle = { 0 };
|
static plot_font_style_t oldStyle = { 0 };
|
||||||
|
|
||||||
@ -203,14 +202,13 @@ static NSLayoutManager *cocoa_prepare_layout_manager( const char *bytes, size_t
|
|||||||
[attributes release];
|
[attributes release];
|
||||||
attributes = [cocoa_font_attributes( style ) retain];
|
attributes = [cocoa_font_attributes( style ) retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
[cocoa_text_storage release];
|
[cocoa_text_storage release];
|
||||||
cocoa_text_storage = [[NSTextStorage alloc] initWithString: string attributes: attributes];
|
cocoa_text_storage = [[NSTextStorage alloc] initWithString: string attributes: attributes];
|
||||||
[cocoa_text_storage addLayoutManager: layout];
|
[cocoa_text_storage addLayoutManager: layout];
|
||||||
|
|
||||||
[layout ensureLayoutForTextContainer: cocoa_text_container];
|
[layout ensureLayoutForTextContainer: cocoa_text_container];
|
||||||
|
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user