Reputation: 527
I need to determine whether two IDWriteFontFace
instances represent the same font file (and index for .ttc font). Would using this solution be a reliable approach?
From my testing, even if two IDWriteFontFace
instances reference the same font file, their IUnknown
values can differ depending on how they were created.
For example:
IDWriteFontFace
using IDWriteGdiInterop::CreateFontFaceFromHdc
, calling this method twice (even with different HDCs but the same LOGFONT
) results in the same IUnknown
value.IDWriteFontFace
obtained via IDWriteFontSet::GetMatchingFonts
with one created using IDWriteGdiInterop::CreateFontFaceFromHdc
, the IUnknown
values sometimes match and sometimes don’t, even when they reference the same file.Given this inconsistency, is this solution only reliable when both IDWriteFontFace
instances are created using the same method? Or even, is it reliable?
Upvotes: 0
Views: 36
Reputation: 1179
What you can do rather reliably is to compare the following:
If you loader is always IDWriteLocalFontFileLoader, you can then get a path directly, and compare that.
Equals() will consider simulations too, meaning faces using same {fontfile, index} could still be unequal.
Upvotes: 0