From ee2000494c4c8367fe20593709a979d158687855 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Tue, 28 Jul 2015 12:48:40 +0900 Subject: Add FcPatternGetWithBinding() to obtain the binding type of the value in FcPattern. https://bugs.freedesktop.org/show_bug.cgi?id=19375 --- doc/fcpattern.fncs | 17 +++++++++++++++++ fontconfig/fontconfig.h | 12 +++++++++++- src/fcint.h | 9 +++------ src/fcpat.c | 18 ++++++++++++++++-- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/doc/fcpattern.fncs b/doc/fcpattern.fncs index 1049d77..e1987ff 100644 --- a/doc/fcpattern.fncs +++ b/doc/fcpattern.fncs @@ -198,6 +198,23 @@ any existing list of values. FcPatternAddRange are available since 2.11.91. @@ +@RET@ FcResult +@FUNC@ FcPatternGetWithBinding +@TYPE1@ FcPattern * @ARG1@ p +@TYPE2@ const char * @ARG2@ object +@TYPE3@ int% @ARG3@ id +@TYPE4@ FcValue * @ARG4@ v +@TYPE5@ FcValueBinding * @ARG5@ b +@PURPOSE@ Return a value with binding from a pattern +@DESC@ +Returns in v the id'th value +and b binding for that associated with the property +object. +The Value returned is not a copy, but rather refers to the data stored +within the pattern directly. Applications must not free this value. +@SINCE@ 2.13.0 +@@ + @RET@ FcResult @FUNC@ FcPatternGet @TYPE1@ FcPattern * @ARG1@ p diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 2e35b6b..9535c56 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -28,6 +28,7 @@ #include #include #include +#include #if defined(__GNUC__) && (__GNUC__ >= 4) #define FC_ATTRIBUTE_SENTINEL(x) __attribute__((__sentinel__(0))) @@ -236,6 +237,12 @@ typedef enum _FcResult { FcResultOutOfMemory } FcResult; +typedef enum _FcValueBinding { + FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame, + /* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */ + FcValueBindingEnd = INT_MAX +} FcValueBinding; + typedef struct _FcPattern FcPattern; typedef struct _FcLangSet FcLangSet; @@ -837,7 +844,10 @@ FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append FcPublic FcResult FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v); - + +FcPublic FcResult +FcPatternGetWithBinding (const FcPattern *p, const char *object, int id, FcValue *v, FcValueBinding *b); + FcPublic FcBool FcPatternDel (FcPattern *p, const char *object); diff --git a/src/fcint.h b/src/fcint.h index dad34c5..360d80d 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -116,12 +116,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA; FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int)); -typedef enum _FcValueBinding { - FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame, - /* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */ - FcValueBindingEnd = INT_MAX -} FcValueBinding; - #define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s))) #define FcFree(s) (free ((FcChar8 *) (s))) @@ -999,6 +993,9 @@ FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append) FcPrivate FcBool FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append); +FcPrivate FcResult +FcPatternObjectGetWithBinding (const FcPattern *p, FcObject object, int id, FcValue *v, FcValueBinding *b); + FcPrivate FcResult FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v); diff --git a/src/fcpat.c b/src/fcpat.c index 3ef1ed2..cc303c6 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -883,7 +883,7 @@ FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r) } FcResult -FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) +FcPatternObjectGetWithBinding (const FcPattern *p, FcObject object, int id, FcValue *v, FcValueBinding *b) { FcPatternElt *e; FcValueListPtr l; @@ -898,6 +898,8 @@ FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) if (!id) { *v = FcValueCanonicalize(&l->value); + if (b) + *b = l->binding; return FcResultMatch; } id--; @@ -905,10 +907,22 @@ FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) return FcResultNoId; } +FcResult +FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) +{ + return FcPatternObjectGetWithBinding (p, object, id, v, NULL); +} + +FcResult +FcPatternGetWithBinding (const FcPattern *p, const char *object, int id, FcValue *v, FcValueBinding *b) +{ + return FcPatternObjectGetWithBinding (p, FcObjectFromName (object), id, v, b); +} + FcResult FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v) { - return FcPatternObjectGet (p, FcObjectFromName (object), id, v); + return FcPatternObjectGetWithBinding (p, FcObjectFromName (object), id, v, NULL); } FcResult -- cgit v1.2.1