FLTK logo

[master] fb7469c - Fix for 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 ]

[master] fb7469c - Fix for issue #452: Fl::get_font_name failure on OS-X. "ManoloFLTK" Jun 24, 2022  
 
commit fb7469c85c86a1a5dc62f5feaf540dbd7307600e
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Jun 24 19:50:47 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Jun 24 19:50:47 2022 +0200

    Fix for issue #452: Fl::get_font_name failure on OS-X.

 src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index b89e359..f34d36d 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -317,12 +317,14 @@ double Fl_Quartz_Graphics_Driver::width(unsigned int wc) {
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
 static void set_fontname_CoreText(Fl_Fontdesc *f) {
   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);
 }
 #endif
 
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'.