diff options
author | Sven Weidauer <sven.weidauer@gmail.com> | 2011-01-28 07:36:09 +0000 |
---|---|---|
committer | Sven Weidauer <sven.weidauer@gmail.com> | 2011-01-28 07:36:09 +0000 |
commit | a1f1138479a276b78be2866bd6a29ee6eb019fb6 (patch) | |
tree | 4e3b4b37ea1d2a77bc5c5a32f821b3818fc7f72d /cocoa/font.m | |
parent | 46a9e334a0a066a7783a487575544b276613e33e (diff) | |
download | netsurf-a1f1138479a276b78be2866bd6a29ee6eb019fb6.tar.gz netsurf-a1f1138479a276b78be2866bd6a29ee6eb019fb6.tar.bz2 |
Updated baseline calculation for fonts
svn path=/trunk/netsurf/; revision=11512
Diffstat (limited to 'cocoa/font.m')
-rw-r--r-- | cocoa/font.m | 13 |
1 files changed, 6 insertions, 7 deletions
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 )]; } |