On Tue, Feb 06, 2007 at 11:10:06PM +0100, Anselm R. Garbe wrote:
> changeset:   1761:4813e030768b
> tag:         tip
> user:        Kris Maglione <jg_AT_suckless.org>
> date:        Tue Feb 06 17:03:07 2007 -0500
> files:       draw.c
> description:
> Only use the ascent/descent from the first font in the fontset. Comments welcome.
> 
> 
> diff -r 62f1a80511e1 -r 4813e030768b draw.c
> --- a/draw.c	Tue Feb 06 15:28:35 2007 -0500
> +++ b/draw.c	Tue Feb 06 17:03:07 2007 -0500
> @@ -40,17 +40,12 @@ loadfont(Blitz *blitz, BlitzFont *font) 
>  		XFontSetExtents *font_extents;
>  		XFontStruct **xfonts;
>  		char **font_names;
> -		unsigned int i;
> +
>  		font->ascent = font->descent = 0;
>  		font_extents = XExtentsOfFontSet(font->set);
> -		n = XFontsOfFontSet(font->set, &xfonts, &font_names);
> -		for(i = 0, font->ascent = 0, font->descent = 0; i < n; i++) {
> -			if(font->ascent < (*xfonts)->ascent)
> -				font->ascent = (*xfonts)->ascent;
> -			if(font->descent < (*xfonts)->descent)
> -				font->descent = (*xfonts)->descent;
> -			xfonts++;
> -		}
> +		XFontsOfFontSet(font->set, &xfonts, &font_names);
> +		font->ascent = xfonts[0]->ascent;
> +		font->descent = xfonts[0]->descent;
>  	}
>  	else {
>  		if(font->xfont)
I'd like to know if this works, I also had a similiar thought
sometime ago. However, I'd consider the corner case that
XFontsOfFontSet(..) returns 0, in such a case xfonts[0] might be
invalid.
Regards,
-- Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361Received on Tue Feb 06 2007 - 23:46:38 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:56 UTC