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
This commit is contained in:
Manolo Gouy 2011-04-04 12:28:20 +00:00
parent a86df5ede6
commit cd2b8ed399

View File

@ -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