From ac052de8f7b6b6976ab89601388a1bd4d421e58b Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 1 Jun 2017 11:25:09 +0200 Subject: directwrite: fix font collections DirectWrite's FontFileStream does not actually use the data of a specific font in a collection, which was an expectation of the existing code. It simply returns a stream to the underlying file, collection or not. So we need to get the index of the font. This needs to be done lazily as this information is only available in a FontFace, which is expensive to initialize. Add a new optional font provider function for lazy initialization of the index and use it. This is similar to the check_postscript callback. Fixes libass#275. v2: fix type of returned value. --- libass/ass_fontselect.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libass/ass_fontselect.c') diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c index 5426b15..8c8882c 100644 --- a/libass/ass_fontselect.c +++ b/libass/ass_fontselect.c @@ -609,6 +609,11 @@ find_font(ASS_FontSelector *priv, ASS_Library *library, 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; } -- cgit v1.2.3