X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=src%2Ffcname.c;h=d77eff6f7518d2785d8c634aae13525229f0796f;hb=HEAD;hp=f55190d9e85bde1da58313e7a53b37213c64c533;hpb=551b6b2cd7d94dd90a9eb22bdb752f264afc48ce;p=fontconfig.git diff --git a/src/fcname.c b/src/fcname.c index f55190d..d77eff6 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -1,5 +1,5 @@ /* - * $RCSId: xc/lib/fontconfig/src/fcname.c,v 1.15 2002/09/26 00:17:28 keithp Exp $ + * fontconfig/src/fcname.c * * Copyright © 2000 Keith Packard * @@ -7,15 +7,15 @@ * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in + * documentation, and that the name of the author(s) not be used in * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no + * specific, written prior permission. The authors make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR @@ -28,9 +28,9 @@ #include #include -/* +/* * Please do not change this list, it is used to initialize the object - * list in this order to match the FC_foo_OBJECT constants. Those + * list in this order to match the FC_foo_OBJECT constants. Those * constants are written into cache files. */ @@ -73,7 +73,9 @@ static const FcObjectType _FcBaseObjectTypes[] = { { FC_CAPABILITY, FcTypeString }, { FC_FONTFORMAT, FcTypeString }, { FC_EMBOLDEN, FcTypeBool }, - { FC_EMBEDDED_BITMAP, FcTypeBool }, /* 39 */ + { FC_EMBEDDED_BITMAP, FcTypeBool }, + { FC_DECORATIVE, FcTypeBool }, + { FC_LCD_FILTER, FcTypeInteger }, /* 41 */ }; #define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0]) @@ -167,7 +169,7 @@ FcObjectFindByName (const char *object, FcBool insert) * Hook it into the hash chain */ b = malloc (sizeof(FcObjectBucket)); - if (!b) + if (!b) return NULL; object = (const char *) FcStrCopy ((FcChar8 *) object); if (!object) { @@ -210,7 +212,7 @@ FcObjectHashInsert (const FcObjectType *object, FcBool copy) * Hook it into the hash chain */ b = malloc (sizeof(FcObjectBucket)); - if (!b) + if (!b) return FcFalse; if (copy) { @@ -325,6 +327,20 @@ FcObjectFromName (const char * name) return 0; } +FcObjectSet * +FcObjectGetSet (void) +{ + int i; + FcObjectSet *os = NULL; + + + os = FcObjectSetCreate (); + for (i = 0; i < FcObjectsNumber; i++) + FcObjectSetAdd (os, FcObjects[i].object); + + return os; +} + FcBool FcObjectInit (void) { @@ -390,6 +406,7 @@ static const FcConstant _FcBaseConstants[] = { { (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, }, @@ -404,7 +421,7 @@ static const FcConstant _FcBaseConstants[] = { { (FcChar8 *) "expanded", "width", FC_WIDTH_EXPANDED }, { (FcChar8 *) "extraexpanded", "width", FC_WIDTH_EXTRAEXPANDED }, { (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED }, - + { (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, }, { (FcChar8 *) "dual", "spacing", FC_DUAL, }, { (FcChar8 *) "mono", "spacing", FC_MONO, }, @@ -421,6 +438,22 @@ static const FcConstant _FcBaseConstants[] = { { (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 }, + { (FcChar8 *) "lcdnone", "lcdfilter", FC_LCD_NONE }, + { (FcChar8 *) "lcddefault", "lcdfilter", FC_LCD_DEFAULT }, + { (FcChar8 *) "lcdlight", "lcdfilter", FC_LCD_LIGHT }, + { (FcChar8 *) "lcdlegacy", "lcdfilter", FC_LCD_LEGACY }, }; #define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0]) @@ -462,8 +495,8 @@ FcNameUnregisterConstants (const FcConstant *consts, int nconsts) { const FcConstantList *l, **prev; - for (prev = &_FcConstants; - (l = *prev); + for (prev = &_FcConstants; + (l = *prev); prev = (const FcConstantList **) &(l->next)) { if (l->consts == consts && l->nconsts == nconsts) @@ -553,6 +586,8 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m) break; case FcTypeString: v.u.s = FcStrStaticName(string); + if (!v.u.s) + v.type = FcTypeVoid; break; case FcTypeBool: if (!FcNameBool (string, &v.u.b)) @@ -567,9 +602,13 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m) break; case FcTypeCharSet: v.u.c = FcNameParseCharSet (string); + if (!v.u.c) + v.type = FcTypeVoid; break; case FcTypeLangSet: v.u.l = FcNameParseLangSet (string); + if (!v.u.l) + v.type = FcTypeVoid; break; default: break; @@ -581,7 +620,7 @@ static const FcChar8 * FcNameFindNext (const FcChar8 *cur, const char *delim, FcChar8 *save, FcChar8 *last) { FcChar8 c; - + while ((c = *cur)) { if (c == '\\') @@ -660,7 +699,7 @@ FcNameParse (const FcChar8 *name) 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)) @@ -696,8 +735,20 @@ FcNameParse (const FcChar8 *name) { 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; + } } } } @@ -714,7 +765,7 @@ bail0: return 0; } static FcBool -FcNameUnparseString (FcStrBuf *buf, +FcNameUnparseString (FcStrBuf *buf, const FcChar8 *string, const FcChar8 *escape) { @@ -732,14 +783,14 @@ FcNameUnparseString (FcStrBuf *buf, return FcTrue; } -static FcBool +FcBool FcNameUnparseValue (FcStrBuf *buf, FcValue *v0, FcChar8 *escape) { FcChar8 temp[1024]; FcValue v = FcValueCanonicalize(v0); - + switch (v.type) { case FcTypeVoid: return FcTrue; @@ -754,7 +805,7 @@ FcNameUnparseValue (FcStrBuf *buf, case FcTypeBool: return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0); case FcTypeMatrix: - sprintf ((char *) temp, "%g %g %g %g", + sprintf ((char *) temp, "%g %g %g %g", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy); return FcNameUnparseString (buf, temp, 0); case FcTypeCharSet: @@ -767,7 +818,7 @@ FcNameUnparseValue (FcStrBuf *buf, return FcFalse; } -static FcBool +FcBool FcNameUnparseValueList (FcStrBuf *buf, FcValueListPtr v, FcChar8 *escape) @@ -822,11 +873,10 @@ FcNameUnparseEscaped (FcPattern *pat, FcBool escape) for (i = 0; i < l->ntypes; i++) { o = &l->types[i]; - if (!strcmp (o->object, FC_FAMILY) || - !strcmp (o->object, FC_SIZE) || - !strcmp (o->object, FC_FILE)) + if (!strcmp (o->object, FC_FAMILY) || + !strcmp (o->object, FC_SIZE)) continue; - + e = FcPatternObjectFindElt (pat, FcObjectFromName (o->object)); if (e) { @@ -836,7 +886,7 @@ FcNameUnparseEscaped (FcPattern *pat, FcBool escape) goto bail0; if (!FcNameUnparseString (&buf, (FcChar8 *) "=", 0)) goto bail0; - if (!FcNameUnparseValueList (&buf, FcPatternEltValues(e), escape ? + if (!FcNameUnparseValueList (&buf, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_VARIABLE : 0)) goto bail0; } @@ -847,3 +897,6 @@ bail0: FcStrBufDestroy (&buf); return 0; } +#define __fcname__ +#include "fcaliastail.h" +#undef __fcname__