sl@0: /* sl@0: ******************************************************************************* sl@0: * sl@0: * Copyright (C) 1999-2004, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ******************************************************************************* sl@0: * file name: gendata.cpp sl@0: * sl@0: * created on: 11/03/2000 sl@0: * created by: Eric R. Mader sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "LETypes.h" sl@0: #include "LEScripts.h" sl@0: #include "LayoutEngine.h" sl@0: sl@0: #include "PortableFontInstance.h" sl@0: sl@0: #include "unicode/uscript.h" sl@0: sl@0: U_NAMESPACE_USE sl@0: sl@0: #define ARRAY_LENGTH(array) (sizeof array / sizeof array[0]) sl@0: sl@0: struct TestInput sl@0: { sl@0: char *fontName; sl@0: LEUnicode *text; sl@0: le_int32 textLength; sl@0: le_int32 scriptCode; sl@0: le_bool rightToLeft; sl@0: }; sl@0: sl@0: /* sl@0: * FIXME: should use the output file name and the current date. sl@0: */ sl@0: char *header = sl@0: "/*\n" sl@0: " *******************************************************************************\n" sl@0: " *\n" sl@0: " * Copyright (C) 1999-2004, International Business Machines\n" sl@0: " * Corporation and others. All Rights Reserved.\n" sl@0: " *\n" sl@0: " * WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT\n" sl@0: " * UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.\n" sl@0: " *\n" sl@0: " *******************************************************************************\n" sl@0: " *\n" sl@0: " * file name: testdata.cpp\n" sl@0: " * created on: 12/14/2000\n" sl@0: " * created by: gendata.cpp\n" sl@0: " */\n" sl@0: "\n" sl@0: "#include \"LETypes.h\"\n" sl@0: "#include \"LEScripts.h\"\n" sl@0: "#include \"letest.h\"\n" sl@0: "\n"; sl@0: sl@0: #if 0 sl@0: char *scriptNames[] = sl@0: { sl@0: "USCRIPT_COMMON", /* Zyyy */ sl@0: "USCRIPT_INHERITED", /* Qaai */ sl@0: "USCRIPT_ARABIC", /* Arab */ sl@0: "USCRIPT_ARMENIAN", /* Armn */ sl@0: "USCRIPT_BENGALI", /* Beng */ sl@0: "USCRIPT_BOPOMOFO", /* Bopo */ sl@0: "USCRIPT_CHEROKEE", /* Cher */ sl@0: "USCRIPT_COPTIC", /* Qaac */ sl@0: "USCRIPT_CYRILLIC", /* Cyrl (Cyrs) */ sl@0: "USCRIPT_DESERET", /* Dsrt */ sl@0: "USCRIPT_DEVANAGARI", /* Deva */ sl@0: "USCRIPT_ETHIOPIC", /* Ethi */ sl@0: "USCRIPT_GEORGIAN", /* Geor (Geon, Geoa) */ sl@0: "USCRIPT_GOTHIC", /* Goth */ sl@0: "USCRIPT_GREEK", /* Grek */ sl@0: "USCRIPT_GUJARATI", /* Gujr */ sl@0: "USCRIPT_GURMUKHI", /* Guru */ sl@0: "USCRIPT_HAN", /* Hani */ sl@0: "USCRIPT_HANGUL", /* Hang */ sl@0: "USCRIPT_HEBREW", /* Hebr */ sl@0: "USCRIPT_HIRAGANA", /* Hira */ sl@0: "USCRIPT_KANNADA", /* Knda */ sl@0: "USCRIPT_KATAKANA", /* Kana */ sl@0: "USCRIPT_KHMER", /* Khmr */ sl@0: "USCRIPT_LAO", /* Laoo */ sl@0: "USCRIPT_LATIN", /* Latn (Latf, Latg) */ sl@0: "USCRIPT_MALAYALAM", /* Mlym */ sl@0: "USCRIPT_MONGOLIAN", /* Mong */ sl@0: "USCRIPT_MYANMAR", /* Mymr */ sl@0: "USCRIPT_OGHAM", /* Ogam */ sl@0: "USCRIPT_OLD_ITALIC", /* Ital */ sl@0: "USCRIPT_ORIYA", /* Orya */ sl@0: "USCRIPT_RUNIC", /* Runr */ sl@0: "USCRIPT_SINHALA", /* Sinh */ sl@0: "USCRIPT_SYRIAC", /* Syrc (Syrj, Syrn, Syre) */ sl@0: "USCRIPT_TAMIL", /* Taml */ sl@0: "USCRIPT_TELUGU", /* Telu */ sl@0: "USCRIPT_THAANA", /* Thaa */ sl@0: "USCRIPT_THAI", /* Thai */ sl@0: "USCRIPT_TIBETAN", /* Tibt */ sl@0: "USCRIPT_UCAS", /* Cans */ sl@0: "USCRIPT_YI", /* Yiii */ sl@0: "USCRIPT_TAGALOG", /* Tglg */ sl@0: "USCRIPT_HANUNOO", /* Hano */ sl@0: "USCRIPT_BUHID", /* Buhd */ sl@0: "USCRIPT_TAGBANWA" /* Tagb */ sl@0: }; sl@0: #endif sl@0: sl@0: LEUnicode devaText[] = sl@0: { sl@0: 0x0936, 0x094d, 0x0930, 0x0940, 0x092e, 0x0926, 0x094d, 0x0020, sl@0: 0x092d, 0x0917, 0x0935, 0x0926, 0x094d, 0x0917, 0x0940, 0x0924, sl@0: 0x093e, 0x0020, 0x0905, 0x0927, 0x094d, 0x092f, 0x093e, 0x092f, sl@0: 0x0020, 0x0905, 0x0930, 0x094d, 0x091c, 0x0941, 0x0928, 0x0020, sl@0: 0x0935, 0x093f, 0x0937, 0x093e, 0x0926, 0x0020, 0x092f, 0x094b, sl@0: 0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 0x093e, 0x0937, sl@0: 0x094d, 0x091f, 0x094d, 0x0930, 0x0020, 0x0909, 0x0935, 0x093E, sl@0: 0x091A, 0x0943, 0x0020, 0x0927, 0x0930, 0x094d, 0x092e, 0x0915, sl@0: 0x094d, 0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 0x0947, 0x0020, sl@0: 0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094d, 0x0937, 0x0947, sl@0: 0x0924, 0x094d, 0x0930, 0x0947, 0x0020, 0x0938, 0x092e, 0x0935, sl@0: 0x0947, 0x0924, 0x093e, 0x0020, 0x092f, 0x0941, 0x092f, 0x0941, sl@0: 0x0924, 0x094d, 0x0938, 0x0935, 0x0903, 0x0020, 0x092e, 0x093e, sl@0: 0x092e, 0x0915, 0x093e, 0x0903, 0x0020, 0x092a, 0x093e, 0x0923, sl@0: 0x094d, 0x0921, 0x0935, 0x093e, 0x0936, 0x094d, 0x091a, 0x0948, sl@0: 0x0935, 0x0020, 0x0915, 0x093f, 0x092e, 0x0915, 0x0941, 0x0930, sl@0: 0x094d, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 0x091c, 0x0935 sl@0: }; sl@0: sl@0: le_int32 devaTextLength = ARRAY_LENGTH(devaText); sl@0: sl@0: LEUnicode arabText[] = sl@0: { sl@0: 0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020, sl@0: 0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, sl@0: 0x0627, 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, sl@0: 0x0020, 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, sl@0: 0x0627, 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, sl@0: 0x0020, 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, sl@0: 0x062A, 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, sl@0: 0x0623, 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, sl@0: 0x0645, 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, sl@0: 0x0623, 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, sl@0: 0x0020, 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, sl@0: 0x064A, 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, sl@0: 0x0639, 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, sl@0: 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, sl@0: 0x0647, 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, sl@0: 0x0020, 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, sl@0: 0x0022, 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, sl@0: 0x0022, 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, sl@0: 0x0646, 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, sl@0: 0x0020, 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, sl@0: 0x0020, 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, sl@0: 0x0020, 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, sl@0: 0x0647, 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, sl@0: 0x0642, 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, sl@0: 0x0627, 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, sl@0: 0x0020, 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, sl@0: 0x0627, 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, sl@0: 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, sl@0: 0x062A, 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, sl@0: 0x062C, 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, sl@0: 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, sl@0: 0x0631, 0x0648, 0x0631, 0x064A, 0x0629 sl@0: sl@0: /* The next few sentences... sl@0: 0x002E, 0x0020, 0x0648, sl@0: 0x0639, 0x0644, 0x0649, 0x0020, 0x0633, 0x0628, 0x064A, 0x0644, sl@0: 0x0020, 0x0627, 0x0644, 0x0645, 0x062B, 0x0627, 0x0644, 0x060C, sl@0: 0x0020, 0x0641, 0x0625, 0x0646, 0x0020, 0x0627, 0x0644, 0x0627, sl@0: 0x062A, 0x062D, 0x0627, 0x062F, 0x0020, 0x0627, 0x0644, 0x0623, sl@0: 0x0648, 0x0631, 0x0648, 0x0628, 0x064A, 0x0020, 0x0644, 0x0648, sl@0: 0x062D, 0x062F, 0x0647, 0x060C, 0x0020, 0x0627, 0x062D, 0x062A, sl@0: 0x0648, 0x0649, 0x0020, 0x0627, 0x0644, 0x0639, 0x062F, 0x064A, sl@0: 0x062F, 0x0020, 0x0645, 0x0646, 0x0020, 0x0627, 0x0644, 0x0634, sl@0: 0x0641, 0x0631, 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x0645, sl@0: 0x062E, 0x062A, 0x0644, 0x0641, 0x0629, 0x0020, 0x0644, 0x064A, sl@0: 0x063A, 0x0637, 0x064A, 0x0020, 0x062C, 0x0645, 0x064A, 0x0639, sl@0: 0x0020, 0x0627, 0x0644, 0x0644, 0x063A, 0x0627, 0x062A, 0x0020, sl@0: 0x0627, 0x0644, 0x0645, 0x0633, 0x062A, 0x062E, 0x062F, 0x0645, sl@0: 0x0629, 0x0020, 0x0641, 0x064A, 0x0020, 0x0627, 0x0644, 0x0627, sl@0: 0x062A, 0x062D, 0x0627, 0x062F, 0x002E, 0x0020, 0x0648, 0x062D, sl@0: 0x062A, 0x0649, 0x0020, 0x0644, 0x0648, 0x0020, 0x0627, 0x0639, sl@0: 0x062A, 0x0628, 0x0631, 0x0646, 0x0627, 0x0020, 0x0644, 0x063A, sl@0: 0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0629, 0x060C, sl@0: 0x0020, 0x0643, 0x0627, 0x0644, 0x0644, 0x063A, 0x0629, 0x0020, sl@0: 0x0627, 0x0644, 0x0625, 0x0646, 0x062C, 0x0644, 0x064A, 0x0632, sl@0: 0x064A, 0x0629, 0x060C, 0x0020, 0x0641, 0x0625, 0x0646, 0x0020, sl@0: 0x062C, 0x062F, 0x0648, 0x0644, 0x0020, 0x0634, 0x0641, 0x0631, sl@0: 0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0644, sl@0: 0x0645, 0x0020, 0x064A, 0x0643, 0x0641, 0x0020, 0x0644, 0x0627, sl@0: 0x0633, 0x062A, 0x064A, 0x0639, 0x0627, 0x0628, 0x0020, 0x062C, sl@0: 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0623, 0x062D, sl@0: 0x0631, 0x0641, 0x0020, 0x0648, 0x0639, 0x0644, 0x0627, 0x0645, sl@0: 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x062A, 0x0631, 0x0642, sl@0: 0x064A, 0x0645, 0x0020, 0x0648, 0x0627, 0x0644, 0x0631, 0x0645, sl@0: 0x0648, 0x0632, 0x0020, 0x0627, 0x0644, 0x0641, 0x0646, 0x064A, sl@0: 0x0629, 0x0020, 0x0648, 0x0627, 0x0644, 0x0639, 0x0644, 0x0645, sl@0: 0x064A, 0x0629, 0x0020, 0x0627, 0x0644, 0x0634, 0x0627, 0x0626, sl@0: 0x0639, 0x0629, 0x0020, 0x0627, 0x0644, 0x0627, 0x0633, 0x062A, sl@0: 0x0639, 0x0645, 0x0627, 0x0644, 0x002E */ sl@0: }; sl@0: le_int32 arabTextLength = ARRAY_LENGTH(arabText); sl@0: sl@0: sl@0: LEUnicode thaiSample[] = sl@0: { sl@0: 0x0E1A, 0x0E17, 0x0E17, 0x0E35, 0x0E48, 0x0E51, 0x0E1E, 0x0E32, sl@0: 0x0E22, 0x0E38, 0x0E44, 0x0E0B, 0x0E42, 0x0E04, 0x0E25, 0x0E19, sl@0: 0x0E42, 0x0E14, 0x0E42, 0x0E23, 0x0E18, 0x0E35, 0x0E2D, 0x0E32, sl@0: 0x0E28, 0x0E31, 0x0E22, 0x0E2D, 0x0E22, 0x0E39, 0x0E48, 0x0E17, sl@0: 0x0E48, 0x0E32, 0x0E21, 0x0E01, 0x0E25, 0x0E32, 0x0E07, 0x0E17, sl@0: 0x0E38, 0x0E48, 0x0E07, 0x0E43, 0x0E2B, 0x0E0D, 0x0E48, 0x0E43, sl@0: 0x0E19, 0x0E41, 0x0E04, 0x0E19, 0x0E0B, 0x0E31, 0x0E2A, 0x0E01, sl@0: 0x0E31, 0x0E1A, 0x0E25, 0x0E38, 0x0E07, 0x0E40, 0x0E2E, 0x0E19, sl@0: 0x0E23, 0x0E35, 0x0E0A, 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, sl@0: 0x0E41, 0x0E25, 0x0E30, 0x0E1B, 0x0E49, 0x0E32, 0x0E40, 0x0E2D, sl@0: 0x0E47, 0x0E21, 0x0E20, 0x0E23, 0x0E23, 0x0E22, 0x0E32, 0x0E0A, sl@0: 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, 0x0E1A, 0x0E49, 0x0E32, sl@0: 0x0E19, 0x0E02, 0x0E2D, 0x0E07, 0x0E1E, 0x0E27, 0x0E01, 0x0E40, sl@0: 0x0E02, 0x0E32, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, 0x0E40, 0x0E25, sl@0: 0x0E47, 0x0E01, 0x0E40, 0x0E1E, 0x0E23, 0x0E32, 0x0E30, 0x0E44, sl@0: 0x0E21, 0x0E49, 0x0E2A, 0x0E23, 0x0E49, 0x0E32, 0x0E07, 0x0E1A, sl@0: 0x0E49, 0x0E32, 0x0E19, 0x0E15, 0x0E49, 0x0E2D, 0x0E07, 0x0E02, sl@0: 0x0E19, 0x0E21, 0x0E32, 0x0E14, 0x0E49, 0x0E27, 0x0E22, 0x0E40, sl@0: 0x0E01, 0x0E27, 0x0E35, 0x0E22, 0x0E19, 0x0E40, 0x0E1B, 0x0E47, sl@0: 0x0E19, 0x0E23, 0x0E30, 0x0E22, 0x0E30, 0x0E17, 0x0E32, 0x0E07, sl@0: 0x0E2B, 0x0E25, 0x0E32, 0x0E22, 0x0E44, 0x0E21, 0x0E25, 0x0E4C sl@0: /* A few more lines... sl@0: 0x0E1A, 0x0E49, 0x0E32, 0x0E19, 0x0E21, 0x0E35, 0x0E2A, 0x0E35, sl@0: 0x0E48, 0x0E1D, 0x0E32, 0x0E21, 0x0E35, 0x0E1E, 0x0E37, 0x0E49, sl@0: 0x0E19, 0x0E01, 0x0E31, 0x0E1A, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, sl@0: 0x0E04, 0x0E32, 0x0E23, 0x0E27, 0x0E21, 0x0E17, 0x0E33, 0x0E40, sl@0: 0x0E1B, 0x0E47, 0x0E19, 0x0E2B, 0x0E49, 0x0E2D, 0x0E07, 0x0E40, sl@0: 0x0E14, 0x0E35, 0x0E22, 0x0E27, 0x0E43, 0x0E19, 0x0E2B, 0x0E49, sl@0: 0x0E2D, 0x0E07, 0x0E21, 0x0E35, 0x0E17, 0x0E31, 0x0E49, 0x0E07, sl@0: 0x0E40, 0x0E15, 0x0E32, 0x0E2B, 0x0E38, 0x0E07, 0x0E15, 0x0E49, sl@0: 0x0E21, 0x0E17, 0x0E35, 0x0E48, 0x0E2A, 0x0E19, 0x0E34, 0x0E21, sl@0: 0x0E14, 0x0E39, 0x0E02, 0x0E36, 0x0E49, 0x0E19, 0x0E40, 0x0E25, sl@0: 0x0E2D, 0x0E30, 0x0E21, 0x0E35, 0x0E15, 0x0E39, 0x0E49, 0x0E43, sl@0: 0x0E2A, 0x0E48, 0x0E16, 0x0E49, 0x0E27, 0x0E22, 0x0E0A, 0x0E32, sl@0: 0x0E21, 0x0E42, 0x0E15, 0x0E4A, 0x0E30, 0x0E40, 0x0E01, 0x0E49, sl@0: 0x0E32, 0x0E2D, 0x0E35, 0x0E49, 0x0E2A, 0x0E32, 0x0E21, 0x0E2B, sl@0: 0x0E23 sl@0: */ sl@0: }; sl@0: sl@0: le_int32 thaiSampleLength = ARRAY_LENGTH(thaiSample); sl@0: sl@0: TestInput testInputs[] = { sl@0: {"raghu.ttf", devaText, devaTextLength, devaScriptCode, FALSE}, sl@0: {"CODE2000.TTF", arabText, arabTextLength, arabScriptCode, TRUE}, sl@0: {"LucidaSansRegular.ttf", arabText, arabTextLength, arabScriptCode, TRUE}, sl@0: {"Thonburi.ttf", thaiSample, thaiSampleLength, thaiScriptCode, FALSE} sl@0: }; sl@0: sl@0: #define TEST_COUNT ARRAY_LENGTH(testInputs) sl@0: sl@0: le_int32 testCount = TEST_COUNT; sl@0: sl@0: void dumpShorts(FILE *file, char *label, le_int32 id, le_uint16 *shorts, le_int32 count) { sl@0: char lineBuffer[8 * 8 + 2]; sl@0: le_int32 bufp = 0; sl@0: sl@0: fprintf(file, label, id); sl@0: sl@0: for (int i = 0; i < count; i += 1) { sl@0: if (i % 8 == 0 && bufp != 0) { sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: bufp = 0; sl@0: } sl@0: sl@0: bufp += sprintf(&lineBuffer[bufp], "0x%4.4X, ", shorts[i]); sl@0: } sl@0: sl@0: if (bufp != 0) { sl@0: lineBuffer[bufp - 2] = '\0'; sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: } sl@0: sl@0: fprintf(file, "};\n\n"); sl@0: } sl@0: sl@0: void dumpLongs(FILE *file, char *label, le_int32 id, le_int32 *longs, le_int32 count) { sl@0: char lineBuffer[8 * 12 + 2]; sl@0: le_int32 bufp = 0; sl@0: sl@0: fprintf(file, label, id); sl@0: sl@0: for (int i = 0; i < count; i += 1) { sl@0: if (i % 8 == 0 && bufp != 0) { sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: bufp = 0; sl@0: } sl@0: sl@0: bufp += sprintf(&lineBuffer[bufp], "0x%8.8X, ", longs[i]); sl@0: } sl@0: sl@0: if (bufp != 0) { sl@0: lineBuffer[bufp - 2] = '\0'; sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: } sl@0: sl@0: fprintf(file, "};\n\n"); sl@0: } sl@0: sl@0: void dumpFloats(FILE *file, char *label, le_int32 id, float *floats, le_int32 count) { sl@0: char lineBuffer[8 * 16 + 2]; sl@0: le_int32 bufp = 0; sl@0: sl@0: fprintf(file, label, id); sl@0: sl@0: for (int i = 0; i < count; i += 1) { sl@0: if (i % 8 == 0 && bufp != 0) { sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: bufp = 0; sl@0: } sl@0: sl@0: bufp += sprintf(&lineBuffer[bufp], "%fF, ", floats[i]); sl@0: } sl@0: sl@0: if (bufp != 0) { sl@0: lineBuffer[bufp - 2] = '\0'; sl@0: fprintf(file, " %s\n", lineBuffer); sl@0: } sl@0: sl@0: fprintf(file, "};\n\n"); sl@0: } sl@0: sl@0: const char *getShortName(le_int32 scriptCode) sl@0: { sl@0: static char shortName[5]; sl@0: const char *name = uscript_getShortName((UScriptCode) scriptCode); sl@0: sl@0: shortName[0] = tolower(name[0]); sl@0: shortName[1] = tolower(name[1]); sl@0: shortName[2] = tolower(name[2]); sl@0: shortName[3] = tolower(name[3]); sl@0: shortName[4] = '\0'; sl@0: sl@0: return shortName; sl@0: } sl@0: sl@0: int main(int argc, char *argv[]) sl@0: { sl@0: le_int32 test; sl@0: FILE *outputFile = fopen(argv[1], "w"); sl@0: sl@0: fprintf(outputFile, header); sl@0: sl@0: for (test = 0; test < testCount; test += 1) { sl@0: LEErrorCode fontStatus = LE_NO_ERROR; sl@0: PortableFontInstance fontInstance(testInputs[test].fontName, 12, fontStatus); sl@0: sl@0: if (LE_FAILURE(fontStatus)) { sl@0: printf("ERROR: test case %d, could not get a font instance for %s\n", test, testInputs[test].fontName); sl@0: continue; sl@0: } sl@0: sl@0: LEErrorCode success = LE_NO_ERROR; sl@0: LayoutEngine *engine = LayoutEngine::layoutEngineFactory(&fontInstance, testInputs[test].scriptCode, -1, success); sl@0: le_uint32 glyphCount; sl@0: LEGlyphID *glyphs; sl@0: le_int32 *indices; sl@0: float *positions; sl@0: sl@0: if (LE_FAILURE(success)) { sl@0: printf("ERROR: test case %d, could not create a LayoutEngine for script %s.\n", test, uscript_getName((UScriptCode) testInputs[test].scriptCode)); sl@0: continue; sl@0: } sl@0: sl@0: glyphCount = engine->layoutChars(testInputs[test].text, 0, testInputs[test].textLength, testInputs[test].textLength, testInputs[test].rightToLeft, 0, 0, success); sl@0: sl@0: glyphs = new LEGlyphID[glyphCount]; sl@0: indices = new le_int32[glyphCount]; sl@0: positions = new float[glyphCount * 2 + 2]; sl@0: sl@0: engine->getGlyphs(glyphs, success); sl@0: engine->getCharIndices(indices, success); sl@0: engine->getGlyphPositions(positions, success); sl@0: sl@0: //fprintf(outputFile, "font: %s\n", testInputs[test].fontName); sl@0: dumpShorts(outputFile, "LEUnicode inputText%d[] =\n{\n", test, testInputs[test].text, testInputs[test].textLength); sl@0: sl@0: dumpLongs(outputFile, "LEGlyphID resultGlyphs%d[] =\n{\n", test, (le_int32 *) glyphs, glyphCount); sl@0: fprintf(outputFile, "le_int32 resultGlyphCount%d = %d;\n\n", test, glyphCount); sl@0: sl@0: dumpLongs(outputFile, "le_int32 resultIndices%d[] =\n{\n", test, indices, glyphCount); sl@0: sl@0: dumpFloats(outputFile, "float resultPositions%d[] =\n{\n", test, positions, glyphCount * 2 + 2); sl@0: sl@0: fprintf(outputFile, "\n"); sl@0: sl@0: delete[] positions; sl@0: delete[] indices; sl@0: delete[] glyphs; sl@0: delete engine; sl@0: } sl@0: sl@0: fprintf(outputFile, "TestInput testInputs[] = \n{\n"); sl@0: sl@0: for (test = 0; test < testCount; test += 1) { sl@0: fprintf(outputFile, " {\"%s\", inputText%d, %d, %sScriptCode, %s},\n", sl@0: testInputs[test].fontName, test, testInputs[test].textLength, getShortName(testInputs[test].scriptCode), sl@0: testInputs[test].rightToLeft? "TRUE" : "FALSE"); sl@0: } sl@0: sl@0: fprintf(outputFile, "};\n\nle_int32 testCount = ARRAY_LENGTH(testInputs);\n\n"); sl@0: sl@0: fprintf(outputFile, "TestResult testResults[] = \n{\n"); sl@0: sl@0: for (test = 0; test < testCount; test += 1) { sl@0: fprintf(outputFile, " {resultGlyphCount%d, resultGlyphs%d, resultIndices%d, resultPositions%d},\n", sl@0: test, test, test, test); sl@0: } sl@0: sl@0: fprintf(outputFile, "};\n\n"); sl@0: sl@0: fclose(outputFile); sl@0: return 0; sl@0: }