From a1f1138479a276b78be2866bd6a29ee6eb019fb6 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Fri, 28 Jan 2011 07:36:09 +0000 Subject: Updated baseline calculation for fonts svn path=/trunk/netsurf/; revision=11512 --- cocoa/font.m | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'cocoa/font.m') diff --git a/cocoa/font.m b/cocoa/font.m index 4e50a48fa..f2f38793c 100644 --- a/cocoa/font.m +++ b/cocoa/font.m @@ -118,14 +118,13 @@ void cocoa_set_font_scale_factor( float newFactor ) void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t length, const plot_font_style_t *style ) { NSLayoutManager *layout = cocoa_prepare_layout_manager( bytes, length, style ); + if (layout == nil) return; - if ([cocoa_text_storage length] > 0) { - NSFont *font = [cocoa_text_storage attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL]; - CGFloat baseline = [layout defaultBaselineOffsetForFont: font]; - - NSRange glyphRange = [layout glyphRangeForTextContainer: cocoa_text_container]; - [layout drawGlyphsForGlyphRange: glyphRange atPoint: NSMakePoint( x, y - baseline )]; - } + NSFont *font = [cocoa_text_storage attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL]; + CGFloat baseline = [layout defaultLineHeightForFont: font] * 3.0 / 4.0; + + NSRange glyphRange = [layout glyphRangeForTextContainer: cocoa_text_container]; + [layout drawGlyphsForGlyphRange: glyphRange atPoint: NSMakePoint( x, y - baseline )]; } -- cgit v1.2.3