summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.h
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2015-11-04 15:25:47 +0200
committerOleg Oshmyan <chortos@inbox.lv>2015-11-04 15:38:50 +0200
commitd0566318ee5035ca3a4d2d65d46a80a4e3d8244c (patch)
treeac342a9147ddc911698235c73a36e66c485b6ce4 /libass/ass_fontselect.h
parentad5988af46f5ca698115140f9252882286539f72 (diff)
downloadlibass-d0566318ee5035ca3a4d2d65d46a80a4e3d8244c.tar.bz2
libass-d0566318ee5035ca3a4d2d65d46a80a4e3d8244c.tar.xz
fontselect: replace is_postscript flag with check_postscript function
DirectWrite does not provide fast access to the is_postscript flag, requiring each font to be loaded before its format can be determined. Eagerly doing this for every installed font can be quite slow, on the order of seconds. To improve performance, ask the font provider for this information only when it is actually needed, i.e. when one of the font's full names or its PostScript name matches a requested font name and we need to know whether to accept this match. The return value of check_postscript is not cached in this commit. This makes repeated calls slower than accessing is_postscript was. This should not be a problem, but if it is, the value can be cached (or precomputed) by font providers in their font private data. This commit also potentially increases the memory usage of some font providers by retaining data structures needed to implement check_postscript in their font private data. This should not be a problem either, but if it is, the value of check_postscript can be precomputed by all providers other than DirectWrite.
Diffstat (limited to 'libass/ass_fontselect.h')
-rw-r--r--libass/ass_fontselect.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h
index eceb2f0..73d5265 100644
--- a/libass/ass_fontselect.h
+++ b/libass/ass_fontselect.h
@@ -54,6 +54,14 @@ typedef size_t (*GetDataFunc)(void *font_priv, unsigned char *data,
size_t offset, size_t len);
/**
+ * Check whether the font contains PostScript outlines.
+ *
+ * \param font_priv font private data
+ * \return true if the font contains PostScript outlines
+ */
+typedef bool (*CheckPostscriptFunc)(void *font_priv);
+
+/**
* Check if a glyph is supported by a font.
*
* \param font_priv font private data
@@ -135,6 +143,7 @@ typedef char *(*GetFallbackFunc)(void *priv,
typedef struct font_provider_funcs {
GetDataFunc get_data; /* optional/mandatory */
+ CheckPostscriptFunc check_postscript; /* mandatory */
CheckGlyphFunc check_glyph; /* mandatory */
DestroyFontFunc destroy_font; /* optional */
DestroyProviderFunc destroy_provider; /* optional */
@@ -172,8 +181,6 @@ struct ass_font_provider_meta_data {
// See FONT_WEIGHT_*
int width; // Font weight in percent, normally 100
// See FONT_WIDTH_*
-
- bool is_postscript; // Whether the font contains PostScript outlines
};
typedef struct ass_font_stream ASS_FontStream;