From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#39264: 26.3; (frame-char-width) is different from real char width of monospace font 'Noto Sans Mono' Date: Fri, 24 Jan 2020 17:34:04 +0200 Message-ID: <83tv4krhqr.fsf@gnu.org> References: <86sgk4sy35.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="59658"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39264@debbugs.gnu.org To: ynyaaa@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 24 16:35:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iv0zJ-000FUU-Qs for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 16:35:13 +0100 Original-Received: from localhost ([::1]:43728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iv0zI-00075G-Td for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 10:35:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55111) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iv0z8-00072e-Ro for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 10:35:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iv0z7-0007qh-Rf for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 10:35:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iv0z7-0007qV-NU for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 10:35:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iv0z7-0006Ke-LZ for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 10:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Jan 2020 15:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39264 X-GNU-PR-Package: emacs Original-Received: via spool by 39264-submit@debbugs.gnu.org id=B39264.157988007024293 (code B ref 39264); Fri, 24 Jan 2020 15:35:01 +0000 Original-Received: (at 39264) by debbugs.gnu.org; 24 Jan 2020 15:34:30 +0000 Original-Received: from localhost ([127.0.0.1]:54641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iv0yc-0006Jf-B1 for submit@debbugs.gnu.org; Fri, 24 Jan 2020 10:34:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45901) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iv0ya-0006JM-ID; Fri, 24 Jan 2020 10:34:28 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iv0yV-0007IV-DZ; Fri, 24 Jan 2020 10:34:23 -0500 Original-Received: from [176.228.60.248] (port=2203 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iv0yU-0001Jf-74; Fri, 24 Jan 2020 10:34:23 -0500 In-reply-to: <86sgk4sy35.fsf@gmail.com> (ynyaaa@gmail.com) 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175228 Archived-At: tags 39264 notabug thanks > From: ynyaaa@gmail.com > Date: Fri, 24 Jan 2020 23:55:42 +0900 > > I installed Noto fonts. > With setting frame font to "Noto Sans Mono", which is a monospace font, > (frame-char-width) and the real char width may differ. > > For example, using "Noto Sans Mono-13", (frame-char-width) is one pixel larger. > (progn > (set-frame-font "Noto Sans Mono-13") > (list (frame-char-width) (car (window-text-pixel-size nil 1 2)))) > => (11 10) This is not a bug. frame-char-width returns the value of the font's "average width" attribute, whereas window-text-pixel-size actually performs the layout of the specified text, simulating its display, and measures the result. Thus, the values can differ, although for monospaced fonts they cannot (or should not) differ by too much. The upshot of this is that you cannot really perform accurate layout calculations from Lisp, at least not easily. There's no way around this basic difficulty.