diff options
author | Akira TAGOH <akira@tagoh.org> | 2015-07-28 12:48:40 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-07-07 15:43:59 +0900 |
commit | ee2000494c4c8367fe20593709a979d158687855 (patch) | |
tree | 0fa6fa45e33f60d8b3839975ed1d7d1b88a29e47 | |
parent | 01085e07857cddf382db736a9e061f92f50397d6 (diff) |
Add FcPatternGetWithBinding() to obtain the binding type of the value in FcPattern.
https://bugs.freedesktop.org/show_bug.cgi?id=19375
-rw-r--r-- | doc/fcpattern.fncs | 17 | ||||
-rw-r--r-- | fontconfig/fontconfig.h | 12 | ||||
-rw-r--r-- | src/fcint.h | 9 | ||||
-rw-r--r-- | src/fcpat.c | 18 |
4 files changed, 47 insertions, 9 deletions
diff --git a/doc/fcpattern.fncs b/doc/fcpattern.fncs index 1049d77a..e1987ff0 100644 --- a/doc/fcpattern.fncs +++ b/doc/fcpattern.fncs @@ -199,6 +199,23 @@ any existing list of values. @@ @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 <parameter>v</parameter> the <parameter>id</parameter>'th value +and <parameter>b</parameter> binding for that associated with the property +<parameter>object</parameter>. +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 @TYPE2@ const char * @ARG2@ object diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 2e35b6be..9535c56e 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -28,6 +28,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <stdarg.h> +#include <limits.h> #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 dad34c5a..360d80de 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))) @@ -1000,6 +994,9 @@ 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); FcPrivate FcBool diff --git a/src/fcpat.c b/src/fcpat.c index 3ef1ed21..cc303c64 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--; @@ -906,9 +908,21 @@ FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) } 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 |