diff --git a/CHANGES b/CHANGES index 46e5c4214..9da6b0ee5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ CHANGES IN FLTK 1.1.10 + - Added Xft2 font lookup table (STR #2215) - Fixed X server "lock", if a modal dialog window is opened while a menu is active (STR #1986) - Updated mirror sites in documentation (STR #2220) diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx index 36ca69ab9..e5f317bca 100644 --- a/src/fl_font_xft.cxx +++ b/src/fl_font_xft.cxx @@ -291,11 +291,11 @@ double fl_width(uchar c) { static XFontStruct* load_xfont_for_xft2(void) { XFontStruct* xgl_font = 0; int size = fl_size_; - char *weight = "medium"; // no specifc weight requested - accept any + const char *weight = "medium"; // no specifc weight requested - accept any char slant = 'r'; // regular non-italic by default char xlfd[128]; // we will put our synthetic XLFD in here char *pc = strdup(fl_fonts[fl_font_].name); // what font were we asked for? - char *name = pc; // keep a handle to the original name for freeing later + const char *name = pc; // keep a handle to the original name for freeing later // Parse the "fltk-name" of the font switch (*name++) { case 'I': slant = 'i'; break; // italic @@ -305,6 +305,19 @@ static XFontStruct* load_xfont_for_xft2(void) { default: name--; // no prefix, restore name } + // map generic Xft names to customary XLFD faces + if (!strcmp(name, "sans")) { + name = "helvetica"; + } else if (!strcmp(name, "mono")) { + name = "courier"; + } else if (!strcmp(name, "serif")) { + name = "times"; + } else if (!strcmp(name, "screen")) { + name = "lucidatypewriter"; + } else if (!strcmp(name, "dingbats")) { + name = "zapf dingbats"; + } + // first, we do a query with no prefered size, to see if the font exists at all snprintf(xlfd, 128, "-*-*%s*-%s-%c-*--*-*-*-*-*-*-*-*", name, weight, slant); // make up xlfd style name xgl_font = XLoadQueryFont(fl_display, xlfd);