[Top][All Lists]

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

Re: How to set the font of a region?

From: Oliver Scholz
Subject: Re: How to set the font of a region?
Date: Thu, 05 Aug 2004 10:12:55 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt)

Pascal Bourguignon <address@hidden> 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


  (switch-to-buffer (generate-new-buffer "*tmp*"))
  (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 :family "times new roman" :foreground "blue"))

19 Thermidor an 212 de la Révolution
Liberté, Egalité, Fraternité!

reply via email to

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