bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#14634: 24.3.50; face attributes for font appearance (:font etc.)


From: Drew Adams
Subject: bug#14634: 24.3.50; face attributes for font appearance (:font etc.)
Date: Sun, 16 Jun 2013 02:15:17 -0700 (PDT)

Trying to figure out how to use face attribute :font, or, since that
does not seem to work, to at least use other font-related face
attributes.

See also bug #14629, which is about the doc for face attribute :font.

Suppose I want to show a string using a `face' text property that
reflects a particular font, as given by its XLFD.

For example, given this value from, say, a frame's `font' parameter:
"-outline-Lucida Bright-bold-italic-normal-serif-14-*-*-*-p-*-iso8859-1"

Suppose I want to propertize that string, for use elsewhere, with
property `face' so that it appears in the same font (WYSIWYG).

If `myfont' is a variable whose value is that XLFD string, you can try
just using the string as the value of face attribute :font:

(propertize myfont 'face (list :font myfont))

But that doesn't work - it seems to have no effect.  Too bad.

You can try splitting that XLFD string and using some of the fields:

(let* ((splits   (split-string myfont "-"))
       (foundry  (nth 1 splits))
       (family   (nth 2 splits))
       (weight   (nth 3 splits))
       (slant    (nth 4 splits))
       (width    (nth 5 splits))) 
  (propertize
   myfont 'face
   (list :foundry foundry :family family :weight weight :slant slant
         :width width)))

IOW:
(propertize myfont 'face
 (list :foundry "outline" :family "Lucida Bright" :weight "bold"
       :slant "italic" :width "normal"))

But that doesn't really show the font as it should either.  It doesn't
appear italic at all.

And you apparently cannot get the size/height this way (by parsing the
XLFD).  There seems to be no correspondence between the value of PIXELS
or HEIGHT from the XLFD and the available face attribute for size (i.e.,
:height).

Nor does there seem to be any correspondence between face attribute
:height and the sizes returned by `font-info' (neither SIZE nor HEIGHT).
(Note that SIZE is not even explained - the `font-info' doc string just
says it is "the pixelsize", whatever that means!)

Why does :height use units of 1/10 point?  None of the ways I can find
to get info about a font's size use such units.  And its not clear how to
convert what you can obtain from the XLFD or from `font-info' into a
:height value you can use as a face attribute.

Why not make `font-info' return info that can be used as face
attributes?

And why not make face attributes that correspond to the font properties
that Emacs uses elsewhere?  (emacs) `Fonts' mentions these, for
"fontconfig patterns": `style' and `spacing' (in addition to `slant',
`weight', and `width').  And for XLFD it mentions all of the XLFD
fields.  Why can't we use such info as face attributes?

Am I missing something, or is it a bug that you cannot easily specify a
font's properties as face attributes?  In general, this seems quite
confusing and buggy.

And isn't it a bug that specifying :slant "italic" has no effect?  That
is easy to see:

emacs -Q
In *scratch*, turn off font-lock-mode, then type this, then hit `C-x C-e':

(put-text-property 92 126 
                   'face (list :foundry "outline"
                               :family "Lucida Bright"
                               :weight "bold" :slant "italic"
                               :width "normal"))

You will see the words "to create a file, visit that file" change font,
but they will not be italic... (I don't think it is bold either, but I
cannot be sure.)  `C-u C-x =' shows that the property was applied, but
it is not reflected.

Yet if you use `M-x customize-face default', and you set the family to
"Lucida Bright", the foundry to "outline", the width to "normal", the
weight to "bold", and the slant to "italic", you will see the font as it
should be (bold italic).






In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-06-13 on ODIEONE
Bzr revision: 112978 xfq.free@gmail.com-20130613224333-3yfl8navh3c1vmxy
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 CFLAGS='-O0 -g3' CPPFLAGS='-Ic:/Devel/emacs/include'
 LDFLAGS='-Lc:/Devel/emacs/lib''





reply via email to

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