[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: face-variable-width-p?

From: Kevin Rodgers
Subject: Re: face-variable-width-p?
Date: Sun, 17 Feb 2008 10:09:08 -0700
User-agent: Thunderbird (Macintosh/20071031)

David Reitter wrote:
I'm trying to figure out whether a given face (the default face in a frame, to be precise) uses a variable width font, but I can't find an appropriate function in Emacs. One could compare the pixel widths of 'w' and 'i', but I can't find a function that would give me the pixel width of a (propertized) string, either.

How about parsing the XLFD font name:

(let ((font (frame-parameter (selected-frame) 'font)))
  (string-match xlfd-tight-regexp font)
  (match-string xlfd-regexp-spacing-subnum font))

On my machine, font is "-apple-monaco-medium-r-normal--12-120-72-72-m-120-iso10646-1",
but match-string returns "72" instead of "m".  So perhaps there's
a bug in xlfd-tight-regexp that can be worked around:

(let ((font (frame-parameter (selected-frame) 'font)))
  (string-match xlfd-tight-regexp font)
  (match-string (1+ xlfd-regexp-spacing-subnum) font))

A variable-width font (aka proportional pitch) should return "p"
-- see section (SPACING Field) in

Kevin Rodgers
Denver, Colorado, USA

reply via email to

[Prev in Thread] Current Thread [Next in Thread]