summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-28 07:36:09 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-28 07:36:09 +0000
commita1f1138479a276b78be2866bd6a29ee6eb019fb6 (patch)
tree4e3b4b37ea1d2a77bc5c5a32f821b3818fc7f72d /cocoa
parent46a9e334a0a066a7783a487575544b276613e33e (diff)
downloadnetsurf-a1f1138479a276b78be2866bd6a29ee6eb019fb6.tar.gz
netsurf-a1f1138479a276b78be2866bd6a29ee6eb019fb6.tar.bz2
Updated baseline calculation for fonts
svn path=/trunk/netsurf/; revision=11512
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/font.m13
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 )];
}