if (fontp)
return fontp;
- path = fontconfig_select(fc_priv, desc->family, desc->bold, desc->italic, &index);
+ path = fontconfig_select(fc_priv, desc->family, desc->bold, desc->italic, &index, 0);
mem_idx = find_font(library, path);
if (mem_idx >= 0) {
font.v.x = font.v.y = 0;
font.size = 0.;
-#ifdef HAVE_FONTCONFIG
- font.charset = FcCharSetCreate();
-#endif
-
return ass_font_cache_add(&font);
}
if (font->n_faces == ASS_FONT_MAX_FACES)
return;
- path = fontconfig_select_with_charset(fontconfig_priv, font->desc.family, font->desc.bold,
- font->desc.italic, &index, font->charset);
+ path = fontconfig_select(fontconfig_priv, font->desc.family, font->desc.bold,
+ font->desc.italic, &index, ch);
error = FT_New_Face(font->ftlibrary, path, index, &face);
if (error) {
}
#ifdef HAVE_FONTCONFIG
- FcCharSetAddChar(font->charset, ch);
if (index == 0) {
mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_GlyphNotFoundReselectingFont,
ch, font->desc.family, font->desc.bold, font->desc.italic);
for (i = 0; i < font->n_faces; ++i)
if (font->faces[i]) FT_Done_Face(font->faces[i]);
if (font->desc.family) free(font->desc.family);
-#ifdef HAVE_FONTCONFIG
- if (font->charset) FcCharSetDestroy(font->charset);
-#endif
free(font);
}
* \param bold font weight value
* \param italic font slant value
* \param index out: font index inside a file
- * \param charset: contains the characters that should be present in the font, can be NULL
+ * \param code: the character that should be present in the font, can be 0
* \return font file path
*/
static char* _select_font(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
- FcCharSet* charset)
+ uint32_t code)
{
FcBool rc;
FcResult result;
FcBool val_b;
FcCharSet* val_cs;
FcFontSet* fset = 0;
- int curf, bestf, bestdiff = 0;
+ int curf;
char* retval = 0;
*index = 0;
fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
- bestf = -1;
- if (charset)
- bestdiff = FcCharSetCount(charset) + 1;
for (curf = 0; curf < fset->nfont; ++curf) {
rpat = fset->fonts[curf];
continue;
if (val_b != FcTrue)
continue;
-
- if (charset) {
- int diff;
- result = FcPatternGetCharSet(rpat, FC_CHARSET, 0, &val_cs);
- if (result != FcResultMatch)
- continue;
- diff = FcCharSetSubtractCount(charset, val_cs);
- if (diff < bestdiff) {
- bestdiff = diff;
- bestf = curf;
- }
- if (diff == 0)
- break;
- } else {
- bestf = curf;
+ if (!code)
+ break;
+ result = FcPatternGetCharSet(rpat, FC_CHARSET, 0, &val_cs);
+ if (result != FcResultMatch)
+ continue;
+ if (FcCharSetHasChar(val_cs, code))
break;
- }
}
- if (bestf < 0)
+ if (curf >= fset->nfont)
goto error;
- rpat = fset->fonts[bestf];
+ rpat = fset->fonts[curf];
result = FcPatternGetInteger(rpat, FC_INDEX, 0, &val_i);
if (result != FcResultMatch)
* \param bold font weight value
* \param italic font slant value
* \param index out: font index inside a file
- * \param charset: contains the characters that should be present in the font, can be NULL
+ * \param code: the character that should be present in the font, can be 0
* \return font file path
*/
-char* fontconfig_select_with_charset(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
- FcCharSet* charset)
+char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
+ uint32_t code)
{
char* res = 0;
if (family && *family)
- res = _select_font(priv, family, bold, italic, index, charset);
+ res = _select_font(priv, family, bold, italic, index, code);
if (!res && priv->family_default) {
- res = _select_font(priv, priv->family_default, bold, italic, index, charset);
+ res = _select_font(priv, priv->family_default, bold, italic, index, code);
if (res)
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFontFamily,
family, bold, italic, res, *index);
family, bold, italic, res, *index);
}
if (!res) {
- res = _select_font(priv, "Arial", bold, italic, index, charset);
+ res = _select_font(priv, "Arial", bold, italic, index, code);
if (res)
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingArialFontFamily,
family, bold, italic, res, *index);
return res;
}
-char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index)
-{
- return fontconfig_select_with_charset(priv, family, bold, italic, index, 0);
-}
-
#if (FC_VERSION < 20402)
static char* validate_fname(char* name)
{