From 681bb379de1847cf288ba27cf29243c8395cff17 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 25 Oct 2007 22:30:49 -0700 Subject: [PATCH] Respect "binding" attribute in entries. This makes creating "same" aliases for renamed font families far easier. --- fonts.dtd | 2 ++ src/fcxml.c | 58 +++++++++++++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/fonts.dtd b/fonts.dtd index a5c54f9..cbdfdab 100644 --- a/fonts.dtd +++ b/fonts.dtd @@ -114,6 +114,8 @@ name CDATA #REQUIRED> + diff --git a/src/fcxml.c b/src/fcxml.c index 3b08fea..e8cfe1f 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -1288,6 +1288,33 @@ FcParseBool (FcConfigParse *parse) FcStrFree (s); } +static FcBool +FcConfigLexBinding (FcConfigParse *parse, + const FcChar8 *binding_string, + FcValueBinding *binding_ret) +{ + FcValueBinding binding; + + if (!binding_string) + binding = FcValueBindingWeak; + else + { + if (!strcmp ((char *) binding_string, "weak")) + binding = FcValueBindingWeak; + else if (!strcmp ((char *) binding_string, "strong")) + binding = FcValueBindingStrong; + else if (!strcmp ((char *) binding_string, "same")) + binding = FcValueBindingSame; + else + { + FcConfigMessage (parse, FcSevereWarning, "invalid binding \"%s\"", binding_string); + return FcFalse; + } + } + *binding_ret = binding; + return FcTrue; +} + static void FcParseFamilies (FcConfigParse *parse, FcVStackTag tag) { @@ -1357,7 +1384,10 @@ FcParseAlias (FcConfigParse *parse) FcEdit *edit = 0, *next; FcVStack *vstack; FcTest *test; + FcValueBinding binding; + if (!FcConfigLexBinding (parse, FcConfigGetAttribute (parse, "binding"), &binding)) + return; while ((vstack = FcVStackPop (parse))) { switch (vstack->tag) { @@ -1419,7 +1449,7 @@ FcParseAlias (FcConfigParse *parse) FC_FAMILY_OBJECT, FcOpPrepend, prefer, - FcValueBindingWeak); + binding); if (edit) edit->next = 0; else @@ -1432,7 +1462,7 @@ FcParseAlias (FcConfigParse *parse) FC_FAMILY_OBJECT, FcOpAppend, accept, - FcValueBindingWeak); + binding); if (edit) edit->next = next; else @@ -1445,7 +1475,7 @@ FcParseAlias (FcConfigParse *parse) FC_FAMILY_OBJECT, FcOpAppendLast, def, - FcValueBindingWeak); + binding); if (edit) edit->next = next; else @@ -1650,7 +1680,6 @@ FcConfigLexCompare (const FcChar8 *compare) return FcConfigLexOp (compare, fcCompareOps, NUM_COMPARE_OPS); } - static void FcParseTest (FcConfigParse *parse) { @@ -1757,7 +1786,6 @@ FcParseEdit (FcConfigParse *parse) { const FcChar8 *name; const FcChar8 *mode_string; - const FcChar8 *binding_string; FcOp mode; FcValueBinding binding; FcExpr *expr; @@ -1781,23 +1809,9 @@ FcParseEdit (FcConfigParse *parse) return; } } - binding_string = FcConfigGetAttribute (parse, "binding"); - if (!binding_string) - binding = FcValueBindingWeak; - else - { - if (!strcmp ((char *) binding_string, "weak")) - binding = FcValueBindingWeak; - else if (!strcmp ((char *) binding_string, "strong")) - binding = FcValueBindingStrong; - else if (!strcmp ((char *) binding_string, "same")) - binding = FcValueBindingSame; - else - { - FcConfigMessage (parse, FcSevereWarning, "invalid edit binding \"%s\"", binding_string); - return; - } - } + if (!FcConfigLexBinding (parse, FcConfigGetAttribute (parse, "binding"), &binding)) + return; + expr = FcPopBinary (parse, FcOpComma); edit = FcEditCreate (parse, FcObjectFromName ((char *) name), mode, expr, binding); -- 2.39.5