Merge branch 'varfonts2'
https://lists.freedesktop.org/archives/fontconfig/2017-September/006048.html
This commit is contained in:
commit
1580593ecc
|
@ -40,11 +40,11 @@
|
|||
<match target="font">
|
||||
<!-- check to see if the font is just regular -->
|
||||
<test name="weight" compare="less_eq">
|
||||
<const>medium</const>
|
||||
<const>regular</const>
|
||||
</test>
|
||||
<!-- check to see if the pattern requests bold -->
|
||||
<test target="pattern" name="weight" compare="more">
|
||||
<const>medium</const>
|
||||
<test target="pattern" name="weight" compare="more_eq">
|
||||
<const>bold</const>
|
||||
</test>
|
||||
<!--
|
||||
set the embolden flag
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <getopt.h>
|
||||
const struct option longopts[] = {
|
||||
{"verbose", 0, 0, 'v'},
|
||||
{"brief", 0, 0, 'b'},
|
||||
{"format", 1, 0, 'f'},
|
||||
{"quiet", 0, 0, 'q'},
|
||||
{"version", 0, 0, 'V'},
|
||||
|
@ -67,22 +68,24 @@ usage (char *program, int error)
|
|||
{
|
||||
FILE *file = error ? stderr : stdout;
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, "usage: %s [-vqVh] [-f FORMAT] [--verbose] [--format=FORMAT] [--quiet] [--version] [--help] [pattern] {element ...} \n",
|
||||
fprintf (file, "usage: %s [-vbqVh] [-f FORMAT] [--verbose] [--brief] [--format=FORMAT] [--quiet] [--version] [--help] [pattern] {element ...} \n",
|
||||
program);
|
||||
#else
|
||||
fprintf (file, "usage: %s [-vqVh] [-f FORMAT] [pattern] {element ...} \n",
|
||||
fprintf (file, "usage: %s [-vbqVh] [-f FORMAT] [pattern] {element ...} \n",
|
||||
program);
|
||||
#endif
|
||||
fprintf (file, "List fonts matching [pattern]\n");
|
||||
fprintf (file, "\n");
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, " -v, --verbose display entire font pattern verbosely\n");
|
||||
fprintf (file, " -b, --brief display entire font pattern briefly\n");
|
||||
fprintf (file, " -f, --format=FORMAT use the given output format\n");
|
||||
fprintf (file, " -q, --quiet suppress all normal output, exit 1 if no fonts matched\n");
|
||||
fprintf (file, " -V, --version display font config version and exit\n");
|
||||
fprintf (file, " -h, --help display this help and exit\n");
|
||||
#else
|
||||
fprintf (file, " -v (verbose) display entire font pattern verbosely\n");
|
||||
fprintf (file, " -b (brief) display entire font pattern briefly\n");
|
||||
fprintf (file, " -f FORMAT (format) use the given output format\n");
|
||||
fprintf (file, " -q, (quiet) suppress all normal output, exit 1 if no fonts matched\n");
|
||||
fprintf (file, " -V (version) display font config version and exit\n");
|
||||
|
@ -95,6 +98,7 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
int verbose = 0;
|
||||
int brief = 0;
|
||||
int quiet = 0;
|
||||
const FcChar8 *format = NULL;
|
||||
int nfont = 0;
|
||||
|
@ -106,15 +110,18 @@ main (int argc, char **argv)
|
|||
int c;
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
while ((c = getopt_long (argc, argv, "vf:qVh", longopts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "vbf:qVh", longopts, NULL)) != -1)
|
||||
#else
|
||||
while ((c = getopt (argc, argv, "vf:qVh")) != -1)
|
||||
while ((c = getopt (argc, argv, "vbf:qVh")) != -1)
|
||||
#endif
|
||||
{
|
||||
switch (c) {
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'b':
|
||||
brief = 1;
|
||||
break;
|
||||
case 'f':
|
||||
format = (FcChar8 *) strdup (optarg);
|
||||
break;
|
||||
|
@ -155,7 +162,7 @@ main (int argc, char **argv)
|
|||
pat = FcPatternCreate ();
|
||||
if (quiet && !os)
|
||||
os = FcObjectSetCreate ();
|
||||
if (!verbose && !format && !os)
|
||||
if (!verbose && !brief && !format && !os)
|
||||
os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, FC_FILE, (char *) 0);
|
||||
if (!format)
|
||||
format = (const FcChar8 *) "%{=fclist}\n";
|
||||
|
@ -171,8 +178,13 @@ main (int argc, char **argv)
|
|||
|
||||
for (j = 0; j < fs->nfont; j++)
|
||||
{
|
||||
if (verbose)
|
||||
if (verbose || brief)
|
||||
{
|
||||
if (brief)
|
||||
{
|
||||
FcPatternDel (fs->fonts[j], FC_CHARSET);
|
||||
FcPatternDel (fs->fonts[j], FC_LANG);
|
||||
}
|
||||
FcPatternPrint (fs->fonts[j]);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -52,6 +52,7 @@ static const struct option longopts[] = {
|
|||
{"sort", 0, 0, 's'},
|
||||
{"all", 0, 0, 'a'},
|
||||
{"verbose", 0, 0, 'v'},
|
||||
{"brief", 0, 0, 'b'},
|
||||
{"format", 1, 0, 'f'},
|
||||
{"version", 0, 0, 'V'},
|
||||
{"help", 0, 0, 'h'},
|
||||
|
@ -69,7 +70,7 @@ usage (char *program, int error)
|
|||
{
|
||||
FILE *file = error ? stderr : stdout;
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, "usage: %s [-savVh] [-f FORMAT] [--sort] [--all] [--verbose] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n",
|
||||
fprintf (file, "usage: %s [-savbVh] [-f FORMAT] [--sort] [--all] [--verbose] [--brief] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n",
|
||||
program);
|
||||
#else
|
||||
fprintf (file, "usage: %s [-savVh] [-f FORMAT] [pattern] {element...}\n",
|
||||
|
@ -81,6 +82,7 @@ usage (char *program, int error)
|
|||
fprintf (file, " -s, --sort display sorted list of matches\n");
|
||||
fprintf (file, " -a, --all display unpruned sorted list of matches\n");
|
||||
fprintf (file, " -v, --verbose display entire font pattern verbosely\n");
|
||||
fprintf (file, " -b, --brief display entire font pattern briefly\n");
|
||||
fprintf (file, " -f, --format=FORMAT use the given output format\n");
|
||||
fprintf (file, " -V, --version display font config version and exit\n");
|
||||
fprintf (file, " -h, --help display this help and exit\n");
|
||||
|
@ -88,6 +90,7 @@ usage (char *program, int error)
|
|||
fprintf (file, " -s, (sort) display sorted list of matches\n");
|
||||
fprintf (file, " -a (all) display unpruned sorted list of matches\n");
|
||||
fprintf (file, " -v (verbose) display entire font pattern verbosely\n");
|
||||
fprintf (file, " -b (brief) display entire font pattern briefly\n");
|
||||
fprintf (file, " -f FORMAT (format) use the given output format\n");
|
||||
fprintf (file, " -V (version) display font config version and exit\n");
|
||||
fprintf (file, " -h (help) display this help and exit\n");
|
||||
|
@ -99,6 +102,7 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
int verbose = 0;
|
||||
int brief = 0;
|
||||
int sort = 0, all = 0;
|
||||
const FcChar8 *format = NULL;
|
||||
int i;
|
||||
|
@ -110,9 +114,9 @@ main (int argc, char **argv)
|
|||
int c;
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
while ((c = getopt_long (argc, argv, "asvf:Vh", longopts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "asvbf:Vh", longopts, NULL)) != -1)
|
||||
#else
|
||||
while ((c = getopt (argc, argv, "asvf:Vh")) != -1)
|
||||
while ((c = getopt (argc, argv, "asvbf:Vh")) != -1)
|
||||
#endif
|
||||
{
|
||||
switch (c) {
|
||||
|
@ -125,6 +129,9 @@ main (int argc, char **argv)
|
|||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'b':
|
||||
brief = 1;
|
||||
break;
|
||||
case 'f':
|
||||
format = (FcChar8 *) strdup (optarg);
|
||||
break;
|
||||
|
@ -218,8 +225,13 @@ main (int argc, char **argv)
|
|||
|
||||
font = FcPatternFilter (fs->fonts[j], os);
|
||||
|
||||
if (verbose)
|
||||
if (verbose || brief)
|
||||
{
|
||||
if (brief)
|
||||
{
|
||||
FcPatternDel (font, FC_CHARSET);
|
||||
FcPatternDel (font, FC_LANG);
|
||||
}
|
||||
FcPatternPrint (font);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
static const struct option longopts[] = {
|
||||
{"ignore-blanks", 0, 0, 'b'},
|
||||
{"index", 1, 0, 'i'},
|
||||
{"brief", 0, 0, 'b'},
|
||||
{"format", 1, 0, 'f'},
|
||||
{"version", 0, 0, 'V'},
|
||||
{"help", 0, 0, 'h'},
|
||||
|
@ -71,23 +71,23 @@ usage (char *program, int error)
|
|||
{
|
||||
FILE *file = error ? stderr : stdout;
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] [--ignore-blanks] [--index index] [--format FORMAT] [--version] [--help] font-file...\n",
|
||||
fprintf (file, "usage: %s [-bVh] [-i index] [-f FORMAT] [--index index] [--brief] [--format FORMAT] [--version] [--help] font-file...\n",
|
||||
program);
|
||||
#else
|
||||
fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] font-file...\n",
|
||||
fprintf (file, "usage: %s [-bVh] [-i index] [-f FORMAT] font-file...\n",
|
||||
program);
|
||||
#endif
|
||||
fprintf (file, "Query font files and print resulting pattern(s)\n");
|
||||
fprintf (file, "\n");
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, " -b, --ignore-blanks ignore blanks to compute langauges\n");
|
||||
fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\n");
|
||||
fprintf (file, " -b, --brief display font pattern briefly\n");
|
||||
fprintf (file, " -f, --format=FORMAT use the given output format\n");
|
||||
fprintf (file, " -V, --version display font config version and exit\n");
|
||||
fprintf (file, " -h, --help display this help and exit\n");
|
||||
#else
|
||||
fprintf (file, " -b (ignore-blanks) ignore blanks to compute languages\n");
|
||||
fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
|
||||
fprintf (file, " -b (brief) display font pattern briefly\n");
|
||||
fprintf (file, " -f FORMAT (format) use the given output format\n");
|
||||
fprintf (file, " -V (version) display font config version and exit\n");
|
||||
fprintf (file, " -h (help) display this help and exit\n");
|
||||
|
@ -98,28 +98,27 @@ usage (char *program, int error)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int id = -1;
|
||||
int ignore_blanks = 0;
|
||||
unsigned int id = (unsigned int) -1;
|
||||
int brief = 0;
|
||||
FcFontSet *fs;
|
||||
FcChar8 *format = NULL;
|
||||
FcBlanks *blanks = NULL;
|
||||
int err = 0;
|
||||
int i;
|
||||
#if HAVE_GETOPT_LONG || HAVE_GETOPT
|
||||
int c;
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
while ((c = getopt_long (argc, argv, "bi:f:Vh", longopts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "i:bf:Vh", longopts, NULL)) != -1)
|
||||
#else
|
||||
while ((c = getopt (argc, argv, "bi:f:Vh")) != -1)
|
||||
while ((c = getopt (argc, argv, "i:bf:Vh")) != -1)
|
||||
#endif
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
ignore_blanks = 1;
|
||||
break;
|
||||
case 'i':
|
||||
id = atoi (optarg);
|
||||
id = (unsigned int) strtol (optarg, NULL, 0); /* strtol() To handle -1. */
|
||||
break;
|
||||
case 'b':
|
||||
brief = 1;
|
||||
break;
|
||||
case 'f':
|
||||
format = (FcChar8 *) strdup (optarg);
|
||||
|
@ -143,14 +142,12 @@ main (int argc, char **argv)
|
|||
usage (argv[0], 1);
|
||||
|
||||
fs = FcFontSetCreate ();
|
||||
if (!ignore_blanks)
|
||||
blanks = FcConfigGetBlanks (NULL);
|
||||
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
if (!FcFreeTypeQueryAll ((FcChar8*) argv[i], id, blanks, NULL, fs))
|
||||
if (!FcFreeTypeQueryAll ((FcChar8*) argv[i], id, NULL, NULL, fs))
|
||||
{
|
||||
fprintf (stderr, "Can't query face %d of font file %s\n", id, argv[i]);
|
||||
fprintf (stderr, "Can't query face %u of font file %s\n", id, argv[i]);
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
@ -159,6 +156,12 @@ main (int argc, char **argv)
|
|||
{
|
||||
FcPattern *pat = fs->fonts[i];
|
||||
|
||||
if (brief)
|
||||
{
|
||||
FcPatternDel (pat, FC_CHARSET);
|
||||
FcPatternDel (pat, FC_LANG);
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
FcChar8 *s;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
static const struct option longopts[] = {
|
||||
{"brief", 0, 0, 'b'},
|
||||
{"format", 1, 0, 'f'},
|
||||
{"version", 0, 0, 'V'},
|
||||
{"help", 0, 0, 'h'},
|
||||
|
@ -69,19 +70,21 @@ usage (char *program, int error)
|
|||
{
|
||||
FILE *file = error ? stderr : stdout;
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, "usage: %s [-Vh] [-f FORMAT] [--format FORMAT] [--version] [--help] font-file...\n",
|
||||
fprintf (file, "usage: %s [-bVh] [-f FORMAT] [--brief] [--format FORMAT] [--version] [--help] font-file...\n",
|
||||
program);
|
||||
#else
|
||||
fprintf (file, "usage: %s [-Vh] [-f FORMAT] font-file...\n",
|
||||
fprintf (file, "usage: %s [-bVh] [-f FORMAT] font-file...\n",
|
||||
program);
|
||||
#endif
|
||||
fprintf (file, "Scan font files and directories, and print resulting pattern(s)\n");
|
||||
fprintf (file, "\n");
|
||||
#if HAVE_GETOPT_LONG
|
||||
fprintf (file, " -b, --brief display font pattern briefly\n");
|
||||
fprintf (file, " -f, --format=FORMAT use the given output format\n");
|
||||
fprintf (file, " -V, --version display font config version and exit\n");
|
||||
fprintf (file, " -h, --help display this help and exit\n");
|
||||
#else
|
||||
fprintf (file, " -b (brief) display font pattern briefly\n");
|
||||
fprintf (file, " -f FORMAT (format) use the given output format\n");
|
||||
fprintf (file, " -V (version) display font config version and exit\n");
|
||||
fprintf (file, " -h (help) display this help and exit\n");
|
||||
|
@ -92,6 +95,7 @@ usage (char *program, int error)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int brief = 0;
|
||||
FcChar8 *format = NULL;
|
||||
int i;
|
||||
FcFontSet *fs;
|
||||
|
@ -105,6 +109,9 @@ main (int argc, char **argv)
|
|||
#endif
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
brief = 1;
|
||||
break;
|
||||
case 'f':
|
||||
format = (FcChar8 *) strdup (optarg);
|
||||
break;
|
||||
|
@ -152,6 +159,12 @@ main (int argc, char **argv)
|
|||
{
|
||||
FcPattern *pat = fs->fonts[i];
|
||||
|
||||
if (brief)
|
||||
{
|
||||
FcPatternDel (pat, FC_CHARSET);
|
||||
FcPatternDel (pat, FC_LANG);
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
FcChar8 *s;
|
||||
|
|
|
@ -51,7 +51,7 @@ FcPatternAddFTFace (FcPattern *p, const char *object, const FT_Face f);
|
|||
FcPublic FcPattern *
|
||||
FcFreeTypeQueryFace (const FT_Face face,
|
||||
const FcChar8 *file,
|
||||
int id,
|
||||
unsigned int id,
|
||||
FcBlanks *blanks);
|
||||
|
||||
_FCFUNCPROTOEND
|
||||
|
|
|
@ -72,8 +72,9 @@ typedef int FcBool;
|
|||
#define _FC_STRINGIFY(s) _FC_STRINGIFY_(s)
|
||||
#define FC_CACHE_VERSION _FC_STRINGIFY(FC_CACHE_VERSION_NUMBER)
|
||||
|
||||
#define FcTrue 1
|
||||
#define FcFalse 0
|
||||
#define FcTrue 1
|
||||
#define FcDontCare 2
|
||||
|
||||
#define FC_FAMILY "family" /* String */
|
||||
#define FC_STYLE "style" /* String */
|
||||
|
@ -99,6 +100,7 @@ typedef int FcBool;
|
|||
#define FC_OUTLINE "outline" /* Bool */
|
||||
#define FC_SCALABLE "scalable" /* Bool */
|
||||
#define FC_COLOR "color" /* Bool */
|
||||
#define FC_VARIABLE "variable" /* Bool */
|
||||
#define FC_SCALE "scale" /* double (deprecated) */
|
||||
#define FC_SYMBOL "symbol" /* Bool */
|
||||
#define FC_DPI "dpi" /* double */
|
||||
|
@ -119,6 +121,7 @@ typedef int FcBool;
|
|||
#define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */
|
||||
#define FC_LCD_FILTER "lcdfilter" /* Int */
|
||||
#define FC_FONT_FEATURES "fontfeatures" /* String */
|
||||
#define FC_FONT_VARIATIONS "fontvariations" /* String */
|
||||
#define FC_NAMELANG "namelang" /* String RFC 3866 langs */
|
||||
#define FC_PRGNAME "prgname" /* String */
|
||||
#define FC_HASH "hash" /* String (deprecated) */
|
||||
|
@ -575,10 +578,10 @@ FcDirCacheUnload (FcCache *cache);
|
|||
|
||||
/* fcfreetype.c */
|
||||
FcPublic FcPattern *
|
||||
FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
|
||||
FcFreeTypeQuery (const FcChar8 *file, unsigned int id, FcBlanks *blanks, int *count);
|
||||
|
||||
FcPublic unsigned int
|
||||
FcFreeTypeQueryAll(const FcChar8 *file, int id, FcBlanks *blanks, int *count, FcFontSet *set);
|
||||
FcFreeTypeQueryAll(const FcChar8 *file, unsigned int id, FcBlanks *blanks, int *count, FcFontSet *set);
|
||||
|
||||
/* fcfs.c */
|
||||
|
||||
|
|
22
src/fccfg.c
22
src/fccfg.c
|
@ -796,14 +796,30 @@ FcConfigCompareValue (const FcValue *left_o,
|
|||
case FcTypeBool:
|
||||
switch ((int) op) {
|
||||
case FcOpEqual:
|
||||
case FcOpContains:
|
||||
case FcOpListing:
|
||||
ret = left.u.b == right.u.b;
|
||||
break;
|
||||
case FcOpContains:
|
||||
case FcOpListing:
|
||||
ret = left.u.b == right.u.b || left.u.b == FcDontCare;
|
||||
break;
|
||||
case FcOpNotEqual:
|
||||
case FcOpNotContains:
|
||||
ret = left.u.b != right.u.b;
|
||||
break;
|
||||
case FcOpNotContains:
|
||||
ret = !(left.u.b == right.u.b || left.u.b == FcDontCare);
|
||||
break;
|
||||
case FcOpLess:
|
||||
ret = left.u.b != right.u.b && right.u.b == FcDontCare;
|
||||
break;
|
||||
case FcOpLessEqual:
|
||||
ret = left.u.b == right.u.b || right.u.b == FcDontCare;
|
||||
break;
|
||||
case FcOpMore:
|
||||
ret = left.u.b != right.u.b && left.u.b == FcDontCare;
|
||||
break;
|
||||
case FcOpMoreEqual:
|
||||
ret = left.u.b == right.u.b || left.u.b == FcDontCare;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,10 @@ _FcValuePrintFile (FILE *f, const FcValue v)
|
|||
fprintf (f, "\"%s\"", v.u.s);
|
||||
break;
|
||||
case FcTypeBool:
|
||||
fprintf (f, "%s", v.u.b ? "True" : "False");
|
||||
fprintf (f,
|
||||
v.u.b == FcTrue ? (FcChar8 *) "True" :
|
||||
v.u.b == FcFalse ? (FcChar8 *) "False" :
|
||||
(FcChar8 *) "DontCare", 0);
|
||||
break;
|
||||
case FcTypeMatrix:
|
||||
fprintf (f, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
|
||||
|
@ -62,7 +65,7 @@ _FcValuePrintFile (FILE *f, const FcValue v)
|
|||
fprintf (f, "face");
|
||||
break;
|
||||
case FcTypeRange:
|
||||
fprintf (f, "[%g %g)", v.u.r->begin, v.u.r->end);
|
||||
fprintf (f, "[%g %g]", v.u.r->begin, v.u.r->end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ static const struct {
|
|||
{ FC_EMBEDDED_BITMAP_OBJECT, FcTrue }, /* !FC_LOAD_NO_BITMAP */
|
||||
{ FC_DECORATIVE_OBJECT, FcFalse },
|
||||
{ FC_SYMBOL_OBJECT, FcFalse },
|
||||
{ FC_VARIABLE_OBJECT, FcFalse },
|
||||
};
|
||||
|
||||
#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
|
||||
|
@ -255,7 +256,14 @@ FcDefaultSubstitute (FcPattern *pattern)
|
|||
FcPatternObjectAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
|
||||
|
||||
if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch)
|
||||
size = 12.0L;
|
||||
{
|
||||
FcRange *r;
|
||||
double b, e;
|
||||
if (FcPatternObjectGetRange (pattern, FC_SIZE_OBJECT, 0, &r) == FcResultMatch && FcRangeGetDouble (r, &b, &e))
|
||||
size = (b + e) * .5;
|
||||
else
|
||||
size = 12.0L;
|
||||
}
|
||||
if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch)
|
||||
scale = 1.0;
|
||||
if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch)
|
||||
|
|
805
src/fcfreetype.c
805
src/fcfreetype.c
File diff suppressed because it is too large
Load Diff
|
@ -485,6 +485,9 @@ FcLangSetCreate (void)
|
|||
void
|
||||
FcLangSetDestroy (FcLangSet *ls)
|
||||
{
|
||||
if (!ls)
|
||||
return;
|
||||
|
||||
if (ls->extra)
|
||||
FcStrSetDestroy (ls->extra);
|
||||
free (ls);
|
||||
|
@ -495,6 +498,9 @@ FcLangSetCopy (const FcLangSet *ls)
|
|||
{
|
||||
FcLangSet *new;
|
||||
|
||||
if (!ls)
|
||||
return NULL;
|
||||
|
||||
new = FcLangSetCreate ();
|
||||
if (!new)
|
||||
goto bail0;
|
||||
|
|
177
src/fcmatch.c
177
src/fcmatch.c
|
@ -25,7 +25,7 @@
|
|||
#include "fcint.h"
|
||||
|
||||
static double
|
||||
FcCompareNumber (FcValue *value1, FcValue *value2)
|
||||
FcCompareNumber (const FcValue *value1, const FcValue *value2, FcValue *bestValue)
|
||||
{
|
||||
double v1, v2, v;
|
||||
|
||||
|
@ -52,23 +52,27 @@ FcCompareNumber (FcValue *value1, FcValue *value2)
|
|||
v = v2 - v1;
|
||||
if (v < 0)
|
||||
v = -v;
|
||||
*bestValue = FcValueCanonicalize (value2);
|
||||
return v;
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareString (FcValue *v1, FcValue *v2)
|
||||
FcCompareString (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
return (double) FcStrCmpIgnoreCase (FcValueString(v1), FcValueString(v2)) != 0;
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareFamily (FcValue *v1, FcValue *v2)
|
||||
FcCompareFamily (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
/* rely on the guarantee in FcPatternObjectAddWithBinding that
|
||||
* families are always FcTypeString. */
|
||||
const FcChar8* v1_string = FcValueString(v1);
|
||||
const FcChar8* v2_string = FcValueString(v2);
|
||||
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
|
||||
if (FcToLower(*v1_string) != FcToLower(*v2_string) &&
|
||||
*v1_string != ' ' && *v2_string != ' ')
|
||||
return 1.0;
|
||||
|
@ -77,13 +81,15 @@ FcCompareFamily (FcValue *v1, FcValue *v2)
|
|||
}
|
||||
|
||||
static double
|
||||
FcComparePostScript (FcValue *v1, FcValue *v2)
|
||||
FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
const FcChar8 *v1_string = FcValueString (v1);
|
||||
const FcChar8 *v2_string = FcValueString (v2);
|
||||
int n;
|
||||
size_t len;
|
||||
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
|
||||
if (FcToLower (*v1_string) != FcToLower (*v2_string) &&
|
||||
*v1_string != ' ' && *v2_string != ' ')
|
||||
return 1.0;
|
||||
|
@ -95,7 +101,7 @@ FcComparePostScript (FcValue *v1, FcValue *v2)
|
|||
}
|
||||
|
||||
static double
|
||||
FcCompareLang (FcValue *v1, FcValue *v2)
|
||||
FcCompareLang (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
FcLangResult result;
|
||||
FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2);
|
||||
|
@ -130,6 +136,7 @@ FcCompareLang (FcValue *v1, FcValue *v2)
|
|||
default:
|
||||
return -1.0;
|
||||
}
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
switch (result) {
|
||||
case FcLangEqual:
|
||||
return 0;
|
||||
|
@ -142,99 +149,134 @@ FcCompareLang (FcValue *v1, FcValue *v2)
|
|||
}
|
||||
|
||||
static double
|
||||
FcCompareBool (FcValue *v1, FcValue *v2)
|
||||
FcCompareBool (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
if (v2->type != FcTypeBool || v1->type != FcTypeBool)
|
||||
return -1.0;
|
||||
return (double) v2->u.b != v1->u.b;
|
||||
|
||||
if (v2->u.b != FcDontCare)
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
else
|
||||
*bestValue = FcValueCanonicalize (v1);
|
||||
|
||||
return (double) ((v2->u.b ^ v1->u.b) == 1);
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareCharSet (FcValue *v1, FcValue *v2)
|
||||
FcCompareCharSet (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
*bestValue = FcValueCanonicalize (v2); /* TODO Improve. */
|
||||
return (double) FcCharSetSubtractCount (FcValueCharSet(v1), FcValueCharSet(v2));
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareSize (FcValue *value1, FcValue *value2)
|
||||
{
|
||||
double v1, v2, v;
|
||||
|
||||
switch ((int) value1->type) {
|
||||
case FcTypeInteger:
|
||||
v1 = value1->u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
v1 = value1->u.d;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
switch ((int) value2->type) {
|
||||
case FcTypeInteger:
|
||||
v2 = value2->u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
v2 = value2->u.d;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if (v2 == 0)
|
||||
return 0;
|
||||
v = v2 - v1;
|
||||
if (v < 0)
|
||||
v = -v;
|
||||
return v;
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareSizeRange (FcValue *v1, FcValue *v2)
|
||||
FcCompareRange (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
FcValue value1 = FcValueCanonicalize (v1);
|
||||
FcValue value2 = FcValueCanonicalize (v2);
|
||||
FcRange *r1 = NULL, *r2 = NULL;
|
||||
double ret = -1.0;
|
||||
double b1, e1, b2, e2, d;
|
||||
|
||||
switch ((int) value1.type) {
|
||||
case FcTypeInteger:
|
||||
b1 = e1 = value1.u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
r1 = FcRangeCreateDouble (value1.u.d, value1.u.d);
|
||||
b1 = e1 = value1.u.d;
|
||||
break;
|
||||
case FcTypeRange:
|
||||
r1 = FcRangeCopy (value1.u.r);
|
||||
abort();
|
||||
b1 = value1.u.r->begin;
|
||||
e1 = value1.u.r->end;
|
||||
break;
|
||||
default:
|
||||
goto bail;
|
||||
return -1;
|
||||
}
|
||||
switch ((int) value2.type) {
|
||||
case FcTypeInteger:
|
||||
b2 = e2 = value2.u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
r2 = FcRangeCreateDouble (value2.u.d, value2.u.d);
|
||||
b2 = e2 = value2.u.d;
|
||||
break;
|
||||
case FcTypeRange:
|
||||
r2 = FcRangeCopy (value2.u.r);
|
||||
b2 = value2.u.r->begin;
|
||||
e2 = value2.u.r->end;
|
||||
break;
|
||||
default:
|
||||
goto bail;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (FcRangeIsInRange (r1, r2))
|
||||
ret = 0.0;
|
||||
if (e1 < b2)
|
||||
d = b2;
|
||||
else if (e2 < b1)
|
||||
d = e2;
|
||||
else
|
||||
ret = FC_MIN (fabs (r1->end - r2->begin), fabs (r1->begin - r2->end));
|
||||
d = (FC_MAX (b1, b2) + FC_MIN (e1, e2)) * .5;
|
||||
|
||||
bail:
|
||||
if (r1)
|
||||
FcRangeDestroy (r1);
|
||||
if (r2)
|
||||
FcRangeDestroy (r2);
|
||||
bestValue->type = FcTypeDouble;
|
||||
bestValue->u.d = d;
|
||||
|
||||
return ret;
|
||||
/* If the ranges overlap, it's a match, otherwise return closest distance. */
|
||||
if (e1 < b2 || e2 < b1)
|
||||
return FC_MIN (fabs (b2 - e1), fabs (b1 - e2));
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareFilename (FcValue *v1, FcValue *v2)
|
||||
FcCompareSize (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
FcValue value1 = FcValueCanonicalize (v1);
|
||||
FcValue value2 = FcValueCanonicalize (v2);
|
||||
double b1, e1, b2, e2;
|
||||
|
||||
switch ((int) value1.type) {
|
||||
case FcTypeInteger:
|
||||
b1 = e1 = value1.u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
b1 = e1 = value1.u.d;
|
||||
break;
|
||||
case FcTypeRange:
|
||||
abort();
|
||||
b1 = value1.u.r->begin;
|
||||
e1 = value1.u.r->end;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
switch ((int) value2.type) {
|
||||
case FcTypeInteger:
|
||||
b2 = e2 = value2.u.i;
|
||||
break;
|
||||
case FcTypeDouble:
|
||||
b2 = e2 = value2.u.d;
|
||||
break;
|
||||
case FcTypeRange:
|
||||
b2 = value2.u.r->begin;
|
||||
e2 = value2.u.r->end;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
bestValue->type = FcTypeDouble;
|
||||
bestValue->u.d = (b1 + e1) * .5;
|
||||
|
||||
/* If the ranges overlap, it's a match, otherwise return closest distance. */
|
||||
if (e1 < b2 || e2 < b1)
|
||||
return FC_MIN (fabs (b2 - e1), fabs (b1 - e2));
|
||||
if (b2 != e2 && b1 == e2) /* Semi-closed interval. */
|
||||
return 1e-15;
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static double
|
||||
FcCompareFilename (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
|
||||
{
|
||||
const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
|
||||
*bestValue = FcValueCanonicalize (v2);
|
||||
if (FcStrCmp (s1, s2) == 0)
|
||||
return 0.0;
|
||||
else if (FcStrCmpIgnoreCase (s1, s2) == 0)
|
||||
|
@ -255,13 +297,13 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
|
|||
#define PRI_FcCompareFamily(n) PRI1(n)
|
||||
#define PRI_FcCompareString(n) PRI1(n)
|
||||
#define PRI_FcCompareNumber(n) PRI1(n)
|
||||
#define PRI_FcCompareSize(n) PRI1(n)
|
||||
#define PRI_FcCompareBool(n) PRI1(n)
|
||||
#define PRI_FcCompareFilename(n) PRI1(n)
|
||||
#define PRI_FcCompareCharSet(n) PRI1(n)
|
||||
#define PRI_FcCompareLang(n) PRI1(n)
|
||||
#define PRI_FcComparePostScript(n) PRI1(n)
|
||||
#define PRI_FcCompareSizeRange(n) PRI1(n)
|
||||
#define PRI_FcCompareRange(n) PRI1(n)
|
||||
#define PRI_FcCompareSize(n) PRI1(n)
|
||||
|
||||
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
|
||||
|
||||
|
@ -283,6 +325,7 @@ typedef enum _FcMatcherPriorityDummy {
|
|||
typedef enum _FcMatcherPriority {
|
||||
PRI1(FILE),
|
||||
PRI1(FONTFORMAT),
|
||||
PRI1(VARIABLE),
|
||||
PRI1(SCALABLE),
|
||||
PRI1(COLOR),
|
||||
PRI1(FOUNDRY),
|
||||
|
@ -312,7 +355,7 @@ typedef enum _FcMatcherPriority {
|
|||
|
||||
typedef struct _FcMatcher {
|
||||
FcObject object;
|
||||
double (*compare) (FcValue *value1, FcValue *value2);
|
||||
double (*compare) (const FcValue *v1, const FcValue *v2, FcValue *bestValue);
|
||||
int strong, weak;
|
||||
} FcMatcher;
|
||||
|
||||
|
@ -382,7 +425,8 @@ FcCompareValueList (FcObject object,
|
|||
{
|
||||
for (v2 = v2orig, k = 0; v2; v2 = FcValueListNext(v2), k++)
|
||||
{
|
||||
v = (match->compare) (&v1->value, &v2->value);
|
||||
FcValue matchValue;
|
||||
v = (match->compare) (&v1->value, &v2->value, &matchValue);
|
||||
if (v < 0)
|
||||
{
|
||||
*result = FcResultTypeMismatch;
|
||||
|
@ -392,7 +436,7 @@ FcCompareValueList (FcObject object,
|
|||
if (v < best)
|
||||
{
|
||||
if (bestValue)
|
||||
*bestValue = FcValueCanonicalize(&v2->value);
|
||||
*bestValue = matchValue;
|
||||
best = v;
|
||||
pos = k;
|
||||
}
|
||||
|
@ -1017,7 +1061,8 @@ FcFontSetSort (FcConfig *config FC_UNUSED,
|
|||
FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch &&
|
||||
FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch)
|
||||
{
|
||||
double compare = FcCompareLang (&patternLang, &nodeLang);
|
||||
FcValue matchValue;
|
||||
double compare = FcCompareLang (&patternLang, &nodeLang, &matchValue);
|
||||
if (compare >= 0 && compare < 2)
|
||||
{
|
||||
if (FcDebug () & FC_DBG_MATCHV)
|
||||
|
|
19
src/fcname.c
19
src/fcname.c
|
@ -258,6 +258,11 @@ FcNameBool (const FcChar8 *v, FcBool *result)
|
|||
*result = FcFalse;
|
||||
return FcTrue;
|
||||
}
|
||||
if (c0 == 'd' || c0 == 'x' || c0 == '2')
|
||||
{
|
||||
*result = FcDontCare;
|
||||
return FcTrue;
|
||||
}
|
||||
if (c0 == 'o')
|
||||
{
|
||||
c1 = v[1];
|
||||
|
@ -272,6 +277,11 @@ FcNameBool (const FcChar8 *v, FcBool *result)
|
|||
*result = FcFalse;
|
||||
return FcTrue;
|
||||
}
|
||||
if (c1 == 'r')
|
||||
{
|
||||
*result = FcDontCare;
|
||||
return FcTrue;
|
||||
}
|
||||
}
|
||||
return FcFalse;
|
||||
}
|
||||
|
@ -318,7 +328,7 @@ FcNameConvert (FcType type, FcChar8 *string)
|
|||
v.type = FcTypeVoid;
|
||||
break;
|
||||
case FcTypeRange:
|
||||
if (sscanf ((char *) string, "[%lg %lg)", &b, &e) != 2)
|
||||
if (sscanf ((char *) string, "[%lg %lg]", &b, &e) != 2)
|
||||
{
|
||||
v.u.d = strtod ((char *) string, &p);
|
||||
if (p != NULL && p[0] != 0)
|
||||
|
@ -514,7 +524,10 @@ FcNameUnparseValue (FcStrBuf *buf,
|
|||
case FcTypeString:
|
||||
return FcNameUnparseString (buf, v.u.s, escape);
|
||||
case FcTypeBool:
|
||||
return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0);
|
||||
return FcNameUnparseString (buf,
|
||||
v.u.b == FcTrue ? (FcChar8 *) "True" :
|
||||
v.u.b == FcFalse ? (FcChar8 *) "False" :
|
||||
(FcChar8 *) "DontCare", 0);
|
||||
case FcTypeMatrix:
|
||||
sprintf ((char *) temp, "%g %g %g %g",
|
||||
v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
|
||||
|
@ -526,7 +539,7 @@ FcNameUnparseValue (FcStrBuf *buf,
|
|||
case FcTypeFTFace:
|
||||
return FcTrue;
|
||||
case FcTypeRange:
|
||||
sprintf ((char *) temp, "[%g %g)", v.u.r->begin, v.u.r->end);
|
||||
sprintf ((char *) temp, "[%g %g]", v.u.r->begin, v.u.r->end);
|
||||
return FcNameUnparseString (buf, temp, 0);
|
||||
}
|
||||
return FcFalse;
|
||||
|
|
10
src/fcobjs.h
10
src/fcobjs.h
|
@ -29,11 +29,11 @@ FC_OBJECT (STYLELANG, FcTypeString, NULL)
|
|||
FC_OBJECT (FULLNAME, FcTypeString, NULL)
|
||||
FC_OBJECT (FULLNAMELANG, FcTypeString, NULL)
|
||||
FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber)
|
||||
FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber)
|
||||
FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber)
|
||||
FC_OBJECT (SIZE, FcTypeRange, FcCompareSizeRange)
|
||||
FC_OBJECT (WEIGHT, FcTypeRange, FcCompareRange)
|
||||
FC_OBJECT (WIDTH, FcTypeRange, FcCompareRange)
|
||||
FC_OBJECT (SIZE, FcTypeRange, FcCompareSize)
|
||||
FC_OBJECT (ASPECT, FcTypeDouble, NULL)
|
||||
FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize)
|
||||
FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareNumber)
|
||||
FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber)
|
||||
FC_OBJECT (FOUNDRY, FcTypeString, FcCompareString)
|
||||
FC_OBJECT (ANTIALIAS, FcTypeBool, FcCompareBool)
|
||||
|
@ -70,4 +70,6 @@ FC_OBJECT (HASH, FcTypeString, NULL) /* deprecated */
|
|||
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
|
||||
FC_OBJECT (COLOR, FcTypeBool, FcCompareBool)
|
||||
FC_OBJECT (SYMBOL, FcTypeBool, FcCompareBool)
|
||||
FC_OBJECT (FONT_VARIATIONS, FcTypeString, NULL)
|
||||
FC_OBJECT (VARIABLE, FcTypeBool, FcCompareBool)
|
||||
/* ^-------------- Add new objects here. */
|
||||
|
|
|
@ -1113,6 +1113,9 @@ FcPatternDuplicate (const FcPattern *orig)
|
|||
int i;
|
||||
FcValueListPtr l;
|
||||
|
||||
if (!orig)
|
||||
return NULL;
|
||||
|
||||
new = FcPatternCreate ();
|
||||
if (!new)
|
||||
goto bail0;
|
||||
|
|
|
@ -96,9 +96,6 @@ FcRangePromote (double v, FcValuePromotionBuffer *vbuf)
|
|||
FcBool
|
||||
FcRangeIsInRange (const FcRange *a, const FcRange *b)
|
||||
{
|
||||
if (!a || !b)
|
||||
return FcFalse;
|
||||
|
||||
return a->begin >= b->begin && a->end <= b->end;
|
||||
}
|
||||
|
||||
|
@ -107,20 +104,22 @@ FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
|
|||
{
|
||||
switch ((int) op) {
|
||||
case FcOpEqual:
|
||||
return a->begin == b->begin && a->end == b->end;
|
||||
case FcOpContains:
|
||||
case FcOpListing:
|
||||
return FcRangeIsInRange (a, b);
|
||||
case FcOpNotEqual:
|
||||
return a->begin != b->begin || a->end != b->end;
|
||||
case FcOpNotContains:
|
||||
return !FcRangeIsInRange (a, b);
|
||||
case FcOpLess:
|
||||
return a->begin < b->begin;
|
||||
return a->end < b->begin;
|
||||
case FcOpLessEqual:
|
||||
return a->begin <= b->begin;
|
||||
return a->end <= b->begin;
|
||||
case FcOpMore:
|
||||
return a->end > b->end;
|
||||
return a->begin > b->end;
|
||||
case FcOpMoreEqual:
|
||||
return a->end >= b->end;
|
||||
return a->begin >= b->end;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue