FLTK logo

[master] feb0d91 - Remove arbitrary maximum length of font name.

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] feb0d91 - Remove arbitrary maximum length of font name. "ManoloFLTK" Jun 25, 2022  
 
commit feb0d918fb8ead02db12a3031b4d46a970a935ef
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sat Jun 25 20:00:17 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sat Jun 25 20:00:17 2022 +0200

    Remove arbitrary maximum length of font name.

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

diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index f34d36d..ce2a7e2 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -679,9 +679,12 @@ Fl_Font Fl_Quartz_Graphics_Driver::ADD_SUFFIX(set_fonts, _CoreText)(const char*
     CTFontRef font = CTFontCreateWithFontDescriptor(fdesc, 0., NULL);
     CFStringRef cfname = CTFontCopyPostScriptName(font);
     CFRelease(font);
-    static char fname[200];
-    CFStringGetCString(cfname, fname, sizeof(fname), kCFStringEncodingUTF8);
-    tabfontnames[i] = fl_strdup(fname); // never free'ed
+    CFDataRef cfdata = CFStringCreateExternalRepresentation(NULL, cfname, kCFStringEncodingUTF8, '?');
+    CFIndex l = CFDataGetLength(cfdata);
+    tabfontnames[i] = (char*)malloc(l+1); // never free'ed
+    memcpy(tabfontnames[i], CFDataGetBytePtr(cfdata), l);
+    tabfontnames[i][l] = 0;
+    CFRelease(cfdata);
     CFRelease(cfname);
   }
   CFRelease(arrayref);
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'.