FLTK logo

[branch-1.3] 2784638 - Fi xfor issue #452: Fl::get_font_name failure on OS-X.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[branch-1.3] 2784638 - Fi xfor issue #452: Fl::get_font_name failure on OS-X. "ManoloFLTK" Jun 24, 2022  
 
commit 27846381ae6966759b8faf19b97c033020a2f5ce
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Jun 24 19:42:02 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Jun 24 19:42:02 2022 +0200

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

 src/fl_set_fonts_mac.cxx | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git src/fl_set_fonts_mac.cxx src/fl_set_fonts_mac.cxx
index a189cb7..75664b8 100644
--- src/fl_set_fonts_mac.cxx
+++ src/fl_set_fonts_mac.cxx
@@ -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 (fl_mac_os_version >= Fl_X::CoreText_threshold) {
       CFStringRef cfname = CFStringCreateWithCString(NULL, f->name, kCFStringEncodingUTF8);
-      CTFontRef ctfont = CTFontCreateWithName(cfname, 0, NULL);
-      CFRelease(cfname);
-      cfname = CTFontCopyFullName(ctfont);
-      CFRelease(ctfont);
-      CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
-      CFRelease(cfname);
-      }
+      CTFontRef ctfont = cfname ? CTFontCreateWithName(cfname, 0, NULL) : NULL;
+      if (cfname) CFRelease(cfname);
+      if (ctfont) {
+        cfname = CTFontCopyFullName(ctfont);
+        CFRelease(ctfont);
+        CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
+        CFRelease(cfname);
+      } else strlcpy(f->fontname, f->name, ENDOFBUFFER);
+    }
     else 
 #endif
       strlcpy(f->fontname, f->name, ENDOFBUFFER);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.