Add API for loading fonts from binary TrueType/OpenType data in memory#15
Conversation
…iro/Pango support Co-authored-by: MatthiasWM <653993+MatthiasWM@users.noreply.github.com>
…ring all fonts Co-authored-by: MatthiasWM <653993+MatthiasWM@users.noreply.github.com>
| #include <unistd.h> // for unlink(), write() | ||
| #include <fcntl.h> // for open(), O_CREAT, O_EXCL | ||
| #include <sys/stat.h> // for mode constants | ||
|
|
There was a problem hiding this comment.
| #include "../../flstring.h" // for fl_strdup() |
There was a problem hiding this comment.
Added the missing flstring.h include in commit eb9c8ec.
Co-authored-by: MatthiasWM <653993+MatthiasWM@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
|
The Wayland build fails with Please fix this. |
MatthiasWM
left a comment
There was a problem hiding this comment.
Remove the dependency on fontconfig in Fl_Cairo_Graphics_Driver.cxx and instead use TrueType calls.
| FT_Done_FreeType(ft_library); | ||
| return (Fl_Font)-1; | ||
| } | ||
|
|
There was a problem hiding this comment.
| Why is fontconfig needed at all? Doesn't FT_New_Memory_Face read a font from memory in ttf format already? Please check if most of the code until line 1683 is needed at all. If possible, remove all fontconfig calls and use only FreeType cals. |
There was a problem hiding this comment.
Good point - I've simplified the code in commit 743aa2a. Now the implementation only uses FreeType to:
- Parse the font data with
FT_New_Memory_Face - Extract the font family name from
ft_face->family_name - Clean up with
FT_Done_FaceandFT_Done_FreeType
All fontconfig code has been removed. The font name is then registered with FLTK's font table for Pango to use.
… memory fonts Co-authored-by: MatthiasWM <653993+MatthiasWM@users.noreply.github.com>
Fixed in commit 743aa2a. Removed all fontconfig calls from the Cairo driver - it now uses only FreeType to parse the font and extract the family name. Also added FreeType linking for USE_PANGO builds in CMakeLists.txt.
Done in commit 743aa2a. Removed the fontconfig dependency entirely and now use only FreeType ( |
Adds cross-platform support for loading fonts directly from memory buffers, enabling embedded fonts in applications without system installation.
API
Platform Implementations
AddFontMemResourceEx()/RemoveFontMemResourceEx()CGFontCreateWithDataProvider()+CTFontManagerRegisterGraphicsFont()FT_New_Memory_Face()+ fontconfig via secure temp file (fontconfig lacks direct memory API)FT_New_Memory_Face()for font parsing (no fontconfig dependency)Changes
FL/Fl.H: PublicFl::load_font()andFl::unload_font()declarationsFl_Graphics_Driver: Virtual methods with default no-op implementationsFl_Fontdesc: Extended withmem_font_data,mem_font_size,mem_font_handlefieldssrc/CMakeLists.txt: Link FreeType on Linux when USE_XFT or USE_PANGO enabledFl_GDI_Graphics_Driver,Fl_Quartz_Graphics_Driver,Fl_Xlib_Graphics_Driver,Fl_Cairo_Graphics_DriverNotes
mkstemps()for secure temp file creationunload_font()on X11/Xft only removes the specific temp file; fontconfig will fail gracefully on next accessOriginal prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.