From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Fangwen Yu Newsgroups: gmane.emacs.bugs Subject: bug#22383: 25.1.50; Wrong font height for some fonts Date: Sat, 16 Jan 2016 15:07:04 +0800 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c15b50cb928d05296e2aaa X-Trace: ger.gmane.org 1452928111 22412 80.91.229.3 (16 Jan 2016 07:08:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Jan 2016 07:08:31 +0000 (UTC) To: 22383@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 16 08:08:12 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 1aKKy1-0003KB-4B for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Jan 2016 08:08:09 +0100 Original-Received: from localhost ([::1]:49973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKy0-0005j0-9E for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Jan 2016 02:08:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKxv-0005iE-SH for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:08:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKKxu-0002Yj-5V for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:08:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKxu-0002Yf-2T for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aKKxt-0006lG-VJ for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Fangwen Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Jan 2016 07:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145292803725931 (code B ref -1); Sat, 16 Jan 2016 07:08:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Jan 2016 07:07:17 +0000 Original-Received: from localhost ([127.0.0.1]:50398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aKKxA-0006kB-OS for submit@debbugs.gnu.org; Sat, 16 Jan 2016 02:07:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56901) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aKKx9-0006jw-HN for submit@debbugs.gnu.org; Sat, 16 Jan 2016 02:07:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKKx2-0002Rx-Tj for submit@debbugs.gnu.org; Sat, 16 Jan 2016 02:07:10 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKx2-0002Rt-Qq for submit@debbugs.gnu.org; Sat, 16 Jan 2016 02:07:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKx1-0005ar-6h for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:07:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKKwz-0002RS-Ln for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:07:07 -0500 Original-Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]:35078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKKwz-0002RO-Dq for bug-gnu-emacs@gnu.org; Sat, 16 Jan 2016 02:07:05 -0500 Original-Received: by mail-io0-x231.google.com with SMTP id 77so476277814ioc.2 for ; Fri, 15 Jan 2016 23:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=IHzMsRLXvRNs0YdQ+kntVV9QyPs6A3O2uJWqF60jqvw=; b=kTRevBrfMVcjunE8V5aUEyUTg03j5+xBRbvKj531od0Wrrm+JJxHE66ZXJJZVniln1 O53clsKu3ZauO+Jx8CaxnBD7ibFAEn7ooVnEERjgAUdEqcqvCs8HSDS+HXUnYNwC9P6d UqG46aR5eVxjW/kA9uYnNXK2hkDvqWc8eDMtNwCtzp4/MNlna2s98s7KtXHBx/yrV/Xt +R3faO3De5gONIK5fuWVtHGg9Oowp/Y0hEUyrkqAd0MwT2iaifNVchwbEXYaxMVH8206 Aafd3nJbmpiJhetFYIae78c5oHdBR8+6nBzibTw6RYUsFJlRGmS0aXhlQj3jb9xJvcUp rObg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=IHzMsRLXvRNs0YdQ+kntVV9QyPs6A3O2uJWqF60jqvw=; b=gp3+1Gc6yMhcE+fPEkMEeem1uBz8WhML4JzuZlRTITetYNhwjS77hvumwdNpvhgsea N3YokzuCKj8Nh8smrPw9nxtW2i8DSLH+ihNsYda4Qtgdyv7xKL8CP/67r5/383X5b+qx erSRSQGIjoRV/Y0uy+Z0jwBOJVSMFmrKhjDKMIKlyqkuF7lED/UBURpNPyc4QyTjntrT Ce1JxdqWU5y3fksq7LoVVodH7q497aRMz+nnO8qZbSlkwp0G+O8qbKaB2ot4tbnUV/UX 6c1e1PXM9HdHFBrwJAW4ct6B9eqKqZL4o3xNfLhfvtERi3HId4JXL+bDFE9CGMcq9l+2 9NNQ== X-Gm-Message-State: ALoCoQnwlw2/62ImBs9mS+MA6Wxm/D8p7QS5VSU2gliBkO1eX2iIVm3VmWzSefPlq3AFBrhUL9daLatYIZSpMVGh/qLy4m0zuQ== X-Received: by 10.107.46.228 with SMTP id u97mr13778695iou.136.1452928024676; Fri, 15 Jan 2016 23:07:04 -0800 (PST) Original-Received: by 10.64.71.105 with HTTP; Fri, 15 Jan 2016 23:07:04 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:111666 Archived-At: --001a11c15b50cb928d05296e2aaa Content-Type: text/plain; charset=UTF-8 With DejaVu Sans Mono-11, text lines in Emacs are 1 pixel taller than in gedit or gnome-terminal, also, bold faces are 1 pixel taller than regular, so if the theme uses bold faces, texts will jump up and down while editing. The line height problem also happens with Consolas font, but the bold faces problem doesn't. Since it clearly has something to do with font height, I digged into the source and found the related code. Apply this patch, and the problem is gone: 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. In GNU Emacs 25.1.50.36 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7) of 2016-01-15 built on katana Repository revision: 4580671f5e2a68885e0fca93eeaf9daaeebe82b3 Windowing system distributor 'The X.Org Foundation', version 11.0.11702000 System Description: Ubuntu 15.10 Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 Important settings: value of $LC_COLLATE: C value of $LC_CTYPE: zh_CN.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=fcitx locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message dired dired-loaddefs format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util china-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 80789 6761) (symbols 48 19157 0) (miscs 40 178 100) (strings 32 12817 4884) (string-bytes 1 387166) (vectors 16 11243) (vector-slots 8 468928 19771) (floats 8 142 27) (intervals 56 206 0) (buffers 976 12) (heap 1024 21736 1037)) --001a11c15b50cb928d05296e2aaa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

With DejaVu Sans Mono-11, text lines in Emacs are 1 pi= xel taller than in
gedit or gnome-terminal, also, bold faces are 1 pixel= taller than
regular, so if the theme uses bold faces, texts will jump u= p and down
while editing. The line height problem also happens with Cons= olas font,
but the bold faces problem doesn't.

Since it clear= ly has something to do with font height, I digged into the
source and fo= und the related code. Apply this patch, and the problem is
gone:

= 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 @@ xft= font_open (struct frame *f, Lisp_Object entity, int pixel_size)
=C2=A0=C2=A0=C2=A0 font->ascent =3D xftfont->ascent;
=C2=A0=C2=A0 font= ->descent =3D xftfont->descent;
-=C2=A0 if (pixel_size >=3D 5)<= br>-=C2=A0=C2=A0=C2=A0 {
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* The above co= ndition is a dirty workaround because
-=C2=A0=C2=A0=C2=A0 =C2=A0XftTextE= xtents8 behaves strangely for some fonts
-=C2=A0=C2=A0=C2=A0 =C2=A0(e.g.= "Dejavu Sans Mono") when pixel_size is less than 5. */
-=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 if (font->ascent < extents.y)
-=C2=A0= =C2=A0=C2=A0 font->ascent =3D extents.y;
-=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (font->descent < extents.height - extents.y)
-=C2=A0=C2=A0= =C2=A0 font->descent =3D extents.height - extents.y;
-=C2=A0=C2=A0=C2= =A0 }
+=C2=A0 /* if (pixel_size >=3D 5) */
+=C2=A0 /*=C2=A0=C2=A0 = { */
+=C2=A0 /*=C2=A0=C2=A0=C2=A0=C2=A0 /\* The above condition is a dir= ty workaround because */
+=C2=A0 /*=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 XftTextExtents8 behaves strangely for some fonts */
+=C2=A0 /*=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (e.g. "Dejavu Sans Mono")= when pixel_size is less than 5. *\/ */
+=C2=A0 /*=C2=A0=C2=A0=C2=A0=C2= =A0 if (font->ascent < extents.y) */
+=C2=A0 /*=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 font->ascent =3D extents.y; */
+=C2=A0 /*=C2=A0=C2= =A0=C2=A0=C2=A0 if (font->descent < extents.height - extents.y) */+=C2=A0 /*=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 font->descent =3D extent= s.height - extents.y; */
+=C2=A0 /*=C2=A0=C2=A0 } */
=C2=A0=C2=A0 fon= t->height =3D font->ascent + font->descent;
=C2=A0
=C2=A0=C2= =A0 if (XINT (AREF (entity, FONT_SIZE_INDEX)) =3D=3D 0)


As the c= omment says, this piece of code is a dirty workaround, and
apparently it= is causing some new problems.



In GNU Emacs 25.1.50.36 (x86_= 64-unknown-linux-gnu, GTK+ Version 3.16.7)
=C2=A0of 2016-01-15 built on = katana
Repository revision: 4580671f5e2a68885e0fca93eeaf9daaeebe82b3
= Windowing system distributor 'The X.Org Foundation', version 11.0.1= 1702000
System Description:=C2=A0=C2=A0=C2=A0 Ubuntu 15.10

Config= ured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCO= NF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBO= TF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
= =C2=A0 value of $LC_COLLATE: C
=C2=A0 value of $LC_CTYPE: zh_CN.UTF-8=C2=A0 value of $LANG: en_US.UTF-8
=C2=A0 value of $XMODIFIERS: @im=3Df= citx
=C2=A0 locale-coding-system: utf-8-unix

Major mode: Lisp Int= eraction

Minor modes in effect:
=C2=A0 tooltip-mode: t
=C2=A0 = global-eldoc-mode: t
=C2=A0 electric-indent-mode: t
=C2=A0 mouse-whee= l-mode: t
=C2=A0 tool-bar-mode: t
=C2=A0 menu-bar-mode: t
=C2=A0 f= ile-name-shadow-mode: t
=C2=A0 global-font-lock-mode: t
=C2=A0 font-l= ock-mode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 auto-composition-mode:= t
=C2=A0 auto-encryption-mode: t
=C2=A0 auto-compression-mode: t
= =C2=A0 line-number-mode: t
=C2=A0 transient-mark-mode: t

Recent m= essages:
For information about GNU Emacs and the GNU system, type C-h C-= a.
Making completion list...

Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr emacsbug message dired d= ired-loaddefs
format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-enco= de mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 r= fc2045
ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase = cl-lib
mail-prsvr mail-utils time-date mule-util china-util tooltip eldo= c
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
= term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabul= ated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-b= ar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax f= acemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vi= etnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebr= ew greek romanian slovak czech european ethiopic indian
cyrillic chinese= charscript case-table epa-hook jka-cmpr-hook help
simple abbrev obarray= minibuffer cl-preloaded nadvice loaddefs button
faces cus-face macroexp= files text-properties overlay sha1 md5 base64
format env code-pages mul= e custom widget hashtable-print-readable
backquote dbusbind inotify dyna= mic-setting system-font-setting
font-render-setting move-toolbar gtk x-t= oolkit x multi-tty
make-network-process emacs)

Memory information= :
((conses 16 80789 6761)
=C2=A0(symbols 48 19157 0)
=C2=A0(miscs = 40 178 100)
=C2=A0(strings 32 12817 4884)
=C2=A0(string-bytes 1 38716= 6)
=C2=A0(vectors 16 11243)
=C2=A0(vector-slots 8 468928 19771)
= =C2=A0(floats 8 142 27)
=C2=A0(intervals 56 206 0)
=C2=A0(buffers 976= 12)
=C2=A0(heap 1024 21736 1037))

--001a11c15b50cb928d05296e2aaa--