From: Dmitry Timoshkov <dmitry@baikal.ru> When there's a duplicate font [Software\\Microsoft\\Windows\\CurrentVersion\\Fonts] "Courier New (TrueType)"="C:\\windows\\Fonts\\COUR.TTF" and [Software\\Wine\\Fonts\\External Fonts] "Courier New (TrueType)"="Z:\\usr\\share\\fonts\\ttf\\ms\\cour.ttf" and the face list has "Courier New" as C:\\windows\\Fonts\\COUR.TTF then 'wcsicmp( face->file, path )' doesn't catch this case and the font will be removed from the registry but won't be added back because the loaded font face doesn't have ADDFONT_EXTERNAL_FONT flag set. This is a real case that happened with the application installer that installs "Courier New" fonts family apparently without checking actual presence of the font with EnumFonts(). Steps to reproduce: 1. apt-get install fonts-ttf-ms 2. winetricks -q courier 3. Both of the above mentioned registry keys must exist: cat > HKLM_Fonts.reg << EOF REGEDIT4 [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Fonts] "Courier New (TrueType)"="C:\\windows\\Fonts\\COUR.TTF" EOF wine regedit HKLM_Fonts.reg cat > HKCU_External_Fonts.reg << EOF REGEDIT4 [HKEY_CURRENT_USER\Software\Wine\Fonts\External Fonts] "Courier New (TrueType)"="Z:\\usr\\share\\fonts\\ttf\\ms\\cour.ttf" EOF wine regedit HKCU_External_Fonts.reg 4. Run 'wine blah' (it's not necessary to run a real application), and check the listed above registry keys, "Courier New (TrueType)" key is gone. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/win32u/font.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index ed2ef5200b2..511f01f371c 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -6595,11 +6595,19 @@ static void update_external_font_keys(void) path = get_nt_path( (WCHAR *)(buffer + info->DataOffset) ); if ((tmp = wcsrchr( value, ' ' )) && !facename_compare( tmp, true_type_suffixW, -1 )) *tmp = 0; - if ((face = find_face_from_full_name( value )) && !wcsicmp( face->file, path )) + if ((face = find_face_from_full_name( value ))) { - face->flags |= ADDFONT_EXTERNAL_FOUND; - free( path ); - continue; + if (!wcsicmp( face->file, path )) + { + face->flags |= ADDFONT_EXTERNAL_FOUND; + free( path ); + continue; + } + if (!(face->flags & ADDFONT_EXTERNAL_FONT)) + { + free( path ); + continue; + } } if (tmp && !*tmp) *tmp = ' '; if (!(key = malloc( sizeof(*key) ))) break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10041