GNU bug report logs - #22383
25.1.50; Wrong font height for some fonts

Previous Next

Package: emacs;

Reported by: Fangwen Yu <yynyygy <at> gmail.com>

Date: Sat, 16 Jan 2016 07:08:01 UTC

Severity: normal

Found in version 25.1.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: handa <handa <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yynyygy <at> gmail.com, 22383 <at> debbugs.gnu.org
Subject: bug#22383: 25.1.50; Wrong font height for some fonts
Date: Thu, 28 Jan 2016 22:00:43 +0900
Sorry for the late response.

In article <834meeeyet.fsf <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org> writes:
> > Date: Sat, 16 Jan 2016 15:07:04 +0800
> > From: Fangwen Yu <yynyygy <at> gmail.com>
[...]
> > diff --git a/src/xftfont.c b/src/xftfont.c
> > index 956231e..d0f9a68 100644
> > --- a/src/xftfont.c
> > +++ b/src/xftfont.c
> > @@ -395,16 +395,16 @@ xftfont_open (struct frame *f, Lisp_Object entity, int
> > pixel_size)
> > 
> > font->ascent = xftfont->ascent;
> > font->descent = xftfont->descent;
> > - if (pixel_size >= 5)
> > - {
> > - /* The above condition is a dirty workaround because
> > - XftTextExtents8 behaves strangely for some fonts
> > - (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */
> > - if (font->ascent < extents.y)
> > - font->ascent = extents.y;
> > - if (font->descent < extents.height - extents.y)
> > - font->descent = extents.height - extents.y;
> > - }
> > + /* if (pixel_size >= 5) */
> > + /* { */
> > + /* /\* The above condition is a dirty workaround because */
> > + /* XftTextExtents8 behaves strangely for some fonts */
> > + /* (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. *\/ */
> > + /* if (font->ascent < extents.y) */
> > + /* font->ascent = extents.y; */
> > + /* if (font->descent < extents.height - extents.y) */
> > + /* font->descent = extents.height - extents.y; */
> > + /* } */
> > font->height = font->ascent + font->descent;
> > 
> > if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
> > 
> > As the comment says, this piece of code is a dirty workaround, and
> > apparently it is causing some new problems.

I've just tried the latest Xft with the attached small program.  It
seems that there's no need to adjust ascent and descent of fonts
(including "dejavu sans mono"); i.e. we can trust xftfont->ascent and
xftfont->descent.  So, I think we can use your patch.

---
K. Handa
handa <at> gnu.org

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xft/Xft.h>

int
main (int argc, char **argv)
{
  Display *display = XOpenDisplay (NULL);
  FcPattern *pat = FcNameParse ((FcChar8 *) argv[1]);
  FcResult result;
  FcPattern *match = XftFontMatch (display, 0, pat, &result);
  XftFont *xftfont = XftFontOpenPattern (display, match);
  XGlyphInfo extents;
  XftTextExtents8 (display, xftfont, "ABCDEF", 6, &extents);
  printf ("%dx%d+%d+%d %d+%d\n",
	  extents.width, extents.height, extents.x, extents.y,
	  xftfont->ascent, xftfont->descent);
}




This bug report was last modified 9 years and 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.