Specifically, I'm interested in the width of characters in the default font assuming that the default font is mono-spaced. From reading the documentation, I got the impression that this should give me the correct value:
(aref (font-info (face-font 'default)) 2)
However, these values are consistently too big. For example, my current default font is
-unknown-DejaVu Sans Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1
and the code above gives me 13. However, when I make a screenshot and measure the characters their width is only 8 pixels. frame-char-width
gives me 8 pixels but if I change the default font size (using text-scale-increase
) it continues to say 8, so that isn't useful.
I'm working with Emacs 25.0.50.2 on Ubuntu 14.04.
font-info
, the resulting array containsMAX-WIDTH
,SPACE-WIDTH
,AVERAGE-WIDTH
, which should be same for a mono font. Does(aref (font-info ...) 7)
gives you the correct result?