From: Jiajin Cui cuijiajin@uniontech.com
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/dwrite/dwrite_private.h | 2 +- dlls/dwrite/font.c | 32 +++++++++++++++++--------------- dlls/dwrite/main.c | 11 +++++++++-- 3 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index d0ed1db97ef..02e28eec60e 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -336,7 +336,7 @@ extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFil DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN; extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files, - DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN; + DWRITE_FONT_SIMULATIONS simulations, const WCHAR *name, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN; extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop) DECLSPEC_HIDDEN; extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces, diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index d2d2b7963f7..a1b7397c99b 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -2191,17 +2191,33 @@ static const IDWriteFontFaceReferenceVtbl dwritefontface_reference_vtbl = dwritefontface_reference_EnqueueFileFragmentDownloadRequest, };
+static void fontstrings_get_en_string(IDWriteLocalizedStrings *strings, WCHAR *buffer, UINT32 size) +{ + BOOL exists = FALSE; + UINT32 index; + HRESULT hr; + + buffer[0] = 0; + hr = IDWriteLocalizedStrings_FindLocaleName(strings, L"en-us", &index, &exists); + if (FAILED(hr) || !exists) + return; + + IDWriteLocalizedStrings_GetString(strings, index, buffer, size); +} + static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace5 **fontface) { struct dwrite_font_data *data = font->data; struct fontface_desc desc; struct list *cached_list; HRESULT hr; + WCHAR familyW[255]={};
*fontface = NULL;
+ fontstrings_get_en_string(data->family_names, familyW, ARRAY_SIZE(familyW)); hr = factory_get_cached_fontface(font->family->collection->factory, &data->file, data->face_index, - font->data->simulations, &cached_list, &IID_IDWriteFontFace4, (void **)fontface); + font->data->simulations, familyW, &cached_list, &IID_IDWriteFontFace4, (void **)fontface); if (hr == S_OK) return hr;
@@ -3574,20 +3590,6 @@ HRESULT get_filestream_from_file(IDWriteFontFile *file, IDWriteFontFileStream ** return hr; }
-static void fontstrings_get_en_string(IDWriteLocalizedStrings *strings, WCHAR *buffer, UINT32 size) -{ - BOOL exists = FALSE; - UINT32 index; - HRESULT hr; - - buffer[0] = 0; - hr = IDWriteLocalizedStrings_FindLocaleName(strings, L"en-us", &index, &exists); - if (FAILED(hr) || !exists) - return; - - IDWriteLocalizedStrings_GetString(strings, index, buffer, size); -} - static int trim_spaces(WCHAR *in, WCHAR *ret) { int len; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 8cc5d4dccf7..da6242e528e 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -926,7 +926,7 @@ void factory_unlock(IDWriteFactory7 *iface) }
HRESULT factory_get_cached_fontface(IDWriteFactory7 *iface, IDWriteFontFile * const *font_files, UINT32 index, - DWRITE_FONT_SIMULATIONS simulations, struct list **cached_list, REFIID riid, void **obj) + DWRITE_FONT_SIMULATIONS simulations, const WCHAR *name, struct list **cached_list, REFIID riid, void **obj) { struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); struct fontfacecached *cached; @@ -969,6 +969,7 @@ HRESULT factory_get_cached_fontface(IDWriteFactory7 *iface, IDWriteFontFile * co DWRITE_FONT_SIMULATIONS cached_simulations; const void *cached_key; IDWriteFontFile *file; + IDWriteLocalizedStrings* family_names;
cached_face_index = IDWriteFontFace5_GetIndex(cached->fontface); cached_simulations = IDWriteFontFace5_GetSimulations(cached->fontface); @@ -977,6 +978,12 @@ HRESULT factory_get_cached_fontface(IDWriteFactory7 *iface, IDWriteFontFile * co if (cached_face_index != index || cached_simulations != simulations) continue;
+ hr = IDWriteFontFace5_GetFaceNames(cached->fontface, &family_names); + if (FAILED(hr)) + break; + + if(name && name[0] && !localizedstrings_contains(family_names, name)) continue; + hr = IDWriteFontFace5_GetFiles(cached->fontface, &count, &file); if (FAILED(hr)) break; @@ -1066,7 +1073,7 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory7 *iface, DWRIT goto failed; }
- hr = factory_get_cached_fontface(iface, font_files, index, simulations, &fontfaces, + hr = factory_get_cached_fontface(iface, font_files, index, simulations, NULL, &fontfaces, &IID_IDWriteFontFace, (void **)fontface); if (hr != S_FALSE) goto failed;