Hello,

Here a proposal for an "API" for font loading and for displaying
string. Any comments welcome before I start the changes.

Before two questions:

The menus code use only XTextWidth and never XmbTextEscapement.
Are there good reasons to do not use XmbTextEscapement (via some ifdef)?

Does a font cache will be useful?

Olivier

------------
/* As it is now but font loading logic will change */
typedef struct FvwmFont
{
  XFontStruct *font;            /* font structure */
#ifdef I18N_MB
  XFontSet fontset;             /* font set */
#endif
  int height;                   /* height of the font */
  int y;                        /* Y coordinate to draw characters */
} FvwmFont;

/*
 * Load fontname into ret_font. For I18N_MB:
 * 1) first try to load fontname with XCreateFontSet
 * 2) If this fail try to load fontname with XLoadQueryFont
 * 3) If this fail try to load
 * -*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*,\
 * -*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*
 * with XCreateFontSet
 * 4) If this fail try to load "fixed" with XLoadQueryFont
 *
 * For !I18N_MB just do 2) and 4) as now but if a "," separated list
 * of fonts is given try to load each.                    
 */
Bool LoadFvwmFont(
  Display *dpy, char *fontname, FvwmFont *ret_font);

typedef struct FvwmWinString
{
  char *str;
  GC gc;
  Window win;
  int x;
  int y;
  /* may add more elements in the future */
} FvwmWinString;

/*
 *  Draw string fstr->str at position fstr->x, fstr->y on window fstr->win
 *  by using either XmbDrawString if ff.fonset != None (and I18N_MB) or
 *  XDrawString. flags: may be used in the future.
 */
void FDrawString(Display *dpy, FvwmFont ff, FvwmWinString *fstr,
                 unsigned long flags);

/* 
 * Simple wapper to XmbTextEscapement (used if ff.fontset != None and I18_MB)
 * and XTextWidth
 */
int FTextWidth(FvwmFont ff, char *str, int sl);

/* 
 * Create a FvwmWinString structure initialized to 0
 */
Bool AllocateFvwmWinString(FvwmWinString **pfws);

/* maybe other warrper as FTextPropertyToTextList */
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to