font-latex-make-title-faces using scaled font height rather than size
"Steven E. Harris" <[email protected]> Wed, 09 Mar 2005 12:18:42 -0800
| Newsgroups | gmane.emacs.auc-tex |
|---|---|
| Organization | SEH Labs |
| Message-ID | <[email protected]> |
I recently updated my XEmacs packages and picked up the recent AUCTex
package version 1.46, with upstream version 11.55.
Starting a new document and inserting a \section{} macro, I noticed
the new font-latex-title-(1|2|3)-face fonts. The fonts looked too big
to my taste, so I decided to look into how they're initialized to
their default values.
In the function `font-latex-make-title-faces' in font-latex.el, we
find this form:
,----[ font-latex-make-title-faces ]
| (dotimes (i 3)
| (let* ((num (1+ i))
| (face-name (intern (concat "font-latex-title-" (number-to-string num)
| "-face"))))
| (if (featurep 'xemacs)
| (let ((size (concat (number-to-string
| (round (* (face-height 'default)
| (expt 1.2 (- 3 i)))))
| "pt")))
`----
The intention is to scale the default font size by factors of 1.2,
1.44, and 1.728, producing a nice hierarchy of sizes. The problem is
with the function `face-height'.
On my system, the default font size is 10:
,----[ default face font specification ]
| (Courier New:Regular:10::Western)
`----
However, (face-height 'default) returns 16. Related functions
`face-ascent' and `face-descent' return 12 and 4 respectively. They
all add up, but these are apparently not font /sizes/.
Using (face-height 'default) as the base size for scaling produces a
family of 19, 23, and 28. More likely we're looking for a family that
scales from a base of 10, producing 12, 14, and 17.
We need some function to get the size of a face. In XEmacs, at least,
I had a hard time figuring out how to get there, but did find a
way. Unfortunately, it requires converting, string to a number, then a
number to a string, concatenating that string with another, then using
a regexp to pull that number back out of the string. Only the last
part is my fault.
(defun face-font-size (face)
(let ((size-string (font-size
(font-create-object (face-font-name face)))))
(when (string-match "^\\([0-9]+\\)pt" size-string)
(string-to-number
(substring size-string
(match-beginning 1)
(match-end 1))))))
I figured this out only by looking at the `custom-face-font-size'
implementation. Perhaps there is a cleaner way to get there. In any
case, substituting a call to the above `face-font-size' function for
the call to `face-height' in font-latex-make-title-faces may provide a
more reasonable set of font sizes, as was likely the author's
intention.
For now I have only been able to investigate the proposal on a single
system (XEmacs 21.4.13 on Cygwin), and imagine that the font queries
may required adaptation for Emacs.
Please let me know if more supporting material is required.
Emacs : XEmacs 21.4 (patch 13) "Rational FORTRAN" [Lucid] (i686-pc-cygwin) of Sun May 25 2003 on TSUNAMI
Package: AUCTeX CVS-1.13 (2005-02-11)
current state:
==============
(setq
window-system 'mswindows
LaTeX-version "2e"
TeX-style-path '("style/" "auto/" "/usr/local/lib/xemacs/xemacs-packages/etc/auctex/style/"
"/usr/local/lib/xemacs/xemacs-packages/etc/auctex/auto/")
TeX-auto-save t
TeX-parse-self t
TeX-master t
)
--
Steven E. Harris