beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / python.c
blob211ad7db6ee84c9708e0a3648ac03cf11d6cedd8
1 /* Copyright (C) 2007,2008 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /* Python Interface to FontForge */
30 #ifdef HAVE_CONFIG_H
31 # include <w2c/config.h>
32 #endif
34 #include <stdio.h>
36 #include "uiinterface.h"
38 typedef struct flaglist {
39 const char *name;
40 int flag;
41 } flaglist;
43 /* These don't get translated. They are a copy of a similar list in fontinfo.c */
44 static struct flaglist sfnt_name_str_ids[] = {
45 { "SubFamily", 2},
46 { "Copyright", 0},
47 { "Family", 1},
48 { "Fullname", 4},
49 { "UniqueID", 3},
50 { "Version", 5},
51 { "PostscriptName", 6},
52 { "Trademark", 7},
53 { "Manufacturer", 8},
54 { "Designer", 9},
55 { "Descriptor", 10},
56 { "Vendor URL", 11},
57 { "Designer URL", 12},
58 { "License", 13},
59 { "License URL", 14},
60 /* slot 15 is reserved */
61 { "Preferred Family", 16},
62 { "Preferred Styles", 17},
63 { "Compatible Full", 18},
64 { "Sample Text", 19},
65 { "CID findfont Name", 20},
66 { "WWS Family", 21},
67 { "WWS Subfamily", 22},
68 { NULL, 0 }
70 /* These don't get translated. They are a copy of a similar list in fontinfo.c */
71 static struct flaglist sfnt_name_mslangs[] = {
72 { "Afrikaans", 0x436},
73 { "Albanian", 0x41c},
74 { "Amharic", 0x45e},
75 { "Arabic (Saudi Arabia)", 0x401},
76 { "Arabic (Iraq)", 0x801},
77 { "Arabic (Egypt)", 0xc01},
78 { "Arabic (Libya)", 0x1001},
79 { "Arabic (Algeria)", 0x1401},
80 { "Arabic (Morocco)", 0x1801},
81 { "Arabic (Tunisia)", 0x1C01},
82 { "Arabic (Oman)", 0x2001},
83 { "Arabic (Yemen)", 0x2401},
84 { "Arabic (Syria)", 0x2801},
85 { "Arabic (Jordan)", 0x2c01},
86 { "Arabic (Lebanon)", 0x3001},
87 { "Arabic (Kuwait)", 0x3401},
88 { "Arabic (U.A.E.)", 0x3801},
89 { "Arabic (Bahrain)", 0x3c01},
90 { "Arabic (Qatar)", 0x4001},
91 { "Armenian", 0x42b},
92 { "Assamese", 0x44d},
93 { "Azeri (Latin)", 0x42c},
94 { "Azeri (Cyrillic)", 0x82c},
95 { "Basque", 0x42d},
96 { "Byelorussian", 0x423},
97 { "Bengali", 0x445},
98 { "Bengali Bangladesh", 0x845},
99 { "Bulgarian", 0x402},
100 { "Burmese", 0x455},
101 { "Catalan", 0x403},
102 { "Cambodian", 0x453},
103 { "Cherokee", 0x45c},
104 { "Chinese (Taiwan)", 0x404},
105 { "Chinese (PRC)", 0x804},
106 { "Chinese (Hong Kong)", 0xc04},
107 { "Chinese (Singapore)", 0x1004},
108 { "Chinese (Macau)", 0x1404},
109 { "Croatian", 0x41a},
110 { "Croatian Bosnia/Herzegovina", 0x101a},
111 { "Czech", 0x405},
112 { "Danish", 0x406},
113 { "Divehi", 0x465},
114 { "Dutch", 0x413},
115 { "Flemish (Belgian Dutch)", 0x813},
116 { "Edo", 0x466},
117 { "English (British)", 0x809},
118 { "English (US)", 0x409},
119 { "English (Canada)", 0x1009},
120 { "English (Australian)", 0xc09},
121 { "English (New Zealand)", 0x1409},
122 { "English (Irish)", 0x1809},
123 { "English (South Africa)", 0x1c09},
124 { "English (Jamaica)", 0x2009},
125 { "English (Caribbean)", 0x2409},
126 { "English (Belize)", 0x2809},
127 { "English (Trinidad)", 0x2c09},
128 { "English (Zimbabwe)", 0x3009},
129 { "English (Philippines)", 0x3409},
130 { "English (Indonesia)", 0x3809},
131 { "English (Hong Kong)", 0x3c09},
132 { "English (India)", 0x4009},
133 { "English (Malaysia)", 0x4409},
134 { "Estonian", 0x425},
135 { "Faeroese", 0x438},
136 { "Farsi", 0x429},
137 { "Filipino", 0x464},
138 { "Finnish", 0x40b},
139 { "French French", 0x40c},
140 { "French Belgium", 0x80c},
141 { "French Canadian", 0xc0c},
142 { "French Swiss", 0x100c},
143 { "French Luxembourg", 0x140c},
144 { "French Monaco", 0x180c},
145 { "French West Indies", 0x1c0c},
146 { "French Réunion", 0x200c},
147 { "French D.R. Congo", 0x240c},
148 { "French Senegal", 0x280c},
149 { "French Camaroon", 0x2c0c},
150 { "French Côte d'Ivoire", 0x300c},
151 { "French Mali", 0x340c},
152 { "French Morocco", 0x380c},
153 { "French Haiti", 0x3c0c},
154 { "French North Africa", 0xe40c},
155 { "Frisian", 0x462},
156 { "Fulfulde", 0x467},
157 { "Gaelic (Scottish)", 0x43c},
158 { "Gaelic (Irish)", 0x83c},
159 { "Galician", 0x467},
160 { "Georgian", 0x437},
161 { "German German", 0x407},
162 { "German Swiss", 0x807},
163 { "German Austrian", 0xc07},
164 { "German Luxembourg", 0x1007},
165 { "German Liechtenstein", 0x1407},
166 { "Greek", 0x408},
167 { "Guarani", 0x474},
168 { "Gujarati", 0x447},
169 { "Hausa", 0x468},
170 { "Hawaiian", 0x475},
171 { "Hebrew", 0x40d},
172 { "Hindi", 0x439},
173 { "Hungarian", 0x40e},
174 { "Ibibio", 0x469},
175 { "Icelandic", 0x40f},
176 { "Igbo", 0x470},
177 { "Indonesian", 0x421},
178 { "Inuktitut", 0x45d},
179 { "Italian", 0x410},
180 { "Italian Swiss", 0x810},
181 { "Japanese", 0x411},
182 { "Kannada", 0x44b},
183 { "Kanuri", 0x471},
184 { "Kashmiri (India)", 0x860},
185 { "Kazakh", 0x43f},
186 { "Khmer", 0x453},
187 { "Kirghiz", 0x440},
188 { "Konkani", 0x457},
189 { "Korean", 0x412},
190 { "Korean (Johab)", 0x812},
191 { "Lao", 0x454},
192 { "Latvian", 0x426},
193 { "Latin", 0x476},
194 { "Lithuanian", 0x427},
195 { "Lithuanian (Classic)", 0x827},
196 { "Macedonian", 0x42f},
197 { "Malay", 0x43e},
198 { "Malay (Brunei)", 0x83e},
199 { "Malayalam", 0x44c},
200 { "Maltese", 0x43a},
201 { "Manipuri", 0x458},
202 { "Maori", 0x481},
203 { "Marathi", 0x44e},
204 { "Mongolian (Cyrillic)", 0x450},
205 { "Mongolian (Mongolian)", 0x850},
206 { "Nepali", 0x461},
207 { "Nepali (India)", 0x861},
208 { "Norwegian (Bokmal)", 0x414},
209 { "Norwegian (Nynorsk)", 0x814},
210 { "Oriya", 0x448},
211 { "Oromo", 0x472},
212 { "Papiamentu", 0x479},
213 { "Pashto", 0x463},
214 { "Polish", 0x415},
215 { "Portugese (Portugal)", 0x416},
216 { "Portuguese (Brasil)", 0x816},
217 { "Punjabi (India)", 0x446},
218 { "Punjabi (Pakistan)", 0x846},
219 { "Quecha (Bolivia)", 0x46b},
220 { "Quecha (Ecuador)", 0x86b},
221 { "Quecha (Peru)", 0xc6b},
222 { "Rhaeto-Romanic", 0x417},
223 { "Romanian", 0x418},
224 { "Romanian (Moldova)", 0x818},
225 { "Russian", 0x419},
226 { "Russian (Moldova)", 0x819},
227 { "Sami (Lappish)", 0x43b},
228 { "Sanskrit", 0x43b},
229 { "Sepedi", 0x46c},
230 { "Serbian (Cyrillic)", 0xc1a},
231 { "Serbian (Latin)", 0x81a},
232 { "Sindhi India", 0x459},
233 { "Sindhi Pakistan", 0x859},
234 { "Sinhalese", 0x45b},
235 { "Slovak", 0x41b},
236 { "Slovenian", 0x424},
237 { "Sorbian", 0x42e},
238 { "Spanish (Traditional)", 0x40a},
239 { "Spanish Mexico", 0x80a},
240 { "Spanish (Modern)", 0xc0a},
241 { "Spanish (Guatemala)", 0x100a},
242 { "Spanish (Costa Rica)", 0x140a},
243 { "Spanish (Panama)", 0x180a},
244 { "Spanish (Dominican Republic)", 0x1c0a},
245 { "Spanish (Venezuela)", 0x200a},
246 { "Spanish (Colombia)", 0x240a},
247 { "Spanish (Peru)", 0x280a},
248 { "Spanish (Argentina)", 0x2c0a},
249 { "Spanish (Ecuador)", 0x300a},
250 { "Spanish (Chile)", 0x340a},
251 { "Spanish (Uruguay)", 0x380a},
252 { "Spanish (Paraguay)", 0x3c0a},
253 { "Spanish (Bolivia)", 0x400a},
254 { "Spanish (El Salvador)", 0x440a},
255 { "Spanish (Honduras)", 0x480a},
256 { "Spanish (Nicaragua)", 0x4c0a},
257 { "Spanish (Puerto Rico)", 0x500a},
258 { "Spanish (United States)", 0x540a},
259 { "Spanish (Latin America)", 0xe40a},
260 { "Sutu", 0x430},
261 { "Swahili (Kenyan)", 0x441},
262 { "Swedish (Sweden)", 0x41d},
263 { "Swedish (Finland)", 0x81d},
264 { "Syriac", 0x45a},
265 { "Tagalog", 0x464},
266 { "Tajik", 0x428},
267 { "Tamazight (Arabic)", 0x45f},
268 { "Tamazight (Latin)", 0x85f},
269 { "Tamil", 0x449},
270 { "Tatar (Tatarstan)", 0x444},
271 { "Telugu", 0x44a},
272 { "Thai", 0x41e},
273 { "Tibetan (PRC)", 0x451},
274 { "Tibetan Bhutan", 0x851},
275 { "Tigrinya Ethiopia", 0x473},
276 { "Tigrinyan Eritrea", 0x873},
277 { "Tsonga", 0x431},
278 { "Tswana", 0x432},
279 { "Turkish", 0x41f},
280 { "Turkmen", 0x442},
281 { "Uighur", 0x480},
282 { "Ukrainian", 0x422},
283 { "Urdu (Pakistan)", 0x420},
284 { "Urdu (India)", 0x820},
285 { "Uzbek (Latin)", 0x443},
286 { "Uzbek (Cyrillic)", 0x843},
287 { "Venda", 0x433},
288 { "Vietnamese", 0x42a},
289 { "Welsh", 0x452},
290 { "Xhosa", 0x434},
291 { "Yi", 0x478},
292 { "Yiddish", 0x43d},
293 { "Yoruba", 0x46a},
294 { "Zulu", 0x435},
295 { NULL, 0 }};
297 const char *NOUI_TTFNameIds(int id) {
298 int i;
300 for ( i=0; sfnt_name_str_ids[i].name!=NULL; ++i )
301 if ( sfnt_name_str_ids[i].flag == id )
302 return( (char *) sfnt_name_str_ids[i].name );
304 return( "Unknown" );
307 const char *NOUI_MSLangString(int language) {
308 int i;
310 for ( i=0; sfnt_name_mslangs[i].name!=NULL; ++i )
311 if ( sfnt_name_mslangs[i].flag == language )
312 return( (char *) sfnt_name_mslangs[i].name );
314 language &= 0xff;
315 for ( i=0; sfnt_name_mslangs[i].name!=NULL; ++i )
316 if ( sfnt_name_mslangs[i].flag == language )
317 return( (char *) sfnt_name_mslangs[i].name );
319 return( "Unknown" );