summaryrefslogtreecommitdiff
blob: 08e3756b215f329f64e02e7a6ee9b612ea0c33f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
diff -urN fontconfig.orig/fc-lang/fc-lang.c fontconfig/fc-lang/fc-lang.c
--- fontconfig.orig/fc-lang/fc-lang.c	2002-08-22 09:36:43.000000000 +0200
+++ fontconfig/fc-lang/fc-lang.c	2002-12-16 11:16:29.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/fc-lang/fc-lang.c,v 1.3 2002/08/22 07:36:43 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/fc-lang/fc-lang.c,v 1.4 2002/12/14 02:03:58 dawes Exp $
  *
  * Copyright � 2002 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -165,22 +165,38 @@
     return FcStrCmpIgnoreCase (*as, *bs);
 }
 
+#define MAX_LANG	    1024
+#define MAX_LANG_SET_MAP    ((MAX_LANG + 31) / 32)
+
+#define BitSet(map, id)   ((map)[(id)>>5] |= ((FcChar32) 1 << ((id) & 0x1f)))
+#define BitGet(map, id)   ((map)[(id)>>5] >> ((id) & 0x1f)) & 1)
+
 int
 main (int argc, char **argv)
 {
-    char	*files[1024];
-    FcCharSet	*sets[1024];
-    int		duplicate[1024];
-    char	*names[1024];
+    char	*files[MAX_LANG];
+    FcCharSet	*sets[MAX_LANG];
+    int		duplicate[MAX_LANG];
+    int		country[MAX_LANG];
+    char	*names[MAX_LANG];
+    char	*langs[MAX_LANG];
     FILE	*f;
+    int		ncountry = 0;
     int		i = 0;
     FcCharLeaf	**leaves, **sleaves;
     int		total_leaves = 0;
     int		l, sl, tl;
+    int		c;
     char	line[1024];
+    FcChar32	map[MAX_LANG_SET_MAP];
+    int		num_lang_set_map;
     
     while (*++argv)
+    {
+	if (i == MAX_LANG)
+	    fatal (*argv, 0, "Too many languages");
 	files[i++] = *argv;
+    }
     files[i] = 0;
     qsort (files, i, sizeof (char *), compare);
     i = 0;
@@ -191,6 +207,10 @@
 	    fatal (files[i], 0, strerror (errno));
 	sets[i] = scan (f, files[i]);
 	names[i] = get_name (files[i]);
+	langs[i] = get_lang(names[i]);
+	if (strchr (langs[i], '-'))
+	    country[ncountry++] = i;
+
 	total_leaves += sets[i]->num;
 	i++;
 	fclose (f);
@@ -319,10 +339,54 @@
 		"      { FC_REF_CONSTANT, %d, "
 		"(FcCharLeaf **) leaves_%s, "
 		"(FcChar16 *) numbers_%s } },\n",
-		get_lang(names[i]),
+		langs[i],
 		sets[j]->num, names[j], names[j]);
     }
     printf ("};\n\n");
+    printf ("#define NUM_LANG_CHAR_SET	%d\n", i);
+    num_lang_set_map = (i + 31) / 32;
+    printf ("#define NUM_LANG_SET_MAP	%d\n", num_lang_set_map);
+    /*
+     * Dump indices with country codes
+     */
+    if (ncountry)
+    {
+	int	ncountry_ent = 0;
+	printf ("\n");
+	printf ("static const FcChar32 fcLangCountrySets[][NUM_LANG_SET_MAP] = {\n");
+	for (c = 0; c < ncountry; c++)
+	{
+	    i = country[c];
+	    if (i >= 0)
+	    {
+		int l = strchr (langs[i], '-') - langs[i];
+		int d, k;
+
+		for (k = 0; k < num_lang_set_map; k++)
+		    map[k] = 0;
+
+		BitSet (map, i);
+		for (d = c + 1; d < ncountry; d++)
+		{
+		    int j = country[d];
+		    if (j >= 0 && !strncmp (langs[j], langs[i], l))
+		    {
+			BitSet(map, j);
+			country[d] = -1;
+		    }
+		}
+		printf ("    {");
+		for (k = 0; k < num_lang_set_map; k++)
+		    printf (" 0x%08x,", map[k]);
+		printf (" }, /* %*.*s */\n",
+			l, l, langs[i]);
+		++ncountry_ent;
+	    }
+	}
+	printf ("};\n\n");
+	printf ("#define NUM_COUNTRY_SET %d\n", ncountry_ent);
+    }
+    
     while (fgets (line, sizeof (line), stdin))
 	fputs (line, stdout);
     
diff -urN fontconfig.orig/fc-lang/fclang.h fontconfig/fc-lang/fclang.h
--- fontconfig.orig/fc-lang/fclang.h	2002-10-21 19:03:47.000000000 +0200
+++ fontconfig/fc-lang/fclang.h	2002-12-16 11:16:29.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/fc-lang/fclang.h,v 1.20 2002/10/21 17:03:47 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/fc-lang/fclang.h,v 1.21 2002/12/14 02:03:58 dawes Exp $
  *
  * Copyright � 2002 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -3996,3 +3996,11 @@
       { FC_REF_CONSTANT, 1, (FcCharLeaf **) leaves_fj, (FcChar16 *) numbers_fj } },
 };
 
+#define NUM_LANG_CHAR_SET	175
+#define NUM_LANG_SET_MAP	6
+
+static const FcChar32 fcLangCountrySets[][NUM_LANG_SET_MAP] = {
+    { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003e00, }, /* zh */
+};
+
+#define NUM_COUNTRY_SET 1
diff -urN fontconfig.orig/fontconfig/fcprivate.h fontconfig/fontconfig/fcprivate.h
--- fontconfig.orig/fontconfig/fcprivate.h	2002-08-22 09:36:44.000000000 +0200
+++ fontconfig/fontconfig/fcprivate.h	2002-12-05 00:45:28.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/fontconfig/fcprivate.h,v 1.6 2002/08/22 07:36:44 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/fontconfig/fcprivate.h,v 1.7 2002/12/04 10:28:03 eich Exp $
  *
  * Copyright � 2001 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -87,7 +87,7 @@
     if (!orig)							    \
 	FcPatternDestroy (__p__);				    \
 _FcPatternVapBuild_bail0:					    \
-    result = 0;							    \
+    result = (void*)0;						    \
 								    \
 _FcPatternVapBuild_return:					    \
     ;								    \
diff -urN fontconfig.orig/setfontdirs fontconfig/setfontdirs
--- fontconfig.orig/setfontdirs	2002-08-01 18:17:33.000000000 +0200
+++ fontconfig/setfontdirs	2002-12-20 08:29:39.000000000 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $XFree86: xc/lib/fontconfig/setfontdirs,v 1.4 2002/08/01 16:17:33 keithp Exp $
+# $XFree86: xc/lib/fontconfig/setfontdirs,v 1.5 2002/12/17 03:26:36 dawes Exp $
 #
 LANG=C
 export LANG
@@ -9,7 +9,17 @@
 sh ./findfonts ${1+"$@"} > $FONTDIRS
 cp fonts.conf.in fonts.conf
 chmod +w fonts.conf
-ed fonts.conf << EOF
+EDITOR=ed
+(echo q | ed) > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+	EDITOR=ex
+	(echo q | ex) > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		echo "$0: *** Error: Cannot find 'ed' or 'ex' editor"
+		exit 1
+	fi
+fi
+$EDITOR fonts.conf << EOF
 /FONTPATH_END/a
 <!-- Font directory list configured on `date` -->
 .
diff -urN fontconfig.orig/src/fclang.c fontconfig/src/fclang.c
--- fontconfig.orig/src/fclang.c	2002-08-27 01:34:31.000000000 +0200
+++ fontconfig/src/fclang.c	2002-12-16 11:16:29.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fclang.c,v 1.7 2002/08/26 23:34:31 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fclang.c,v 1.8 2002/12/14 02:03:59 dawes Exp $
  *
  * Copyright � 2002 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -31,9 +31,6 @@
 
 #include "../fc-lang/fclang.h"
 
-#define NUM_LANG_CHAR_SET   (sizeof (fcLangCharSets) / sizeof (fcLangCharSets[0]))
-#define NUM_LANG_SET_MAP    ((NUM_LANG_CHAR_SET + 31) / 32)
-
 struct _FcLangSet {
     FcChar32	map[NUM_LANG_SET_MAP];
     FcStrSet	*extra;
@@ -339,13 +336,21 @@
 FcLangResult
 FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
 {
-    int		    i;
+    int		    i, j;
     FcLangResult    best, r;
 
     for (i = 0; i < NUM_LANG_SET_MAP; i++)
 	if (lsa->map[i] & lsb->map[i])
 	    return FcLangEqual;
     best = FcLangDifferentLang;
+    for (j = 0; j < NUM_COUNTRY_SET; j++)
+	for (i = 0; i < NUM_LANG_SET_MAP; i++)
+	    if ((lsa->map[i] & fcLangCountrySets[j][i]) &&
+		(lsb->map[i] & fcLangCountrySets[j][i]))
+	    {
+		best = FcLangDifferentCountry;
+		break;
+	    }
     if (lsa->extra)
     {
 	r = FcLangSetCompareStrSet (lsb, lsa->extra);
diff -urN fontconfig.orig/src/fcstr.c fontconfig/src/fcstr.c
--- fontconfig.orig/src/fcstr.c	2002-09-01 00:17:32.000000000 +0200
+++ fontconfig/src/fcstr.c	2002-12-16 11:16:29.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.10 2002/08/31 22:17:32 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.11 2002/12/14 01:59:38 dawes Exp $
  *
  * Copyright � 2000 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -283,7 +283,7 @@
 	if ((b & 0xfc00) != 0xdc00)
 	    return 0;
 	result = ((((FcChar32) a & 0x3ff) << 10) |
-		  ((FcChar32) b & 0x3ff)) | 0x10000;
+		  ((FcChar32) b & 0x3ff)) + 0x10000;
     }
     else
 	result = a;