Subject: Re: bug#19194: 24.4.50; `window-body-width' is not dynamic relative to font size changes

From: Eli Zaretskii <[email-masked]>
Date: Fri, 28 Nov 2014 10:49:36 +0200

> Date: Fri, 28 Nov 2014 08:29:05 +0100
> From: martin rudalics <[email-masked]>
> CC: [email-masked], [email-masked]
> 
>  > Faces are frame-specific.  The same face can have different attributes
>  > on each frame, and that includes the size.
> 
> That's what I'm trying to fathom out here all the time.  So when
> calculating the actual height of a character as it will be displayed in
> a window I have to apply (in some order) the height attribute specified
> by (1) the font of the frame the window belongs to, (2) the font of the
> buffer shown in the window, and (3) the font of the default face.

We always use the current default face's font for this.  Otherwise,
you get to a problem that IMO is insoluble even in principle.

>  >> Is this the final value as it would be displayed or could the height
>  >> of "the font of the frame's 'default' face" get mixed in afterwards?
>  >
>  > The former, I think.
> 
> OK.  Now how do I get the `default-font-width' from that?

You need help from Emacs, because it knows everything about that
font's metrics.  But we don't have an API for that for now.

>  > default-line-height includes the line-spacing.
> 
> I see.  Silly of me to ask.
> 
> The doc-string of this should be slightly improved because OT1H
> `line-spacing' is buffer-local and OTOH "the frame" in
> 
>    The value includes `line-spacing', if any, defined for the buffer
>    or the frame.
> 
> is slightly ambiguous.

It's ambiguous on purpose: the line-spacing can be specified in
several ways.  Feel free to improve the doc string.

>  >>   > Btw, the OP wanted the width of the window, not its height, AFAIR.
>  >>
>  >> ... we would need `window-screen-columns' too.
>  >
>  > That will be harder, unless we change some APIs.  We currently don't
>  > have the font width in what font-info returns.
> 
> Is there a way to approximate the "width of a character" in points from
> (1) its height and (2) its width attribute?

There's no need: the width of a font is well defined, and the display
engine uses it all the time.  We just don't expose it in the font-info
API; we should add that.