Closed miquik closed 2 years ago
Hi,
Hmmm... there are two GetMatchingFonts methods to IDWriteFontSet. That may be the issue described here: https://stackoverflow.com/questions/61542063/inversion-of-generated-vtable-functions-order-for-functions-with-the-same-name
Can you test change this:
public partial interface IDWriteFontSet
{
...
[PreserveSig]
HRESULT GetMatchingFonts(/* _In_reads_(propertyCount) */ [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] DWRITE_FONT_PROPERTY[] properties, int propertyCount, /* _COM_Outptr_ */ out IDWriteFontSet filteredSet);
[PreserveSig]
HRESULT GetMatchingFonts(/* _In_z_ */ [MarshalAs(UnmanagedType.LPWStr)] string familyName, DWRITE_FONT_WEIGHT fontWeight, DWRITE_FONT_STRETCH fontStretch, DWRITE_FONT_STYLE fontStyle, /* _COM_Outptr_ */ out IDWriteFontSet filteredSet);
}
into this:
public partial interface IDWriteFontSet
{
...
[PreserveSig]
HRESULT GetMatchingFonts(/* _In_z_ */ [MarshalAs(UnmanagedType.LPWStr)] string familyName, DWRITE_FONT_WEIGHT fontWeight, DWRITE_FONT_STRETCH fontStretch, DWRITE_FONT_STYLE fontStyle, /* _COM_Outptr_ */ out IDWriteFontSet filteredSet);
[PreserveSig]
HRESULT GetMatchingFonts(/* _In_reads_(propertyCount) */ [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] DWRITE_FONT_PROPERTY[] properties, int propertyCount, /* _COM_Outptr_ */ out IDWriteFontSet filteredSet);
}
and see it it works any better?
Yes, that seems to be the problem. I made a quick test and at least I didn’t get any exception. Later I will try deeper but I think this solve my problem. I’m not sure but probably also GetPropertyValues in same interface have same problems
Certainly, all methods with the same name should be declared in reverse order with respect to the native C/C++ header order.
I need to work on this. I think this is not the only interface like that (not even speaking of derivates IDWriteFontSet2, etc.)
Hi, I don't know if it is a bug or if I'm missing something; I can't get IDWriteFontSet.GetMatchingFonts to work I always get Access Violation exception. This is my sample code:
I tried different IDWriteFactory interfaces (IDWriteFactory3 to IDWriteFactory7) and different IDWriteFontSet interfaces, but I always get same exception
Any idea? I'm doing something wrong? Thanks