On Mon, Feb 04, 2002 at 08:35:14AM +0100, Olivier Chapuis wrote:
> 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?

The X server already caches fonts, so an fvwm font cache needs to
cache only the information about the fonts that would have to be
queried from the server.  To me, it seems to be a good idea to do
this in order to reduce network traffic.

> /* 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);

Looks good this far.  But let's rename I18N_MB to something that
makes more sense.  Also, I'd use "FFontStruct" instead of
"FvwmFont" to indicate that it's our replacement for XFontStruct.

> 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);

Again, I'd use a different name since it is *not* an exact
replacement for XDrawString (the parameters are different).  The
idea I had in mind with the F... names was to replace 'X' with 'F'
if - and only if - the object is our own replacement for
functionally identical object in X.  If the parameter list is
different, I'd indicate that by giving it a different name.

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

Ok.

> /* 
>  * Create a FvwmWinString structure initialized to 0
>  */
> Bool AllocateFvwmWinString(FvwmWinString **pfws);
> 
> /* maybe other warrper as FTextPropertyToTextList */

In addition, I'd prefix all the names from Flocale.h with
"Flocale" (only those that don't have an X->F name of course)

  FlocaleWinString
  FlocaleAllocateWinString
  FlocaleFont
  FlocaleLoadFont
  ...

BTW, the font handling functions should probably be moved into
Flocale.

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: [EMAIL PROTECTED]
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
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