Bug 71287 - size specific design selection support in OS/2 table version 5
This feature requires the FreeType 2.5.1 or later at the build time. Besides <range> element allows <double> elements with this changes. This may breaks the cache but not bumping in this change sets at this moment. please be aware if you want to try it and run fc-cache before/after to avoid the weird thing against it.
This commit is contained in:
parent
9260b7ec39
commit
3cd573fc1f
|
@ -321,6 +321,10 @@ AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
|
||||||
#include FT_FREETYPE_H])
|
#include FT_FREETYPE_H])
|
||||||
AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
|
AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
|
||||||
[FT_Bitmap_Size structure includes y_ppem field])
|
[FT_Bitmap_Size structure includes y_ppem field])
|
||||||
|
AC_CHECK_MEMBERS([TT_OS2.usLowerOpticalPointSize, TT_OS2.usUpperOpticalPointSize], [], [], [[
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
#include FT_TRUETYPE_TABLES_H]])
|
||||||
CFLAGS="$fontconfig_save_cflags"
|
CFLAGS="$fontconfig_save_cflags"
|
||||||
LIBS="$fontconfig_save_libs"
|
LIBS="$fontconfig_save_libs"
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@
|
||||||
case FcTypeLangSet: \
|
case FcTypeLangSet: \
|
||||||
__v__.u.l = va_arg (va, const FcLangSet *); \
|
__v__.u.l = va_arg (va, const FcLangSet *); \
|
||||||
break; \
|
break; \
|
||||||
|
case FcTypeRange: \
|
||||||
|
__v__.u.r = va_arg (va, const FcRange *); \
|
||||||
|
break; \
|
||||||
} \
|
} \
|
||||||
if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
|
if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
|
||||||
goto _FcPatternVapBuild_bail1; \
|
goto _FcPatternVapBuild_bail1; \
|
||||||
|
|
|
@ -75,7 +75,7 @@ typedef int FcBool;
|
||||||
#define FC_STYLE "style" /* String */
|
#define FC_STYLE "style" /* String */
|
||||||
#define FC_SLANT "slant" /* Int */
|
#define FC_SLANT "slant" /* Int */
|
||||||
#define FC_WEIGHT "weight" /* Int */
|
#define FC_WEIGHT "weight" /* Int */
|
||||||
#define FC_SIZE "size" /* Double */
|
#define FC_SIZE "size" /* Range (double) */
|
||||||
#define FC_ASPECT "aspect" /* Double */
|
#define FC_ASPECT "aspect" /* Double */
|
||||||
#define FC_PIXEL_SIZE "pixelsize" /* Double */
|
#define FC_PIXEL_SIZE "pixelsize" /* Double */
|
||||||
#define FC_SPACING "spacing" /* Int */
|
#define FC_SPACING "spacing" /* Int */
|
||||||
|
@ -194,7 +194,8 @@ typedef enum _FcType {
|
||||||
FcTypeMatrix,
|
FcTypeMatrix,
|
||||||
FcTypeCharSet,
|
FcTypeCharSet,
|
||||||
FcTypeFTFace,
|
FcTypeFTFace,
|
||||||
FcTypeLangSet
|
FcTypeLangSet,
|
||||||
|
FcTypeRange
|
||||||
} FcType;
|
} FcType;
|
||||||
|
|
||||||
typedef struct _FcMatrix {
|
typedef struct _FcMatrix {
|
||||||
|
@ -231,6 +232,8 @@ typedef struct _FcPattern FcPattern;
|
||||||
|
|
||||||
typedef struct _FcLangSet FcLangSet;
|
typedef struct _FcLangSet FcLangSet;
|
||||||
|
|
||||||
|
typedef struct _FcRange FcRange;
|
||||||
|
|
||||||
typedef struct _FcValue {
|
typedef struct _FcValue {
|
||||||
FcType type;
|
FcType type;
|
||||||
union {
|
union {
|
||||||
|
@ -242,6 +245,7 @@ typedef struct _FcValue {
|
||||||
const FcCharSet *c;
|
const FcCharSet *c;
|
||||||
void *f;
|
void *f;
|
||||||
const FcLangSet *l;
|
const FcLangSet *l;
|
||||||
|
const FcRange *r;
|
||||||
} u;
|
} u;
|
||||||
} FcValue;
|
} FcValue;
|
||||||
|
|
||||||
|
@ -853,6 +857,9 @@ FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
|
||||||
FcPublic FcBool
|
FcPublic FcBool
|
||||||
FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
|
FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
|
||||||
|
|
||||||
|
FcPublic FcBool
|
||||||
|
FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r);
|
||||||
|
|
||||||
FcPublic FcResult
|
FcPublic FcResult
|
||||||
FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i);
|
FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i);
|
||||||
|
|
||||||
|
@ -874,6 +881,9 @@ FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b);
|
||||||
FcPublic FcResult
|
FcPublic FcResult
|
||||||
FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls);
|
FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls);
|
||||||
|
|
||||||
|
FcPublic FcResult
|
||||||
|
FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r);
|
||||||
|
|
||||||
FcPublic FcPattern *
|
FcPublic FcPattern *
|
||||||
FcPatternVaBuild (FcPattern *p, va_list va);
|
FcPatternVaBuild (FcPattern *p, va_list va);
|
||||||
|
|
||||||
|
@ -883,6 +893,20 @@ FcPatternBuild (FcPattern *p, ...) FC_ATTRIBUTE_SENTINEL(0);
|
||||||
FcPublic FcChar8 *
|
FcPublic FcChar8 *
|
||||||
FcPatternFormat (FcPattern *pat, const FcChar8 *format);
|
FcPatternFormat (FcPattern *pat, const FcChar8 *format);
|
||||||
|
|
||||||
|
/* fcrange.c */
|
||||||
|
FcPublic FcRange *
|
||||||
|
FcRangeCreateDouble (double begin, double end);
|
||||||
|
|
||||||
|
FcPublic FcRange *
|
||||||
|
FcRangeCreateInteger (FcChar32 begin, FcChar32 end);
|
||||||
|
|
||||||
|
FcPublic void
|
||||||
|
FcRangeDestroy (FcRange *range);
|
||||||
|
|
||||||
|
FcPublic FcRange *
|
||||||
|
FcRangeCopy (const FcRange *r);
|
||||||
|
|
||||||
|
|
||||||
/* fcstr.c */
|
/* fcstr.c */
|
||||||
|
|
||||||
FcPublic FcChar8 *
|
FcPublic FcChar8 *
|
||||||
|
|
|
@ -151,6 +151,7 @@ libfontconfig_la_SOURCES = \
|
||||||
fcobjs.h \
|
fcobjs.h \
|
||||||
fcobjshash.h \
|
fcobjshash.h \
|
||||||
fcpat.c \
|
fcpat.c \
|
||||||
|
fcrange.c \
|
||||||
fcserialize.c \
|
fcserialize.c \
|
||||||
fcstat.c \
|
fcstat.c \
|
||||||
fcstr.c \
|
fcstr.c \
|
||||||
|
|
48
src/fccfg.c
48
src/fccfg.c
|
@ -722,6 +722,11 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
|
||||||
v.u.l = FcLangSetPromote (v.u.s, buf);
|
v.u.l = FcLangSetPromote (v.u.s, buf);
|
||||||
v.type = FcTypeLangSet;
|
v.type = FcTypeLangSet;
|
||||||
}
|
}
|
||||||
|
if (buf && v.type == FcTypeDouble && u.type == FcTypeRange)
|
||||||
|
{
|
||||||
|
v.u.r = FcRangePromote (v.u.d, buf);
|
||||||
|
v.type = FcTypeRange;
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,6 +899,9 @@ FcConfigCompareValue (const FcValue *left_o,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
ret = FcRangeCompare (op, left.u.r, right.u.r);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -915,10 +923,11 @@ FcConfigCompareValue (const FcValue *left_o,
|
||||||
static FcValue
|
static FcValue
|
||||||
FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
{
|
{
|
||||||
FcValue v, vl, vr;
|
FcValue v, vl, vr, vle, vre;
|
||||||
FcMatrix *m;
|
FcMatrix *m;
|
||||||
FcChar8 *str;
|
FcChar8 *str;
|
||||||
FcOp op = FC_OP_GET_OP (e->op);
|
FcOp op = FC_OP_GET_OP (e->op);
|
||||||
|
FcValuePromotionBuffer buf1, buf2;
|
||||||
|
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpInteger:
|
case FcOpInteger:
|
||||||
|
@ -967,6 +976,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
v.u.l = e->u.lval;
|
v.u.l = e->u.lval;
|
||||||
v = FcValueSave (v);
|
v = FcValueSave (v);
|
||||||
break;
|
break;
|
||||||
|
case FcOpRange:
|
||||||
|
v.type = FcTypeRange;
|
||||||
|
v.u.r = e->u.rval;
|
||||||
|
v = FcValueSave (v);
|
||||||
|
break;
|
||||||
case FcOpBool:
|
case FcOpBool:
|
||||||
v.type = FcTypeBool;
|
v.type = FcTypeBool;
|
||||||
v.u.b = e->u.bval;
|
v.u.b = e->u.bval;
|
||||||
|
@ -1033,28 +1047,28 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
case FcOpDivide:
|
case FcOpDivide:
|
||||||
vl = FcConfigEvaluate (p, p_pat, kind, e->u.tree.left);
|
vl = FcConfigEvaluate (p, p_pat, kind, e->u.tree.left);
|
||||||
vr = FcConfigEvaluate (p, p_pat, kind, e->u.tree.right);
|
vr = FcConfigEvaluate (p, p_pat, kind, e->u.tree.right);
|
||||||
vl = FcConfigPromote (vl, vr, NULL);
|
vle = FcConfigPromote (vl, vr, &buf1);
|
||||||
vr = FcConfigPromote (vr, vl, NULL);
|
vre = FcConfigPromote (vr, vle, &buf2);
|
||||||
if (vl.type == vr.type)
|
if (vle.type == vre.type)
|
||||||
{
|
{
|
||||||
switch ((int) vl.type) {
|
switch ((int) vle.type) {
|
||||||
case FcTypeDouble:
|
case FcTypeDouble:
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpPlus:
|
case FcOpPlus:
|
||||||
v.type = FcTypeDouble;
|
v.type = FcTypeDouble;
|
||||||
v.u.d = vl.u.d + vr.u.d;
|
v.u.d = vle.u.d + vre.u.d;
|
||||||
break;
|
break;
|
||||||
case FcOpMinus:
|
case FcOpMinus:
|
||||||
v.type = FcTypeDouble;
|
v.type = FcTypeDouble;
|
||||||
v.u.d = vl.u.d - vr.u.d;
|
v.u.d = vle.u.d - vre.u.d;
|
||||||
break;
|
break;
|
||||||
case FcOpTimes:
|
case FcOpTimes:
|
||||||
v.type = FcTypeDouble;
|
v.type = FcTypeDouble;
|
||||||
v.u.d = vl.u.d * vr.u.d;
|
v.u.d = vle.u.d * vre.u.d;
|
||||||
break;
|
break;
|
||||||
case FcOpDivide:
|
case FcOpDivide:
|
||||||
v.type = FcTypeDouble;
|
v.type = FcTypeDouble;
|
||||||
v.u.d = vl.u.d / vr.u.d;
|
v.u.d = vle.u.d / vre.u.d;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
|
@ -1071,11 +1085,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpOr:
|
case FcOpOr:
|
||||||
v.type = FcTypeBool;
|
v.type = FcTypeBool;
|
||||||
v.u.b = vl.u.b || vr.u.b;
|
v.u.b = vle.u.b || vre.u.b;
|
||||||
break;
|
break;
|
||||||
case FcOpAnd:
|
case FcOpAnd:
|
||||||
v.type = FcTypeBool;
|
v.type = FcTypeBool;
|
||||||
v.u.b = vl.u.b && vr.u.b;
|
v.u.b = vle.u.b && vre.u.b;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
|
@ -1086,7 +1100,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpPlus:
|
case FcOpPlus:
|
||||||
v.type = FcTypeString;
|
v.type = FcTypeString;
|
||||||
str = FcStrPlus (vl.u.s, vr.u.s);
|
str = FcStrPlus (vle.u.s, vre.u.s);
|
||||||
v.u.s = FcStrdup (str);
|
v.u.s = FcStrdup (str);
|
||||||
FcStrFree (str);
|
FcStrFree (str);
|
||||||
|
|
||||||
|
@ -1105,7 +1119,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
m = malloc (sizeof (FcMatrix));
|
m = malloc (sizeof (FcMatrix));
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
FcMatrixMultiply (m, vl.u.m, vr.u.m);
|
FcMatrixMultiply (m, vle.u.m, vre.u.m);
|
||||||
v.u.m = m;
|
v.u.m = m;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1122,13 +1136,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpPlus:
|
case FcOpPlus:
|
||||||
v.type = FcTypeCharSet;
|
v.type = FcTypeCharSet;
|
||||||
v.u.c = FcCharSetUnion (vl.u.c, vr.u.c);
|
v.u.c = FcCharSetUnion (vle.u.c, vre.u.c);
|
||||||
if (!v.u.c)
|
if (!v.u.c)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
case FcOpMinus:
|
case FcOpMinus:
|
||||||
v.type = FcTypeCharSet;
|
v.type = FcTypeCharSet;
|
||||||
v.u.c = FcCharSetSubtract (vl.u.c, vr.u.c);
|
v.u.c = FcCharSetSubtract (vle.u.c, vre.u.c);
|
||||||
if (!v.u.c)
|
if (!v.u.c)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
@ -1141,13 +1155,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
switch ((int) op) {
|
switch ((int) op) {
|
||||||
case FcOpPlus:
|
case FcOpPlus:
|
||||||
v.type = FcTypeLangSet;
|
v.type = FcTypeLangSet;
|
||||||
v.u.l = FcLangSetUnion (vl.u.l, vr.u.l);
|
v.u.l = FcLangSetUnion (vle.u.l, vre.u.l);
|
||||||
if (!v.u.l)
|
if (!v.u.l)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
case FcOpMinus:
|
case FcOpMinus:
|
||||||
v.type = FcTypeLangSet;
|
v.type = FcTypeLangSet;
|
||||||
v.u.l = FcLangSetSubtract (vl.u.l, vr.u.l);
|
v.u.l = FcLangSetSubtract (vle.u.l, vre.u.l);
|
||||||
if (!v.u.l)
|
if (!v.u.l)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
|
13
src/fcdbg.c
13
src/fcdbg.c
|
@ -29,6 +29,8 @@
|
||||||
static void
|
static void
|
||||||
_FcValuePrintFile (FILE *f, const FcValue v)
|
_FcValuePrintFile (FILE *f, const FcValue v)
|
||||||
{
|
{
|
||||||
|
FcRange r;
|
||||||
|
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case FcTypeUnknown:
|
case FcTypeUnknown:
|
||||||
fprintf (f, "<unknown>");
|
fprintf (f, "<unknown>");
|
||||||
|
@ -61,6 +63,10 @@ _FcValuePrintFile (FILE *f, const FcValue v)
|
||||||
case FcTypeFTFace:
|
case FcTypeFTFace:
|
||||||
fprintf (f, "face");
|
fprintf (f, "face");
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
r = FcRangeCanonicalize (v.u.r);
|
||||||
|
fprintf (f, "(%g, %g)", r.u.d.begin, r.u.d.end);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +267,8 @@ FcOpPrint (FcOp op_)
|
||||||
void
|
void
|
||||||
FcExprPrint (const FcExpr *expr)
|
FcExprPrint (const FcExpr *expr)
|
||||||
{
|
{
|
||||||
|
FcRange r;
|
||||||
|
|
||||||
if (!expr) printf ("none");
|
if (!expr) printf ("none");
|
||||||
else switch (FC_OP_GET_OP (expr->op)) {
|
else switch (FC_OP_GET_OP (expr->op)) {
|
||||||
case FcOpInteger: printf ("%d", expr->u.ival); break;
|
case FcOpInteger: printf ("%d", expr->u.ival); break;
|
||||||
|
@ -277,7 +285,10 @@ FcExprPrint (const FcExpr *expr)
|
||||||
FcExprPrint (expr->u.mexpr->yy);
|
FcExprPrint (expr->u.mexpr->yy);
|
||||||
printf ("]");
|
printf ("]");
|
||||||
break;
|
break;
|
||||||
case FcOpRange: break;
|
case FcOpRange:
|
||||||
|
r = FcRangeCanonicalize (expr->u.rval);
|
||||||
|
printf ("(%g, %g)", r.u.d.begin, r.u.d.end);
|
||||||
|
break;
|
||||||
case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
|
case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
|
||||||
case FcOpCharSet: printf ("charset\n"); break;
|
case FcOpCharSet: printf ("charset\n"); break;
|
||||||
case FcOpLangSet:
|
case FcOpLangSet:
|
||||||
|
|
|
@ -219,6 +219,7 @@ FcDefaultSubstitute (FcPattern *pattern)
|
||||||
{
|
{
|
||||||
FcValue v, namelang, v2;
|
FcValue v, namelang, v2;
|
||||||
int i;
|
int i;
|
||||||
|
double dpi, size, scale, pixelsize;
|
||||||
|
|
||||||
if (FcPatternObjectGet (pattern, FC_WEIGHT_OBJECT, 0, &v) == FcResultNoMatch )
|
if (FcPatternObjectGet (pattern, FC_WEIGHT_OBJECT, 0, &v) == FcResultNoMatch )
|
||||||
FcPatternObjectAddInteger (pattern, FC_WEIGHT_OBJECT, FC_WEIGHT_NORMAL);
|
FcPatternObjectAddInteger (pattern, FC_WEIGHT_OBJECT, FC_WEIGHT_NORMAL);
|
||||||
|
@ -233,32 +234,30 @@ FcDefaultSubstitute (FcPattern *pattern)
|
||||||
if (FcPatternObjectGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch)
|
if (FcPatternObjectGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch)
|
||||||
FcPatternObjectAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
|
FcPatternObjectAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
|
||||||
|
|
||||||
if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) == FcResultNoMatch)
|
|
||||||
{
|
|
||||||
double dpi, size, scale;
|
|
||||||
|
|
||||||
if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch)
|
if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch)
|
||||||
{
|
size = 12.0L;
|
||||||
size = 12.0;
|
|
||||||
(void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT);
|
|
||||||
FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size);
|
|
||||||
}
|
|
||||||
if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch)
|
if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch)
|
||||||
{
|
|
||||||
scale = 1.0;
|
scale = 1.0;
|
||||||
|
if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch)
|
||||||
|
dpi = 75.0;
|
||||||
|
|
||||||
|
if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) != FcResultMatch)
|
||||||
|
{
|
||||||
(void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT);
|
(void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT);
|
||||||
FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale);
|
FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale);
|
||||||
}
|
pixelsize = size * scale;
|
||||||
size *= scale;
|
|
||||||
if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch)
|
|
||||||
{
|
|
||||||
dpi = 75.0;
|
|
||||||
(void) FcPatternObjectDel (pattern, FC_DPI_OBJECT);
|
(void) FcPatternObjectDel (pattern, FC_DPI_OBJECT);
|
||||||
FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi);
|
FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi);
|
||||||
|
pixelsize *= dpi / 72.0;
|
||||||
|
FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, pixelsize);
|
||||||
}
|
}
|
||||||
size *= dpi / 72.0;
|
else
|
||||||
FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, size);
|
{
|
||||||
|
size = v.u.d;
|
||||||
|
size = size / dpi * 72.0 / scale;
|
||||||
}
|
}
|
||||||
|
(void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT);
|
||||||
|
FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size);
|
||||||
|
|
||||||
if (FcPatternObjectGet (pattern, FC_FONTVERSION_OBJECT, 0, &v) == FcResultNoMatch)
|
if (FcPatternObjectGet (pattern, FC_FONTVERSION_OBJECT, 0, &v) == FcResultNoMatch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1107,6 +1107,11 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
FcChar8 *hashstr = NULL;
|
FcChar8 *hashstr = NULL;
|
||||||
FT_Error err;
|
FT_Error err;
|
||||||
FT_ULong len = 0, alen;
|
FT_ULong len = 0, alen;
|
||||||
|
FcRange *r = NULL;
|
||||||
|
#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
|
||||||
|
double lower_size = 0.0L, upper_size = DBL_MAX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
pat = FcPatternCreate ();
|
pat = FcPatternCreate ();
|
||||||
if (!pat)
|
if (!pat)
|
||||||
|
@ -1514,6 +1519,39 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
free (complex_);
|
free (complex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
|
||||||
|
if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
|
||||||
|
{
|
||||||
|
/* usLowerPointSize and usUpperPointSize is actually twips */
|
||||||
|
lower_size = os2->usLowerOpticalPointSize / 20.0L;
|
||||||
|
upper_size = os2->usUpperOpticalPointSize / 20.0L;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (os2)
|
||||||
|
{
|
||||||
|
r = FcRangeCreateDouble (lower_size, upper_size);
|
||||||
|
if (!FcPatternAddRange (pat, FC_SIZE, r))
|
||||||
|
{
|
||||||
|
FcRangeDestroy (r);
|
||||||
|
goto bail1;
|
||||||
|
}
|
||||||
|
FcRangeDestroy (r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < face->num_fixed_sizes; i++)
|
||||||
|
{
|
||||||
|
double d = FcGetPixelSize (face, i);
|
||||||
|
r = FcRangeCreateDouble (d, d);
|
||||||
|
if (!FcPatternAddRange (pat, FC_SIZE, r))
|
||||||
|
{
|
||||||
|
FcRangeDestroy (r);
|
||||||
|
goto bail1;
|
||||||
|
}
|
||||||
|
FcRangeDestroy (r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Type 1: Check for FontInfo dictionary information
|
* Type 1: Check for FontInfo dictionary information
|
||||||
* Code from g2@magestudios.net (Gerard Escalante)
|
* Code from g2@magestudios.net (Gerard Escalante)
|
||||||
|
|
65
src/fcint.h
65
src/fcint.h
|
@ -38,6 +38,8 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -94,6 +96,11 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
|
||||||
#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
|
#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#define FC_ABS(a) ((a) < 0 ? -(a) : (a))
|
#define FC_ABS(a) ((a) < 0 ? -(a) : (a))
|
||||||
|
|
||||||
|
#define FcDoubleIsZero(a) (fabs ((a)) <= DBL_EPSILON)
|
||||||
|
#define FcDoubleCmpEQ(a,b) (fabs ((a) - (b)) <= DBL_EPSILON)
|
||||||
|
#define FcDoubleCmpGE(a,b) (FcDoubleCmpEQ (a, b) || (a) > (b))
|
||||||
|
#define FcDoubleCmpLE(a,b) (FcDoubleCmpEQ (a, b) || (a) < (b))
|
||||||
|
|
||||||
/* slim_internal.h */
|
/* slim_internal.h */
|
||||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
|
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
|
||||||
#define FcPrivate __attribute__((__visibility__("hidden")))
|
#define FcPrivate __attribute__((__visibility__("hidden")))
|
||||||
|
@ -161,6 +168,7 @@ typedef enum _FcValueBinding {
|
||||||
#define FcValueString(v) FcPointerMember(v,u.s,FcChar8)
|
#define FcValueString(v) FcPointerMember(v,u.s,FcChar8)
|
||||||
#define FcValueCharSet(v) FcPointerMember(v,u.c,const FcCharSet)
|
#define FcValueCharSet(v) FcPointerMember(v,u.c,const FcCharSet)
|
||||||
#define FcValueLangSet(v) FcPointerMember(v,u.l,const FcLangSet)
|
#define FcValueLangSet(v) FcPointerMember(v,u.l,const FcLangSet)
|
||||||
|
#define FcValueRange(v) FcPointerMember(v,u.r,const FcRange)
|
||||||
|
|
||||||
typedef struct _FcValueList *FcValueListPtr;
|
typedef struct _FcValueList *FcValueListPtr;
|
||||||
|
|
||||||
|
@ -244,6 +252,23 @@ typedef struct _FcExprName {
|
||||||
FcMatchKind kind;
|
FcMatchKind kind;
|
||||||
} FcExprName;
|
} FcExprName;
|
||||||
|
|
||||||
|
typedef struct _FcRangeInt {
|
||||||
|
FcChar32 begin;
|
||||||
|
FcChar32 end;
|
||||||
|
} FcRangeInt;
|
||||||
|
typedef struct _FcRangeDouble {
|
||||||
|
double begin;
|
||||||
|
double end;
|
||||||
|
} FcRangeDouble;
|
||||||
|
struct _FcRange {
|
||||||
|
FcBool is_double;
|
||||||
|
FcBool is_inclusive;
|
||||||
|
union {
|
||||||
|
FcRangeInt i;
|
||||||
|
FcRangeDouble d;
|
||||||
|
} u;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _FcExpr {
|
typedef struct _FcExpr {
|
||||||
FcOp op;
|
FcOp op;
|
||||||
|
@ -255,6 +280,7 @@ typedef struct _FcExpr {
|
||||||
FcBool bval;
|
FcBool bval;
|
||||||
FcCharSet *cval;
|
FcCharSet *cval;
|
||||||
FcLangSet *lval;
|
FcLangSet *lval;
|
||||||
|
FcRange *rval;
|
||||||
|
|
||||||
FcExprName name;
|
FcExprName name;
|
||||||
const FcChar8 *constant;
|
const FcChar8 *constant;
|
||||||
|
@ -532,13 +558,6 @@ typedef struct _FcFileTime {
|
||||||
|
|
||||||
typedef struct _FcCharMap FcCharMap;
|
typedef struct _FcCharMap FcCharMap;
|
||||||
|
|
||||||
typedef struct _FcRange FcRange;
|
|
||||||
|
|
||||||
struct _FcRange {
|
|
||||||
FcChar32 begin;
|
|
||||||
FcChar32 end;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _FcStatFS FcStatFS;
|
typedef struct _FcStatFS FcStatFS;
|
||||||
|
|
||||||
struct _FcStatFS {
|
struct _FcStatFS {
|
||||||
|
@ -1008,6 +1027,9 @@ FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b);
|
||||||
FcPrivate FcBool
|
FcPrivate FcBool
|
||||||
FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
|
FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r);
|
||||||
|
|
||||||
FcPrivate FcResult
|
FcPrivate FcResult
|
||||||
FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
|
FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
|
||||||
|
|
||||||
|
@ -1029,6 +1051,9 @@ FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
|
||||||
FcPrivate FcResult
|
FcPrivate FcResult
|
||||||
FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
|
FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
|
||||||
|
|
||||||
|
FcPrivate FcResult
|
||||||
|
FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r);
|
||||||
|
|
||||||
FcPrivate FcBool
|
FcPrivate FcBool
|
||||||
FcPatternAppend (FcPattern *p, FcPattern *s);
|
FcPatternAppend (FcPattern *p, FcPattern *s);
|
||||||
|
|
||||||
|
@ -1056,6 +1081,32 @@ extern FcPrivate const FcMatrix FcIdentityMatrix;
|
||||||
FcPrivate void
|
FcPrivate void
|
||||||
FcMatrixFree (FcMatrix *mat);
|
FcMatrixFree (FcMatrix *mat);
|
||||||
|
|
||||||
|
/* fcrange.c */
|
||||||
|
|
||||||
|
FcPrivate FcRange
|
||||||
|
FcRangeCanonicalize (const FcRange *range);
|
||||||
|
|
||||||
|
FcPrivate FcRange *
|
||||||
|
FcRangePromote (double v, FcValuePromotionBuffer *vbuf);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcRangeIsZero (const FcRange *r);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcRangeIsInRange (const FcRange *a, const FcRange *b);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b);
|
||||||
|
|
||||||
|
FcPrivate FcChar32
|
||||||
|
FcRangeHash (const FcRange *r);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r);
|
||||||
|
|
||||||
|
FcPrivate FcRange *
|
||||||
|
FcRangeSerialize (FcSerialize *serialize, const FcRange *r);
|
||||||
|
|
||||||
/* fcstat.c */
|
/* fcstat.c */
|
||||||
|
|
||||||
FcPrivate int
|
FcPrivate int
|
||||||
|
|
|
@ -273,6 +273,8 @@ FcListValueHash (FcValue *value)
|
||||||
return (long) v.u.f;
|
return (long) v.u.f;
|
||||||
case FcTypeLangSet:
|
case FcTypeLangSet:
|
||||||
return FcLangSetHash (v.u.l);
|
return FcLangSetHash (v.u.l);
|
||||||
|
case FcTypeRange:
|
||||||
|
return FcRangeHash (v.u.r);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,49 @@ FcCompareSize (FcValue *value1, FcValue *value2)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
FcCompareSizeRange (FcValue *v1, FcValue *v2)
|
||||||
|
{
|
||||||
|
FcValue value1 = FcValueCanonicalize (v1);
|
||||||
|
FcValue value2 = FcValueCanonicalize (v2);
|
||||||
|
FcRange *r1 = NULL, *r2 = NULL;
|
||||||
|
double ret = -1.0;
|
||||||
|
|
||||||
|
switch ((int) value1.type) {
|
||||||
|
case FcTypeDouble:
|
||||||
|
r1 = FcRangeCreateDouble (value1.u.d, value1.u.d);
|
||||||
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
r1 = FcRangeCopy (value1.u.r);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
switch ((int) value2.type) {
|
||||||
|
case FcTypeDouble:
|
||||||
|
r2 = FcRangeCreateDouble (value2.u.d, value2.u.d);
|
||||||
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
r2 = FcRangeCopy (value2.u.r);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FcRangeIsInRange (r1, r2))
|
||||||
|
ret = 0.0;
|
||||||
|
else
|
||||||
|
ret = FC_MIN (fabs (r1->u.d.end - r2->u.d.begin), fabs (r1->u.d.begin - r2->u.d.end));
|
||||||
|
|
||||||
|
bail:
|
||||||
|
if (r1)
|
||||||
|
FcRangeDestroy (r1);
|
||||||
|
if (r2)
|
||||||
|
FcRangeDestroy (r2);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
FcCompareFilename (FcValue *v1, FcValue *v2)
|
FcCompareFilename (FcValue *v1, FcValue *v2)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +270,7 @@ FcCompareHash (FcValue *v1, FcValue *v2)
|
||||||
#define PRI_FcCompareLang(n) PRI1(n)
|
#define PRI_FcCompareLang(n) PRI1(n)
|
||||||
#define PRI_FcComparePostScript(n) PRI1(n)
|
#define PRI_FcComparePostScript(n) PRI1(n)
|
||||||
#define PRI_FcCompareHash(n) PRI1(n)
|
#define PRI_FcCompareHash(n) PRI1(n)
|
||||||
|
#define PRI_FcCompareSizeRange(n) PRI1(n)
|
||||||
|
|
||||||
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
|
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
|
||||||
|
|
||||||
|
@ -255,6 +299,7 @@ typedef enum _FcMatcherPriority {
|
||||||
PRI_FAMILY_WEAK,
|
PRI_FAMILY_WEAK,
|
||||||
PRI_POSTSCRIPT_NAME_WEAK,
|
PRI_POSTSCRIPT_NAME_WEAK,
|
||||||
PRI1(SPACING),
|
PRI1(SPACING),
|
||||||
|
PRI1(SIZE),
|
||||||
PRI1(PIXEL_SIZE),
|
PRI1(PIXEL_SIZE),
|
||||||
PRI1(STYLE),
|
PRI1(STYLE),
|
||||||
PRI1(SLANT),
|
PRI1(SLANT),
|
||||||
|
|
49
src/fcname.c
49
src/fcname.c
|
@ -87,6 +87,10 @@ FcObjectValidType (FcObject object, FcType type)
|
||||||
if (type == FcTypeLangSet || type == FcTypeString)
|
if (type == FcTypeLangSet || type == FcTypeString)
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
if (type == FcTypeRange || type == FcTypeDouble)
|
||||||
|
return FcTrue;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (type == t->type)
|
if (type == t->type)
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
@ -273,6 +277,8 @@ FcNameConvert (FcType type, FcChar8 *string)
|
||||||
{
|
{
|
||||||
FcValue v;
|
FcValue v;
|
||||||
FcMatrix m;
|
FcMatrix m;
|
||||||
|
double b, e;
|
||||||
|
char *p;
|
||||||
|
|
||||||
v.type = type;
|
v.type = type;
|
||||||
switch ((int) v.type) {
|
switch ((int) v.type) {
|
||||||
|
@ -307,6 +313,20 @@ FcNameConvert (FcType type, FcChar8 *string)
|
||||||
if (!v.u.l)
|
if (!v.u.l)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
if (sscanf ((char *) string, "(%lg %lg)", &b, &e) != 2)
|
||||||
|
{
|
||||||
|
v.u.d = strtod ((char *) string, &p);
|
||||||
|
if (p != NULL && p[0] != 0)
|
||||||
|
{
|
||||||
|
v.type = FcTypeVoid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
v.type = FcTypeDouble;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
v.u.r = FcRangeCreateDouble (b, e);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -476,6 +496,7 @@ FcNameUnparseValue (FcStrBuf *buf,
|
||||||
{
|
{
|
||||||
FcChar8 temp[1024];
|
FcChar8 temp[1024];
|
||||||
FcValue v = FcValueCanonicalize(v0);
|
FcValue v = FcValueCanonicalize(v0);
|
||||||
|
FcRange r;
|
||||||
|
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case FcTypeUnknown:
|
case FcTypeUnknown:
|
||||||
|
@ -501,6 +522,18 @@ FcNameUnparseValue (FcStrBuf *buf,
|
||||||
return FcNameUnparseLangSet (buf, v.u.l);
|
return FcNameUnparseLangSet (buf, v.u.l);
|
||||||
case FcTypeFTFace:
|
case FcTypeFTFace:
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
case FcTypeRange:
|
||||||
|
r = FcRangeCanonicalize (v.u.r);
|
||||||
|
if (!FcDoubleIsZero (r.u.d.begin) || !FcDoubleIsZero (r.u.d.end))
|
||||||
|
{
|
||||||
|
if (FcDoubleCmpEQ (r.u.d.begin, r.u.d.end))
|
||||||
|
sprintf ((char *) temp, "%g", r.u.d.begin);
|
||||||
|
else
|
||||||
|
sprintf ((char *) temp, "(%g %g)", r.u.d.begin, r.u.d.end);
|
||||||
|
return FcNameUnparseString (buf, temp, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FcTrue;
|
||||||
}
|
}
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
|
@ -533,12 +566,13 @@ FcNameUnparse (FcPattern *pat)
|
||||||
FcChar8 *
|
FcChar8 *
|
||||||
FcNameUnparseEscaped (FcPattern *pat, FcBool escape)
|
FcNameUnparseEscaped (FcPattern *pat, FcBool escape)
|
||||||
{
|
{
|
||||||
FcStrBuf buf;
|
FcStrBuf buf, buf2;
|
||||||
FcChar8 buf_static[8192];
|
FcChar8 buf_static[8192], buf2_static[256];
|
||||||
int i;
|
int i;
|
||||||
FcPatternElt *e;
|
FcPatternElt *e;
|
||||||
|
|
||||||
FcStrBufInit (&buf, buf_static, sizeof (buf_static));
|
FcStrBufInit (&buf, buf_static, sizeof (buf_static));
|
||||||
|
FcStrBufInit (&buf2, buf2_static, sizeof (buf2_static));
|
||||||
e = FcPatternObjectFindElt (pat, FC_FAMILY_OBJECT);
|
e = FcPatternObjectFindElt (pat, FC_FAMILY_OBJECT);
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
@ -548,9 +582,16 @@ FcNameUnparseEscaped (FcPattern *pat, FcBool escape)
|
||||||
e = FcPatternObjectFindElt (pat, FC_SIZE_OBJECT);
|
e = FcPatternObjectFindElt (pat, FC_SIZE_OBJECT);
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0))
|
FcChar8 *p;
|
||||||
|
|
||||||
|
if (!FcNameUnparseString (&buf2, (FcChar8 *) "-", 0))
|
||||||
goto bail0;
|
goto bail0;
|
||||||
if (!FcNameUnparseValueList (&buf, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0))
|
if (!FcNameUnparseValueList (&buf2, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0))
|
||||||
|
goto bail0;
|
||||||
|
p = FcStrBufDoneStatic (&buf2);
|
||||||
|
FcStrBufDestroy (&buf2);
|
||||||
|
if (strlen ((const char *)p) > 1)
|
||||||
|
if (!FcStrBufString (&buf, p))
|
||||||
goto bail0;
|
goto bail0;
|
||||||
}
|
}
|
||||||
for (i = 0; i < NUM_OBJECT_TYPES; i++)
|
for (i = 0; i < NUM_OBJECT_TYPES; i++)
|
||||||
|
|
|
@ -31,7 +31,7 @@ FC_OBJECT (FULLNAMELANG, FcTypeString, NULL)
|
||||||
FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber)
|
FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber)
|
||||||
FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber)
|
FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber)
|
||||||
FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber)
|
FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber)
|
||||||
FC_OBJECT (SIZE, FcTypeDouble, NULL)
|
FC_OBJECT (SIZE, FcTypeRange, FcCompareSizeRange)
|
||||||
FC_OBJECT (ASPECT, FcTypeDouble, NULL)
|
FC_OBJECT (ASPECT, FcTypeDouble, NULL)
|
||||||
FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize)
|
FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize)
|
||||||
FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber)
|
FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber)
|
||||||
|
|
73
src/fcpat.c
73
src/fcpat.c
|
@ -57,6 +57,9 @@ FcValueDestroy (FcValue v)
|
||||||
case FcTypeLangSet:
|
case FcTypeLangSet:
|
||||||
FcLangSetDestroy ((FcLangSet *) v.u.l);
|
FcLangSetDestroy ((FcLangSet *) v.u.l);
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
FcRangeDestroy ((FcRange *) v.u.r);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +84,10 @@ FcValueCanonicalize (const FcValue *v)
|
||||||
new.u.l = FcValueLangSet(v);
|
new.u.l = FcValueLangSet(v);
|
||||||
new.type = FcTypeLangSet;
|
new.type = FcTypeLangSet;
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
new.u.r = FcValueRange(v);
|
||||||
|
new.type = FcTypeRange;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
new = *v;
|
new = *v;
|
||||||
break;
|
break;
|
||||||
|
@ -112,6 +119,11 @@ FcValueSave (FcValue v)
|
||||||
if (!v.u.l)
|
if (!v.u.l)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
v.u.r = FcRangeCopy (v.u.r);
|
||||||
|
if (!v.u.r)
|
||||||
|
v.type = FcTypeVoid;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +157,9 @@ FcValueListDestroy (FcValueListPtr l)
|
||||||
FcLangSetDestroy
|
FcLangSetDestroy
|
||||||
((FcLangSet *) (l->value.u.l));
|
((FcLangSet *) (l->value.u.l));
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
FcRangeDestroy ((FcRange *) (l->value.u.r));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +282,8 @@ FcValueEqual (FcValue va, FcValue vb)
|
||||||
return va.u.f == vb.u.f;
|
return va.u.f == vb.u.f;
|
||||||
case FcTypeLangSet:
|
case FcTypeLangSet:
|
||||||
return FcLangSetEqual (va.u.l, vb.u.l);
|
return FcLangSetEqual (va.u.l, vb.u.l);
|
||||||
|
case FcTypeRange:
|
||||||
|
return FcRangeIsInRange (va.u.r, vb.u.r);
|
||||||
}
|
}
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
|
@ -320,6 +337,8 @@ FcValueHash (const FcValue *v)
|
||||||
FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->style_name);
|
FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->style_name);
|
||||||
case FcTypeLangSet:
|
case FcTypeLangSet:
|
||||||
return FcLangSetHash (FcValueLangSet(v));
|
return FcLangSetHash (FcValueLangSet(v));
|
||||||
|
case FcTypeRange:
|
||||||
|
return FcRangeHash (v->u.r);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -841,6 +860,22 @@ FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls)
|
||||||
return FcPatternAdd (p, object, v, FcTrue);
|
return FcPatternAdd (p, object, v, FcTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r)
|
||||||
|
{
|
||||||
|
FcValue v;
|
||||||
|
|
||||||
|
v.type = FcTypeRange;
|
||||||
|
v.u.r = (FcRange *)r;
|
||||||
|
return FcPatternObjectAdd (p, object, v, FcTrue);
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r)
|
||||||
|
{
|
||||||
|
return FcPatternObjectAddRange (p, FcObjectFromName (object), r);
|
||||||
|
}
|
||||||
|
|
||||||
FcResult
|
FcResult
|
||||||
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
|
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
|
||||||
{
|
{
|
||||||
|
@ -1025,6 +1060,31 @@ FcPatternGetLangSet(const FcPattern *p, const char *object, int id, FcLangSet **
|
||||||
return FcResultMatch;
|
return FcResultMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcResult
|
||||||
|
FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r)
|
||||||
|
{
|
||||||
|
FcValue v;
|
||||||
|
FcResult res;
|
||||||
|
|
||||||
|
res = FcPatternObjectGet (p, object, id, &v);
|
||||||
|
if (res != FcResultMatch)
|
||||||
|
return res;
|
||||||
|
switch ((int)v.type) {
|
||||||
|
case FcTypeRange:
|
||||||
|
*r = (FcRange *)v.u.r;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FcResultTypeMismatch;
|
||||||
|
}
|
||||||
|
return FcResultMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcResult
|
||||||
|
FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r)
|
||||||
|
{
|
||||||
|
return FcPatternObjectGetRange (p, FcObjectFromName (object), id, r);
|
||||||
|
}
|
||||||
|
|
||||||
FcPattern *
|
FcPattern *
|
||||||
FcPatternDuplicate (const FcPattern *orig)
|
FcPatternDuplicate (const FcPattern *orig)
|
||||||
{
|
{
|
||||||
|
@ -1230,6 +1290,10 @@ FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *vl)
|
||||||
if (!FcLangSetSerializeAlloc (serialize, vl->value.u.l))
|
if (!FcLangSetSerializeAlloc (serialize, vl->value.u.l))
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
if (!FcRangeSerializeAlloc (serialize, vl->value.u.r))
|
||||||
|
return FcFalse;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1245,6 +1309,7 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
|
||||||
FcChar8 *s_serialized;
|
FcChar8 *s_serialized;
|
||||||
FcCharSet *c_serialized;
|
FcCharSet *c_serialized;
|
||||||
FcLangSet *l_serialized;
|
FcLangSet *l_serialized;
|
||||||
|
FcRange *r_serialized;
|
||||||
FcValueList *head_serialized = NULL;
|
FcValueList *head_serialized = NULL;
|
||||||
FcValueList *prev_serialized = NULL;
|
FcValueList *prev_serialized = NULL;
|
||||||
|
|
||||||
|
@ -1303,6 +1368,14 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
|
||||||
l_serialized,
|
l_serialized,
|
||||||
FcLangSet);
|
FcLangSet);
|
||||||
break;
|
break;
|
||||||
|
case FcTypeRange:
|
||||||
|
r_serialized = FcRangeSerialize (serialize, vl->value.u.r);
|
||||||
|
if (!r_serialized)
|
||||||
|
return NULL;
|
||||||
|
vl_serialized->value.u.r = FcPtrToEncodedOffset (&vl_serialized->value,
|
||||||
|
r_serialized,
|
||||||
|
FcRange);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,207 @@
|
||||||
|
/*
|
||||||
|
* fontconfig/src/fcrange.c
|
||||||
|
*
|
||||||
|
* Copyright © 2002 Keith Packard
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* 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 the author(s) not be used in
|
||||||
|
* advertising or publicity pertaining to distribution of the software without
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* 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
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "fcint.h"
|
||||||
|
|
||||||
|
|
||||||
|
FcRange *
|
||||||
|
FcRangeCreateDouble (double begin, double end)
|
||||||
|
{
|
||||||
|
FcRange *ret = malloc (sizeof (FcRange));
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
ret->is_double = FcTrue;
|
||||||
|
ret->is_inclusive = FcDoubleCmpEQ (begin, end);
|
||||||
|
ret->u.d.begin = begin;
|
||||||
|
ret->u.d.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcRange *
|
||||||
|
FcRangeCreateInteger (FcChar32 begin, FcChar32 end)
|
||||||
|
{
|
||||||
|
FcRange *ret = malloc (sizeof (FcRange));
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
ret->is_double = FcFalse;
|
||||||
|
ret->is_inclusive = (begin == end);
|
||||||
|
ret->u.i.begin = begin;
|
||||||
|
ret->u.i.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FcRangeDestroy (FcRange *range)
|
||||||
|
{
|
||||||
|
free (range);
|
||||||
|
}
|
||||||
|
|
||||||
|
FcRange *
|
||||||
|
FcRangeCopy (const FcRange *range)
|
||||||
|
{
|
||||||
|
FcRange *ret;
|
||||||
|
|
||||||
|
if (range->is_double)
|
||||||
|
ret = FcRangeCreateDouble (range->u.d.begin, range->u.d.end);
|
||||||
|
else
|
||||||
|
ret = FcRangeCreateInteger (range->u.i.begin, range->u.i.end);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcRange
|
||||||
|
FcRangeCanonicalize (const FcRange *range)
|
||||||
|
{
|
||||||
|
FcRange new;
|
||||||
|
|
||||||
|
if (range->is_double)
|
||||||
|
new = *range;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new.is_double = FcTrue;
|
||||||
|
new.is_inclusive = range->is_inclusive;
|
||||||
|
new.u.d.begin = (double)range->u.i.begin;
|
||||||
|
new.u.d.end = (double)range->u.i.end;
|
||||||
|
}
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcRange *
|
||||||
|
FcRangePromote (double v, FcValuePromotionBuffer *vbuf)
|
||||||
|
{
|
||||||
|
typedef struct {
|
||||||
|
FcRange r;
|
||||||
|
} FcRangePromotionBuffer;
|
||||||
|
FcRangePromotionBuffer *buf = (FcRangePromotionBuffer *) vbuf;
|
||||||
|
|
||||||
|
FC_ASSERT_STATIC (sizeof (FcRangePromotionBuffer) <= sizeof (FcValuePromotionBuffer));
|
||||||
|
buf->r.is_double = FcTrue;
|
||||||
|
buf->r.is_inclusive = FcTrue;
|
||||||
|
buf->r.u.d.begin = v;
|
||||||
|
buf->r.u.d.end = v;
|
||||||
|
|
||||||
|
return &buf->r;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcRangeIsZero (const FcRange *r)
|
||||||
|
{
|
||||||
|
FcRange c;
|
||||||
|
|
||||||
|
if (!r)
|
||||||
|
return FcFalse;
|
||||||
|
c = FcRangeCanonicalize (r);
|
||||||
|
|
||||||
|
return FcDoubleIsZero (c.u.d.begin) && FcDoubleIsZero (c.u.d.end);
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcRangeIsInRange (const FcRange *a, const FcRange *b)
|
||||||
|
{
|
||||||
|
FcRange ca, cb;
|
||||||
|
FcBool f;
|
||||||
|
|
||||||
|
if (!a || !b)
|
||||||
|
return FcFalse;
|
||||||
|
|
||||||
|
ca = FcRangeCanonicalize (a);
|
||||||
|
cb = FcRangeCanonicalize (b);
|
||||||
|
if (ca.is_inclusive & cb.is_inclusive)
|
||||||
|
f = ca.u.d.end <= cb.u.d.end;
|
||||||
|
else
|
||||||
|
f = ca.u.d.end < cb.u.d.end;
|
||||||
|
|
||||||
|
return FcDoubleCmpGE (ca.u.d.begin, cb.u.d.begin) && f;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
|
||||||
|
{
|
||||||
|
FcRange ca, cb;
|
||||||
|
|
||||||
|
switch ((int) op) {
|
||||||
|
case FcOpEqual:
|
||||||
|
case FcOpContains:
|
||||||
|
case FcOpListing:
|
||||||
|
return FcRangeIsInRange (a, b);
|
||||||
|
case FcOpNotEqual:
|
||||||
|
case FcOpNotContains:
|
||||||
|
return !FcRangeIsInRange (a, b);
|
||||||
|
case FcOpLess:
|
||||||
|
ca = FcRangeCanonicalize (a);
|
||||||
|
cb = FcRangeCanonicalize (b);
|
||||||
|
return ca.u.d.begin < cb.u.d.begin;
|
||||||
|
case FcOpLessEqual:
|
||||||
|
ca = FcRangeCanonicalize (a);
|
||||||
|
cb = FcRangeCanonicalize (b);
|
||||||
|
return FcDoubleCmpLE (ca.u.d.begin, cb.u.d.begin);
|
||||||
|
case FcOpMore:
|
||||||
|
ca = FcRangeCanonicalize (a);
|
||||||
|
cb = FcRangeCanonicalize (b);
|
||||||
|
return ca.u.d.end > cb.u.d.end;
|
||||||
|
case FcOpMoreEqual:
|
||||||
|
ca = FcRangeCanonicalize (a);
|
||||||
|
cb = FcRangeCanonicalize (b);
|
||||||
|
return FcDoubleCmpGE (ca.u.d.end, cb.u.d.end);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FcFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcChar32
|
||||||
|
FcRangeHash (const FcRange *r)
|
||||||
|
{
|
||||||
|
FcRange c = FcRangeCanonicalize (r);
|
||||||
|
int b = (int) (c.u.d.begin * 100);
|
||||||
|
int e = (int) (c.u.d.end * 100);
|
||||||
|
|
||||||
|
return b ^ (b << 1) ^ (e << 9);
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r)
|
||||||
|
{
|
||||||
|
if (!FcSerializeAlloc (serialize, r, sizeof (FcRange)))
|
||||||
|
return FcFalse;
|
||||||
|
return FcTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcRange *
|
||||||
|
FcRangeSerialize (FcSerialize *serialize, const FcRange *r)
|
||||||
|
{
|
||||||
|
FcRange *r_serialize = FcSerializePtr (serialize, r);
|
||||||
|
|
||||||
|
if (!r_serialize)
|
||||||
|
return NULL;
|
||||||
|
memcpy (r_serialize, r, sizeof (FcRange));
|
||||||
|
|
||||||
|
return r_serialize;
|
||||||
|
}
|
106
src/fcxml.c
106
src/fcxml.c
|
@ -168,6 +168,18 @@ FcExprCreateMatrix (FcConfig *config, const FcExprMatrix *matrix)
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FcExpr *
|
||||||
|
FcExprCreateRange (FcConfig *config, FcRange *range)
|
||||||
|
{
|
||||||
|
FcExpr *e = FcConfigAllocExpr (config);
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
e->op = FcOpRange;
|
||||||
|
e->u.rval = FcRangeCopy (range);
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
static FcExpr *
|
static FcExpr *
|
||||||
FcExprCreateBool (FcConfig *config, FcBool b)
|
FcExprCreateBool (FcConfig *config, FcBool b)
|
||||||
{
|
{
|
||||||
|
@ -258,6 +270,7 @@ FcExprDestroy (FcExpr *e)
|
||||||
FcExprMatrixFree (e->u.mexpr);
|
FcExprMatrixFree (e->u.mexpr);
|
||||||
break;
|
break;
|
||||||
case FcOpRange:
|
case FcOpRange:
|
||||||
|
FcRangeDestroy (e->u.rval);
|
||||||
break;
|
break;
|
||||||
case FcOpCharSet:
|
case FcOpCharSet:
|
||||||
FcCharSetDestroy (e->u.cval);
|
FcCharSetDestroy (e->u.cval);
|
||||||
|
@ -503,7 +516,7 @@ typedef struct _FcVStack {
|
||||||
int integer;
|
int integer;
|
||||||
double _double;
|
double _double;
|
||||||
FcExprMatrix *matrix;
|
FcExprMatrix *matrix;
|
||||||
FcRange range;
|
FcRange *range;
|
||||||
FcBool bool_;
|
FcBool bool_;
|
||||||
FcCharSet *charset;
|
FcCharSet *charset;
|
||||||
FcLangSet *langset;
|
FcLangSet *langset;
|
||||||
|
@ -593,6 +606,8 @@ FcTypeName (FcType type)
|
||||||
return "FT_Face";
|
return "FT_Face";
|
||||||
case FcTypeLangSet:
|
case FcTypeLangSet:
|
||||||
return "langset";
|
return "langset";
|
||||||
|
case FcTypeRange:
|
||||||
|
return "range";
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -608,7 +623,9 @@ FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type)
|
||||||
if (value != type)
|
if (value != type)
|
||||||
{
|
{
|
||||||
if ((value == FcTypeLangSet && type == FcTypeString) ||
|
if ((value == FcTypeLangSet && type == FcTypeString) ||
|
||||||
(value == FcTypeString && type == FcTypeLangSet))
|
(value == FcTypeString && type == FcTypeLangSet) ||
|
||||||
|
(value == FcTypeInteger && type == FcTypeRange) ||
|
||||||
|
(value == FcTypeDouble && type == FcTypeRange))
|
||||||
return;
|
return;
|
||||||
if (type == FcTypeUnknown)
|
if (type == FcTypeUnknown)
|
||||||
return;
|
return;
|
||||||
|
@ -651,6 +668,9 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
|
||||||
case FcOpLangSet:
|
case FcOpLangSet:
|
||||||
FcTypecheckValue (parse, FcTypeLangSet, type);
|
FcTypecheckValue (parse, FcTypeLangSet, type);
|
||||||
break;
|
break;
|
||||||
|
case FcOpRange:
|
||||||
|
FcTypecheckValue (parse, FcTypeRange, type);
|
||||||
|
break;
|
||||||
case FcOpNil:
|
case FcOpNil:
|
||||||
break;
|
break;
|
||||||
case FcOpField:
|
case FcOpField:
|
||||||
|
@ -868,8 +888,7 @@ FcVStackPushRange (FcConfigParse *parse, FcRange *range)
|
||||||
FcVStack *vstack = FcVStackCreateAndPush (parse);
|
FcVStack *vstack = FcVStackCreateAndPush (parse);
|
||||||
if (!vstack)
|
if (!vstack)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
vstack->u.range.begin = range->begin;
|
vstack->u.range = range;
|
||||||
vstack->u.range.end = range->end;
|
|
||||||
vstack->tag = FcVStackRange;
|
vstack->tag = FcVStackRange;
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
@ -1017,9 +1036,11 @@ FcVStackPopAndDestroy (FcConfigParse *parse)
|
||||||
case FcVStackMatrix:
|
case FcVStackMatrix:
|
||||||
FcExprMatrixFreeShallow (vstack->u.matrix);
|
FcExprMatrixFreeShallow (vstack->u.matrix);
|
||||||
break;
|
break;
|
||||||
case FcVStackRange:
|
|
||||||
case FcVStackBool:
|
case FcVStackBool:
|
||||||
break;
|
break;
|
||||||
|
case FcVStackRange:
|
||||||
|
FcRangeDestroy (vstack->u.range);
|
||||||
|
break;
|
||||||
case FcVStackCharSet:
|
case FcVStackCharSet:
|
||||||
FcCharSetDestroy (vstack->u.charset);
|
FcCharSetDestroy (vstack->u.charset);
|
||||||
break;
|
break;
|
||||||
|
@ -1232,7 +1253,9 @@ static void
|
||||||
FcParseBlank (FcConfigParse *parse)
|
FcParseBlank (FcConfigParse *parse)
|
||||||
{
|
{
|
||||||
int n = FcVStackElements (parse);
|
int n = FcVStackElements (parse);
|
||||||
FcChar32 i;
|
FcChar32 i, begin, end;
|
||||||
|
FcRange r;
|
||||||
|
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
{
|
{
|
||||||
FcVStack *v = FcVStackFetch (parse, n);
|
FcVStack *v = FcVStackFetch (parse, n);
|
||||||
|
@ -1248,9 +1271,12 @@ FcParseBlank (FcConfigParse *parse)
|
||||||
goto bail;
|
goto bail;
|
||||||
break;
|
break;
|
||||||
case FcVStackRange:
|
case FcVStackRange:
|
||||||
if (v->u.range.begin <= v->u.range.end)
|
r = FcRangeCanonicalize (v->u.range);
|
||||||
|
begin = (FcChar32)r.u.d.begin;
|
||||||
|
end = (FcChar32)r.u.d.end;
|
||||||
|
if (begin <= end)
|
||||||
{
|
{
|
||||||
for (i = v->u.range.begin; i <= v->u.range.end; i++)
|
for (i = begin; i <= end; i++)
|
||||||
{
|
{
|
||||||
if (!FcBlanksAdd (parse->config->blanks, i))
|
if (!FcBlanksAdd (parse->config->blanks, i))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -1463,9 +1489,11 @@ static void
|
||||||
FcParseRange (FcConfigParse *parse)
|
FcParseRange (FcConfigParse *parse)
|
||||||
{
|
{
|
||||||
FcVStack *vstack;
|
FcVStack *vstack;
|
||||||
FcRange r = {0, 0};
|
FcRange *r;
|
||||||
FcChar32 n;
|
FcChar32 n[2] = {0, 0};
|
||||||
int count = 1;
|
int count = 1;
|
||||||
|
double d[2] = {0.0L, 0.0L};
|
||||||
|
FcBool dflag = FcFalse;
|
||||||
|
|
||||||
while ((vstack = FcVStackPeek (parse)))
|
while ((vstack = FcVStackPeek (parse)))
|
||||||
{
|
{
|
||||||
|
@ -1476,31 +1504,52 @@ FcParseRange (FcConfigParse *parse)
|
||||||
}
|
}
|
||||||
switch ((int) vstack->tag) {
|
switch ((int) vstack->tag) {
|
||||||
case FcVStackInteger:
|
case FcVStackInteger:
|
||||||
n = vstack->u.integer;
|
if (dflag)
|
||||||
|
d[count] = (double)vstack->u.integer;
|
||||||
|
else
|
||||||
|
n[count] = vstack->u.integer;
|
||||||
|
break;
|
||||||
|
case FcVStackDouble:
|
||||||
|
if (count == 0 && !dflag)
|
||||||
|
d[1] = (double)n[1];
|
||||||
|
d[count] = vstack->u._double;
|
||||||
|
dflag = FcTrue;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FcConfigMessage (parse, FcSevereError, "invalid element in range");
|
FcConfigMessage (parse, FcSevereError, "invalid element in range");
|
||||||
n = 0;
|
if (dflag)
|
||||||
|
d[count] = 0.0L;
|
||||||
|
else
|
||||||
|
n[count] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (count == 1)
|
|
||||||
r.end = n;
|
|
||||||
else
|
|
||||||
r.begin = n;
|
|
||||||
count--;
|
count--;
|
||||||
FcVStackPopAndDestroy (parse);
|
FcVStackPopAndDestroy (parse);
|
||||||
}
|
}
|
||||||
if (count < 0)
|
if (count >= 0)
|
||||||
{
|
|
||||||
if (r.begin > r.end)
|
|
||||||
{
|
{
|
||||||
FcConfigMessage (parse, FcSevereError, "invalid range");
|
FcConfigMessage (parse, FcSevereError, "invalid range");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FcVStackPushRange (parse, &r);
|
if (dflag)
|
||||||
|
{
|
||||||
|
if (d[0] > d[1])
|
||||||
|
{
|
||||||
|
FcConfigMessage (parse, FcSevereError, "invalid range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
r = FcRangeCreateDouble (d[0], d[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (n[0] > n[1])
|
||||||
|
{
|
||||||
FcConfigMessage (parse, FcSevereError, "invalid range");
|
FcConfigMessage (parse, FcSevereError, "invalid range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
r = FcRangeCreateInteger (n[0], n[1]);
|
||||||
|
}
|
||||||
|
FcVStackPushRange (parse, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
|
@ -1536,7 +1585,8 @@ FcParseCharSet (FcConfigParse *parse)
|
||||||
{
|
{
|
||||||
FcVStack *vstack;
|
FcVStack *vstack;
|
||||||
FcCharSet *charset = FcCharSetCreate ();
|
FcCharSet *charset = FcCharSetCreate ();
|
||||||
FcChar32 i;
|
FcChar32 i, begin, end;
|
||||||
|
FcRange r;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
while ((vstack = FcVStackPeek (parse)))
|
while ((vstack = FcVStackPeek (parse)))
|
||||||
|
@ -1551,9 +1601,13 @@ FcParseCharSet (FcConfigParse *parse)
|
||||||
n++;
|
n++;
|
||||||
break;
|
break;
|
||||||
case FcVStackRange:
|
case FcVStackRange:
|
||||||
if (vstack->u.range.begin <= vstack->u.range.end)
|
r = FcRangeCanonicalize (vstack->u.range);
|
||||||
|
begin = (FcChar32)r.u.d.begin;
|
||||||
|
end = (FcChar32)r.u.d.end;
|
||||||
|
|
||||||
|
if (begin <= end)
|
||||||
{
|
{
|
||||||
for (i = vstack->u.range.begin; i <= vstack->u.range.end; i++)
|
for (i = begin; i <= end; i++)
|
||||||
{
|
{
|
||||||
if (!FcCharSetAddChar (charset, i))
|
if (!FcCharSetAddChar (charset, i))
|
||||||
{
|
{
|
||||||
|
@ -1888,6 +1942,7 @@ FcPopExpr (FcConfigParse *parse)
|
||||||
expr = FcExprCreateMatrix (parse->config, vstack->u.matrix);
|
expr = FcExprCreateMatrix (parse->config, vstack->u.matrix);
|
||||||
break;
|
break;
|
||||||
case FcVStackRange:
|
case FcVStackRange:
|
||||||
|
expr = FcExprCreateRange (parse->config, vstack->u.range);
|
||||||
break;
|
break;
|
||||||
case FcVStackBool:
|
case FcVStackBool:
|
||||||
expr = FcExprCreateBool (parse->config, vstack->u.bool_);
|
expr = FcExprCreateBool (parse->config, vstack->u.bool_);
|
||||||
|
@ -2653,6 +2708,11 @@ FcPopValue (FcConfigParse *parse)
|
||||||
if (value.u.l)
|
if (value.u.l)
|
||||||
value.type = FcTypeLangSet;
|
value.type = FcTypeLangSet;
|
||||||
break;
|
break;
|
||||||
|
case FcVStackRange:
|
||||||
|
value.u.r = FcRangeCopy (vstack->u.range);
|
||||||
|
if (value.u.r)
|
||||||
|
value.type = FcTypeRange;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FcConfigMessage (parse, FcSevereWarning, "unknown pattern element %d",
|
FcConfigMessage (parse, FcSevereWarning, "unknown pattern element %d",
|
||||||
vstack->tag);
|
vstack->tag);
|
||||||
|
|
Loading…
Reference in New Issue