Setting face size and inheriting face properties

Setting face size and inheriting face properties

Post by Reiner Ste » Thu, 14 Apr 2005 01:48:37


Hi,

in AUCTeX, we have several faces (font-latex-title-N-face, N=0...7 [1])
defined for chapter and section titles in *** with increasing size
from \subparagraph upto \part. The result looks similar to the
screenshots in
<URL: http://www.yqcomputer.com/ ;.

The "base face" is the face for \subparagraph called
font-latex-title-7-face. The face 0...6 are base on title-7-face with
the size increased by a factor F from N to N-1. The factor F and the
title-7-face is supposed to be customizable by the user. Changes of
the factor F or the title-7-face should be inherited to all other
title-0...6 faces. I.e. when the user customizes title-7-face
foreground to red, all title faces are red. When the user increases
height-scale, the face of all title faces increases.

In Emacs, we can achieve this by calling `set-face-attribute'
with :height and :inherit for those faces:

(dotimes (num (or max font-latex-title-max))
(let ((face-name (intern (format "font-latex-title-%s-face" num)))
(f-inherit (intern (format "font-latex-title-%s-face" (1+ num))))
(f-minus (intern (format "font-latex-title-%s-face" (1- num)))))
(when (facep face-name)
(when (<= num font-latex-title-increase-start)
(set-face-attribute face-name nil :height height-scale))
(set-face-attribute face-name nil :inherit f-inherit))))

How can I do the same in XEmacs? I thought it should be possible with
`set-face-parent' and (set-face-property face-name 'size size) but I
couldn't find out how to do it[2]. Any hints?

The (not functional) XEmacs code looks like this:

(dotimes (num (or max font-latex-title-max))
(let ((face-name (intern (format "font-latex-title-%s-face" num)))
(f-inherit (intern (format "font-latex-title-%s-face" (1+ num))))
(f-minus (intern (format "font-latex-title-%s-face" (1- num)))))
(if (featurep 'xemacs)
(let ((size
(format "%spt"
;; Multiply with .9 because `face-height' returns a
;; value slightly larger than the actual font size.
(round (* .9
(face-height 'default)
(expt height-scale (- max 1 num)))))))
(message "%s - %s - %s" face-name f-inherit size)
(when (>= (1- num) 0)
(message "set-face-parent %s %s" face-name f-minus)
(set-face-parent face-name f-minus))
;; (set-face-parent face-name f-inherit)
(when (<= num font-latex-title-increase-start)
(message "set-face-property %s 'size %s" face-name size)
(set-face-property face-name 'size size))))))
;; [...]
(when (featurep 'xemacs)
(set-face-parent 'font-latex-title-7-face 'font-latex-title-6-face))

Bye, Reiner.

[1] Well, up to now we have N=1...4 but we may change it.

[2] I didn't find anything on change the font size in (info "lispref")
and (info "XEmacs"). `set-face-parent' doesn't even appear in
these manuals.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://www.yqcomputer.com/
 
 
 

Setting face size and inheriting face properties

Post by Aidan Keho » Thu, 14 Apr 2005 04:49:52


Ar an dara l dag de m Aibran, scrobh Reiner Steib:

> How can I do the same in XEmacs? I thought it should be possible with
> `set-face-parent' and (set-face-property face-name 'size size) but I
> couldn't find out how to do it[2]. Any hints?

(make-face-size FACE SIZE) should do it, together with the set-face-parent
call youe suggesting, though make-face-size is broken on 21.5 and gives me
horrible faces on 21.4. But maybe youl think better of them than I do.

> [...]
>
> [2] I didn't find anything on change the font size in (info "lispref")
> and (info "XEmacs"). `set-face-parent' doesn't even appear in
> these manuals.

Ah, bollocks. Thank you for the pointer to the issue.

--
, for instance, am gung-ho about open source because my family is being
held hostage in Rob Malda ba *** t. But who fact-checks me, or Enderle,
when we say something in public? No-one!?-- Danny Orien

 
 
 

Setting face size and inheriting face properties

Post by Reiner Ste » Thu, 14 Apr 2005 22:58:24


Thanks for your answer. At least, I could get the inheriting of colors
to work: (set-face-foreground 'font-latex-title-3-face "blue1") and
(set-face-foreground 'font-latex-title-6-face "darkgreen") behave as
I'd expect: See this screen shot:
http://www.yqcomputer.com/ ~ste/comp/emacs/auctex/xemacs-title-face-01.png

But I can't get the modification of the size running: Neither
(make-face-size 'font-latex-title-1-face "26pt")
nor
(make-face-size 'font-latex-title-1-face 120)
give any visual results.

Here is how it looks in Emacs. After evaluating `set-face-attribute',
the face is changed immediately:
http://www.yqcomputer.com/ ~ste/comp/emacs/auctex/emacs-title-face-01.png


While at it: I can't find `make-face-size' in both manuals
(xemacs-21.4.17). The doc string says:

,----[ C-h f make-face-size RET ]
| `make-face-size' is a compiled Lisp function
| -- loaded from "[...]/xemacs-21.4.17/lisp/faces.elc"
| (make-face-size FACE SIZE &optional LOCALE TAGS)
|
| Documentation:
| Adjust FACE to SIZE in LOCALE, if possible.
|
| Add/replace settings specified by TAGS only.
`----

What is SIZE supposed to be? A string like "20pt" (like in
`defface'), an integer specifying the height of the font (what
units?)? I don't know. I don't get any error with whatever I tried,
but the size doesn't change.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://www.yqcomputer.com/
 
 
 

Setting face size and inheriting face properties

Post by Aidan Keho » Fri, 15 Apr 2005 00:37:20


Ar an tri l dag de m Aibran, scrobh Reiner Steib:

> Thanks for your answer. At least, I could get the inheriting of colors
> to work: (set-face-foreground 'font-latex-title-3-face "blue1") and
> (set-face-foreground 'font-latex-title-6-face "darkgreen") behave as
> I'd expect: See this screen shot:
> http://www.yqcomputer.com/ ~ste/comp/emacs/auctex/xemacs-title-face-01.png
>
> But I can't get the modification of the size running: Neither
> (make-face-size 'font-latex-title-1-face "26pt")
> nor
> (make-face-size 'font-latex-title-1-face 120)
> give any visual results.

make-face-size takes numeric points; so, that first call should be
(make-face-size 'font-latex-title-1-face 26) . Again, underdocumented, as
you say.

For me, doing M-x edit-faces, splitting the window, and running
make-face-size on various of those faces in *scratch* in the other window
gives immediate feedback--the face size is changed as I watch. So I not
certain what the issue youe seeing is--perhaps your X11 server doesn
have any fonts available with the desired face and size? Does

(make-face-larger 'font-latex-title-1-face)

have any effect?

--
, for instance, am gung-ho about open source because my family is being
held hostage in Rob Malda ba *** t. But who fact-checks me, or Enderle,
when we say something in public? No-one!?-- Danny Orien
 
 
 

Setting face size and inheriting face properties

Post by Reiner Ste » Fri, 15 Apr 2005 01:34:46


Thanks.


But you need to guess a valid X font specification here.


I have quite a lot of fonts installed locally plus a font server. But
I think that the problem is that XEmacs doesn't fall back to the next
available font if a given point size is not available: If I say
(make-face-size 'bold 26), I'd expect XEmacs to pick 24 (which is
available). But XEmacs doesn't: The size is unchanged from the 14pt
default.


Nothing. Nichts. Nada. I have tried: (make-face-larger 'default),
(make-face-larger 'bold), (make-face-larger 'font-latex-title-1-face),
... (make-face-larger 'font-latex-title-4-face).

Do you have AUCTeX from XEmacs package system installed?
When you put the following lines in foo.tex, you should see the
section title in font-latex-title-[1...4]-face:

--8<---------------cut here---------------start------------->8---
\chapter{Ein Kapitel --- Title 1}
\section{Ein Abschnitt --- Title 2}
\subsection{Ein Unterabschnitt --- Title 3}
\subsubsection{Ein Unterunterabschnitt --- Title 4}
--8<---------------cut here---------------end--------------->8---

Do you get appealing results (I don't: see the URLs below)? Can you
change the size of `font-latex-title-[1...4]-face' as you described
it?

http://www.yqcomputer.com/ ~ste/comp/emacs/auctex/xemacs-title-face-00-CVS-2005-04-13.png
http://www.yqcomputer.com/ ~ste/comp/emacs/auctex/xemacs-title-face-01-CVS-2005-04-13.png

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://www.yqcomputer.com/
 
 
 

Setting face size and inheriting face properties

Post by Aidan Keho » Sat, 16 Apr 2005 01:18:53

Ar an tri l dag de m Aibran, scrobh Reiner Steib:

> > [...] For me, doing M-x edit-faces, splitting the window, and running
> > make-face-size on various of those faces in *scratch* in the other
> > window gives immediate feedback--the face size is changed as I watch.
>
> But you need to guess a valid X font specification here.

? No. Along the left edge of the buffer are the face names--that is, the
names of the symbols you can use as the first argument to
make-face-size. Yes, along the right edge is the XLFD that being used for
that face, but there no reason to pay attention to that except perhaps in
debugging.

> > So I not certain what the issue youe seeing is--perhaps your X11
> > server doesn have any fonts available with the desired face and
> > size?
>
> I have quite a lot of fonts installed locally plus a font server. But
> I think that the problem is that XEmacs doesn't fall back to the next
> available font if a given point size is not available: If I say
> (make-face-size 'bold 26), I'd expect XEmacs to pick 24 (which is
> available). But XEmacs doesn't: The size is unchanged from the 14pt
> default.

Least helpful answer in the world; it works for me. :-(

> > Does (make-face-larger 'font-latex-title-1-face) have any effect?
>
> Nothing. Nichts. Nada. I have tried: (make-face-larger 'default),
> (make-face-larger 'bold), (make-face-larger 'font-latex-title-1-face),
> ... (make-face-larger 'font-latex-title-4-face).
>
> Do you have AUCTeX from XEmacs package system installed?

[Just installed it.]

> When you put the following lines in foo.tex, you should see the
> section title in font-latex-title-[1...4]-face:
>
> --8<---------------cut here---------------start------------->8---
> \chapter{Ein Kapitel --- Title 1}
> \section{Ein Abschnitt --- Title 2}
> \subsection{Ein Unterabschnitt --- Title 3}
> \subsubsection{Ein Unterunterabschnitt --- Title 4}
> --8<---------------cut here---------------end--------------->8---
>
> Do you get appealing results (I don't: see the URLs below)?

I get titles with varying size--I don find them appealing, see the
screenshots, but that because XFree86 reneged on their
don-scale-bitmap-fonts decision of a few years ago and I have taken the
time to hunt down the issue and fix it.

> Can you change the size of `font-latex-title-[1...4]-face' as you
> described it?

Yes.

http://parhasard.net/vanilla-auctex-startup.png is what I get with
xemacs-21.4.17 -vanilla , then (require 'tex-site), and C-x C-f
/tmp/aidan/foo.tex . (After changing my X resources to use the same font
spec for the default face that you do.)

http://parhasard.net/vanilla-auctex-f-l-t-1.png is the same XEmacs process
after evaluating (make-font-size 'font-latex-title-1-face 21) --the face is
clearly smaller.

http://parhasard.net/vanilla-auctex-f-l-t-2.png is the same process after
evaluating (make-font-size 'font-latex-title-2-face 21) --the face has
changed size, and is the same size as the Title 1.

So, something broken in your XEmacs. If you have a source tree around,
could you try compiling it without optimisation? If not, M-x
report-xemacs-bug to give us some more details of what might be causing the
issue.

--
, for instance, am gung-ho about open so
 
 
 

Setting face size and inheriting face properties

Post by Reiner Ste » Sat, 16 Apr 2005 01:44:42


You can find my setting in one of my recent reports on xemacs-beta:

or < http://www.yqcomputer.com/ ;. And I
have xemacs-sumo-2005-03-07.tar.gz installed.

I also found that I have problems with the current `font-latex.el'
(without changing the font size), see my post on xemacs-beta and
auctex-devel:
< http://www.yqcomputer.com/ @XXXXX.COM >.
Let's shift this discussion to this thread, please.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://www.yqcomputer.com/