// simple types
result = FcPatternGetInteger(pat, FC_SLANT, 0, &meta.slant);
+ result |= FcPatternGetInteger(pat, FC_WIDTH, 0, &meta.width);
result |= FcPatternGetInteger(pat, FC_WEIGHT, 0, &weight);
result |= FcPatternGetInteger(pat, FC_INDEX, 0, &index);
if (result != FcResultMatch)
meta.weight = FONT_WEIGHT_BOLD;
// family name
- // HACK: get the last family name. that fixes fonts
- // like Arial Narrow in some versions
- int n_family = 0;
- while (FcPatternGetString(pat, FC_FAMILY, n_family,
- (FcChar8 **)&meta.family) == FcResultMatch)
- n_family++;
+ result = FcPatternGetString(pat, FC_FAMILY, 0,
+ (FcChar8 **)&meta.family);
+ if (result != FcResultMatch)
+ continue;
// path
result = FcPatternGetString(pat, FC_FILE, 0, (FcChar8 **)&path);
int slant;
int weight; // TrueType scale, 100-900
+ int width;
// how to access this face
char *path; // absolute path
unsigned int index, void *data)
{
int i;
- int weight, slant;
+ int weight, slant, width;
ASS_FontSelector *selector = provider->parent;
ASS_FontInfo *info;
weight = meta->weight;
slant = meta->slant;
+ width = meta->width;
// check slant/weight for validity, use defaults if they're invalid
if (weight < 100 || weight > 900)
weight = 400;
if (slant < 0 || slant > 110)
slant = 0;
+ if (width < 50 || width > 200)
+ width = 100;
// check size
if (selector->n_font >= selector->alloc_font) {
info->slant = slant;
info->weight = weight;
+ info->width = width;
info->family = strdup(meta->family);
info->n_fullname = meta->n_fullname;
info->fullnames = calloc(meta->n_fullname, sizeof(char *));
// compare weight
similarity += ABS(a->weight - req->weight);
+ // compare width
+ similarity += ABS(a->width - req->width);
+
return similarity;
}
memset(&req, 0, sizeof(ASS_FontInfo));
req.slant = italic;
req.weight = bold;
+ req.width = 100;
req.n_fullname = 1;
req.fullnames = &req_fullname;
req.fullnames[0] = trim_space(strdup(family));
#define FONT_SLANT_NONE 0
#define FONT_SLANT_ITALIC 100
#define FONT_SLANT_OBLIQUE 110
+#define FONT_WIDTH_CONDENSED 75
+#define FONT_WIDTH_NORMAL 100
+#define FONT_WIDTH_EXPANDED 125
/* Opaque objects internally used by libass. Contents are private. */
int n_fullname; // number of localized full names
int slant; // uses the above scale (NONE/ITALIC/OBLIQUE)
int weight; // TrueType scale, 100-900
+ int width; // in percent, normally 100
} ASS_FontProviderMetaData;