Fi xfor issue #452: Fl::get_font_name failure on OS-X.

This commit is contained in:
ManoloFLTK 2022-06-24 19:42:02 +02:00
parent 80e4dd20dc
commit 27846381ae

View File

@ -35,13 +35,15 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (fl_mac_os_version >= Fl_X::CoreText_threshold) { if (fl_mac_os_version >= Fl_X::CoreText_threshold) {
CFStringRef cfname = CFStringCreateWithCString(NULL, f->name, kCFStringEncodingUTF8); CFStringRef cfname = CFStringCreateWithCString(NULL, f->name, kCFStringEncodingUTF8);
CTFontRef ctfont = CTFontCreateWithName(cfname, 0, NULL); CTFontRef ctfont = cfname ? CTFontCreateWithName(cfname, 0, NULL) : NULL;
CFRelease(cfname); if (cfname) CFRelease(cfname);
cfname = CTFontCopyFullName(ctfont); if (ctfont) {
CFRelease(ctfont); cfname = CTFontCopyFullName(ctfont);
CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8); CFRelease(ctfont);
CFRelease(cfname); CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
} CFRelease(cfname);
} else strlcpy(f->fontname, f->name, ENDOFBUFFER);
}
else else
#endif #endif
strlcpy(f->fontname, f->name, ENDOFBUFFER); strlcpy(f->fontname, f->name, ENDOFBUFFER);