DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2215
Version: 1.1.9
When load_xfont_for_xft2 looks for a corresponding core font, it keeps the
requested face name as is, even when it is an Xft-specific alias. I'm
attaching a patch that addresses that with a (hard-coded) map, and also
adjusts weight's type for const correctness.
Link: http://www.fltk.org/str.php?L2215
Version: 1.1.9
Index: fl_font_xft.cxx
===================================================================
--- fl_font_xft.cxx (revision 6826)
+++ fl_font_xft.cxx (working copy)
@@ -291,11 +291,11 @@
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 @@
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);
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs