From 53469038ce3921395649ae33d11fca75a5ae36c4 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 31 Jul 2024 17:04:34 +0200 Subject: [PATCH] Enable setting a fixed font for 'wine' in test/handle_keys.cxx ... w/o editing a file. The default font is "Liberation Mono". Just set environment variable FLTK_USING_WINE=1 to enable this feature. Rationale: on /my/ current test system the font chosen by `wine` for FL_COURIER is a proportional font whereas the display in Fl_Terminal requires a fixed font for correct output. Font "Liberation Mono" solves this long standing issue for me w/o having to change source code but other Linux systems may require a different font. --- test/handle_keys.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/handle_keys.cxx b/test/handle_keys.cxx index c5b4409cd..e63aa280d 100644 --- a/test/handle_keys.cxx +++ b/test/handle_keys.cxx @@ -335,16 +335,21 @@ void close_cb(Fl_Widget *win, void *) { int main(int argc, char **argv) { -// Set an appropriate font for Wine on Linux (test only). -// This is very likely not necessary on a real Windows system + // Set an appropriate font for Wine on Linux (test only). + // This is very likely not necessary on a real Windows system. + // Set environment variable FLTK_USING_WINE to a non-empty string + // to enable this feature, e.g. (in bash) `export FLTK_USING_WINE=1`. -#if (0) // test/experimental for wine on Linux (maybe missing fonts) #ifdef _WIN32 - // Fl::set_font(FL_COURIER, " DejaVu Sans Mono"); // DejaVu Mono - // Fl::set_font(FL_COURIER, "BNimbus Mono PS"); // Nimbus Mono PS bold - Fl::set_font(FL_COURIER, " Liberation Mono"); // Liberation Mono + const char *using_wine = fl_getenv("FLTK_USING_WINE"); + printf("FLTK_USING_WINE = %s\n", using_wine ? using_wine : ""); + if (using_wine && *using_wine) { + // set an alternate fixed font for the terminal widget + // Fl::set_font(FL_COURIER, " DejaVu Sans Mono"); // DejaVu Mono + // Fl::set_font(FL_COURIER, "BNimbus Mono PS"); // Nimbus Mono PS bold + Fl::set_font(FL_COURIER, " Liberation Mono"); // Liberation Mono + } #endif -#endif // test const int WW = 700, WH = 400; app *win = new app(0, 0, WW, WH);