src/fccfg.c | 5 ++ src/fcdbg.c | 2 + src/fcint.h | 2 + src/fcxml.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 127 insertions(+), 2 deletions(-) diff --git a/src/fccfg.c b/src/fccfg.c index fc06220..e3d1a34 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -897,6 +897,11 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e) v.u.c = e->u.cval; v = FcValueSave (v); break; + case FcOpLangSet: + v.type = FcTypeLangSet; + v.u.l = e->u.lval; + v = FcValueSave (v); + break; case FcOpBool: v.type = FcTypeBool; v.u.b = e->u.bval; diff --git a/src/fcdbg.c b/src/fcdbg.c index bdb8fa2..44e839f 100644 --- a/src/fcdbg.c +++ b/src/fcdbg.c @@ -193,6 +193,7 @@ FcOpPrint (FcOp op) case FcOpRound: printf ("Round"); break; case FcOpTrunc: printf ("Trunc"); break; case FcOpListing: printf ("Listing"); break; + case FcOpLangSet: printf ("LangSet"); break; case FcOpInvalid: printf ("Invalid"); break; } } @@ -212,6 +213,7 @@ FcExprPrint (const FcExpr *expr) expr->u.mval->yy); break; case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break; case FcOpCharSet: printf ("charset\n"); break; + case FcOpLangSet: printf ("langset:"); FcLangSetPrint(expr->u.lval); printf ("\n"); break; case FcOpNil: printf ("nil\n"); break; case FcOpField: printf ("%s", FcObjectName(expr->u.object)); break; case FcOpConst: printf ("%s", expr->u.constant); break; diff --git a/src/fcint.h b/src/fcint.h index 46b6ddd..9acd2de 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -227,6 +227,7 @@ typedef enum _FcOp { FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual, FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide, FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc, + FcOpLangSet, FcOpInvalid } FcOp; @@ -239,6 +240,7 @@ typedef struct _FcExpr { FcMatrix *mval; FcBool bval; FcCharSet *cval; + FcLangSet *lval; FcObject object; FcChar8 *constant; struct { diff --git a/src/fcxml.c b/src/fcxml.c index b03385f..d9d962a 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -158,6 +158,28 @@ FcExprCreateConst (FcConfig *config, const FcChar8 *constant) } static FcExpr * +FcExprCreateCharSet (FcConfig *config, FcCharSet *charset) +{ + FcExpr *e = FcConfigAllocExpr (config); + if (e) { + e->op = FcOpCharSet; + e->u.cval = FcCharSetCopy (charset); + } + return e; +} + +static FcExpr * +FcExprCreateLangSet (FcConfig *config, FcLangSet *langset) +{ + FcExpr *e = FcConfigAllocExpr (config); + if (e) { + e->op = FcOpLangSet; + e->u.lval = FcLangSetCopy (langset); + } + return e; +} + +static FcExpr * FcExprCreateOp (FcConfig *config, FcExpr *left, FcOp op, FcExpr *right) { FcExpr *e = FcConfigAllocExpr (config); @@ -188,6 +210,9 @@ FcExprDestroy (FcExpr *e) case FcOpCharSet: FcCharSetDestroy (e->u.cval); break; + case FcOpLangSet: + FcLangSetDestroy (e->u.lval); + break; case FcOpBool: break; case FcOpField: @@ -301,6 +326,7 @@ typedef enum _FcElement { FcElementCeil, FcElementRound, FcElementTrunc, + FcElementLangSet, FcElementUnknown } FcElement; @@ -362,6 +388,7 @@ static const struct { { "ceil", FcElementCeil }, { "round", FcElementRound }, { "trunc", FcElementTrunc }, + { "langset", FcElementLangSet }, }; #define NUM_ELEMENT_MAPS (int) (sizeof fcElementMap / sizeof fcElementMap[0]) @@ -405,7 +432,10 @@ typedef enum _FcVStackTag { FcVStackTest, FcVStackExpr, - FcVStackEdit + FcVStackEdit, + + FcVStackCharSet, + FcVStackLangSet } FcVStackTag; typedef struct _FcVStack { @@ -427,6 +457,9 @@ typedef struct _FcVStack { FcEdit *edit; FcPattern *pattern; + + FcCharSet *charset; + FcLangSet *langset; } u; } FcVStack; @@ -551,6 +584,9 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type) case FcOpCharSet: FcTypecheckValue (parse, FcTypeCharSet, type); break; + case FcOpLangSet: + FcTypecheckValue (parse, FcTypeLangSet, type); + break; case FcOpNil: break; case FcOpField: @@ -796,6 +832,28 @@ FcVStackPushPattern (FcConfigParse *parse, FcPattern *pattern) return FcTrue; } +static FcBool +FcVStackPushCharSet (FcConfigParse *parse, FcCharSet *charset) +{ + FcVStack *vstack = FcVStackCreateAndPush (parse); + if (!vstack) + return FcFalse; + vstack->u.charset = charset; + vstack->tag = FcVStackCharSet; + return FcTrue; +} + +static FcBool +FcVStackPushLangSet (FcConfigParse *parse, FcLangSet *langset) +{ + FcVStack *vstack = FcVStackCreateAndPush (parse); + if (!vstack) + return FcFalse; + vstack->u.langset = langset; + vstack->tag = FcVStackLangSet; + return FcTrue; +} + static FcVStack * FcVStackFetch (FcConfigParse *parse, int off) { @@ -857,6 +915,10 @@ FcVStackPopAndDestroy (FcConfigParse *parse) case FcVStackEdit: FcEditDestroy (vstack->u.edit); break; + case FcVStackCharSet: + break; + case FcVStackLangSet: + break; } if (vstack == &parse->vstack_static[parse->vstack_static_used - 1]) @@ -1526,6 +1588,12 @@ FcPopExpr (FcConfigParse *parse) break; case FcVStackEdit: break; + case FcVStackCharSet: + expr = FcExprCreateCharSet (parse->config, vstack->u.charset); + break; + case FcVStackLangSet: + expr = FcExprCreateLangSet (parse->config, vstack->u.langset); + break; default: break; } @@ -1934,6 +2002,14 @@ FcPopValue (FcConfigParse *parse) value.u.b = vstack->u.bool_; value.type = FcTypeBool; break; + case FcVStackCharSet: + value.u.c = FcCharSetCopy (vstack->u.charset); + value.type = FcTypeCharSet; + break; + case FcVStackLangSet: + value.u.l = FcLangSetCopy (vstack->u.langset); + value.type = FcTypeLangSet; + break; default: FcConfigMessage (parse, FcSevereWarning, "unknown pattern element %d", vstack->tag); @@ -2016,6 +2092,43 @@ FcParsePattern (FcConfigParse *parse) } static void +FcParseCharSet (FcConfigParse *parse) +{ + FcChar8 *s; + const FcCharSet *charset; + + if (!parse->pstack) + return; + s = FcStrBufDoneStatic (&parse->pstack->str); + if (!s) { + FcConfigMessage (parse, FcSevereError, "out of memory"); + return; + } + charset = FcLangGetCharSet(s); + FcVStackPushCharSet (parse, charset); + FcStrBufDestroy (&parse->pstack->str); +} + +static void +FcParseLangSet (FcConfigParse *parse) +{ + FcChar8 *s; + FcLangSet *ls; + + if (!parse->pstack) + return; + s = FcStrBufDoneStatic (&parse->pstack->str); + if (!s) { + FcConfigMessage (parse, FcSevereError, "out of memory"); + return; + } + ls = FcLangSetCreate(); + FcLangSetAdd(ls, s); + FcVStackPushLangSet (parse, ls); + FcStrBufDestroy (&parse->pstack->str); +} + +static void FcEndElement(void *userData, const XML_Char *name) { FcConfigParse *parse = userData; @@ -2203,7 +2316,10 @@ FcEndElement(void *userData, const XML_Char *name) FcParseBool (parse); break; case FcElementCharset: -/* FcParseCharset (parse); */ + FcParseCharSet (parse); + break; + case FcElementLangSet: + FcParseLangSet (parse); break; case FcElementSelectfont: break;