type == DWRITE_FONT_FACE_TYPE_TYPE1;
}
+/*
+ * Lazily return index of font. It requires the FontFace to be present, which is expensive to initialize.
+ */
+static unsigned get_font_index(void *data)
+{
+ FontPrivate *priv = (FontPrivate *)data;
+
+ if (!init_font_private_face(priv))
+ return 0;
+
+ return IDWriteFontFace_GetIndex(priv->face);
+}
+
/*
* Check if the passed font has a specific unicode character.
*/
.destroy_provider = destroy_provider,
.get_substitutions = get_substitutions,
.get_fallback = get_fallback,
+ .get_font_index = get_font_index,
};
typedef HRESULT (WINAPI *DWriteCreateFactoryFn)(
result = selected->path;
}
+ // set up index, if lazy evaluation function exists
+ if (selected->provider->funcs.get_font_index) {
+ *index = selected->provider->funcs.get_font_index(selected->priv);
+ }
+
return result;
}
*/
typedef bool (*CheckGlyphFunc)(void *font_priv, uint32_t codepoint);
+/**
+* Get index of a font in context of a font collection.
+* This function is optional and may be needed to initialize the font index
+* lazily.
+*
+* \param font_priv font private data
+* \return font index inside the collection, or 0 in case of a single font
+*/
+typedef unsigned (*GetFontIndex)(void *font_priv);
+
/**
* Destroy a font's private data.
*
MatchFontsFunc match_fonts; /* optional */
SubstituteFontFunc get_substitutions; /* optional */
GetFallbackFunc get_fallback; /* optional */
+ GetFontIndex get_font_index; /* optional */
} ASS_FontProviderFuncs;
/*
UINT32 *numberOfFiles,
IDWriteFontFile **fontFiles) PURE;
+ STDMETHOD_(UINT32, GetIndex)(THIS) PURE;
+
/* rest dropped */
END_INTERFACE
};
#define IDWriteFontFace_Release(This) (This)->lpVtbl->Release(This)
#define IDWriteFontFace_GetType(This) (This)->lpVtbl->GetType(This)
#define IDWriteFontFace_GetFiles(This,fontFiles,b) (This)->lpVtbl->GetFiles(This,fontFiles,b)
+#define IDWriteFontFace_GetIndex(This) (This)->lpVtbl->GetIndex(This)
#endif /*COBJMACROS*/
#undef INTERFACE