Add binding property to edit element

This commit is contained in:
Keith Packard 2002-07-31 01:36:37 +00:00
parent 327a7fd491
commit 6fff2cda0a
5 changed files with 45 additions and 16 deletions

View File

@ -9,12 +9,18 @@
Common X11R6 font directories Common X11R6 font directories
--> -->
<dir>/usr/X11R6/lib/X11/fonts/truetype</dir> <dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir> <dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts/TrueType</dir>
<!-- FONTPATH_END --> <!-- FONTPATH_END -->
<!--
Enable sub-pixel rendering
<match target="font">
<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
-->
<!-- <!--
Accept deprecated 'mono' alias, replacing it with 'monospace' Accept deprecated 'mono' alias, replacing it with 'monospace'
--> -->

View File

@ -140,7 +140,8 @@
<!ELEMENT edit (%expr;)*> <!ELEMENT edit (%expr;)*>
<!ATTLIST edit <!ATTLIST edit
name CDATA #REQUIRED name CDATA #REQUIRED
mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign"> mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign"
binding (weak|strong) "weak">
<!-- <!--
Elements of expressions follow Elements of expressions follow

View File

@ -903,7 +903,7 @@ FcConfigMatchValueList (FcPattern *p,
} }
static FcValueList * static FcValueList *
FcConfigValues (FcPattern *p, FcExpr *e) FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
{ {
FcValueList *l; FcValueList *l;
@ -916,14 +916,14 @@ FcConfigValues (FcPattern *p, FcExpr *e)
if (e->op == FcOpComma) if (e->op == FcOpComma)
{ {
l->value = FcConfigEvaluate (p, e->u.tree.left); l->value = FcConfigEvaluate (p, e->u.tree.left);
l->next = FcConfigValues (p, e->u.tree.right); l->next = FcConfigValues (p, e->u.tree.right, binding);
} }
else else
{ {
l->value = FcConfigEvaluate (p, e); l->value = FcConfigEvaluate (p, e);
l->next = 0; l->next = 0;
} }
l->binding = FcValueBindingWeak; l->binding = binding;
while (l && l->value.type == FcTypeVoid) while (l && l->value.type == FcTypeVoid)
{ {
FcValueList *next = l->next; FcValueList *next = l->next;
@ -1146,7 +1146,7 @@ FcConfigSubstitute (FcConfig *config,
/* /*
* Evaluate the list of expressions * Evaluate the list of expressions
*/ */
l = FcConfigValues (p, e->expr); l = FcConfigValues (p, e->expr, e->binding);
/* /*
* Locate any test associated with this field * Locate any test associated with this field
*/ */

View File

@ -151,6 +151,7 @@ typedef struct _FcEdit {
const char *field; const char *field;
FcOp op; FcOp op;
FcExpr *expr; FcExpr *expr;
FcValueBinding binding;
} FcEdit; } FcEdit;
typedef struct _FcSubst { typedef struct _FcSubst {
@ -515,7 +516,7 @@ void
FcExprDestroy (FcExpr *e); FcExprDestroy (FcExpr *e);
FcEdit * FcEdit *
FcEditCreate (const char *field, FcOp op, FcExpr *expr); FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
void void
FcEditDestroy (FcEdit *e); FcEditDestroy (FcEdit *e);

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.14 2002/06/21 07:01:11 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.16 2002/07/12 19:19:16 keithp Exp $
* *
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -251,7 +251,7 @@ FcExprDestroy (FcExpr *e)
} }
FcEdit * FcEdit *
FcEditCreate (const char *field, FcOp op, FcExpr *expr) FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding)
{ {
FcEdit *e = (FcEdit *) malloc (sizeof (FcEdit)); FcEdit *e = (FcEdit *) malloc (sizeof (FcEdit));
@ -261,6 +261,7 @@ FcEditCreate (const char *field, FcOp op, FcExpr *expr)
e->field = field; /* already saved in grammar */ e->field = field; /* already saved in grammar */
e->op = op; e->op = op;
e->expr = expr; e->expr = expr;
e->binding = binding;
} }
return e; return e;
} }
@ -1170,7 +1171,8 @@ FcParseAlias (FcConfigParse *parse)
{ {
edit = FcEditCreate (FcConfigSaveField ("family"), edit = FcEditCreate (FcConfigSaveField ("family"),
FcOpPrepend, FcOpPrepend,
prefer); prefer,
FcValueBindingWeak);
if (edit) if (edit)
edit->next = 0; edit->next = 0;
else else
@ -1181,7 +1183,8 @@ FcParseAlias (FcConfigParse *parse)
next = edit; next = edit;
edit = FcEditCreate (FcConfigSaveField ("family"), edit = FcEditCreate (FcConfigSaveField ("family"),
FcOpAppend, FcOpAppend,
accept); accept,
FcValueBindingWeak);
if (edit) if (edit)
edit->next = next; edit->next = next;
else else
@ -1192,7 +1195,8 @@ FcParseAlias (FcConfigParse *parse)
next = edit; next = edit;
edit = FcEditCreate (FcConfigSaveField ("family"), edit = FcEditCreate (FcConfigSaveField ("family"),
FcOpAppendLast, FcOpAppendLast,
def); def,
FcValueBindingWeak);
if (edit) if (edit)
edit->next = next; edit->next = next;
else else
@ -1436,7 +1440,9 @@ FcParseEdit (FcConfigParse *parse)
{ {
const FcChar8 *name; const FcChar8 *name;
const FcChar8 *mode_string; const FcChar8 *mode_string;
const FcChar8 *binding_string;
FcOp mode; FcOp mode;
FcValueBinding binding;
FcExpr *expr; FcExpr *expr;
FcEdit *edit; FcEdit *edit;
@ -1458,8 +1464,23 @@ FcParseEdit (FcConfigParse *parse)
return; 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
{
FcConfigMessage (parse, FcSevereWarning, "invalid edit binding \"%s\"", binding_string);
return;
}
}
expr = FcPopExprs (parse, FcOpComma); expr = FcPopExprs (parse, FcOpComma);
edit = FcEditCreate ((char *) FcStrCopy (name), mode, expr); edit = FcEditCreate ((char *) FcStrCopy (name), mode, expr, binding);
if (!edit) if (!edit)
{ {
FcConfigMessage (parse, FcSevereError, "out of memory"); FcConfigMessage (parse, FcSevereError, "out of memory");