From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: How to set the font of a region?
Date: Thu, 05 Aug 2004 10:12:55 +0200 [thread overview]
Message-ID: <u1xim3svs.fsf@ID-87814.user.uni-berlin.de> (raw)
In-Reply-To: 8765876iil.fsf@thalassa.informatimago.com
Pascal Bourguignon <spam@thalassa.informatimago.com> writes:
> I tried this (on X, emacs 21.3.1):
>
> (let* ((default-font "-*-console-medium-r-normal-*-16-*-*-*-*-*-*-*")
> (default-face (gensym "face")))
> (make-face default-face)
> (set-face-font default-face default-font)
> (dolist (font font-list)
> (let ((face (gensym "face")))
> (make-face face)
> (set-face-font face font)
> (let ((start (point)))
> (insert font)
> (insert "\n")
> (facemenu-add-face 'default start (point))
> (facemenu-set-face default-face start (point)))
> (let ((start (point)))
> (insert "The lazy dog jumped over the fast fox! (let [it {be} and] say) no.more;\n")
> (facemenu-add-face 'default start (point))
> (facemenu-set-face face start (point))))))
>
[...]
> but all the text generated keeps the same default font. Why my
> facemenu-set-face calls are without effect?
What major mode had the buffer in which you tried it? If font-lock
mode is on, it removes all faces from buffer text before it adds its
own. (In CVS Emacs you can use the text property `font-lock-face' to
deal with that.)
Also, I'd use `put-text-property' to add faces programmatically. And
for cases like the above, I'd use an anonymous face---a list of the
form:
(face . PROPERTIES)
(progn
(switch-to-buffer (generate-new-buffer "*tmp*"))
(fundamental-mode)
(let ((start (point)))
(insert "The quick brown fox jumps over the lazy dog.\n")
;; (facemenu-add-face 'font-lock-warning-face start (point))
(put-text-property start (point)
'face
'(face :family "times new roman" :foreground "blue"))
))
Oliver
--
19 Thermidor an 212 de la Révolution
Liberté, Egalité, Fraternité!
prev parent reply other threads:[~2004-08-05 8:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-29 13:38 How to set the font of a region? Pascal Bourguignon
2004-07-29 14:51 ` Kevin Rodgers
2004-07-29 15:28 ` Pascal Bourguignon
2004-08-05 8:12 ` Oliver Scholz [this message]
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=u1xim3svs.fsf@ID-87814.user.uni-berlin.de \
--to=alkibiades@gmx.de \
/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.
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).