summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'libass/ass_fontselect.c')
-rw-r--r--libass/ass_fontselect.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 3bf67fd..ad91bf6 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -62,7 +62,7 @@ struct font_info {
int n_fullname;
int slant;
- int weight;
+ int weight; // TrueType scale, 100-900
// how to access this face
char *path;
@@ -175,11 +175,21 @@ ass_font_provider_add_font(ASS_FontProvider *provider,
unsigned int index, void *data)
{
int i;
+ int weight, slant;
ASS_FontSelector *selector = provider->parent;
ASS_FontInfo *info;
// TODO: sanity checks. do we have a path or valid get_face function?
+ weight = meta->weight;
+ slant = meta->slant;
+
+ // check slant/weight for validity, use defaults if they're invalid
+ if (weight < 100 || weight > 900)
+ meta->weight = 400;
+ if (slant < 0 || slant > 110)
+ slant = 0;
+
// check size
if (selector->n_font >= selector->alloc_font) {
selector->alloc_font = FFMAX(1, 2 * selector->alloc_font);
@@ -194,8 +204,8 @@ ass_font_provider_add_font(ASS_FontProvider *provider,
// set uid
info->uid = selector->uid++;
- info->slant = meta->slant;
- info->weight = meta->weight;
+ info->slant = slant;
+ info->weight = weight;
info->family = strdup(meta->family);
info->n_fullname = meta->n_fullname;
info->fullnames = calloc(meta->n_fullname, sizeof(char *));