The offending font is NotoColorEmoji.ttf which is present in, e. g., google-noto-emoji-color-fonts or noto-fonts-emoji packages available in various distribution. Attempting to load this font on Windows 10 (with AddFontResourceA() or open it with default font viewer) fails while currently succeeds on Windows. fontforge also refuses to open this font. That is because the font is bitmap only but missing bitmap table.
Some apps (Glyph launcher is an example) try to GetOutlineTextMetrics() on this font and do not expect that to have an error return (as we currenly do), which leads to crash on unhandled division by zero exception.
I am attaching a bitmap-only ttf test font (with only one bitmap) which I created with fontforge to make sure that such font can still be loaded in Wine. This font also loads on Windows (both with AddFontResourceA() and with default font viewer).
There are other font types which can be legitimately missing EBDT table, but FT_Load_Sfnt_Table() returns a different error for those and my patch doesn't reject those fonts.
[test.ttf](/uploads/b41472180b80c2c53f9dcc06055990f0/test.ttf)
-- v2: win32u: Don't load bitmap only TTF fonts without bitmap table.
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/freetype.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index f00df7ed86d..4514574ec42 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -254,6 +254,8 @@ MAKE_FUNCPTR(FcStrSetMember); #define GET_BE_DWORD(x) RtlUlongByteSwap(x) #endif
+#define MS_EBDT_TAG MS_MAKE_TAG('E','B','D','T') + /* 'gasp' flags */ #define GASP_GRIDFIT 0x01 #define GASP_DOGRAY 0x02 @@ -1177,6 +1179,8 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr struct stat st; DWORD face_count; int fd, length; + FT_Error error; + FT_ULong len;
TRACE( "unix_name %s, face_index %u, data_ptr %p, data_size %u, flags %#x\n", unix_name, face_index, data_ptr, data_size, flags ); @@ -1268,7 +1272,20 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr
This->ntm_flags = get_ntm_flags( This->ft_face ); This->font_version = get_font_version( This->ft_face ); - if (!This->scalable) get_bitmap_size( This->ft_face, &This->size ); + if (!This->scalable) + { + error = pFT_Load_Sfnt_Table( This->ft_face, RtlUlongByteSwap(MS_EBDT_TAG), 0, NULL, &len ); + if (error == FT_Err_Table_Missing) + { + WARN( "EBDT table is missing in bitmap only font %s.\n", + debugstr_w(ft_face_get_family_name( This->ft_face, system_lcid ))); + pFT_Done_Face( This->ft_face ); + free( This ); + This = NULL; + goto done; + } + get_bitmap_size( This->ft_face, &This->size ); + } get_fontsig( This->ft_face, &This->fs ); } else