From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: handa Newsgroups: gmane.emacs.bugs Subject: bug#22383: 25.1.50; Wrong font height for some fonts Date: Thu, 28 Jan 2016 22:00:43 +0900 Message-ID: <87bn85amf8.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1453986151 28777 80.91.229.3 (28 Jan 2016 13:02:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Jan 2016 13:02:31 +0000 (UTC) Cc: yynyygy@gmail.com, 22383@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 28 14:02:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aOmDK-0004jr-A1 for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Jan 2016 14:02:18 +0100 Original-Received: from localhost ([::1]:56088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOmDI-00069X-G4 for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Jan 2016 08:02:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOmD8-00065D-IC for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 08:02:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOmD4-0007Fd-5q for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 08:02:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOmD4-0007FV-3X for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 08:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aOmD3-0004ML-TI for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 08:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: handa Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Jan 2016 13:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22383-submit@debbugs.gnu.org id=B22383.145398608416714 (code B ref 22383); Thu, 28 Jan 2016 13:02:01 +0000 Original-Received: (at 22383) by debbugs.gnu.org; 28 Jan 2016 13:01:24 +0000 Original-Received: from localhost ([127.0.0.1]:39204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aOmCR-0004LW-P9 for submit@debbugs.gnu.org; Thu, 28 Jan 2016 08:01:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60561) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aOmCQ-0004LG-9K for 22383@debbugs.gnu.org; Thu, 28 Jan 2016 08:01:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOmC8-0006bw-TR for 22383@debbugs.gnu.org; Thu, 28 Jan 2016 08:01:17 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOmBt-0006N6-Jp; Thu, 28 Jan 2016 08:00:49 -0500 Original-Received: from fl1-110-233-34-83.iba.mesh.ad.jp ([110.233.34.83]:42168 helo=shatin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aOmBs-0000Kz-8p; Thu, 28 Jan 2016 08:00:48 -0500 Original-Received: from handa by shatin with local (Exim 4.86) (envelope-from ) id 1aOmBn-0005FE-NE; Thu, 28 Jan 2016 22:00:44 +0900 In-Reply-To: <834meeeyet.fsf@gnu.org> (message from Eli Zaretskii on Sat, 16 Jan 2016 10:11:54 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112052 Archived-At: Sorry for the late response. In article <834meeeyet.fsf@gnu.org>, Eli Zaretskii writes: > > Date: Sat, 16 Jan 2016 15:07:04 +0800 > > From: Fangwen Yu [...] > > 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 #include #include 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); }