[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Tue May 13 05:24:55 PDT 2014


 src/fccfg.c     |   10 ++++++++++
 src/fccharset.c |   15 +++++++++++++++
 src/fcint.h     |    3 +++
 src/fclang.c    |   27 +++++++++++++++------------
 4 files changed, 43 insertions(+), 12 deletions(-)

New commits:
commit 48c8b7938a0f1412d31dbe2f4e332e460f624068
Author: Akira TAGOH <akira at tagoh.org>
Date:   Tue May 13 21:21:43 2014 +0900

    Allow the modification on FcTypeVoid with FcTypeLangSet and FcTypeCharSet
    
    FcTypeVoid is likely to happen when 'lang' and 'charset'
    is deleted by 'delete' or 'delete_all' mode in edit.
    Without this change, any modification on them are simply
    ignored.
    
    This is useful to make a lot of changes, particularly
    when one wants to add a few and delete a lot say.

diff --git a/src/fccfg.c b/src/fccfg.c
index cdb8c0f..fe69eec 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -722,6 +722,16 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
 	v.u.l = FcLangSetPromote (v.u.s, buf);
 	v.type = FcTypeLangSet;
     }
+    else if (v.type == FcTypeVoid && u.type == FcTypeLangSet)
+    {
+	v.u.l = FcLangSetPromote (NULL, buf);
+	v.type = FcTypeLangSet;
+    }
+    else if (v.type == FcTypeVoid && u.type == FcTypeCharSet)
+    {
+	v.u.c = FcCharSetPromote (buf);
+	v.type = FcTypeCharSet;
+    }
     if (buf && v.type == FcTypeDouble && u.type == FcTypeRange)
     {
 	v.u.r = FcRangePromote (v.u.d, buf);
diff --git a/src/fccharset.c b/src/fccharset.c
index c9f928c..43a3cc0 100644
--- a/src/fccharset.c
+++ b/src/fccharset.c
@@ -43,6 +43,21 @@ FcCharSetCreate (void)
 }
 
 FcCharSet *
+FcCharSetPromote (FcValuePromotionBuffer *vbuf)
+{
+    FcCharSet *fcs = (FcCharSet *) vbuf;
+
+    FC_ASSERT_STATIC (sizeof (FcCharSet) <= sizeof (FcValuePromotionBuffer));
+
+    FcRefSetConst (&fcs->ref);
+    fcs->num = 0;
+    fcs->leaves_offset = 0;
+    fcs->numbers_offset = 0;
+
+    return fcs;
+}
+
+FcCharSet *
 FcCharSetNew (void)
 {
     return FcCharSetCreate ();
diff --git a/src/fcint.h b/src/fcint.h
index dd26fd8..3950e01 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -720,6 +720,9 @@ FcPrivate FcLangSet *
 FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
 
 /* fccharset.c */
+FcPrivate FcCharSet *
+FcCharSetPromote (FcValuePromotionBuffer *vbuf);
+
 FcPrivate void
 FcLangCharSetPopulate (void);
 
diff --git a/src/fclang.c b/src/fclang.c
index 9f685f6..b1fd1bc 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -720,19 +720,22 @@ FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *vbuf)
     memset (buf->ls.map, '\0', sizeof (buf->ls.map));
     buf->ls.map_size = NUM_LANG_SET_MAP;
     buf->ls.extra = 0;
-    id = FcLangSetIndex (lang);
-    if (id > 0)
+    if (lang)
     {
-	FcLangSetBitSet (&buf->ls, id);
-    }
-    else
-    {
-	buf->ls.extra = &buf->strs;
-	buf->strs.num = 1;
-	buf->strs.size = 1;
-	buf->strs.strs = &buf->str;
-	FcRefInit (&buf->strs.ref, 1);
-	buf->str = (FcChar8 *) lang;
+	id = FcLangSetIndex (lang);
+	if (id > 0)
+	{
+	    FcLangSetBitSet (&buf->ls, id);
+	}
+	else
+	{
+	    buf->ls.extra = &buf->strs;
+	    buf->strs.num = 1;
+	    buf->strs.size = 1;
+	    buf->strs.strs = &buf->str;
+	    FcRefInit (&buf->strs.ref, 1);
+	    buf->str = (FcChar8 *) lang;
+	}
     }
     return &buf->ls;
 }


More information about the Fontconfig mailing list