CONF_FILES = \
10LohitGujarati.conf \
10-fonts-persian.conf \
+ 60-delicious.conf \
autohint.conf \
no-bitmaps.conf \
no-sub-pixel.conf \
a (possibly empty) list of <sgmltag>edit</> elements. Patterns which match all of the
tests are subjected to all the edits. If 'target' is set to "font" instead
of the default "pattern", then this element applies to the font name
-resulting from a match rather than a font pattern to be matched.
+resulting from a match rather than a font pattern to be matched. If 'target'
+is set to "scan", then this element applies when the font is scanned to
+build the fontconfig database.
</para></refsect2>
<refsect2><title><sgmltag>test qual="any" name="property" target="default" compare="eq"</></title><para>
This element contains a single value which is compared with the target
-('pattern', 'font' or 'default') property "property" (substitute any of the property names seen
+('pattern', 'font', 'scan' or 'default') property "property" (substitute any of the property names seen
above). 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", or
"more_eq". 'qual' may either be the default, "any", in which case the match
succeeds if any value associated with the property matches the test value, or
#define FC_FONTFORMAT "fontformat" /* String */
#define FC_EMBOLDEN "embolden" /* Bool - true if emboldening needed*/
#define FC_EMBEDDED_BITMAP "embeddedbitmap" /* Bool - true to enable embedded bitmaps */
+#define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */
#define FC_CACHE_SUFFIX ".cache-"FC_CACHE_VERSION
#define FC_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION
} FcObjectSet;
typedef enum _FcMatchKind {
- FcMatchPattern, FcMatchFont
+ FcMatchPattern, FcMatchFont, FcMatchScan
} FcMatchKind;
typedef enum _FcLangResult {
-->
<!ELEMENT match (test*, edit*)>
<!ATTLIST match
- target (pattern|font) "pattern">
+ target (pattern|font|scan) "pattern">
<!--
Match a field in a pattern
For match elements with target=font, if test 'target' is 'pattern',
then the test is applied to the pattern used in matching rather than
to the resulting font.
+
+ Match elements with target=scan are applied as fonts are scanned.
+ They edit the pattern generated from the scanned font and affect
+ what the fontconfig database contains.
-->
<!ELEMENT test (%expr;)*>
<!ATTLIST test
FcTest *t;
int num;
+ switch (kind) {
+ case FcMatchPattern:
+ prev = &config->substPattern;
+ break;
+ case FcMatchFont:
+ prev = &config->substFont;
+ break;
+ case FcMatchScan:
+ prev = &config->substScan;
+ break;
+ default:
+ return FcFalse;
+ }
subst = (FcSubst *) malloc (sizeof (FcSubst));
if (!subst)
return FcFalse;
FcMemAlloc (FC_MEM_SUBST, sizeof (FcSubst));
- if (kind == FcMatchPattern)
- prev = &config->substPattern;
- else
- prev = &config->substFont;
for (; *prev; prev = &(*prev)->next);
*prev = subst;
subst->next = 0;
return FcFalse;
}
+ switch (kind) {
+ case FcMatchPattern:
+ s = config->substPattern;
+ break;
+ case FcMatchFont:
+ s = config->substFont;
+ break;
+ case FcMatchScan:
+ s = config->substScan;
+ break;
+ default:
+ return FcFalse;
+ }
+
st = (FcSubState *) malloc (config->maxObjects * sizeof (FcSubState));
if (!st && config->maxObjects)
return FcFalse;
printf ("FcConfigSubstitute ");
FcPatternPrint (p);
}
- if (kind == FcMatchPattern)
- s = config->substPattern;
- else
- s = config->substFont;
for (; s; s = s->next)
{
/*
intptr_t *leaves = FcCharSetLeaves (c);
FcChar16 *numbers = FcCharSetNumbers (c);
+#if 0
printf ("CharSet 0x%x\n", (intptr_t) c);
printf ("Leaves: +%d = 0x%x\n", c->leaves_offset, (intptr_t) leaves);
printf ("Numbers: +%d = 0x%x\n", c->numbers_offset, (intptr_t) numbers);
i, numbers[i], leaves[i],
(intptr_t) FcOffsetToPtr (leaves, leaves[i], FcCharLeaf));
}
+#endif
for (i = 0; i < c->num; i++)
{
intptr_t leaf_offset = leaves[i];
FcCharLeaf *leaf = FcOffsetToPtr (leaves, leaf_offset, FcCharLeaf);
+ if (i)
+ printf ("\t");
printf ("%04x:", numbers[i]);
for (j = 0; j < 256/32; j++)
printf (" %08x", leaf->map[j]);
case FcMatchFont:
printf ("font ");
break;
+ case FcMatchScan:
+ printf ("scan ");
+ break;
}
switch (test->qual) {
case FcQualAny:
{ FC_AUTOHINT_OBJECT, FcFalse }, /* FC_LOAD_FORCE_AUTOHINT */
{ FC_GLOBAL_ADVANCE_OBJECT, FcTrue }, /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
{ FC_EMBEDDED_BITMAP_OBJECT, FcTrue }, /* !FC_LOAD_NO_BITMAP */
+ { FC_DECORATIVE_OBJECT, FcFalse },
};
#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
font = FcFreeTypeQuery (file, id, blanks, &count);
if (FcDebug () & FC_DBG_SCAN)
printf ("done\n");
+
+ /*
+ * Edit pattern with user-defined rules
+ */
+ if (config && !FcConfigSubstituteWithPat (config, font, NULL, FcMatchScan))
+ {
+ FcPatternDestroy (font);
+ font = NULL;
+ ret = FcFalse;
+ }
+
/*
* Add the font
*/
if (font && (!config || FcConfigAcceptFont (config, font)))
{
+ if (FcDebug() & FC_DBG_SCANV)
+ {
+ printf ("Final font pattern:\n");
+ FcPatternPrint (font);
+ }
if (!FcFontSetAdd (set, font))
{
FcPatternDestroy (font);
- font = 0;
+ font = NULL;
ret = FcFalse;
}
}
{ (FC8) "demibold", FC_WEIGHT_DEMIBOLD },
{ (FC8) "demi", FC_WEIGHT_DEMIBOLD },
{ (FC8) "semibold", FC_WEIGHT_SEMIBOLD },
- { (FC8) "bold", FC_WEIGHT_BOLD },
{ (FC8) "extrabold", FC_WEIGHT_EXTRABOLD },
+ { (FC8) "superbold", FC_WEIGHT_EXTRABOLD },
{ (FC8) "ultrabold", FC_WEIGHT_ULTRABOLD },
+ { (FC8) "bold", FC_WEIGHT_BOLD },
{ (FC8) "black", FC_WEIGHT_BLACK },
{ (FC8) "heavy", FC_WEIGHT_HEAVY },
};
static const FcStringConst slantConsts[] = {
{ (FC8) "italic", FC_SLANT_ITALIC },
+ { (FC8) "kursiv", FC_SLANT_ITALIC },
{ (FC8) "oblique", FC_SLANT_OBLIQUE },
};
#define FcIsSlant(s) FcStringIsConst(s,slantConsts,NUM_SLANT_CONSTS)
#define FcContainsSlant(s) FcStringContainsConst (s,slantConsts,NUM_SLANT_CONSTS)
+static const FcStringConst decorativeConsts[] = {
+ { (FC8) "shadow", FcTrue },
+ { (FC8) "smallcaps", FcTrue },
+ { (FC8) "antiqua", FcTrue },
+ { (FC8) "romansc", FcTrue },
+ { (FC8) "embosed", FcTrue },
+ { (FC8) "romansmallcaps", FcTrue },
+};
+
+#define NUM_DECORATIVE_CONSTS (int) (sizeof (decorativeConsts) / sizeof (decorativeConsts[0]))
+
+#define FcIsDecorative(s) FcStringIsConst(s,decorativeConsts,NUM_DECORATIVE_CONSTS)
+#define FcContainsDecorative(s) FcStringContainsConst (s,decorativeConsts,NUM_DECORATIVE_CONSTS)
+
static double
FcGetPixelSize (FT_Face face, int i)
{
int slant = -1;
int weight = -1;
int width = -1;
+ FcBool decorative = FcFalse;
int i;
FcCharSet *cs;
FcLangSet *ls;
weight = FC_WEIGHT_EXTRABOLD;
else if (os2->usWeightClass < 950)
weight = FC_WEIGHT_BLACK;
+ if ((FcDebug() & FC_DBG_SCANV) && weight != -1)
+ printf ("\tos2 weight class %d maps to weight %d\n",
+ os2->usWeightClass, weight);
switch (os2->usWidthClass) {
case 1: width = FC_WIDTH_ULTRACONDENSED; break;
case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
}
+ if ((FcDebug() & FC_DBG_SCANV) && width != -1)
+ printf ("\tos2 width class %d maps to width %d\n",
+ os2->usWidthClass, width);
}
if (os2 && (complex = FcFontCapabilities(face)))
{
if (FcDebug() & FC_DBG_SCANV)
printf ("\tStyle %s maps to slant %d\n", style, slant);
}
+ if (decorative == FcFalse)
+ {
+ decorative = FcContainsDecorative (style) > 0;
+ if (FcDebug() & FC_DBG_SCANV)
+ printf ("\tStyle %s maps to decorative %d\n", style, decorative);
+ }
}
/*
* Pull default values from the FreeType flags if more
if (!FcPatternAddString (pat, FC_FOUNDRY, foundry))
goto bail1;
+ if (!FcPatternAddBool (pat, FC_DECORATIVE, decorative))
+ goto bail1;
+
/*
* Compute the unicode coverage for the font
*/
*/
FcSubst *substPattern; /* substitutions for patterns */
FcSubst *substFont; /* substitutions for fonts */
+ FcSubst *substScan; /* substitutions for scanned fonts */
int maxObjects; /* maximum number of tests in all substs */
/*
* List of patterns used to control font file selection
#define FC_FONTFORMAT_OBJECT 37
#define FC_EMBOLDEN_OBJECT 38
#define FC_EMBEDDED_BITMAP_OBJECT 39
+#define FC_DECORATIVE_OBJECT 40
FcBool
FcNameBool (const FcChar8 *v, FcBool *result);
#define MATCH_WIDTH 9
#define MATCH_WIDTH_INDEX 10
- { FC_ANTIALIAS_OBJECT, FcCompareBool, 11, 11 },
-#define MATCH_ANTIALIAS 10
-#define MATCH_ANTIALIAS_INDEX 11
+ { FC_DECORATIVE_OBJECT, FcCompareBool, 11, 11 },
+#define MATCH_DECORATIVE 11
+#define MATCH_DECORATIVE_INDEX 12
+
+ { FC_ANTIALIAS_OBJECT, FcCompareBool, 12, 12 },
+
+#define MATCH_ANTIALIAS 11
+#define MATCH_ANTIALIAS_INDEX 12
- { FC_RASTERIZER_OBJECT, FcCompareString, 12, 12 },
-#define MATCH_RASTERIZER 11
-#define MATCH_RASTERIZER_INDEX 12
+ { FC_RASTERIZER_OBJECT, FcCompareString, 13, 13 },
+#define MATCH_RASTERIZER 12
+#define MATCH_RASTERIZER_INDEX 12
- { FC_OUTLINE_OBJECT, FcCompareBool, 13, 13 },
-#define MATCH_OUTLINE 12
-#define MATCH_OUTLINE_INDEX 13
+ { FC_OUTLINE_OBJECT, FcCompareBool, 14, 14 },
+#define MATCH_OUTLINE 13
+#define MATCH_OUTLINE_INDEX 14
- { FC_FONTVERSION_OBJECT, FcCompareNumber, 14, 14 },
-#define MATCH_FONTVERSION 13
-#define MATCH_FONTVERSION_INDEX 14
+ { FC_FONTVERSION_OBJECT, FcCompareNumber, 15, 15 },
+#define MATCH_FONTVERSION 14
+#define MATCH_FONTVERSION_INDEX 15
};
-#define NUM_MATCH_VALUES 15
+#define NUM_MATCH_VALUES 16
static FcMatcher*
FcObjectToMatcher (FcObject object)
i = MATCH_RASTERIZER; break;
case FC_OUTLINE_OBJECT:
i = MATCH_OUTLINE; break;
+ case FC_DECORATIVE_OBJECT:
+ i = MATCH_DECORATIVE; break;
}
if (i < 0)
{ FC_CAPABILITY, FcTypeString },
{ FC_FONTFORMAT, FcTypeString },
{ FC_EMBOLDEN, FcTypeBool },
- { FC_EMBEDDED_BITMAP, FcTypeBool }, /* 39 */
+ { FC_EMBEDDED_BITMAP, FcTypeBool },
+ { FC_DECORATIVE, FcTypeBool }, /* 40 */
};
#define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
{ (FcChar8 *) "extrabold", "weight", FC_WEIGHT_EXTRABOLD, },
{ (FcChar8 *) "ultrabold", "weight", FC_WEIGHT_EXTRABOLD, },
{ (FcChar8 *) "black", "weight", FC_WEIGHT_BLACK, },
+ { (FcChar8 *) "heavy", "weight", FC_WEIGHT_HEAVY, },
{ (FcChar8 *) "roman", "slant", FC_SLANT_ROMAN, },
{ (FcChar8 *) "italic", "slant", FC_SLANT_ITALIC, },
{ (FcChar8 *) "hintslight", "hintstyle", FC_HINT_SLIGHT },
{ (FcChar8 *) "hintmedium", "hintstyle", FC_HINT_MEDIUM },
{ (FcChar8 *) "hintfull", "hintstyle", FC_HINT_FULL },
+
+ { (FcChar8 *) "antialias", "antialias", FcTrue },
+ { (FcChar8 *) "hinting", "hinting", FcTrue },
+ { (FcChar8 *) "verticallayout", "verticallayout", FcTrue },
+ { (FcChar8 *) "autohint", "autohint", FcTrue },
+ { (FcChar8 *) "globaladvance", "globaladvance", FcTrue },
+ { (FcChar8 *) "outline", "outline", FcTrue },
+ { (FcChar8 *) "scalable", "scalable", FcTrue },
+ { (FcChar8 *) "minspace", "minspace", FcTrue },
+ { (FcChar8 *) "embolden", "embolden", FcTrue },
+ { (FcChar8 *) "embeddedbitmap", "embeddedbitmap", FcTrue },
+ { (FcChar8 *) "decorative", "decorative", FcTrue },
};
#define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0])
for (;;)
{
name = FcNameFindNext (name, ":,", save, &delim);
- if (t && strcmp (t->object, _FcBaseObjectTypes[0].object))
+ if (t)
{
v = FcNameConvert (t->type, save, &m);
if (!FcPatternAdd (pat, t->object, v, FcTrue))
{
if ((c = FcNameGetConstant (save)))
{
- if (!FcPatternAddInteger (pat, c->object, c->value))
- goto bail2;
+ t = FcNameGetObjectType ((char *) c->object);
+ switch (t->type) {
+ case FcTypeInteger:
+ case FcTypeDouble:
+ if (!FcPatternAddInteger (pat, c->object, c->value))
+ goto bail2;
+ break;
+ case FcTypeBool:
+ if (!FcPatternAddBool (pat, c->object, c->value))
+ goto bail2;
+ break;
+ default:
+ break;
+ }
}
}
}
kind = FcMatchPattern;
else if (!strcmp ((char *) kind_string, "font"))
kind = FcMatchFont;
+ else if (!strcmp ((char *) kind_string, "scan"))
+ kind = FcMatchScan;
else if (!strcmp ((char *) kind_string, "default"))
kind = FcMatchDefault;
else
kind = FcMatchPattern;
else if (!strcmp ((char *) kind_name, "font"))
kind = FcMatchFont;
+ else if (!strcmp ((char *) kind_name, "scan"))
+ kind = FcMatchScan;
else
{
FcConfigMessage (parse, FcSevereWarning, "invalid match target \"%s\"", kind_name);