summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libass/ass.h35
-rw-r--r--libass/ass_fontselect.h37
-rw-r--r--libass/ass_render_api.c7
-rw-r--r--libass/ass_types.h38
-rw-r--r--libass/libass.sym3
5 files changed, 83 insertions, 37 deletions
diff --git a/libass/ass.h b/libass/ass.h
index 774f344..d6728ed 100644
--- a/libass/ass.h
+++ b/libass/ass.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
+ * Copyright (C) 2011 Grigori Goronzy <greg@chown.ath.cx>
*
* This file is part of libass.
*
@@ -435,6 +436,40 @@ void ass_set_selective_style_override(ASS_Renderer *priv, ASS_Style *style);
int ass_fonts_update(ASS_Renderer *priv);
/**
+ * \brief Create an empty font provider. A font provider can be used to
+ * provide additional fonts to libass.
+ * \param priv parent renderer
+ * \param funcs callback functions
+ * \param private data for provider callbacks
+ *
+ */
+ASS_FontProvider *
+ass_create_font_provider(ASS_Renderer *priv, ASS_FontProviderFuncs *funcs,
+ void *data);
+
+/**
+ * \brief Add a font to a font provider.
+ * \param provider the font provider
+ * \param meta font metadata. See struct definition for more information.
+ * \param path absolute path to font, or NULL for memory-based fonts
+ * \param index index inside a font collection file
+ * \param data private data for font callbacks
+ * \return success
+ *
+ */
+int
+ass_font_provider_add_font(ASS_FontProvider *provider,
+ ASS_FontProviderMetaData *meta, const char *path,
+ unsigned int index, void *data);
+
+/**
+ * \brief Free font provider and associated fonts.
+ * \param provider the font provider
+ *
+ */
+void ass_font_provider_free(ASS_FontProvider *provider);
+
+/**
* \brief Set hard cache limits. Do not set, or set to zero, for reasonable
* defaults.
*
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h
index ec4c793..59a447b 100644
--- a/libass/ass_fontselect.h
+++ b/libass/ass_fontselect.h
@@ -25,45 +25,12 @@
typedef struct ass_shaper_font_data ASS_ShaperFontData;
typedef struct font_selector ASS_FontSelector;
-typedef struct font_provider ASS_FontProvider;
typedef struct font_info ASS_FontInfo;
#include "ass_types.h"
#include "ass.h"
#include "ass_font.h"
-// get face data
-typedef void *(*GetFaceFunc)(void *, size_t *);
-
-// check for a glyph
-typedef int (*CheckGlyphFunc)(void *, uint32_t);
-
-// destroy font_info and related data
-typedef void (*DestroyFunc)(void *);
-typedef void (*DestroyProviderFunc)(void *);
-
-typedef struct font_provider_funcs {
- GetFaceFunc get_face;
- CheckGlyphFunc check_glyph;
- DestroyFunc destroy_font;
- DestroyProviderFunc destroy_provider;
-} ASS_FontProviderFuncs;
-
-#define FONT_WEIGHT_LIGHT 300
-#define FONT_WEIGHT_MEDIUM 400
-#define FONT_WEIGHT_BOLD 700
-#define FONT_SLANT_NONE 0
-#define FONT_SLANT_ITALIC 100
-#define FONT_SLANT_OBLIQUE 110
-
-typedef struct font_provider_meta_data {
- char *family;
- char **fullnames;
- int n_fullname;
- int slant;
- int weight;
-} ASS_FontProviderMetaData;
-
ASS_FontSelector *
ass_fontselect_init(ASS_Library *library,
FT_Library ftlibrary, const char *family,
@@ -76,9 +43,5 @@ void ass_fontselect_free(ASS_FontSelector *priv);
// Font provider functions
ASS_FontProvider *ass_font_provider_new(ASS_FontSelector *selector,
ASS_FontProviderFuncs *funcs, void *data);
-int ass_font_provider_add_font(ASS_FontProvider *provider,
- ASS_FontProviderMetaData *meta, const char *path, unsigned int index,
- void *data);
-void ass_font_provider_free(ASS_FontProvider *provider);
#endif /* LIBASS_FONTCONFIG_H */
diff --git a/libass/ass_render_api.c b/libass/ass_render_api.c
index 5310060..fe883bb 100644
--- a/libass/ass_render_api.c
+++ b/libass/ass_render_api.c
@@ -179,3 +179,10 @@ void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
BITMAP_CACHE_MAX_SIZE;
}
+
+ASS_FontProvider *
+ass_create_font_provider(ASS_Renderer *priv, ASS_FontProviderFuncs *funcs,
+ void *data)
+{
+ return ass_font_provider_new(priv->fontselect, funcs, data);
+}
diff --git a/libass/ass_types.h b/libass/ass_types.h
index ccb0a0e..01e7306 100644
--- a/libass/ass_types.h
+++ b/libass/ass_types.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
+ * Copyright (C) 2011 Grigori Goronzy <greg@chown.ath.cx>
*
* This file is part of libass.
*
@@ -28,11 +29,47 @@
#define HALIGN_CENTER 2
#define HALIGN_RIGHT 3
+#define FONT_WEIGHT_LIGHT 300
+#define FONT_WEIGHT_MEDIUM 400
+#define FONT_WEIGHT_BOLD 700
+#define FONT_SLANT_NONE 0
+#define FONT_SLANT_ITALIC 100
+#define FONT_SLANT_OBLIQUE 110
+
+
/* Opaque objects internally used by libass. Contents are private. */
typedef struct ass_renderer ASS_Renderer;
typedef struct render_priv ASS_RenderPriv;
typedef struct parser_priv ASS_ParserPriv;
typedef struct ass_library ASS_Library;
+typedef struct font_provider ASS_FontProvider;
+
+
+/* Font Provider */
+typedef void *(*GetFaceFunc)(void *, size_t *);
+typedef int (*CheckGlyphFunc)(void *, uint32_t);
+typedef void (*DestroyFontFunc)(void *);
+typedef void (*DestroyProviderFunc)(void *);
+
+typedef struct font_provider_funcs {
+ GetFaceFunc get_face; // callback for memory fonts
+ CheckGlyphFunc check_glyph; // test codepoint for coverage
+ DestroyFontFunc destroy_font; // destroy a single font
+ DestroyProviderFunc destroy_provider; // destroy provider only
+} ASS_FontProviderFuncs;
+
+/*
+ * Basic font metadata. All strings must be encoded with UTF-8.
+ * At minimum `family' is required.
+ */
+typedef struct font_provider_meta_data {
+ char *family; // English font family, e.g. "Arial"
+ char **fullnames; // list of localized full names, e.g. "Arial Bold"
+ int n_fullname; // number of localized full names
+ int slant; // uses the above scale (NONE/ITALIC/OBLIQUE)
+ int weight; // TrueType scale, 100-900
+} ASS_FontProviderMetaData;
+
/* ASS Style: line */
typedef struct ass_style {
@@ -63,6 +100,7 @@ typedef struct ass_style {
double Blur;
} ASS_Style;
+
/*
* ASS_Event corresponds to a single Dialogue line;
* text is stored as-is, style overrides will be parsed later.
diff --git a/libass/libass.sym b/libass/libass.sym
index 89e212c..aafb7a8 100644
--- a/libass/libass.sym
+++ b/libass/libass.sym
@@ -41,3 +41,6 @@ ass_set_line_position
ass_set_pixel_aspect
ass_set_selective_style_override_enabled
ass_set_selective_style_override
+ass_create_font_provider
+ass_font_provider_add_font
+ass_font_provider_free