jeremie bergeron
jeremie bergeron

Reputation: 527

Are 2 IDWriteFontFace instances equals?

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:

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

Answers (1)

bunglehead
bunglehead

Reputation: 1179

What you can do rather reliably is to compare the following:

  • GetFiles() -> GetLoader(). If you get same loader instance, you can then compare reference keys;
  • GetIndex() have to match;

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

Related Questions