diff options
author | Pierre Ossman <ossman@cendio.se> | 2022-07-15 14:50:46 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2022-12-22 13:37:07 +0100 |
commit | 9bc9e442329b77127296adbf2e4b51b6009d2235 (patch) | |
tree | 2e9c7e8e1d17287ac5c5d9e110afc1f31c4de925 /vncviewer/fltk | |
parent | d751b1837f5baed6bb7f2d3991a81ce4368e2121 (diff) | |
download | tigervnc-9bc9e442329b77127296adbf2e4b51b6009d2235.tar.gz tigervnc-9bc9e442329b77127296adbf2e4b51b6009d2235.zip |
Respect system UI font
Use the font specified by the system for UI elements. For Windows and
macOS this is straight forward, but Linux is more complex as there is no
single source for this information.
Diffstat (limited to 'vncviewer/fltk')
-rw-r--r-- | vncviewer/fltk/theme.cxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/vncviewer/fltk/theme.cxx b/vncviewer/fltk/theme.cxx index 7478cd88..cb786e4c 100644 --- a/vncviewer/fltk/theme.cxx +++ b/vncviewer/fltk/theme.cxx @@ -25,6 +25,14 @@ #include <config.h> #endif +#ifdef WIN32 +#include <windows.h> +#endif + +#ifdef __APPLE__ +#include <ApplicationServices/ApplicationServices.h> +#endif + #include <FL/Fl.H> #include <FL/Fl_Widget.H> #include <FL/fl_ask.H> @@ -50,8 +58,31 @@ void init_theme() // with the above schemes. fl_message_icon()->box(FL_UP_BOX); -#ifdef WIN32 - // Most "normal" Windows apps use this font for UI elements. - Fl::set_font(FL_HELVETICA, "Tahoma"); +#if defined(WIN32) + NONCLIENTMETRICS metrics; + metrics.cbSize = sizeof(metrics); + if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, + sizeof(metrics), &metrics, 0)) + Fl::set_font(FL_HELVETICA, metrics.lfMessageFont.lfFaceName); +#elif defined(__APPLE__) + CTFontRef font; + CFStringRef name; + char cname[256]; + + font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL); + if (font != NULL) { + name = CTFontCopyFullName(font); + if (name != NULL) { + CFStringGetCString(name, cname, sizeof(cname), + kCFStringEncodingUTF8); + + Fl::set_font(FL_HELVETICA, cname); + + CFRelease(name); + } + CFRelease(font); + } +#else + // FIXME: Get font from GTK or QT #endif } |