Subject: bug#73730: 31.0.50; Support for color fonts on MS-Windows

From: Cecilio Pardo <[email-masked]>
Date: Sun, 20 Oct 2024 15:35:10 +0200

On 17/10/2024 12:38, Cecilio Pardo wrote:

>>> Still not done with this, but I am sending a new patch to fix the bug
>>> with w32-find-non-USB-fonts.  It calls text_extents with a font of size
>>> 0. Checking for that seems to solve the problem.
>>
>> Is that really TRT?  What does it mean font_size = 0 in this case?
> 
> No, I was wrong, sorry. DirectDwrite is failing to create a font from 
> certain GDI fonts. I need to then fall back to w32font. I'm on it.
> 

The error is caused indeed by fonts with size == 0.

  - w32-find-non-USB-fonts calls open-font with size == nil.
  - open-font gets the size from font-entity, that is also empty.
  - It ends up calling CreateFontIndirect with a LOGFONT
    with lfHeight == 0
  - Then, w32-find-non-USB-fonts calls font-get-glyphs, which call
    text_extents.
  - text_extents on DirectWrite fails with a font of size 0, but
    w32font_text_extents does return values that are not 0.

If the case of size <= 0, we are now falling back to
w32font_text_extents.

Also, in the case of failures to get text size, draw, or encode char,
now we will disable directwrite for the particular font.

I'll send a patch as soon as I can.