GNU bug report logs - #39264
26.3; (frame-char-width) is different from real char width of monospace font 'Noto Sans Mono'

Previous Next

Package: emacs;

Reported by: ynyaaa <at> gmail.com

Date: Fri, 24 Jan 2020 14:56:02 UTC

Severity: normal

Tags: notabug

Found in version 26.3

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: ynyaaa <at> gmail.com
Cc: 39264 <at> debbugs.gnu.org
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
tags 39264 notabug
thanks

> From: ynyaaa <at> 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.




This bug report was last modified 5 years and 157 days ago.

Previous Next


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