* Stephen J. Turnbull (2005-03-18) writes:
>>>>> "Ralf" == Ralf Angeli
<angeli(a)iwi.uni-sb.de> writes:
Ralf> Emacs.Font:
Ralf> -bitstream-terminal-medium-r-normal--18-140-100-100-c-110-iso8859-1
Ralf> Shouldn't it be able to resolve this itself?
Yes, "it" should, but "it" refers to the X server or X font server,
not to the application.
I don't know if this is possible, but wouldn't it be a good idea for
XEmacs to ask the X server to resolve the value? I dug a bit in the
code and what it actually does is simply exchanging certain parts in
the XLFD string of the default font when a face is altered. This
fails on my computer when it tries to compute the canonical size (in
points) for the new XLFD.
I used the following code snippet for debugging (extracted from
`make-face-family' and `frob-face-property'):
(let* ((f (face-property-instance 'default 'font))
(d (car (device-list)))
(fo (font-create-object (font-instance-name f) d)))
(set-font-family fo "helvetica")
(font-create-name fo d))
In case the X resource of the default font includes both the size in
pixels and decipoints (in my setup 18 pixels and 140 decipoints) the
snippet returns
"-*-helvetica-medium-r-*-*-*-140-*-*-*-*-iso8859-1"
This looks reasonable.
If the XLFD includes only the size in pixels XEmacs tries to convert
it into points and this is where it fails on my computer. The
result of executing the snippet above is this:
"-*-helvetica-medium-r-*-*-*-300-*-*-*-*-iso8859-*"
What happens is that `font-size' for the default font returns "18px"
(instead of 14 for the fully specified one). This value gets fed into
`font-spatial-to-canonical' which returns 30.97. This can be checked
easily with
(font-spatial-to-canonical "18px" (car (device-list)))
(The car of `device-list' on my computer is the X device.)
The return value is computed from
(setq retval (* num (/ pix-width mm-width) (/ 25.4 72.0))))
with num=18, pix-width=1400 and mm-width=287 on my setup.
This formula is not correct. You can deduct that by looking at the
units:
(* px (/ px mm) (/ mm pt)) will result in px²/pt
The correct formula would look like this:
(* num (/ mm-width pix-width) (/ 72 25.4))
On my computer this will result in 10.46pt which is a _much_ saner
value than the one computed before. The resulting font is a bit too
small because the 18 pixels of the default font correspond to 14
points and not 10 points, but I guess one cannot do much about that.
So this indeed is a bug in XEmacs and not a broken setup.
Do you want a patch with that? (c;
--
Ralf