As quick answer, I'd take two good ideas from you suggestion instantly:

(1) Use XListFonts() instead of XLoadQueryFont() to test if a font is

(2) Use DefaultFont as a first fallback if requested font could not be
loaded. (I don't know if it makes sense to give a stderr warning that
the requested font could not be found and a replacement was needed?)

Regarding the issue of "fixed"/"variable" <--> "mono-10"/"sans-10"  I'd
suggest to find out how XftFontOpenXlfd() is per definition _supposed_
to work if called with "fixed" or "variable".  Now my installed Xft
library crashes twm in whole;  but irrespective to that, if
XftFontOpenXlfd() is supposed or is free to choose a random replacement
(as not being able to load "fixed" for example), then initialising to
"mono-10" instead of "fixed" makes sense as the outcome to the user is
kind of more deterministic.  This is a matter of opinion/taste, and in
the end a minor issue.

> void
> GetFont(font)
> MyFont *font;
> {
> #ifdef TWM_USE_XFT
>      char **fontlist;
>      int listcount;
>      if (font->font != NULL)
>       XftFontClose(dpy, font->font);

GetFont() is only called on screen initialisation in CreateFonts() and
the font->font variable is priorly initialised to NULL; this is
guaranteed.  So the 'if' test here --- if passing --- would hide some
programming error somewhere else, if I am correct...  :-)


    Eeri Kask
Devel mailing list

Reply via email to