From ab7c915bf026fe9eb574942717953a000af2dd73 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 27 Aug 2017 07:58:38 +0000 Subject: Fix for STR#3397: find adequate X font to use it with GL. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12404 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- .../Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx index 2f9ca8b4c..f130acbd3 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -1078,20 +1078,8 @@ static XFontStruct* load_xfont_for_xft2(Fl_Graphics_Driver *driver) { char xlfd[128]; // we will put our synthetic XLFD in here char *pc = strdup(fl_fonts[fnum].name); // what font were we asked for? #if USE_PANGO - char *p = pc; + char *p = pc + 1; while (*p) { *p = tolower(*p); p++; } - p = pc + strlen(pc) - 12; - if (memcmp(p, " bold italic\0", 13) == 0) { - *pc = 'P'; *p = 0; - } - p = pc + strlen(pc) - 5; - if (memcmp(p, " bold\0", 6) == 0) { - *pc = 'B'; *p = 0; - } - p = pc + strlen(pc) - 7; - if (memcmp(p, " italic\0", 8) == 0) { - *pc = 'I'; *p = 0; - } #endif // USE_PANGO const char *name = pc; // keep a handle to the original name for freeing later // Parse the "fltk-name" of the font @@ -1137,9 +1125,14 @@ static XFontStruct* load_xfont_for_xft2(Fl_Graphics_Driver *driver) { snprintf(xlfd, 128, "-*-helvetica-*-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10)); xgl_font = XLoadQueryFont(fl_display, xlfd); } + // If that still didn't work, try courier with resquested weight and slant + if(!xgl_font && weight != wt_med) { + snprintf(xlfd, 128, "-*-courier*-%s-%c-*--*-%d-*-*-*-*-*-*", weight, slant, (size*10)); + xgl_font = XLoadQueryFont(fl_display, xlfd); + } // If that still didn't work, try this instead if(!xgl_font) { - snprintf(xlfd, 128, "-*-courier-medium-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10)); + snprintf(xlfd, 128, "-*-courier*-medium-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10)); xgl_font = XLoadQueryFont(fl_display, xlfd); } //printf("glf: %d\n%s\n%s\n", size, xlfd, fl_fonts[fl_font_].name); -- cgit v1.2.3