summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.h
diff options
context:
space:
mode:
Diffstat (limited to 'libass/ass_fontselect.h')
-rw-r--r--libass/ass_fontselect.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h
index c989e1a..1e0959e 100644
--- a/libass/ass_fontselect.h
+++ b/libass/ass_fontselect.h
@@ -177,6 +177,37 @@ struct ass_font_stream {
void *priv;
};
+
+typedef struct ass_font_mapping ASS_FontMapping;
+
+struct ass_font_mapping {
+ const char *from;
+ const char *to;
+};
+
+/**
+ * Simple font substitution helper. This can be used to implement basic
+ * mappings from one name to another. This is useful for supporting
+ * generic font families in font providers.
+ *
+ * \param map list of mappings
+ * \param len length of list of mappings
+ * \param name font name to map from
+ * \param meta metadata struct, mapped fonts will be stored into this
+ */
+inline void ass_map_font(const ASS_FontMapping *map, int len, const char *name,
+ ASS_FontProviderMetaData *meta)
+{
+ for (int i = 0; i < len; i++) {
+ if (strcasecmp(map[i].from, name) == 0) {
+ meta->n_fullname = 1;
+ meta->fullnames = calloc(1, sizeof(char *));
+ meta->fullnames[0] = strdup(map[i].to);
+ return;
+ }
+ }
+}
+
ASS_FontSelector *
ass_fontselect_init(ASS_Library *library,
FT_Library ftlibrary, const char *family,