1 /* ====================================================================
2 * Copyright (c) 2011-2011 Open Source Applications Foundation.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 * ====================================================================
22 */
23
24 #include "common.h"
25 #include "structmember.h"
26
27 #if U_ICU_VERSION_HEX < VERSION_HEX(58, 0, 0)
28
29 #include <layout/LayoutEngine.h>
30 #include <layout/LEFontInstance.h>
31 #include <layout/LELanguages.h>
32 #include <layout/LEScripts.h>
33
34 #include "bases.h"
35 #include "layoutengine.h"
36 #include "macros.h"
37
38 DECLARE_CONSTANTS_TYPE(ScriptCode);
39 DECLARE_CONSTANTS_TYPE(LanguageCode);
40
41 static PyObject *getFontTable_NAME;
42
43 /* LEFontInstance */
44
45 class t_lefontinstance : public _wrapper {
46 public:
47 LEFontInstance *object;
48 };
49
50 U_NAMESPACE_BEGIN
51
52 class U_EXPORT PythonLEFontInstance : public LEFontInstance {
53 public:
54 /**
55 * ICU "poor man's RTTI", returns a UClassID for the actual class.
56 */
57 virtual UClassID getDynamicClassID() const;
58
59 /**
60 * ICU "poor man's RTTI", returns a UClassID for this class.
61 */
62 static UClassID getStaticClassID();
63
PythonLEFontInstance(t_lefontinstance * t_self)64 PythonLEFontInstance(t_lefontinstance *t_self) : self(t_self)
65 {
66 tables = PyDict_New();
67 }
68
69 /**
70 * Destructor.
71 */
~PythonLEFontInstance()72 virtual ~PythonLEFontInstance()
73 {
74 Py_DECREF(tables);
75 }
76
get_le_int32(const char * name) const77 le_int32 get_le_int32(const char *name) const
78 {
79 PyObject *s = PyString_FromString(name);
80 PyObject *result =
81 PyObject_CallMethodObjArgs((PyObject *) self, s, NULL);
82
83 Py_DECREF(s);
84 if (result != NULL)
85 {
86 int n;
87
88 if (!parseArg(result, "i", &n))
89 {
90 Py_DECREF(result);
91 return (le_int32) n;
92 }
93 }
94
95 return 0;
96 }
97
get_float(const char * name) const98 float get_float(const char *name) const
99 {
100 PyObject *s = PyString_FromString(name);
101 PyObject *result =
102 PyObject_CallMethodObjArgs((PyObject *) self, s, NULL);
103
104 Py_DECREF(s);
105 if (result != NULL)
106 {
107 double d;
108
109 if (!parseArg(result, "d", &d))
110 {
111 Py_DECREF(result);
112 return (float) d;
113 }
114 }
115
116 return 0.0f;
117 }
118
119 /**
120 * LEFontInstance API.
121 */
122
getFontTable(LETag tableTag,size_t & length) const123 virtual const void *getFontTable(LETag tableTag, size_t &length) const
124 {
125 length = -1;
126 return getFontTable(tableTag);
127 }
128
getFontTable(LETag tag) const129 virtual const void *getFontTable(LETag tag) const
130 {
131 #if PY_MAJOR_VERSION >= 3
132 PyObject *key = PyUnicode_FromStringAndSize(NULL, 4);
133 Py_UNICODE *s = PyUnicode_AS_UNICODE(key);
134 #else
135 PyObject *key = PyString_FromStringAndSize(NULL, 4);
136 char *s = PyString_AS_STRING(key);
137 #endif
138 for (int i = 0; i < 4; ++i) {
139 s[3 - i] = tag & 0xff;
140 tag >>= 8;
141 }
142
143 PyObject *result = PyDict_GetItem(tables, key);
144
145 if (result == NULL)
146 {
147 result = PyObject_CallMethodObjArgs((PyObject *) self,
148 getFontTable_NAME, key, NULL);
149 if (result == NULL)
150 {
151 if (PyErr_ExceptionMatches(PyExc_KeyError))
152 PyErr_Clear();
153 Py_DECREF(key);
154
155 return NULL;
156 }
157
158 #if PY_MAJOR_VERSION >= 3
159 if (!PyBytes_CheckExact(result))
160 #else
161 if (!PyString_CheckExact(result))
162 #endif
163 {
164 PyErr_SetObject(PyExc_TypeError, result);
165 Py_DECREF(result);
166 Py_DECREF(key);
167
168 return NULL;
169 }
170
171 PyDict_SetItem(tables, key, result);
172
173 Py_DECREF(result);
174 Py_DECREF(key);
175 }
176 else
177 Py_DECREF(key);
178
179 #if PY_MAJOR_VERSION >= 3
180 return PyBytes_AS_STRING(result);
181 #else
182 return PyString_AS_STRING(result);
183 #endif
184 }
185
getAscent() const186 virtual le_int32 getAscent() const
187 {
188 return get_le_int32("getAscent");
189 }
190
getDescent() const191 virtual le_int32 getDescent() const
192 {
193 return get_le_int32("getDescent");
194 }
195
getLeading() const196 virtual le_int32 getLeading() const
197 {
198 return get_le_int32("getLeading");
199 }
200
getUnitsPerEM() const201 virtual le_int32 getUnitsPerEM() const
202 {
203 return get_le_int32("getUnitsPerEm");
204 }
205
mapCharToGlyph(LEUnicode32 u) const206 virtual LEGlyphID mapCharToGlyph(LEUnicode32 u) const
207 {
208 PyObject *name = PyString_FromString("mapCharToGlyph");
209 PyObject *n = PyInt_FromLong(u);
210 PyObject *result =
211 PyObject_CallMethodObjArgs((PyObject *) self, name, n, NULL);
212
213 Py_DECREF(n);
214 Py_DECREF(name);
215 if (result != NULL)
216 {
217 int id;
218
219 if (!parseArg(result, "i", &id))
220 {
221 Py_DECREF(result);
222 return id;
223 }
224 }
225
226 return 0;
227 }
228
mapCharToGlyph(LEUnicode32 u,const LECharMapper * mapper) const229 virtual LEGlyphID mapCharToGlyph(LEUnicode32 u,
230 const LECharMapper *mapper) const {
231 return LEFontInstance::mapCharToGlyph(u, mapper);
232 }
233
mapCharToGlyph(LEUnicode32 u,const LECharMapper * mapper,le_bool filterZeroWidth) const234 virtual LEGlyphID mapCharToGlyph(LEUnicode32 u, const LECharMapper *mapper,
235 le_bool filterZeroWidth) const {
236 return LEFontInstance::mapCharToGlyph(u, mapper, filterZeroWidth);
237 }
238
getGlyphAdvance(LEGlyphID glyph,LEPoint & advance) const239 virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
240 {
241 PyObject *name = PyString_FromString("getGlyphAdvance");
242 PyObject *g = PyInt_FromLong(LE_GET_GLYPH(glyph));
243 PyObject *result =
244 PyObject_CallMethodObjArgs((PyObject *) self, name, g, NULL);
245
246 Py_DECREF(g);
247 Py_DECREF(name);
248
249 if (result != NULL)
250 {
251 PyArg_ParseTuple(result, "ff", &advance.fX, &advance.fY);
252 Py_DECREF(result);
253 }
254 }
255
getGlyphPoint(LEGlyphID glyph,le_int32 pointNumber,LEPoint & point) const256 virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber,
257 LEPoint &point) const
258 {
259 PyObject *name = PyString_FromString("getGlyphPoint");
260 PyObject *g = PyInt_FromLong(LE_GET_GLYPH(glyph));
261 PyObject *pn = PyInt_FromLong(pointNumber);
262 PyObject *result =
263 PyObject_CallMethodObjArgs((PyObject *) self, name, g, pn, NULL);
264
265 Py_DECREF(pn);
266 Py_DECREF(g);
267 Py_DECREF(name);
268
269 if (result != NULL)
270 {
271 PyArg_ParseTuple(result, "ff", &point.fX, &point.fY);
272 Py_DECREF(result);
273
274 return true;
275 }
276
277 return false;
278 }
279
getXPixelsPerEm() const280 virtual float getXPixelsPerEm() const
281 {
282 return get_float("getXPixelsPerEm");
283 }
284
getYPixelsPerEm() const285 virtual float getYPixelsPerEm() const
286 {
287 return get_float("getYPixelsPerEm");
288 }
289
getScaleFactorX() const290 virtual float getScaleFactorX() const
291 {
292 return get_float("getScaleFactorX");
293 }
294
getScaleFactorY() const295 virtual float getScaleFactorY() const
296 {
297 return get_float("getScaleFactorY");
298 }
299
300 private:
301 t_lefontinstance *self;
302 PyObject *tables;
303 };
304
305 U_NAMESPACE_END
306
307 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PythonLEFontInstance);
308
309 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getFontTable);
310 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getAscent);
311 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getDescent);
312 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getLeading);
313 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, canDisplay);
314 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getUnitsPerEm);
315 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, mapCharToGlyph);
316 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getGlyphAdvance);
317 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getGlyphPoint);
318 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getXPixelsPerEm);
319 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getYPixelsPerEm);
320 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getScaleFactorX);
321 DEFINE_ABSTRACT(t_lefontinstance, LEFontInstance, getScaleFactorY);
322
323 static PyMethodDef t_lefontinstance_methods[] = {
324 DECLARE_METHOD(t_lefontinstance, getFontTable, METH_O),
325 DECLARE_METHOD(t_lefontinstance, getAscent, METH_NOARGS),
326 DECLARE_METHOD(t_lefontinstance, getDescent, METH_NOARGS),
327 DECLARE_METHOD(t_lefontinstance, getLeading, METH_NOARGS),
328 DECLARE_METHOD(t_lefontinstance, canDisplay, METH_O),
329 DECLARE_METHOD(t_lefontinstance, getUnitsPerEm, METH_NOARGS),
330 DECLARE_METHOD(t_lefontinstance, mapCharToGlyph, METH_O),
331 DECLARE_METHOD(t_lefontinstance, getGlyphAdvance, METH_O),
332 DECLARE_METHOD(t_lefontinstance, getGlyphPoint, METH_VARARGS),
333 DECLARE_METHOD(t_lefontinstance, getXPixelsPerEm, METH_NOARGS),
334 DECLARE_METHOD(t_lefontinstance, getYPixelsPerEm, METH_NOARGS),
335 DECLARE_METHOD(t_lefontinstance, getScaleFactorX, METH_NOARGS),
336 DECLARE_METHOD(t_lefontinstance, getScaleFactorY, METH_NOARGS),
337 { NULL, NULL, 0, NULL }
338 };
339
340 static int t_lefontinstance_init(t_lefontinstance *self,
341 PyObject *args, PyObject *kwds);
342
343 DECLARE_TYPE(LEFontInstance, t_lefontinstance, UObject, LEFontInstance,
344 t_lefontinstance_init, NULL);
345
t_lefontinstance_init(t_lefontinstance * self,PyObject * args,PyObject * kwds)346 static int t_lefontinstance_init(t_lefontinstance *self,
347 PyObject *args, PyObject *kwds)
348 {
349 if (PyTuple_Size(args) == 0)
350 {
351 self->object = new PythonLEFontInstance(self);
352 self->flags = T_OWNED;
353 return 0;
354 }
355
356 PyErr_SetArgsError((PyObject *) self, "__init__", args);
357 return -1;
358 }
359
360
361 /* LayoutEngine */
362
363 class t_layoutengine : public _wrapper {
364 public:
365 LayoutEngine *object;
366 };
367
368 static PyObject *t_layoutengine_layoutEngineFactory(PyTypeObject *type,
369 PyObject *args);
370 static PyObject *t_layoutengine_layoutChars(t_layoutengine *self,
371 PyObject *args);
372 static PyObject *t_layoutengine_getGlyphCount(t_layoutengine *self);
373 static PyObject *t_layoutengine_getGlyphs(t_layoutengine *self);
374 static PyObject *t_layoutengine_getCharIndices(t_layoutengine *self);
375 static PyObject *t_layoutengine_getGlyphPositions(t_layoutengine *self);
376 static PyObject *t_layoutengine_getGlyphPosition(t_layoutengine *self,
377 PyObject *arg);
378
379 static PyMethodDef t_layoutengine_methods[] = {
380 DECLARE_METHOD(t_layoutengine, layoutEngineFactory, METH_VARARGS | METH_CLASS),
381 DECLARE_METHOD(t_layoutengine, layoutChars, METH_VARARGS),
382 DECLARE_METHOD(t_layoutengine, getGlyphCount, METH_NOARGS),
383 DECLARE_METHOD(t_layoutengine, getGlyphs, METH_NOARGS),
384 DECLARE_METHOD(t_layoutengine, getCharIndices, METH_NOARGS),
385 DECLARE_METHOD(t_layoutengine, getGlyphPositions, METH_NOARGS),
386 DECLARE_METHOD(t_layoutengine, getGlyphPosition, METH_O),
387 { NULL, NULL, 0, NULL }
388 };
389
390 DECLARE_TYPE(LayoutEngine, t_layoutengine, UObject, LayoutEngine,
391 abstract_init, NULL);
392
393
t_layoutengine_layoutEngineFactory(PyTypeObject * type,PyObject * args)394 static PyObject *t_layoutengine_layoutEngineFactory(PyTypeObject *type,
395 PyObject *args)
396 {
397 LayoutEngine *le = NULL;
398 LEFontInstance *fe;
399 le_int32 script, language, typo_flag;
400
401 switch (PyTuple_Size(args)) {
402 case 3:
403 if (!parseArgs(args, "Pii", TYPE_CLASSID(LEFontInstance), &fe,
404 &script, &language))
405 {
406 STATUS_CALL(
407 le = LayoutEngine::layoutEngineFactory(
408 fe, script, language, (LEErrorCode &) status));
409 break;
410 }
411 return PyErr_SetArgsError((PyObject *) type, "__init__", args);
412
413 case 4:
414 if (!parseArgs(args, "Piii", TYPE_CLASSID(LEFontInstance), &fe,
415 &script, &language, &typo_flag))
416 {
417 STATUS_CALL(
418 le = LayoutEngine::layoutEngineFactory(
419 fe, script, language, typo_flag, (LEErrorCode &) status));
420 break;
421 }
422 return PyErr_SetArgsError((PyObject *) type, "__init__", args);
423
424 default:
425 return PyErr_SetArgsError((PyObject *) type, "__init__", args);
426 }
427
428 return wrap_LayoutEngine(le, T_OWNED);
429 }
430
t_layoutengine_layoutChars(t_layoutengine * self,PyObject * args)431 static PyObject *t_layoutengine_layoutChars(t_layoutengine *self,
432 PyObject *args)
433 {
434 UnicodeString *u0, _u0;
435 le_int32 n, offset, count;
436 double x, y;
437 int rtl;
438
439 switch (PyTuple_Size(args)) {
440 case 1:
441 if (!parseArgs(args, "S", &u0, &_u0))
442 {
443 STATUS_CALL(
444 n = self->object->layoutChars(
445 (const LEUnicode *) (u0->getBuffer()),
446 0, u0->length(), u0->length(), false,
447 0.0f, 0.0f, (LEErrorCode &) status));
448 return PyInt_FromLong(n);
449 }
450 break;
451 case 3:
452 if (!parseArgs(args, "Sii", &u0, &_u0, &offset, &count))
453 {
454 STATUS_CALL(
455 n = self->object->layoutChars(
456 (const LEUnicode *) (u0->getBuffer()),
457 offset, count, u0->length(), false,
458 0.0f, 0.0f, (LEErrorCode &) status));
459 return PyInt_FromLong(n);
460 }
461 break;
462 case 4:
463 if (!parseArgs(args, "Siii", &u0, &_u0, &offset, &count, &rtl))
464 {
465 STATUS_CALL(
466 n = self->object->layoutChars(
467 (const LEUnicode *) (u0->getBuffer()),
468 offset, count, u0->length(), rtl,
469 0.0f, 0.0f, (LEErrorCode &) status));
470 return PyInt_FromLong(n);
471 }
472 break;
473 case 6:
474 if (!parseArgs(args, "Siiidd", &u0, &_u0, &offset, &count, &rtl,
475 &x, &y))
476 {
477 STATUS_CALL(
478 n = self->object->layoutChars(
479 (const LEUnicode *) (u0->getBuffer()),
480 offset, count, u0->length(), rtl,
481 (float) x, (float) y, (LEErrorCode &) status));
482 return PyInt_FromLong(n);
483 }
484 break;
485 }
486
487 return PyErr_SetArgsError((PyObject *) self, "layoutChars", args);
488 }
489
t_layoutengine_getGlyphCount(t_layoutengine * self)490 static PyObject *t_layoutengine_getGlyphCount(t_layoutengine *self)
491 {
492 return PyInt_FromLong(self->object->getGlyphCount());
493 }
494
t_layoutengine_getGlyphs(t_layoutengine * self)495 static PyObject *t_layoutengine_getGlyphs(t_layoutengine *self)
496 {
497 le_int32 num = self->object->getGlyphCount();
498 LEGlyphID *glyphs = new LEGlyphID[num];
499 PyObject *tuple;
500
501 STATUS_CALL(self->object->getGlyphs(glyphs, (LEErrorCode &) status));
502
503 tuple = PyTuple_New(num);
504 for (int i = 0; i < num; i++)
505 PyTuple_SET_ITEM(tuple, i, PyInt_FromLong(glyphs[i]));
506 delete[] glyphs;
507
508 return tuple;
509 }
510
t_layoutengine_getCharIndices(t_layoutengine * self)511 static PyObject *t_layoutengine_getCharIndices(t_layoutengine *self)
512 {
513 le_int32 num = self->object->getGlyphCount();
514 le_int32 *charIndices = new le_int32[num];
515 PyObject *tuple;
516
517 STATUS_CALL(self->object->getCharIndices(charIndices,
518 (LEErrorCode &) status));
519 tuple = PyTuple_New(num);
520 for (int i = 0; i < num; i++)
521 PyTuple_SET_ITEM(tuple, i, PyInt_FromLong(charIndices[i]));
522 delete[] charIndices;
523
524 return tuple;
525 }
526
t_layoutengine_getGlyphPositions(t_layoutengine * self)527 static PyObject *t_layoutengine_getGlyphPositions(t_layoutengine *self)
528 {
529 le_int32 num = self->object->getGlyphCount() + 1;
530 float *positions = new float[num * 2];
531 PyObject *tuple;
532
533 STATUS_CALL(self->object->getGlyphPositions(positions,
534 (LEErrorCode &) status));
535 tuple = PyTuple_New(num);
536 for (int i = 0; i < num; i++)
537 PyTuple_SET_ITEM(tuple, i, Py_BuildValue("(ff)", positions[2 * i],
538 positions[2 * i + 1]));
539 delete[] positions;
540
541 return tuple;
542 }
543
t_layoutengine_getGlyphPosition(t_layoutengine * self,PyObject * arg)544 static PyObject *t_layoutengine_getGlyphPosition(t_layoutengine *self,
545 PyObject *arg)
546 {
547 le_int32 n;
548 float x, y;
549
550 if (!parseArg(arg, "i", &n))
551 {
552 STATUS_CALL(self->object->getGlyphPosition(n, x, y,
553 (LEErrorCode &) status));
554 return Py_BuildValue("(ff)", x, y);
555 }
556
557 return PyErr_SetArgsError((PyObject *) self, "getGlyphPosition", arg);
558 }
559
560
_init_layoutengine(PyObject * m)561 void _init_layoutengine(PyObject *m)
562 {
563 INSTALL_CONSTANTS_TYPE(ScriptCode, m);
564 INSTALL_CONSTANTS_TYPE(LanguageCode, m);
565
566 REGISTER_TYPE(LEFontInstance, m);
567 REGISTER_TYPE(LayoutEngine, m);
568
569 INSTALL_ENUM(ScriptCode, "zyyy", zyyyScriptCode);
570 #if U_ICU_VERSION_HEX >= 0x04040200
571 INSTALL_ENUM(ScriptCode, "zinh", zinhScriptCode);
572 #endif
573 INSTALL_ENUM(ScriptCode, "qaai", qaaiScriptCode);
574 INSTALL_ENUM(ScriptCode, "arab", arabScriptCode);
575 INSTALL_ENUM(ScriptCode, "armn", armnScriptCode);
576 INSTALL_ENUM(ScriptCode, "beng", bengScriptCode);
577 INSTALL_ENUM(ScriptCode, "bopo", bopoScriptCode);
578 INSTALL_ENUM(ScriptCode, "cher", cherScriptCode);
579 INSTALL_ENUM(ScriptCode, "copt", coptScriptCode);
580 INSTALL_ENUM(ScriptCode, "cyrl", cyrlScriptCode);
581 INSTALL_ENUM(ScriptCode, "dsrt", dsrtScriptCode);
582 INSTALL_ENUM(ScriptCode, "deva", devaScriptCode);
583 INSTALL_ENUM(ScriptCode, "ethi", ethiScriptCode);
584 INSTALL_ENUM(ScriptCode, "geor", georScriptCode);
585 INSTALL_ENUM(ScriptCode, "goth", gothScriptCode);
586 INSTALL_ENUM(ScriptCode, "grek", grekScriptCode);
587 INSTALL_ENUM(ScriptCode, "gujr", gujrScriptCode);
588 INSTALL_ENUM(ScriptCode, "guru", guruScriptCode);
589 INSTALL_ENUM(ScriptCode, "hani", haniScriptCode);
590 INSTALL_ENUM(ScriptCode, "hang", hangScriptCode);
591 INSTALL_ENUM(ScriptCode, "hebr", hebrScriptCode);
592 INSTALL_ENUM(ScriptCode, "hira", hiraScriptCode);
593 INSTALL_ENUM(ScriptCode, "knda", kndaScriptCode);
594 INSTALL_ENUM(ScriptCode, "kana", kanaScriptCode);
595 INSTALL_ENUM(ScriptCode, "khmr", khmrScriptCode);
596 INSTALL_ENUM(ScriptCode, "laoo", laooScriptCode);
597 INSTALL_ENUM(ScriptCode, "latn", latnScriptCode);
598 INSTALL_ENUM(ScriptCode, "mlym", mlymScriptCode);
599 INSTALL_ENUM(ScriptCode, "mong", mongScriptCode);
600 INSTALL_ENUM(ScriptCode, "mymr", mymrScriptCode);
601 INSTALL_ENUM(ScriptCode, "ogam", ogamScriptCode);
602 INSTALL_ENUM(ScriptCode, "ital", italScriptCode);
603 INSTALL_ENUM(ScriptCode, "orya", oryaScriptCode);
604 INSTALL_ENUM(ScriptCode, "runr", runrScriptCode);
605 INSTALL_ENUM(ScriptCode, "sinh", sinhScriptCode);
606 INSTALL_ENUM(ScriptCode, "syrc", syrcScriptCode);
607 INSTALL_ENUM(ScriptCode, "taml", tamlScriptCode);
608 INSTALL_ENUM(ScriptCode, "telu", teluScriptCode);
609 INSTALL_ENUM(ScriptCode, "thaa", thaaScriptCode);
610 INSTALL_ENUM(ScriptCode, "thai", thaiScriptCode);
611 INSTALL_ENUM(ScriptCode, "tibt", tibtScriptCode);
612 INSTALL_ENUM(ScriptCode, "cans", cansScriptCode);
613 INSTALL_ENUM(ScriptCode, "yiii", yiiiScriptCode);
614 INSTALL_ENUM(ScriptCode, "tglg", tglgScriptCode);
615 INSTALL_ENUM(ScriptCode, "hano", hanoScriptCode);
616 INSTALL_ENUM(ScriptCode, "buhd", buhdScriptCode);
617 INSTALL_ENUM(ScriptCode, "tagb", tagbScriptCode);
618 INSTALL_ENUM(ScriptCode, "brai", braiScriptCode);
619 INSTALL_ENUM(ScriptCode, "cprt", cprtScriptCode);
620 INSTALL_ENUM(ScriptCode, "limb", limbScriptCode);
621 INSTALL_ENUM(ScriptCode, "linb", linbScriptCode);
622 INSTALL_ENUM(ScriptCode, "osma", osmaScriptCode);
623 INSTALL_ENUM(ScriptCode, "shaw", shawScriptCode);
624 INSTALL_ENUM(ScriptCode, "tale", taleScriptCode);
625 INSTALL_ENUM(ScriptCode, "ugar", ugarScriptCode);
626 INSTALL_ENUM(ScriptCode, "hrkt", hrktScriptCode);
627 INSTALL_ENUM(ScriptCode, "bugi", bugiScriptCode);
628 INSTALL_ENUM(ScriptCode, "glag", glagScriptCode);
629 INSTALL_ENUM(ScriptCode, "khar", kharScriptCode);
630 INSTALL_ENUM(ScriptCode, "sylo", syloScriptCode);
631 INSTALL_ENUM(ScriptCode, "talu", taluScriptCode);
632 INSTALL_ENUM(ScriptCode, "tfng", tfngScriptCode);
633 INSTALL_ENUM(ScriptCode, "xpeo", xpeoScriptCode);
634 INSTALL_ENUM(ScriptCode, "bali", baliScriptCode);
635 INSTALL_ENUM(ScriptCode, "batk", batkScriptCode);
636 INSTALL_ENUM(ScriptCode, "blis", blisScriptCode);
637 INSTALL_ENUM(ScriptCode, "brah", brahScriptCode);
638 INSTALL_ENUM(ScriptCode, "cham", chamScriptCode);
639 INSTALL_ENUM(ScriptCode, "cirt", cirtScriptCode);
640 INSTALL_ENUM(ScriptCode, "cyrs", cyrsScriptCode);
641 INSTALL_ENUM(ScriptCode, "egyd", egydScriptCode);
642 INSTALL_ENUM(ScriptCode, "egyh", egyhScriptCode);
643 INSTALL_ENUM(ScriptCode, "egyp", egypScriptCode);
644 INSTALL_ENUM(ScriptCode, "geok", geokScriptCode);
645 INSTALL_ENUM(ScriptCode, "hans", hansScriptCode);
646 INSTALL_ENUM(ScriptCode, "hant", hantScriptCode);
647 INSTALL_ENUM(ScriptCode, "hmng", hmngScriptCode);
648 INSTALL_ENUM(ScriptCode, "hung", hungScriptCode);
649 INSTALL_ENUM(ScriptCode, "inds", indsScriptCode);
650 INSTALL_ENUM(ScriptCode, "java", javaScriptCode);
651 INSTALL_ENUM(ScriptCode, "kali", kaliScriptCode);
652 INSTALL_ENUM(ScriptCode, "latf", latfScriptCode);
653 INSTALL_ENUM(ScriptCode, "latg", latgScriptCode);
654 INSTALL_ENUM(ScriptCode, "lepc", lepcScriptCode);
655 INSTALL_ENUM(ScriptCode, "lina", linaScriptCode);
656 INSTALL_ENUM(ScriptCode, "mand", mandScriptCode);
657 INSTALL_ENUM(ScriptCode, "maya", mayaScriptCode);
658 INSTALL_ENUM(ScriptCode, "mero", meroScriptCode);
659 INSTALL_ENUM(ScriptCode, "nkoo", nkooScriptCode);
660 INSTALL_ENUM(ScriptCode, "orkh", orkhScriptCode);
661 INSTALL_ENUM(ScriptCode, "perm", permScriptCode);
662 INSTALL_ENUM(ScriptCode, "phag", phagScriptCode);
663 INSTALL_ENUM(ScriptCode, "phnx", phnxScriptCode);
664 INSTALL_ENUM(ScriptCode, "plrd", plrdScriptCode);
665 INSTALL_ENUM(ScriptCode, "roro", roroScriptCode);
666 INSTALL_ENUM(ScriptCode, "sara", saraScriptCode);
667 INSTALL_ENUM(ScriptCode, "syre", syreScriptCode);
668 INSTALL_ENUM(ScriptCode, "syrj", syrjScriptCode);
669 INSTALL_ENUM(ScriptCode, "syrn", syrnScriptCode);
670 INSTALL_ENUM(ScriptCode, "teng", tengScriptCode);
671 INSTALL_ENUM(ScriptCode, "vaii", vaiiScriptCode);
672 INSTALL_ENUM(ScriptCode, "visp", vispScriptCode);
673 INSTALL_ENUM(ScriptCode, "xsux", xsuxScriptCode);
674 INSTALL_ENUM(ScriptCode, "zxxx", zxxxScriptCode);
675 INSTALL_ENUM(ScriptCode, "zzzz", zzzzScriptCode);
676 INSTALL_ENUM(ScriptCode, "cari", cariScriptCode);
677 INSTALL_ENUM(ScriptCode, "jpan", jpanScriptCode);
678 INSTALL_ENUM(ScriptCode, "lana", lanaScriptCode);
679 INSTALL_ENUM(ScriptCode, "lyci", lyciScriptCode);
680 INSTALL_ENUM(ScriptCode, "lydi", lydiScriptCode);
681 INSTALL_ENUM(ScriptCode, "olck", olckScriptCode);
682 INSTALL_ENUM(ScriptCode, "rjng", rjngScriptCode);
683 INSTALL_ENUM(ScriptCode, "saur", saurScriptCode);
684 INSTALL_ENUM(ScriptCode, "sgnw", sgnwScriptCode);
685 INSTALL_ENUM(ScriptCode, "sund", sundScriptCode);
686 INSTALL_ENUM(ScriptCode, "moon", moonScriptCode);
687 INSTALL_ENUM(ScriptCode, "mtei", mteiScriptCode);
688
689 #if U_ICU_VERSION_HEX >= 0x04000000
690 INSTALL_ENUM(ScriptCode, "armi", armiScriptCode);
691 INSTALL_ENUM(ScriptCode, "avst", avstScriptCode);
692 INSTALL_ENUM(ScriptCode, "cakm", cakmScriptCode);
693 INSTALL_ENUM(ScriptCode, "kore", koreScriptCode);
694 INSTALL_ENUM(ScriptCode, "kthi", kthiScriptCode);
695 INSTALL_ENUM(ScriptCode, "mani", maniScriptCode);
696 INSTALL_ENUM(ScriptCode, "phli", phliScriptCode);
697 INSTALL_ENUM(ScriptCode, "phlp", phlpScriptCode);
698 INSTALL_ENUM(ScriptCode, "phlv", phlvScriptCode);
699 INSTALL_ENUM(ScriptCode, "prti", prtiScriptCode);
700 INSTALL_ENUM(ScriptCode, "samr", samrScriptCode);
701 INSTALL_ENUM(ScriptCode, "tavt", tavtScriptCode);
702 INSTALL_ENUM(ScriptCode, "zmth", zmthScriptCode);
703 INSTALL_ENUM(ScriptCode, "zsym", zsymScriptCode);
704
705 #if U_ICU_VERSION_HEX >= 0x04040000
706 INSTALL_ENUM(ScriptCode, "bamu", bamuScriptCode);
707 INSTALL_ENUM(ScriptCode, "lisu", lisuScriptCode);
708 INSTALL_ENUM(ScriptCode, "nkgb", nkgbScriptCode);
709 INSTALL_ENUM(ScriptCode, "sarb", sarbScriptCode);
710
711 #if U_ICU_VERSION_HEX >= 0x04060000
712 INSTALL_ENUM(ScriptCode, "bass", bassScriptCode);
713 INSTALL_ENUM(ScriptCode, "dupl", duplScriptCode);
714 INSTALL_ENUM(ScriptCode, "elba", elbaScriptCode);
715 INSTALL_ENUM(ScriptCode, "gran", granScriptCode);
716 INSTALL_ENUM(ScriptCode, "kpel", kpelScriptCode);
717 INSTALL_ENUM(ScriptCode, "loma", lomaScriptCode);
718 INSTALL_ENUM(ScriptCode, "mend", mendScriptCode);
719 INSTALL_ENUM(ScriptCode, "merc", mercScriptCode);
720 INSTALL_ENUM(ScriptCode, "narb", narbScriptCode);
721 INSTALL_ENUM(ScriptCode, "nbat", nbatScriptCode);
722 INSTALL_ENUM(ScriptCode, "palm", palmScriptCode);
723 INSTALL_ENUM(ScriptCode, "sind", sindScriptCode);
724 INSTALL_ENUM(ScriptCode, "wara", waraScriptCode);
725
726 #if U_ICU_VERSION_HEX >= VERSION_HEX(49, 0, 0)
727 INSTALL_ENUM(ScriptCode, "afak", afakScriptCode);
728 INSTALL_ENUM(ScriptCode, "jurc", jurcScriptCode);
729 INSTALL_ENUM(ScriptCode, "khoj", khojScriptCode);
730 INSTALL_ENUM(ScriptCode, "mroo", mrooScriptCode);
731 INSTALL_ENUM(ScriptCode, "nshu", nshuScriptCode);
732 INSTALL_ENUM(ScriptCode, "shrd", shrdScriptCode);
733 INSTALL_ENUM(ScriptCode, "sora", soraScriptCode);
734 INSTALL_ENUM(ScriptCode, "takr", takrScriptCode);
735 INSTALL_ENUM(ScriptCode, "tang", tangScriptCode);
736 INSTALL_ENUM(ScriptCode, "tirh", tirhScriptCode);
737 INSTALL_ENUM(ScriptCode, "wole", woleScriptCode);
738 #endif /* 49.0 */
739 #endif /* 4.6 */
740 #endif /* 4.4 */
741 #endif /* 4.0 */
742
743 INSTALL_ENUM(LanguageCode, "nul", nullLanguageCode);
744 INSTALL_ENUM(LanguageCode, "ara", araLanguageCode);
745 INSTALL_ENUM(LanguageCode, "asm", asmLanguageCode);
746 INSTALL_ENUM(LanguageCode, "ben", benLanguageCode);
747 INSTALL_ENUM(LanguageCode, "far", farLanguageCode);
748 INSTALL_ENUM(LanguageCode, "guj", gujLanguageCode);
749 INSTALL_ENUM(LanguageCode, "hin", hinLanguageCode);
750 INSTALL_ENUM(LanguageCode, "iwr", iwrLanguageCode);
751 INSTALL_ENUM(LanguageCode, "jii", jiiLanguageCode);
752 INSTALL_ENUM(LanguageCode, "jan", janLanguageCode);
753 INSTALL_ENUM(LanguageCode, "kan", kanLanguageCode);
754 INSTALL_ENUM(LanguageCode, "kok", kokLanguageCode);
755 INSTALL_ENUM(LanguageCode, "kor", korLanguageCode);
756 INSTALL_ENUM(LanguageCode, "ksh", kshLanguageCode);
757 INSTALL_ENUM(LanguageCode, "mal", malLanguageCode);
758 INSTALL_ENUM(LanguageCode, "mar", marLanguageCode);
759 INSTALL_ENUM(LanguageCode, "mlr", mlrLanguageCode);
760 INSTALL_ENUM(LanguageCode, "mni", mniLanguageCode);
761 INSTALL_ENUM(LanguageCode, "ori", oriLanguageCode);
762 INSTALL_ENUM(LanguageCode, "san", sanLanguageCode);
763 INSTALL_ENUM(LanguageCode, "snd", sndLanguageCode);
764 INSTALL_ENUM(LanguageCode, "snh", snhLanguageCode);
765 INSTALL_ENUM(LanguageCode, "syr", syrLanguageCode);
766 INSTALL_ENUM(LanguageCode, "tam", tamLanguageCode);
767 INSTALL_ENUM(LanguageCode, "tel", telLanguageCode);
768 INSTALL_ENUM(LanguageCode, "tha", thaLanguageCode);
769 INSTALL_ENUM(LanguageCode, "urd", urdLanguageCode);
770 INSTALL_ENUM(LanguageCode, "zhp", zhpLanguageCode);
771 INSTALL_ENUM(LanguageCode, "zhs", zhsLanguageCode);
772 INSTALL_ENUM(LanguageCode, "zht", zhtLanguageCode);
773
774 #if U_ICU_VERSION_HEX >= 0x04000000
775 INSTALL_ENUM(LanguageCode, "afk", afkLanguageCode);
776 INSTALL_ENUM(LanguageCode, "bel", belLanguageCode);
777 INSTALL_ENUM(LanguageCode, "bgr", bgrLanguageCode);
778 INSTALL_ENUM(LanguageCode, "cat", catLanguageCode);
779 INSTALL_ENUM(LanguageCode, "che", cheLanguageCode);
780 INSTALL_ENUM(LanguageCode, "cop", copLanguageCode);
781 INSTALL_ENUM(LanguageCode, "csy", csyLanguageCode);
782 INSTALL_ENUM(LanguageCode, "dan", danLanguageCode);
783 INSTALL_ENUM(LanguageCode, "deu", deuLanguageCode);
784 INSTALL_ENUM(LanguageCode, "dzn", dznLanguageCode);
785 INSTALL_ENUM(LanguageCode, "ell", ellLanguageCode);
786 INSTALL_ENUM(LanguageCode, "eng", engLanguageCode);
787 INSTALL_ENUM(LanguageCode, "esp", espLanguageCode);
788 INSTALL_ENUM(LanguageCode, "eti", etiLanguageCode);
789 INSTALL_ENUM(LanguageCode, "euq", euqLanguageCode);
790 INSTALL_ENUM(LanguageCode, "fin", finLanguageCode);
791 INSTALL_ENUM(LanguageCode, "fra", fraLanguageCode);
792 INSTALL_ENUM(LanguageCode, "gae", gaeLanguageCode);
793 INSTALL_ENUM(LanguageCode, "hau", hauLanguageCode);
794 INSTALL_ENUM(LanguageCode, "hrv", hrvLanguageCode);
795 INSTALL_ENUM(LanguageCode, "hun", hunLanguageCode);
796 INSTALL_ENUM(LanguageCode, "hye", hyeLanguageCode);
797 INSTALL_ENUM(LanguageCode, "ind", indLanguageCode);
798 INSTALL_ENUM(LanguageCode, "ita", itaLanguageCode);
799 INSTALL_ENUM(LanguageCode, "khm", khmLanguageCode);
800 INSTALL_ENUM(LanguageCode, "mng", mngLanguageCode);
801 INSTALL_ENUM(LanguageCode, "mts", mtsLanguageCode);
802 INSTALL_ENUM(LanguageCode, "nep", nepLanguageCode);
803 INSTALL_ENUM(LanguageCode, "nld", nldLanguageCode);
804 INSTALL_ENUM(LanguageCode, "pas", pasLanguageCode);
805 INSTALL_ENUM(LanguageCode, "plk", plkLanguageCode);
806 INSTALL_ENUM(LanguageCode, "ptg", ptgLanguageCode);
807 INSTALL_ENUM(LanguageCode, "rom", romLanguageCode);
808 INSTALL_ENUM(LanguageCode, "rus", rusLanguageCode);
809 INSTALL_ENUM(LanguageCode, "sky", skyLanguageCode);
810 INSTALL_ENUM(LanguageCode, "slv", slvLanguageCode);
811 INSTALL_ENUM(LanguageCode, "sqi", sqiLanguageCode);
812 INSTALL_ENUM(LanguageCode, "srb", srbLanguageCode);
813 INSTALL_ENUM(LanguageCode, "sve", sveLanguageCode);
814 INSTALL_ENUM(LanguageCode, "tib", tibLanguageCode);
815 INSTALL_ENUM(LanguageCode, "trk", trkLanguageCode);
816 INSTALL_ENUM(LanguageCode, "wel", welLanguageCode);
817 #endif /* 4.0 */
818
819 getFontTable_NAME = PyString_FromString("getFontTable");
820 }
821
822 #endif /* < 58 */
823