diff options
| author | Manolo Gouy <Manolo> | 2011-04-04 12:28:20 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-04-04 12:28:20 +0000 |
| commit | cd2b8ed39958133f06e60954150a271391134aac (patch) | |
| tree | ab2613f01c17da9bff2587e3c67390f046ac1754 /src | |
| parent | a86df5ede60c0e0c3f46fe897ad10824e8133a87 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/fl_font_mac.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
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 |
