On Thu, 12 Sept 2024 at 14:28, Eli Zaretskii <e...@gnu.org> wrote: > > > From: Chang Xiaoduan <dr...@sina.com> > > Cc: help-emacs-windows@gnu.org > > Date: Thu, 12 Sep 2024 10:14:23 +0800 > > > > > Windows doesn't consider the 'light weight to be a standard weight of > > > a font family, it only supports regular, bold, italic, and > > > bold-italic. > > > > I am a little confused by this, since in Windows' fonts management > > interface, there are fonts of different weights, light among them. Then, > > it is weird that it does not support light as a standard weight. Could > > you point me to some documentation or code about this? That would be a > > lot of help. > > I'm not aware of any documentation. What I know is that Emacs calls > the EnumFontFamiliesEx API to get the list of all installed fonts that > belong to a given family (in your case Cascadia Code), and all it gets > back as result are the above 4 variants, even if other weights are > also installed. > > If someone knows how to make this process better to include other > weights (without making it mush slower: e.g., examining all the > installed fonts on the system would be unacceptably slow), please > tell, because improvements in this area will certainly be welcome.
The current font handling code for Windows was written in 1998 based on the APIs available in NT 3.5, 4.0 and Windows 95. There is support for other weights, but Windows and X use different numeric values for font weight, so the mapping from Emacs font string type "light" (based on X conventions) to Windows may not be perfect - you may need to try "extralight" instead. The standard font dialog in those old versions of Windows only supported Bold and Normal weights, so I would not be surprised if the API used to list fonts does not return all the available weights for modern fonts that support a wide range of weights within the same font file. There is probably a more modern way of handling fonts that could be used here, but I haven't kept up with Windows APIs so I would not be the right person to tackle it.