unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: handa <handa@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: yynyygy@gmail.com, 22383@debbugs.gnu.org
Subject: bug#22383: 25.1.50; Wrong font height for some fonts
Date: Thu, 28 Jan 2016 22:00:43 +0900	[thread overview]
Message-ID: <87bn85amf8.fsf@gnu.org> (raw)
In-Reply-To: <834meeeyet.fsf@gnu.org> (message from Eli Zaretskii on Sat, 16 Jan 2016 10:11:54 +0200)

Sorry for the late response.

In article <834meeeyet.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:
> > Date: Sat, 16 Jan 2016 15:07:04 +0800
> > From: Fangwen Yu <yynyygy@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@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);
}





  reply	other threads:[~2016-01-28 13:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-16  7:07 bug#22383: 25.1.50; Wrong font height for some fonts Fangwen Yu
2016-01-16  8:11 ` Eli Zaretskii
2016-01-28 13:00   ` handa [this message]
2016-02-25 20:02     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bn85amf8.fsf@gnu.org \
    --to=handa@gnu.org \
    --cc=22383@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=yynyygy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).