Search user fonts in GDI font lister

Windows now allow user install fonts without admin. List HKCU for those fonts.
https://blogs.windows.com/windowsexperience/2018/06/27/announcing-windows-10-insider-preview-build-17704/
This commit is contained in:
wangqr 2019-09-13 15:49:15 -04:00 committed by Thomas Goyne
parent 7a1756a26f
commit 896011f535

View file

@ -66,9 +66,10 @@ std::vector<agi::fs::path> get_installed_fonts() {
std::vector<agi::fs::path> files; std::vector<agi::fs::path> files;
for (HKEY hKey : { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }) {
HKEY key; HKEY key;
auto ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, fonts_key_name, 0, KEY_QUERY_VALUE, &key); auto ret = RegOpenKeyExW(hKey, fonts_key_name, 0, KEY_QUERY_VALUE, &key);
if (ret != ERROR_SUCCESS) return files; if (ret != ERROR_SUCCESS) continue;
BOOST_SCOPE_EXIT_ALL(= ) { RegCloseKey(key); }; BOOST_SCOPE_EXIT_ALL(= ) { RegCloseKey(key); };
wchar_t fdir[MAX_PATH]; wchar_t fdir[MAX_PATH];
@ -85,10 +86,11 @@ std::vector<agi::fs::path> get_installed_fonts() {
if (ret != ERROR_SUCCESS) continue; if (ret != ERROR_SUCCESS) continue;
agi::fs::path font_path(font_filename); agi::fs::path font_path(font_filename);
if (!agi::fs::FileExists(font_path)) if (!agi::fs::FileExists(font_path) && agi::fs::FileExists(font_dir / font_path))
font_path = font_dir / font_path; font_path = font_dir / font_path;
files.push_back(font_path); files.push_back(font_path);
} }
}
return files; return files;
} }