Subject: bug#65803: 29.1; Noto Sans Mono CJK JP has doubled-width on Windows

From: Eli Zaretskii <[email-masked]>
Date: Sun, 10 Sep 2023 15:43:24 +0300

> From: Po Lu <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 10 Sep 2023 20:09:08 +0800
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > That's what I tried.  The problem is, first time we open the fonts
> > (which is when it's important to have the metrics of the default
> > face's font), we are called from x-create-frame for the initial frame,
> > and the frame's w32-specific attributes are not yet set.  The
> > window-system for the frame is still "initial", and get_frame_dc
> > aborts.
> 
> Can't font initialization be moved to a location slightly later in the
> frame initialization process?

It is needed for determining the frame geometry, since it provides us
with the column width and line height.  Maybe something could be done
about that, for example using the current approximation initially,
then correcting this with another iteration or somesuch.  But that
requires a better understanding of the fine details of w32font.c and
w32uniscribe.c than what I have.  For example, there's a cache of
metrics there, which would need to be discarded somehow.

> xfont_open uses the frame's X display without ill effect.

xfont_open gets the font metrics from Xlib calls, and its X display
argument is also something returned by Xlib.  With w32, I simply don't
know what minimum amount of setup is needed to make a frame a capable
enough w32 frame that can support get_frame_dc and the calls like
SelectObject we need for this particular job.  Feel free to
experiment, you or someone else; I simply don't have enough time for
that, sorry.