unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 14634@debbugs.gnu.org
Subject: bug#14634: 24.3.50; face attributes for font appearance (:font etc.)
Date: Sun, 16 Jun 2013 02:15:17 -0700 (PDT)	[thread overview]
Message-ID: <feea0d49-49ae-496f-9349-53696db9290d@default> (raw)


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	other threads:[~2013-06-16  9:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16  9:15 Drew Adams [this message]
2019-11-01 17:14 ` bug#14634: 24.3.50; face attributes for font appearance (:font etc.) Lars Ingebrigtsen
2019-11-01 17:57   ` Drew Adams
2019-11-02 14:31     ` Lars Ingebrigtsen
2019-11-02 15:02       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=feea0d49-49ae-496f-9349-53696db9290d@default \
    --to=drew.adams@oracle.com \
    --cc=14634@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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