New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FLTK doesn't use system UI font #466
Comments
What is the macOS special API mentionned above ? Is it CTFontCreateUIFontForLanguage() ? Does it produce a CTFontRef value ? That is the value the FLTK macOS code uses to set what font is used when drawing text. I could try to add a public API allowing to set the FLTK font from a CTFontRef. |
I believe no new API is necessary, as shown by this code snippet :
This requires macOS 10.5 or above. |
Many thanks. That actually worked. Tested on macOS 12. I'm not sure what method I used, but I couldn't get it to accept any of the strings I tried to use. I also found posts (even from Apple people), stating that the system would reject even the correct string to force people to use the newer APIs that had constants for the system fonts. That evidently isn't true. So, it seems everything can be done from the application, and FLTK doesn't need to change. :) It might still be nice if FLTK defaults to the system UI font, though, if you feel it is worth the effort. (minor note is that |
@CendioOssman I don't think that this is appropriate, keeping backwards and cross-platform compatibility in mind. There would be at least eight fonts affected (FL_HELVETICA (proportional): normal, bold, italic, and bold italic) and the same for FL_COURIER (fixed font). These are the fonts that are most likely used by all applications. Loading other fonts than we have now by default would likely cause trouble because applications would look different, maybe font sizes and spacing would be different, etc.. That said, an additional API to overload specific fonts with all variants from alternate system UI fonts might make sense. A global flag set by a function call early in the program, i.e. before "the display is opened", might also be useful. However, such an API would need to be well defined and usable cross platform etc. etc. |
Apparently, it just got renamed in 10.8 from |
Closing since the required solution under macOS is provided here. |
Pretty much all platforms have a font dedicated to UI elements, that is extra tailored for that use case. Unfortunately FLTK defaults to something Helvetica compatible, which will give a worse appearance and also make FLTK applications look (even more) different¹ than ones using the native toolkit.
Right now applications can try to work around this. E.g. on Windows you can do:
On Linux it should also be possible, but it's a bit more complex. You need to decide on a toolkit to follow, e.g. GTK vs QT, and then dig around in their settings.
On macOS, it looks like it is impossible given FLTK's API. They seem to refuse to let you access the UI font using the name of the font, and must get a font object via special APIs.
¹ Fortunately the UI font is almost always a sans serif font, so they are at least very similar
The text was updated successfully, but these errors were encountered: