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,12 +35,14 @@ 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);
if (ctfont) {
cfname = CTFontCopyFullName(ctfont); cfname = CTFontCopyFullName(ctfont);
CFRelease(ctfont); CFRelease(ctfont);
CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8); CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
CFRelease(cfname); CFRelease(cfname);
} else strlcpy(f->fontname, f->name, ENDOFBUFFER);
} }
else else
#endif #endif