w3-dev
[Top][All Lists]
Advanced

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

[W3-dev] Re: wrong font-size calculations in css.el and font.el


From: Magnus Henoch
Subject: [W3-dev] Re: wrong font-size calculations in css.el and font.el
Date: Fri, 15 Dec 2006 16:24:02 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (berkeley-unix)

Klaus Straubinger <address@hidden> writes:

> The function css-expand-length does not take the default character size
> in pixels into account when calculating em and ex values. This results
> typically in values very much too large.
>
> I would like to suggest using something like the following in the
> condition branch that deals with em and ex values:
>
>     (round (font-spatial-to-canonical
>             (concat (number-to-string
>                      (* (string-to-number (match-string 1 spec))
>                         (if height (frame-char-height) (frame-char-width))))
>                     "px")))
>
> I don't know if it is advisable to use font-spatial-to-canonical. But
> it could be used in other places in this function too.

This is not entirely correct, as these specifications are relative to
the font size of the enclosing element, not to the default font size.
However, this is good enough for now (until I find time to look at how
css.el handles inheritance), so I applied your change.

> By the way, this function font-spatial-to-canonical has another bug:
> Pixel values are calculated with
>
>       (setq retval (* num (/ pix-width mm-width) (/ 25.4 72.0))))
>
> instead of the correct
>
>       (setq retval (* num (/ mm-width pix-width) (/ 72.0 25.4))))
>
> i.e., exactly the other way round with respect to dividing and
> multiplying.

Indeed, applied.

Thanks!

Magnus





reply via email to

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