[PATCH 0/2] MR11396: dwrite: Implement IDWriteFontFace5::HasVariations().
Signed-off-by: Jiangyi Chen <chenjiangyi@uniontech.com> As shown in the figure below, the application needs to use the IDWriteFontFace5::HasVariations interface. {width=900 height=551} In the attachment I provided, dwrite_hasvariations_demo.cpp is the test demo source code, and the corresponding executable file is Project1.exe. The running results are as follows: {width=749 height=600}[dwrite_hasvariations_demo.cpp](/uploads/207b45735099f56eabc0070a810f296d/dwrite_hasvariations_demo.cpp)[Project1.exe](/uploads/06a7e416fca5effedb87b101eb2fb290/Project1.exe) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396
From: Jiangyi Chen <chenjiangyi@uniontech.com> Signed-off-by: Jiangyi Chen <chenjiangyi@uniontech.com> --- dlls/dwrite/font.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index f207bade10e..73e9af20c78 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -1950,12 +1950,38 @@ static HRESULT WINAPI dwritefontface5_GetFontAxisValues(IDWriteFontFace5 *iface, static BOOL WINAPI dwritefontface5_HasVariations(IDWriteFontFace5 *iface) { - static int once; + struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface); + IDWriteFontResource *resource; + DWRITE_FONT_AXIS_RANGE *ranges; + UINT32 axis_count, i; + BOOL ret = FALSE; + HRESULT hr; - if (!once++) - FIXME("%p: stub\n", iface); + TRACE("%p.\n", iface); - return FALSE; + hr = IDWriteFactory7_CreateFontResource(fontface->factory, fontface->file, fontface->index, &resource); + if (FAILED(hr)) + return FALSE; + + axis_count = IDWriteFontResource_GetFontAxisCount(resource); + if (axis_count && (ranges = malloc(axis_count * sizeof(*ranges)))) + { + if (SUCCEEDED(IDWriteFontResource_GetFontAxisRanges(resource, ranges, axis_count))) + { + for (i = 0; i < axis_count; i++) + { + if (ranges[i].minValue != ranges[i].maxValue) + { + ret = TRUE; + break; + } + } + } + free(ranges); + } + + IDWriteFontResource_Release(resource); + return ret; } static HRESULT WINAPI dwritefontface5_GetFontResource(IDWriteFontFace5 *iface, IDWriteFontResource **resource) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11396
From: Jiangyi Chen <chenjiangyi@uniontech.com> Signed-off-by: Jiangyi Chen <chenjiangyi@uniontech.com> --- dlls/dwrite/font.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 73e9af20c78..20c40adee56 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -7300,7 +7300,16 @@ static HRESULT WINAPI dwritefontresource_GetAxisValueNames(IDWriteFontResource * static BOOL WINAPI dwritefontresource_HasVariations(IDWriteFontResource *iface) { - FIXME("%p.\n", iface); + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + unsigned int i; + + TRACE("%p.\n", iface); + + for (i = 0; i < resource->axis_count; i++) + { + if (resource->axis[i].min_value != resource->axis[i].max_value) + return TRUE; + } return FALSE; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11396
I don't think we want to claim variable font support before it actually works. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396#note_145709
On Thu Jul 16 01:36:35 2026 +0000, Nikolay Sivov wrote:
I don't think we want to claim variable font support before it actually works. On MSDN, the documentation for the IDWriteFontFace5::HasVariations interface only provides a brief functional description. Could you give more specific implementation suggestions?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396#note_145776
On Thu Jul 16 01:36:35 2026 +0000, JiangYi Chen wrote:
On MSDN, the documentation for the IDWriteFontFace5::HasVariations interface only provides a brief functional description. Could you give more specific implementation suggestions? HasVariations() tells you if it's a variable font. It's not enough to report just that flag, everything from metrics to shaping, layout and rendering should respect variations. And it should be consistent between all of those. Just returning this flag won't really help anything.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396#note_145811
On Thu Jul 16 09:04:22 2026 +0000, Nikolay Sivov wrote:
HasVariations() tells you if it's a variable font. It's not enough to report just that flag, everything from metrics to shaping, layout and rendering should respect variations. And it should be consistent between all of those. Just returning this flag won't really help anything. Also please next time attach textual output as text, not screenshots.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396#note_145812
On Thu Jul 16 09:05:44 2026 +0000, Nikolay Sivov wrote:
Also please next time attach textual output as text, not screenshots. Thank you for your valuable feedback. I will close this merge request.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396#note_145824
This merge request was closed by JiangYi Chen. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11396
participants (3)
-
Jiangyi Chen -
JiangYi Chen (@meshine) -
Nikolay Sivov (@nsivov)