aboutsummaryrefslogtreecommitdiff
path: root/fontconfig
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig')
-rw-r--r--fontconfig/doc/fcconfig.fncs10
-rw-r--r--fontconfig/doc/fcrange.fncs1
-rw-r--r--fontconfig/doc/fontconfig-devel.sgml8
-rw-r--r--fontconfig/fc-cache/fc-cache.c29
-rw-r--r--fontconfig/fc-cache/fc-cache.sgml31
-rw-r--r--fontconfig/fontconfig/fontconfig.h3
-rw-r--r--fontconfig/src/fccfg.c23
-rw-r--r--fontconfig/src/fcfreetype.c30
-rw-r--r--fontconfig/src/fcint.h2
-rw-r--r--fontconfig/src/fcmatch.c1
-rw-r--r--fontconfig/src/fcobjs.h1
11 files changed, 106 insertions, 33 deletions
diff --git a/fontconfig/doc/fcconfig.fncs b/fontconfig/doc/fcconfig.fncs
index 10f5afc7f..af328fc70 100644
--- a/fontconfig/doc/fcconfig.fncs
+++ b/fontconfig/doc/fcconfig.fncs
@@ -219,8 +219,9 @@ If <parameter>config</parameter> is NULL, the current configuration is used.
@PURPOSE@ Add font file to font database
@DESC@
Adds an application-specific font to the configuration. Returns FcFalse
-if the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
-If <parameter>config</parameter> is NULL, the current configuration is used.
+if the fonts cannot be added (due to allocation failure or no fonts found).
+Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
+the current configuration is used.
@@
@RET@ FcBool
@@ -231,8 +232,9 @@ If <parameter>config</parameter> is NULL, the current configuration is used.
@DESC@
Scans the specified directory for fonts, adding each one found to the
application-specific set of fonts. Returns FcFalse
-if the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
-If <parameter>config</parameter> is NULL, the current configuration is used.
+if the fonts cannot be added (due to allocation failure or no fonts found).
+Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
+the current configuration is used.
@@
@RET@ void
diff --git a/fontconfig/doc/fcrange.fncs b/fontconfig/doc/fcrange.fncs
index 4181b8093..ba76f65b2 100644
--- a/fontconfig/doc/fcrange.fncs
+++ b/fontconfig/doc/fcrange.fncs
@@ -72,3 +72,4 @@ all memory associated with it.
@DESC@
Returns in <parameter>begin</parameter> and <parameter>end</parameter> as the range.
@SINCE@ 2.11.91
+@@
diff --git a/fontconfig/doc/fontconfig-devel.sgml b/fontconfig/doc/fontconfig-devel.sgml
index 2b1122f18..7410ef0c0 100644
--- a/fontconfig/doc/fontconfig-devel.sgml
+++ b/fontconfig/doc/fontconfig-devel.sgml
@@ -20,6 +20,7 @@
<!ENTITY fcstring SYSTEM "fcstring.sgml">
<!ENTITY fcstrset SYSTEM "fcstrset.sgml">
<!ENTITY fcvalue SYSTEM "fcvalue.sgml">
+<!ENTITY fcweight SYSTEM "fcweight.sgml">
<!ENTITY version SYSTEM "version.sgml">
]>
<!--
@@ -176,6 +177,7 @@ convenience for the application's rendering mechanism.
scalable FC_SCALABLE Bool Whether glyphs can be scaled
scale FC_SCALE Double Scale factor for point->pixel
conversions
+ color FC_COLOR Bool Whether any glyphs have color
dpi FC_DPI Double Target dots per inch
rgba FC_RGBA Int unknown, rgb, bgr, vrgb,
vbgr, none - subpixel geometry
@@ -536,6 +538,12 @@ Provides for application-specified symbolic constants for font names.
</para>
&fcconstant;
</sect2>
+ <sect2><title>FcWeight</title>
+ <para>
+Maps weights to and from OpenType weights.
+ </para>
+ &fcweight;
+ </sect2>
<sect2><title>FcBlanks</title>
<para>
An FcBlanks object holds a list of Unicode chars which are expected to
diff --git a/fontconfig/fc-cache/fc-cache.c b/fontconfig/fc-cache/fc-cache.c
index 406ac6a8a..18cd6c5d6 100644
--- a/fontconfig/fc-cache/fc-cache.c
+++ b/fontconfig/fc-cache/fc-cache.c
@@ -65,6 +65,7 @@
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
+ {"error-on-no-fonts", 0, 0, 'E'},
{"force", 0, 0, 'f'},
{"really-force", 0, 0, 'r'},
{"sysroot", required_argument, 0, 'y'},
@@ -86,16 +87,17 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
+ fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
program);
#else
- fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [dirs]\n",
+ fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [dirs]\n",
program);
#endif
fprintf (file, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -E, --error-on-no-fonts raise an error if no fonts in a directory\n");
fprintf (file, " -f, --force scan directories with apparently valid caches\n");
fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
fprintf (file, " -s, --system-only scan system-wide directories only\n");
@@ -104,6 +106,8 @@ usage (char *program, int error)
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
+ fprintf (file, " -E (error-on-no-fonts)\n");
+ fprintf (file, " raise an error if no fonts in a directory\n");
fprintf (file, " -f (force) scan directories with apparently valid caches\n");
fprintf (file, " -r, (really force) erase all existing caches, then rescan\n");
fprintf (file, " -s (system) scan system-wide directories only\n");
@@ -118,7 +122,7 @@ usage (char *program, int error)
static FcStrSet *processed_dirs;
static int
-scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, int *changed, FcStrSet *updateDirs)
+scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, FcBool error_on_no_fonts, int *changed, FcStrSet *updateDirs)
{
int ret = 0;
const FcChar8 *dir;
@@ -126,7 +130,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
FcStrList *sublist;
FcCache *cache;
struct stat statb;
- FcBool was_valid;
+ FcBool was_valid, was_processed = FcFalse;
int i;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
@@ -175,6 +179,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
fprintf (stderr, "\"%s\": not a directory, skipping\n", dir);
continue;
}
+ was_processed = FcTrue;
if (really_force)
FcDirCacheUnlink (dir, config);
@@ -250,12 +255,14 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
continue;
}
FcStrSetAdd (processed_dirs, dir);
- ret += scanDirs (sublist, config, force, really_force, verbose, recursive, changed, updateDirs);
+ ret += scanDirs (sublist, config, force, really_force, verbose, recursive, error_on_no_fonts, changed, updateDirs);
FcStrListDone (sublist);
}
else
FcDirCacheUnload (cache);
}
+ if (error_on_no_fonts && !was_processed)
+ ret++;
return ret;
}
@@ -289,6 +296,7 @@ main (int argc, char **argv)
FcBool force = FcFalse;
FcBool really_force = FcFalse;
FcBool systemOnly = FcFalse;
+ FcBool error_on_no_fonts = FcFalse;
FcConfig *config;
FcChar8 *sysroot = NULL;
int i;
@@ -298,12 +306,15 @@ main (int argc, char **argv)
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "frsy:Vvh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "Efrsy:Vvh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "frsy:Vvh")) != -1)
+ while ((c = getopt (argc, argv, "Efrsy:Vvh")) != -1)
#endif
{
switch (c) {
+ case 'E':
+ error_on_no_fonts = FcTrue;
+ break;
case 'r':
really_force = FcTrue;
/* fall through */
@@ -384,13 +395,13 @@ main (int argc, char **argv)
updateDirs = FcStrSetCreate ();
changed = 0;
- ret = scanDirs (list, config, force, really_force, verbose, FcTrue, &changed, updateDirs);
+ ret = scanDirs (list, config, force, really_force, verbose, FcTrue, error_on_no_fonts, &changed, updateDirs);
/* Update the directory cache again to avoid the race condition as much as possible */
FcStrListDone (list);
list = FcStrListCreate (updateDirs);
if (list)
{
- ret += scanDirs (list, config, FcTrue, FcFalse, verbose, FcFalse, &changed, NULL);
+ ret += scanDirs (list, config, FcTrue, FcFalse, verbose, FcFalse, error_on_no_fonts, &changed, NULL);
FcStrListDone (list);
}
FcStrSetDestroy (updateDirs);
diff --git a/fontconfig/fc-cache/fc-cache.sgml b/fontconfig/fc-cache/fc-cache.sgml
index 3740be77f..7e5159b11 100644
--- a/fontconfig/fc-cache/fc-cache.sgml
+++ b/fontconfig/fc-cache/fc-cache.sgml
@@ -63,9 +63,14 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-frsvVh</option></arg>
+ <arg><option>-EfrsvVh</option></arg>
+ <arg><option>--error-on-no-fonts</option></arg>
<arg><option>--force</option></arg>
<arg><option>--really-force</option></arg>
+ <group>
+ <arg><option>-y</option> <option><replaceable>dir</replaceable></option></arg>
+ <arg><option>--sysroot</option> <option><replaceable>dir</replaceable></option></arg>
+ </group>
<arg><option>--system-only</option></arg>
<arg><option>--verbose</option></arg>
<arg><option>--version</option></arg>
@@ -103,6 +108,16 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-E</option>
+ <option>--error-on-no-fonts</option>
+ </term>
+ <listitem>
+ <para>Raise an error if there are no fonts in
+ <option><replaceable>dir</replaceable></option> or directories
+ in the configuration if not given.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-f</option>
<option>--force</option>
</term>
@@ -137,6 +152,15 @@ manpage.1: manpage.sgml
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-y</option>
+ <option>-sysroot</option>
+ <option><replaceable>dir</replaceable></option>
+ </term>
+ <listitem>
+ <para>Prepend <option><replaceable>dir</replaceable></option> to all paths for scanning.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-h</option>
<option>--help</option>
</term>
@@ -163,6 +187,11 @@ manpage.1: manpage.sgml
</refsect1>
<refsect1>
+ <title>RETURN CODES</title>
+ <para><command>fc-cache</command> returns zero if the caches successfully generated. otherwise non-zero.</para>
+ </refsect1>
+
+ <refsect1>
<title>FILES</title>
<variablelist>
<varlistentry>
diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h
index afc917c6b..c571e28b2 100644
--- a/fontconfig/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig/fontconfig.h
@@ -66,7 +66,7 @@ typedef int FcBool;
* it means multiple copies of the font information.
*/
-#define FC_CACHE_VERSION "4"
+#define FC_CACHE_VERSION "5"
#define FcTrue 1
#define FcFalse 0
@@ -94,6 +94,7 @@ typedef int FcBool;
#define FC_RASTERIZER "rasterizer" /* String (deprecated) */
#define FC_OUTLINE "outline" /* Bool */
#define FC_SCALABLE "scalable" /* Bool */
+#define FC_COLOR "color" /* Bool */
#define FC_SCALE "scale" /* double */
#define FC_DPI "dpi" /* double */
#define FC_RGBA "rgba" /* Int */
diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c
index 55cb297cd..b27ab0b43 100644
--- a/fontconfig/src/fccfg.c
+++ b/fontconfig/src/fccfg.c
@@ -367,6 +367,7 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
FcStrList *dirlist;
FcChar8 *dir;
FcCache *cache;
+ FcBool ret = FcFalse;
dirlist = FcStrListCreate (dirSet);
if (!dirlist)
@@ -381,9 +382,10 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
continue;
FcConfigAddCache (config, cache, set, dirSet);
FcDirCacheUnload (cache);
+ ret = FcTrue;
}
FcStrListDone (dirlist);
- return FcTrue;
+ return ret;
}
/*
@@ -2185,6 +2187,7 @@ FcConfigAppFontAddFile (FcConfig *config,
FcStrSet *subdirs;
FcStrList *sublist;
FcChar8 *subdir;
+ FcBool ret = FcFalse;
if (!config)
{
@@ -2218,12 +2221,13 @@ FcConfigAppFontAddFile (FcConfig *config,
{
while ((subdir = FcStrListNext (sublist)))
{
- FcConfigAppFontAddDir (config, subdir);
+ if (FcConfigAppFontAddDir (config, subdir))
+ ret = FcTrue;
}
FcStrListDone (sublist);
}
FcStrSetDestroy (subdirs);
- return FcTrue;
+ return ret;
}
FcBool
@@ -2232,6 +2236,7 @@ FcConfigAppFontAddDir (FcConfig *config,
{
FcFontSet *set;
FcStrSet *dirs;
+ FcBool ret = FcTrue;
if (!config)
{
@@ -2250,8 +2255,8 @@ FcConfigAppFontAddDir (FcConfig *config,
set = FcFontSetCreate ();
if (!set)
{
- FcStrSetDestroy (dirs);
- return FcFalse;
+ ret = FcFalse;
+ goto bail;
}
FcConfigSetFonts (config, set, FcSetApplication);
}
@@ -2259,12 +2264,10 @@ FcConfigAppFontAddDir (FcConfig *config,
FcStrSetAddFilename (dirs, dir);
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
- {
- FcStrSetDestroy (dirs);
- return FcFalse;
- }
+ ret = FcFalse;
+bail:
FcStrSetDestroy (dirs);
- return FcTrue;
+ return ret;
}
void
diff --git a/fontconfig/src/fcfreetype.c b/fontconfig/src/fcfreetype.c
index aca2f70b2..81ebda707 100644
--- a/fontconfig/src/fcfreetype.c
+++ b/fontconfig/src/fcfreetype.c
@@ -1277,13 +1277,28 @@ FcFreeTypeQueryFace (const FT_Face face,
if (!pat)
goto bail0;
- if (!FcPatternAddBool (pat, FC_OUTLINE,
- (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
- goto bail1;
+ {
+ int has_outline = !!(face->face_flags & FT_FACE_FLAG_SCALABLE);
+ int has_color = 0;
- if (!FcPatternAddBool (pat, FC_SCALABLE,
- (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
- goto bail1;
+#ifdef FT_FACE_FLAG_COLOR
+ has_color = !!(face->face_flags & FT_FACE_FLAG_COLOR);
+#endif
+
+ if (!FcPatternAddBool (pat, FC_OUTLINE, has_outline))
+ goto bail1;
+
+#ifdef FT_FACE_FLAG_COLOR
+ if (!FcPatternAddBool (pat, FC_COLOR, has_color))
+ goto bail1;
+#endif
+
+ /* All color fonts are designed to be scaled, even if they only have
+ * bitmap strikes. Client is responsible to scale the bitmaps. This
+ * is in constrast to non-color strikes... */
+ if (!FcPatternAddBool (pat, FC_SCALABLE, has_outline || has_color))
+ goto bail1;
+ }
/*
@@ -1556,7 +1571,8 @@ FcFreeTypeQueryFace (const FT_Face face,
}
else
{
- strcpy (psname, tmp);
+ strncpy (psname, tmp, 255);
+ psname[255] = 0;
}
if (!FcPatternAddString (pat, FC_POSTSCRIPT_NAME, (const FcChar8 *)psname))
goto bail1;
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index 45dfc6e61..80205c950 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -470,7 +470,7 @@ typedef struct _FcCaseFold {
#define FC_CACHE_MAGIC_MMAP 0xFC02FC04
#define FC_CACHE_MAGIC_ALLOC 0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION 4
+#define FC_CACHE_CONTENT_VERSION 5
struct _FcAtomic {
FcChar8 *file; /* original file name */
diff --git a/fontconfig/src/fcmatch.c b/fontconfig/src/fcmatch.c
index 25081e2cb..46d08bcc7 100644
--- a/fontconfig/src/fcmatch.c
+++ b/fontconfig/src/fcmatch.c
@@ -284,6 +284,7 @@ typedef enum _FcMatcherPriority {
PRI1(FILE),
PRI1(FONTFORMAT),
PRI1(SCALABLE),
+ PRI1(COLOR),
PRI1(FOUNDRY),
PRI1(CHARSET),
PRI_FAMILY_STRONG,
diff --git a/fontconfig/src/fcobjs.h b/fontconfig/src/fcobjs.h
index bfdf4b58b..573fa610d 100644
--- a/fontconfig/src/fcobjs.h
+++ b/fontconfig/src/fcobjs.h
@@ -68,4 +68,5 @@ FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
FC_OBJECT (PRGNAME, FcTypeString, NULL)
FC_OBJECT (HASH, FcTypeString, NULL) /* deprecated */
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
+FC_OBJECT (COLOR, FcTypeBool, FcCompareBool)
/* ^-------------- Add new objects here. */