GNU bug report logs - #14634
24.3.50; face attributes for font appearance (:font etc.)

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 16 Jun 2013 09:16:02 UTC

Severity: minor

Tags: fixed

Found in version 24.3.50

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14634 in the body.
You can then email your comments to 14634 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14634; Package emacs. (Sun, 16 Jun 2013 09:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 16 Jun 2013 09:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 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 <at> 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''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14634; Package emacs. (Fri, 01 Nov 2019 17:15:01 GMT) Full text and rfc822 format available.

Message #8 received at 14634 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 14634 <at> debbugs.gnu.org
Subject: Re: 24.3.50; face attributes for font appearance (:font etc.)
Date: Fri, 01 Nov 2019 18:14:35 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

> 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.

The syntax is with symbols, not strings:

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

This isn't mentioned in "Low-Level Font", so I've now done so.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 01 Nov 2019 17:15:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 14634 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 01 Nov 2019 17:15:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14634; Package emacs. (Fri, 01 Nov 2019 17:59:02 GMT) Full text and rfc822 format available.

Message #15 received at 14634 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 14634 <at> debbugs.gnu.org
Subject: RE: 24.3.50; face attributes for font appearance (:font etc.)
Date: Fri, 1 Nov 2019 10:57:49 -0700 (PDT)
> The syntax is with symbols, not strings:
> 
> (insert (propertize "foo" 'face (list :foundry "outline"
> 			               :family "Lucida Bright"
> 			               :weight 'bold :slant 'italic
> 			               :width 'normal)))
> 
> This isn't mentioned in "Low-Level Font", so I've now done so.

Thanks.

Could you also please take a look at the related bug #14629?  Thx.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14634; Package emacs. (Sat, 02 Nov 2019 14:32:01 GMT) Full text and rfc822 format available.

Message #18 received at 14634 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 14634 <at> debbugs.gnu.org
Subject: Re: 24.3.50; face attributes for font appearance (:font etc.)
Date: Sat, 02 Nov 2019 15:31:29 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

> Could you also please take a look at the related bug #14629?  Thx.

I'm slowly working my way through all the bugs that have "font" in their
subject lines, but that's an earlier one than this one, which means that
I've probably looked at it, but didn't have anything to contribute,
unfortunately.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14634; Package emacs. (Sat, 02 Nov 2019 15:03:02 GMT) Full text and rfc822 format available.

Message #21 received at 14634 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 14634 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#14634: 24.3.50;
 face attributes for font appearance (:font etc.)
Date: Sat, 02 Nov 2019 17:02:22 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Sat, 02 Nov 2019 15:31:29 +0100
> Cc: 14634 <at> debbugs.gnu.org
> 
> Drew Adams <drew.adams <at> oracle.com> writes:
> 
> > Could you also please take a look at the related bug #14629?  Thx.
> 
> I'm slowly working my way through all the bugs that have "font" in their
> subject lines, but that's an earlier one than this one, which means that
> I've probably looked at it, but didn't have anything to contribute,
> unfortunately.

I just did.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 01 Dec 2019 12:24:05 GMT) Full text and rfc822 format available.

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

Previous Next


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