unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* face-variable-width-p?
@ 2008-02-06 12:19 David Reitter
  2008-02-17 17:09 ` face-variable-width-p? Kevin Rodgers
       [not found] ` <mailman.7529.1203268160.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: David Reitter @ 2008-02-06 12:19 UTC (permalink / raw)
  To: gnu emacs-help gnu

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.

Any suggestions? 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: face-variable-width-p?
  2008-02-06 12:19 face-variable-width-p? David Reitter
@ 2008-02-17 17:09 ` Kevin Rodgers
       [not found] ` <mailman.7529.1203268160.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2008-02-17 17:09 UTC (permalink / raw)
  To: help-gnu-emacs

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 3.1.2.10 (SPACING Field) in 
http://ftp.xfree.org/pub/XFree86/4.5.0/doc/xlfd.txt

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: face-variable-width-p?
       [not found] ` <mailman.7529.1203268160.18990.help-gnu-emacs@gnu.org>
@ 2008-02-26 12:24   ` David Reitter
  0 siblings, 0 replies; 3+ messages in thread
From: David Reitter @ 2008-02-26 12:24 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 17, 5:09 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:

> 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 3.1.2.10 (SPACING Field) inhttp://ftp.xfree.org/pub/XFree86/4.5.0/doc/xlfd.txt

Nice idea for a hack, but it doesn't work for me.
This returns "m" no matter what.

Some examples on my machine:

"-apple-times new roman-medium-r-normal--12-120-72-72-m-120-
iso10646-1"
"-apple-lucida grande-medium-r-normal--14-140-72-72-m-140-iso10646-1"
"-apple-monaco-medium-r-normal--12-120-72-72-m-120-iso10646-1"

I can't see any indication of mono/variable width here.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-26 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-06 12:19 face-variable-width-p? David Reitter
2008-02-17 17:09 ` face-variable-width-p? Kevin Rodgers
     [not found] ` <mailman.7529.1203268160.18990.help-gnu-emacs@gnu.org>
2008-02-26 12:24   ` face-variable-width-p? David Reitter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).