summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2010-01-08 18:00:17 +0100
committerGrigori Goronzy <greg@blackbox>2010-01-08 18:00:17 +0100
commit01b0e9a1bb517eeba755154264d6bebe49e8bfcb (patch)
tree12000cdec4b65c0457d094927e06c572f4ab96a5
parent9e64911f424dac4e960fbe4c7a4df98433d05b93 (diff)
downloadlibass-01b0e9a1bb517eeba755154264d6bebe49e8bfcb.tar.bz2
libass-01b0e9a1bb517eeba755154264d6bebe49e8bfcb.tar.xz
Remove support for fontconfig < 2.4.2
Get rid of compatibility code and #ifdefs for very old fontconfig versions. libass now requires at least version 2.4.2.
-rw-r--r--configure.ac2
-rw-r--r--libass/ass_fontconfig.c120
2 files changed, 2 insertions, 120 deletions
diff --git a/configure.ac b/configure.ac
index 7698492..42523b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,7 @@ PKG_CHECK_MODULES([FREETYPE], freetype2 >= 9.6.3, [
])
if test x$enable_fontconfig != xno; then
-PKG_CHECK_MODULES([FONTCONFIG], fontconfig >= 2.2.0, [
+PKG_CHECK_MODULES([FONTCONFIG], fontconfig >= 2.4.2, [
CFLAGS="$CFLAGS $FONTCONFIG_CFLAGS"
LIBS="$LIBS $FONTCONFIG_LIBS"
AC_DEFINE(CONFIG_FONTCONFIG, 1, [found fontconfig via pkg-config])
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index 83cde1c..2a43694 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -51,15 +51,6 @@ struct fc_instance {
#ifdef CONFIG_FONTCONFIG
-// 4yo fontconfig does not have these.
-// They are only needed for debug output, anyway.
-#ifndef FC_FULLNAME
-#define FC_FULLNAME "fullname"
-#endif
-#ifndef FC_EMBOLDEN
-#define FC_EMBOLDEN "embolden"
-#endif
-
/**
* \brief Low-level font selection.
* \param priv private data
@@ -159,7 +150,6 @@ static char *_select_font(ASS_Library *library, FCInstance *priv,
if (curf >= fset->nfont)
goto error;
-#if (FC_VERSION >= 20297)
if (!treat_family_as_pattern) {
// Remove all extra family names from original pattern.
// After this, FcFontRenderPrepare will select the most relevant family
@@ -167,7 +157,6 @@ static char *_select_font(ASS_Library *library, FCInstance *priv,
for (; family_cnt > 1; --family_cnt)
FcPatternRemove(pat, FC_FAMILY, family_cnt - 1);
}
-#endif
rpat = FcFontRenderPrepare(priv->config, pat, fset->fonts[curf]);
if (!rpat)
@@ -288,41 +277,6 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv,
return res;
}
-#if (FC_VERSION < 20402)
-static char *validate_fname(char *name)
-{
- char *fname;
- char *p;
- char *q;
- unsigned code;
- int sz = strlen(name);
-
- q = fname = malloc(sz + 1);
- p = name;
- while (*p) {
- code = ass_utf8_get_char(&p);
- if (code == 0)
- break;
- if ((code > 0x7F) ||
- (code == '\\') ||
- (code == '/') ||
- (code == ':') ||
- (code == '*') ||
- (code == '?') ||
- (code == '<') ||
- (code == '>') || (code == '|') || (code == 0)) {
- *q++ = '_';
- } else {
- *q++ = code;
- }
- if (p - name > sz)
- break;
- }
- *q = 0;
- return fname;
-}
-#endif
-
/**
* \brief Process memory font.
* \param priv private data
@@ -340,44 +294,6 @@ static void process_fontdata(FCInstance *priv, ASS_Library *library,
const char *data = library->fontdata[idx].data;
int data_size = library->fontdata[idx].size;
-#if (FC_VERSION < 20402)
- struct stat st;
- char *fname;
- const char *fonts_dir = library->fonts_dir;
- char buf[1000];
- FILE *fp = NULL;
-
- if (!fonts_dir)
- return;
- rc = stat(fonts_dir, &st);
- if (rc) {
- int res;
-#ifndef __MINGW32__
- res = mkdir(fonts_dir, 0700);
-#else
- res = mkdir(fonts_dir);
-#endif
- if (res) {
- ass_msg(library, MSGL_WARN, "Failed to create directory '%s'",
- fonts_dir);
- }
- } else if (!S_ISDIR(st.st_mode)) {
- ass_msg(library, MSGL_WARN, "Not a directory: '%s'", fonts_dir);
- }
-
- fname = validate_fname((char *) name);
-
- snprintf(buf, 1000, "%s/%s", fonts_dir, fname);
- free(fname);
-
- fp = fopen(buf, "wb");
- if (!fp)
- return;
-
- fwrite(data, data_size, 1, fp);
- fclose(fp);
-
-#else // (FC_VERSION >= 20402)
FT_Face face;
FcPattern *pattern;
FcFontSet *fset;
@@ -419,7 +335,6 @@ static void process_fontdata(FCInstance *priv, ASS_Library *library,
FT_Done_Face(face);
}
-#endif
}
/**
@@ -473,40 +388,7 @@ FCInstance *fontconfig_init(ASS_Library *library,
process_fontdata(priv, library, ftlibrary, i);
if (dir) {
- if (FcDirCacheValid((const FcChar8 *) dir) == FcFalse) {
- ass_msg(library, MSGL_INFO, "Updating font cache");
- if (FcGetVersion() >= 20390 && FcGetVersion() < 20400)
- ass_msg(library, MSGL_WARN, "Beta versions of fontconfig"
- "are not supported. Update before reporting any bugs");
- // FontConfig >= 2.4.0 updates cache automatically in FcConfigAppFontAddDir()
- if (FcGetVersion() < 20390) {
- FcFontSet *fcs;
- FcStrSet *fss;
- fcs = FcFontSetCreate();
- fss = FcStrSetCreate();
- rc = FcStrSetAdd(fss, (const FcChar8 *) dir);
- if (!rc) {
- ass_msg(library, MSGL_WARN, "%s failed", "FcStrSetAdd");
- goto ErrorFontCache;
- }
-
- rc = FcDirScan(fcs, fss, NULL,
- FcConfigGetBlanks(priv->config),
- (const FcChar8 *) dir, FcFalse);
- if (!rc) {
- ass_msg(library, MSGL_WARN, "%s failed", "FcDirScan");
- goto ErrorFontCache;
- }
-
- rc = FcDirSave(fcs, fss, (const FcChar8 *) dir);
- if (!rc) {
- ass_msg(library, MSGL_WARN, "%s failed", "FcDirSave");
- goto ErrorFontCache;
- }
- ErrorFontCache:
- ;
- }
- }
+ ass_msg(library, MSGL_INFO, "Updating font cache");
rc = FcConfigAppFontAddDir(priv->config, (const FcChar8 *) dir);
if (!rc) {