aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fclang.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-25 10:41:05 +0000
committermarha <marha@users.sourceforge.net>2011-03-25 10:41:05 +0000
commit272e57235cd60a2e65ac8258d96a02eb3939b687 (patch)
tree789d74bd6ec1cc468f1f81aab97d4e4dfdb2d5c5 /fontconfig/src/fclang.c
parentb39f063f74bf0163eaf34db03134f226d18142ec (diff)
downloadvcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.tar.gz
vcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.tar.bz2
vcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.zip
git update until 25 Mar 2011
xserver fontconfig glproto libXau libXft libXmu libfontenc libxcb mesa mkfontscale pixman randrproto xkeyboard-config xtrans xwininfo updated following packages: xproto-7.0.21 xineramaproto-1.2.1 libXt-1.1.1 libxkbfile-1.0.7 libXpm-3.5.9 libXfont-1.4.3 libXaw-1.0.9 bdftopcf-1.0.3 encodings-1.0.4 fixesproto-5.0 font-adobe-100dpi-1.0.3 font-adobe-75dpi-1.0.3 font-adobe-utopia-100dpi-1.0.4 font-adobe-utopia-75dpi-1.0.4 font-adobe-utopia-type1-1.0.4 font-alias-1.0.3 font-arabic-misc-1.0.3 font-bh-100dpi-1.0.3 font-bh-75dpi-1.0.3 font-bh-lucidatypewriter-100dpi-1.0.3 font-bh-lucidatypewriter-75dpi-1.0.3 font-bh-ttf-1.0.3 font-bh-type1-1.0.3 font-bitstream-100dpi-1.0.3 font-bitstream-75dpi-1.0.3 font-bitstream-speedo-1.0.2 font-bitstream-type1-1.0.3 font-cronyx-cyrillic-1.0.3 font-cursor-misc-1.0.3 font-daewoo-misc-1.0.3 font-dec-misc-1.0.3 font-ibm-type1-1.0.3 font-isas-misc-1.0.3 font-jis-misc-1.0.3 font-micro-misc-1.0.3 font-misc-cyrillic-1.0.3 font-misc-ethiopic-1.0.3 font-misc-meltho-1.0.3 font-misc-misc-1.1.2 font-mutt-misc-1.0.3 font-schumacher-misc-1.1.2 font-screen-cyrillic-1.0.4 font-sony-misc-1.0.3 font-sun-misc-1.0.3 font-util-1.2.0 font-winitzki-cyrillic-1.0.3 font-xfree86-type1-1.0.4
Diffstat (limited to 'fontconfig/src/fclang.c')
-rw-r--r--fontconfig/src/fclang.c96
1 files changed, 80 insertions, 16 deletions
diff --git a/fontconfig/src/fclang.c b/fontconfig/src/fclang.c
index 1d62c4e3f..be42b58c4 100644
--- a/fontconfig/src/fclang.c
+++ b/fontconfig/src/fclang.c
@@ -7,9 +7,9 @@
* 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.
*
@@ -71,8 +71,22 @@ FcLangSetBitGet (const FcLangSet *ls,
return ((ls->map[bucket] >> (id & 0x1f)) & 1) ? FcTrue : FcFalse;
}
+static void
+FcLangSetBitReset (FcLangSet *ls,
+ unsigned int id)
+{
+ int bucket;
+
+ id = fcLangCharSetIndices[id];
+ bucket = id >> 5;
+ if (bucket >= ls->map_size)
+ return; /* shouldn't happen really */
+
+ ls->map[bucket] &= ~((FcChar32) 1 << (id & 0x1f));
+}
+
FcLangSet *
-FcFreeTypeLangSet (const FcCharSet *charset,
+FcFreeTypeLangSet (const FcCharSet *charset,
const FcChar8 *exclusiveLang)
{
int i, j;
@@ -85,7 +99,7 @@ FcFreeTypeLangSet (const FcCharSet *charset,
ls = FcLangSetCreate ();
if (!ls)
return 0;
- if (FcDebug() & FC_DBG_LANGSET)
+ if (FcDebug() & FC_DBG_LANGSET)
{
printf ("font charset");
FcCharSetPrint (charset);
@@ -93,7 +107,7 @@ FcFreeTypeLangSet (const FcCharSet *charset,
}
for (i = 0; i < NUM_LANG_CHAR_SET; i++)
{
- if (FcDebug() & FC_DBG_LANGSET)
+ if (FcDebug() & FC_DBG_LANGSET)
{
printf ("%s charset", fcLangCharSets[i].lang);
FcCharSetPrint (&fcLangCharSets[i].charset);
@@ -112,7 +126,7 @@ FcFreeTypeLangSet (const FcCharSet *charset,
continue;
for (j = 0; j < fcLangCharSets[i].charset.num; j++)
- if (FcCharSetLeaf(&fcLangCharSets[i].charset, j) !=
+ if (FcCharSetLeaf(&fcLangCharSets[i].charset, j) !=
FcCharSetLeaf(exclusiveCharset, j))
continue;
}
@@ -121,7 +135,7 @@ FcFreeTypeLangSet (const FcCharSet *charset,
{
if (missing && missing < 10)
{
- FcCharSet *missed = FcCharSetSubtract (&fcLangCharSets[i].charset,
+ FcCharSet *missed = FcCharSetSubtract (&fcLangCharSets[i].charset,
charset);
FcChar32 ucs4;
FcChar32 map[FC_CHARSET_MAP_SIZE];
@@ -154,8 +168,8 @@ FcFreeTypeLangSet (const FcCharSet *charset,
if (FcDebug() & FC_DBG_SCANV)
printf ("\n");
-
-
+
+
return ls;
}
@@ -188,7 +202,7 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
}
/*
- * Return FcTrue when super contains sub.
+ * Return FcTrue when super contains sub.
*
* super contains sub if super and sub have the same
* language and either the same country or one
@@ -329,9 +343,9 @@ FcLangSetIndex (const FcChar8 *lang)
{
int low, high, mid = 0;
int cmp = 0;
- FcChar8 firstChar = FcToLower(lang[0]);
+ FcChar8 firstChar = FcToLower(lang[0]);
FcChar8 secondChar = firstChar ? FcToLower(lang[1]) : '\0';
-
+
if (firstChar < 'a')
{
low = 0;
@@ -360,11 +374,11 @@ FcLangSetIndex (const FcChar8 *lang)
{ /* fast path for resolving 2-letter languages (by far the most common) after
* finding the first char (probably already true because of the hash table) */
cmp = fcLangCharSets[mid].lang[1] - secondChar;
- if (cmp == 0 &&
- (fcLangCharSets[mid].lang[2] != '\0' ||
+ if (cmp == 0 &&
+ (fcLangCharSets[mid].lang[2] != '\0' ||
lang[2] != '\0'))
{
- cmp = FcStrCmpIgnoreCase(fcLangCharSets[mid].lang+2,
+ cmp = FcStrCmpIgnoreCase(fcLangCharSets[mid].lang+2,
lang+2);
}
}
@@ -400,6 +414,23 @@ FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang)
return FcStrSetAdd (ls->extra, lang);
}
+FcBool
+FcLangSetDel (FcLangSet *ls, const FcChar8 *lang)
+{
+ int id;
+
+ id = FcLangSetIndex (lang);
+ if (id >= 0)
+ {
+ FcLangSetBitReset (ls, id);
+ }
+ else if (ls->extra)
+ {
+ FcStrSetDel (ls->extra, lang);
+ }
+ return FcTrue;
+}
+
FcLangResult
FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang)
{
@@ -505,6 +536,7 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
/*
* Used in computing values -- mustn't allocate any storage
+ * XXX Not thread-safe
*/
FcLangSet *
FcLangSetPromote (const FcChar8 *lang)
@@ -515,6 +547,7 @@ FcLangSetPromote (const FcChar8 *lang)
int id;
memset (ls.map, '\0', sizeof (ls.map));
+ ls.map_size = NUM_LANG_SET_MAP;
ls.extra = 0;
id = FcLangSetIndex (lang);
if (id > 0)
@@ -727,7 +760,7 @@ FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb)
if (missing)
{
for (j = 0; j < 32; j++)
- if (missing & (1 << j))
+ if (missing & (1 << j))
{
if (!FcLangSetContainsLang (lsa,
fcLangCharSets[fcLangCharSetIndicesInv[i*32 + j]].lang))
@@ -816,6 +849,37 @@ FcLangSetGetLangs (const FcLangSet *ls)
return langs;
}
+static FcLangSet *
+FcLangSetOperate(const FcLangSet *a,
+ const FcLangSet *b,
+ FcBool (*func) (FcLangSet *ls,
+ const FcChar8 *s))
+{
+ FcLangSet *langset = FcLangSetCopy (a);
+ FcStrList *sl = FcStrListCreate (FcLangSetGetLangs (b));
+ FcChar8 *str;
+
+ while ((str = FcStrListNext (sl)))
+ {
+ func (langset, str);
+ }
+ FcStrListDone (sl);
+
+ return langset;
+}
+
+FcLangSet *
+FcLangSetUnion (const FcLangSet *a, const FcLangSet *b)
+{
+ return FcLangSetOperate(a, b, FcLangSetAdd);
+}
+
+FcLangSet *
+FcLangSetSubtract (const FcLangSet *a, const FcLangSet *b)
+{
+ return FcLangSetOperate(a, b, FcLangSetDel);
+}
+
#define __fclang__
#include "fcaliastail.h"
#include "fcftaliastail.h"