From: Luc Moulinier on
Hello,

While exercising with fonts using the Tk C API , I noted something I
don't understand :

tkmafonte = Tk_GetFont(interp, tkwin, "-adobe-courier-bold-r-
normal--24-240-75-75-m-150-iso10646-1");
Tk_GetFontMetrics(tkmafonte,&fm);
wdt = Tk_TextWidth(tkmafonte,"X",1);
printf("Tk : ascent ascent %d descent %d width %d
\n",fm.ascent,fm.descent, wdt);
Tk_FreeFont(tkmafonte);

XFontStruct *maSfonte;
maSfonte = XLoadQueryFont(Tk_Display(tkwin),"-adobe-courier-bold-r-
normal--24-240-75-75-m-150-iso10646-1");
wdt = XTextWidth(maSfonte,"X",1);
printf("xlib : ascent ascent %d descent %d width %d\n",maSfonte-
>ascent,maSfonte->descent, wdt);

gives (the font is Courier 24 bold):

Tk : ascent ascent 22 descent 6 width 15
xlib : ascent ascent 19 descent 5 width 15

Can someone explain me the observed differences in ascent and
descent ? I found nothing in the man pages about that...

Many thanks !

Luc
From: Luc Moulinier on
To precise : working with Tcl/Tk 8.5.8 under Linux (redhat)


Luc
From: Eric Boudaillier on
Hello Luc,

The difference is probably due to the use of XFT in Tk 8.5.
XLoadFont is not used in this case. XFT add antialiasing, and explain
the size difference.

-eric

On 28 juin, 16:34, Luc Moulinier <luc.moulin...(a)igbmc.fr> wrote:
>   Hello,
>
>   While exercising with fonts using the Tk C API , I noted something I
> don't understand :
>
>   tkmafonte = Tk_GetFont(interp, tkwin, "-adobe-courier-bold-r-
> normal--24-240-75-75-m-150-iso10646-1");
>   Tk_GetFontMetrics(tkmafonte,&fm);
>   wdt = Tk_TextWidth(tkmafonte,"X",1);
>   printf("Tk : ascent ascent %d descent %d width %d
> \n",fm.ascent,fm.descent, wdt);
>   Tk_FreeFont(tkmafonte);
>
>   XFontStruct *maSfonte;
>   maSfonte = XLoadQueryFont(Tk_Display(tkwin),"-adobe-courier-bold-r-
> normal--24-240-75-75-m-150-iso10646-1");
>   wdt = XTextWidth(maSfonte,"X",1);
>   printf("xlib : ascent ascent %d descent %d width %d\n",maSfonte-
>
> >ascent,maSfonte->descent, wdt);
>
>   gives (the font is Courier 24 bold):
>
> Tk : ascent ascent 22 descent 6 width 15
> xlib : ascent ascent 19 descent 5 width 15
>
> Can someone explain me the observed differences in ascent and
> descent ? I found nothing in the man pages about that...
>
> Many thanks !
>
> Luc