get_name(fontd, kCTFontFamilyNameAttribute, families, &meta.n_family);
meta.families = families;
- int zero = 0;
- get_name(fontd, kCTFontNameAttribute, identifiers, &zero);
get_name(fontd, kCTFontDisplayNameAttribute, fullnames, &meta.n_fullname);
meta.fullnames = fullnames;
+ int zero = 0;
+ get_name(fontd, kCTFontNameAttribute, identifiers, &zero);
+ meta.postscript_name = identifiers[0];
+
CFCharacterSetRef chset =
CTFontDescriptorCopyAttribute(fontd, kCTFontCharacterSetAttribute);
- ass_font_provider_add_font(provider, &meta, path, index,
- identifiers[0], (void*)chset);
+ ass_font_provider_add_font(provider, &meta, path, index, (void*)chset);
for (int j = 0; j < meta.n_family; j++)
free(meta.families[j]);
for (int j = 0; j < meta.n_fullname; j++)
free(meta.fullnames[j]);
- free(identifiers[0]);
+ free(meta.postscript_name);
free(path);
}
IDWriteLocalizedStrings *fontNames = NULL;
IDWriteLocalizedStrings *psNames = NULL;
BOOL exists = FALSE;
- char *psName = NULL;
hr = IDWriteFontCollection_GetFontFamily(fontCollection, i, &fontFamily);
if (FAILED(hr))
temp_name[NAME_MAX_LENGTH-1] = 0;
size_needed = WideCharToMultiByte(CP_UTF8, 0, temp_name, -1, NULL, 0,NULL, NULL);
- psName = (char *) malloc(size_needed);
- WideCharToMultiByte(CP_UTF8, 0, temp_name, -1, psName, size_needed, NULL, NULL);
+ char *mbName = (char *) malloc(size_needed);
+ WideCharToMultiByte(CP_UTF8, 0, temp_name, -1, mbName, size_needed, NULL, NULL);
+ meta.postscript_name = mbName;
+
IDWriteLocalizedStrings_Release(psNames);
}
FontPrivate *font_priv = (FontPrivate *) calloc(1, sizeof(*font_priv));
font_priv->font = font;
- ass_font_provider_add_font(provider, &meta, NULL, 0, psName, font_priv);
+ ass_font_provider_add_font(provider, &meta, NULL, 0, font_priv);
for (UINT32 k = 0; k < meta.n_family; ++k)
free(meta.families[k]);
free(meta.fullnames[k]);
free(meta.fullnames);
free(meta.families);
- free(psName);
+ free(meta.postscript_name);
}
}
}
meta.n_fullname++;
meta.fullnames = fullnames;
- ass_font_provider_add_font(provider, &meta, path, index, NULL,
- (void *)pat);
+ ass_font_provider_add_font(provider, &meta, path, index, (void *)pat);
}
}
* \param meta basic metadata of the font
* \param path path to the font file, or NULL
* \param index face index inside the file (-1 to look up by PostScript name)
- * \param psname PostScript name of the face
* \param data private data for the font
* \return success
*/
int
ass_font_provider_add_font(ASS_FontProvider *provider,
ASS_FontProviderMetaData *meta, const char *path,
- int index, const char *psname, void *data)
+ int index, void *data)
{
int i;
int weight, slant, width;
goto error;
}
- if (path) {
- info->path = strdup(path);
- if (info->path == NULL)
+ if (meta->postscript_name) {
+ info->postscript_name = strdup(meta->postscript_name);
+ if (info->postscript_name == NULL)
goto error;
}
- if (psname) {
- info->postscript_name = strdup(psname);
- if (info->postscript_name == NULL)
+ if (path) {
+ info->path = strdup(path);
+ if (info->path == NULL)
goto error;
}
ft->face = face;
ft->idx = idx;
- if (ass_font_provider_add_font(priv, &info, NULL, face_index,
- NULL, ft)) {
+ if (ass_font_provider_add_font(priv, &info, NULL, face_index, ft)) {
ass_msg(library, MSGL_WARN, "Failed to add embedded font '%s'",
name);
}
* At minimum one family is required.
*/
struct ass_font_provider_meta_data {
-
/**
* List of localized font family names, e.g. "Arial".
*/
* The English name should be listed first to speed up typical matching.
*/
char **fullnames;
+
+ /**
+ * The PostScript name, e.g. "Arial-BoldMT".
+ */
+ char *postscript_name;
+
int n_family; // Number of localized family names
int n_fullname; // Number of localized full names
* \param path absolute path to font, or NULL for memory-based fonts
* \param index index inside a font collection file
* (-1 to look up by PostScript name)
- * \param psname PostScript name of the face
* \param data private data for font callbacks
* \return success
*
int
ass_font_provider_add_font(ASS_FontProvider *provider,
ASS_FontProviderMetaData *meta, const char *path,
- int index, const char *psname, void *data);
+ int index, void *data);
/**
* \brief Free font provider and associated fonts.