From cd2b8ed39958133f06e60954150a271391134aac Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 4 Apr 2011 12:28:20 +0000 Subject: Fix error that can happen with some 3rd party fonts lacking certain size information. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8558 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_font_mac.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index bc777ad12..dfadfcb15 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -80,6 +80,17 @@ if (fl_mac_os_version >= 100500) {//unfortunately, CTFontCreateWithName != NULL &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue (attributes, kCTKernAttributeName, zero_ref); } + if (ascent == 0) { // this may happen with some third party fonts + CFDictionarySetValue (attributes, kCTFontAttributeName, fontref); + CFAttributedStringRef mastr = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("Wj"), attributes); + CTLineRef ctline = CTLineCreateWithAttributedString(mastr); + CFRelease(mastr); + CGFloat fascent, fdescent; + CTLineGetTypographicBounds(ctline, &fascent, &fdescent, NULL); + CFRelease(ctline); + ascent = (short)(fascent + 0.5); + descent = (short)(fdescent + 0.5); + } } else { #endif -- cgit v1.2.3