os/textandloc/fontservices/textshaperplugin/test/letest/gendata.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/test/letest/gendata.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,428 @@
     1.4 +/*
     1.5 + *******************************************************************************
     1.6 + *
     1.7 + *   Copyright (C) 1999-2004, International Business Machines
     1.8 + *   Corporation and others.  All Rights Reserved.
     1.9 + *
    1.10 + *******************************************************************************
    1.11 + *   file name:  gendata.cpp
    1.12 + *
    1.13 + *   created on: 11/03/2000
    1.14 + *   created by: Eric R. Mader
    1.15 + */
    1.16 +
    1.17 +#include <stdio.h>
    1.18 +#include <ctype.h>
    1.19 +
    1.20 +#include "LETypes.h"
    1.21 +#include "LEScripts.h"
    1.22 +#include "LayoutEngine.h"
    1.23 +
    1.24 +#include "PortableFontInstance.h"
    1.25 +
    1.26 +#include "unicode/uscript.h"
    1.27 +
    1.28 +U_NAMESPACE_USE
    1.29 +
    1.30 +#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
    1.31 +
    1.32 +struct TestInput
    1.33 +{
    1.34 +    char      *fontName;
    1.35 +    LEUnicode *text;
    1.36 +    le_int32   textLength;
    1.37 +    le_int32   scriptCode;
    1.38 +    le_bool    rightToLeft;
    1.39 +};
    1.40 +
    1.41 +/* 
    1.42 + * FIXME: should use the output file name and the current date.
    1.43 + */
    1.44 +char *header =
    1.45 +    "/*\n"
    1.46 +    " *******************************************************************************\n"
    1.47 +    " *\n"
    1.48 +    " *   Copyright (C) 1999-2004, International Business Machines\n"
    1.49 +    " *   Corporation and others.  All Rights Reserved.\n"
    1.50 +    " *\n"
    1.51 +    " *   WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT\n"
    1.52 +    " *   UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.\n"
    1.53 +    " *\n"
    1.54 +    " *******************************************************************************\n"
    1.55 +    " *\n"
    1.56 +    " *   file name:  testdata.cpp\n"
    1.57 +    " *   created on: 12/14/2000\n"
    1.58 +    " *   created by: gendata.cpp\n"
    1.59 +    " */\n"
    1.60 +    "\n"
    1.61 +    "#include \"LETypes.h\"\n"
    1.62 +    "#include \"LEScripts.h\"\n"
    1.63 +    "#include \"letest.h\"\n"
    1.64 +    "\n";
    1.65 +
    1.66 +#if 0
    1.67 +char *scriptNames[] =
    1.68 +{
    1.69 +      "USCRIPT_COMMON",      /* Zyyy */
    1.70 +      "USCRIPT_INHERITED",   /* Qaai */
    1.71 +      "USCRIPT_ARABIC",      /* Arab */
    1.72 +      "USCRIPT_ARMENIAN",    /* Armn */
    1.73 +      "USCRIPT_BENGALI",     /* Beng */
    1.74 +      "USCRIPT_BOPOMOFO",    /* Bopo */
    1.75 +      "USCRIPT_CHEROKEE",    /* Cher */
    1.76 +      "USCRIPT_COPTIC",      /* Qaac */
    1.77 +      "USCRIPT_CYRILLIC",    /* Cyrl (Cyrs) */
    1.78 +      "USCRIPT_DESERET",     /* Dsrt */
    1.79 +      "USCRIPT_DEVANAGARI",  /* Deva */
    1.80 +      "USCRIPT_ETHIOPIC",    /* Ethi */
    1.81 +      "USCRIPT_GEORGIAN",    /* Geor (Geon, Geoa) */
    1.82 +      "USCRIPT_GOTHIC",      /* Goth */
    1.83 +      "USCRIPT_GREEK",       /* Grek */
    1.84 +      "USCRIPT_GUJARATI",    /* Gujr */
    1.85 +      "USCRIPT_GURMUKHI",    /* Guru */
    1.86 +      "USCRIPT_HAN",         /* Hani */
    1.87 +      "USCRIPT_HANGUL",      /* Hang */
    1.88 +      "USCRIPT_HEBREW",      /* Hebr */
    1.89 +      "USCRIPT_HIRAGANA",    /* Hira */
    1.90 +      "USCRIPT_KANNADA",     /* Knda */
    1.91 +      "USCRIPT_KATAKANA",    /* Kana */
    1.92 +      "USCRIPT_KHMER",       /* Khmr */
    1.93 +      "USCRIPT_LAO",         /* Laoo */
    1.94 +      "USCRIPT_LATIN",       /* Latn (Latf, Latg) */
    1.95 +      "USCRIPT_MALAYALAM",   /* Mlym */
    1.96 +      "USCRIPT_MONGOLIAN",   /* Mong */
    1.97 +      "USCRIPT_MYANMAR",     /* Mymr */
    1.98 +      "USCRIPT_OGHAM",       /* Ogam */
    1.99 +      "USCRIPT_OLD_ITALIC",  /* Ital */
   1.100 +      "USCRIPT_ORIYA",       /* Orya */
   1.101 +      "USCRIPT_RUNIC",       /* Runr */
   1.102 +      "USCRIPT_SINHALA",     /* Sinh */
   1.103 +      "USCRIPT_SYRIAC",      /* Syrc (Syrj, Syrn, Syre) */
   1.104 +      "USCRIPT_TAMIL",       /* Taml */
   1.105 +      "USCRIPT_TELUGU",      /* Telu */
   1.106 +      "USCRIPT_THAANA",      /* Thaa */
   1.107 +      "USCRIPT_THAI",        /* Thai */
   1.108 +      "USCRIPT_TIBETAN",     /* Tibt */
   1.109 +      "USCRIPT_UCAS",        /* Cans */
   1.110 +      "USCRIPT_YI",          /* Yiii */
   1.111 +      "USCRIPT_TAGALOG",     /* Tglg */
   1.112 +      "USCRIPT_HANUNOO",     /* Hano */
   1.113 +      "USCRIPT_BUHID",       /* Buhd */
   1.114 +      "USCRIPT_TAGBANWA"     /* Tagb */
   1.115 +};
   1.116 +#endif
   1.117 +
   1.118 +LEUnicode devaText[] =
   1.119 +{
   1.120 +    0x0936, 0x094d, 0x0930, 0x0940, 0x092e, 0x0926, 0x094d, 0x0020,
   1.121 +    0x092d, 0x0917, 0x0935, 0x0926, 0x094d, 0x0917, 0x0940, 0x0924,
   1.122 +    0x093e, 0x0020, 0x0905, 0x0927, 0x094d, 0x092f, 0x093e, 0x092f,
   1.123 +    0x0020, 0x0905, 0x0930, 0x094d, 0x091c, 0x0941, 0x0928, 0x0020,
   1.124 +    0x0935, 0x093f, 0x0937, 0x093e, 0x0926, 0x0020, 0x092f, 0x094b,
   1.125 +    0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 0x093e, 0x0937,
   1.126 +    0x094d, 0x091f, 0x094d, 0x0930, 0x0020, 0x0909, 0x0935, 0x093E,
   1.127 +    0x091A, 0x0943, 0x0020, 0x0927, 0x0930, 0x094d, 0x092e, 0x0915,
   1.128 +    0x094d, 0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 0x0947, 0x0020,
   1.129 +    0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094d, 0x0937, 0x0947,
   1.130 +    0x0924, 0x094d, 0x0930, 0x0947, 0x0020, 0x0938, 0x092e, 0x0935,
   1.131 +    0x0947, 0x0924, 0x093e, 0x0020, 0x092f, 0x0941, 0x092f, 0x0941,
   1.132 +    0x0924, 0x094d, 0x0938, 0x0935, 0x0903, 0x0020, 0x092e, 0x093e,
   1.133 +    0x092e, 0x0915, 0x093e, 0x0903, 0x0020, 0x092a, 0x093e, 0x0923,
   1.134 +    0x094d, 0x0921, 0x0935, 0x093e, 0x0936, 0x094d, 0x091a, 0x0948,
   1.135 +    0x0935, 0x0020, 0x0915, 0x093f, 0x092e, 0x0915, 0x0941, 0x0930,
   1.136 +    0x094d, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 0x091c, 0x0935
   1.137 +};
   1.138 +
   1.139 +le_int32 devaTextLength = ARRAY_LENGTH(devaText);
   1.140 +
   1.141 +LEUnicode arabText[] =
   1.142 +{
   1.143 +    0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020, 
   1.144 +    0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 
   1.145 +    0x0627, 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 
   1.146 +    0x0020, 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 
   1.147 +    0x0627, 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 
   1.148 +    0x0020, 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 
   1.149 +    0x062A, 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 
   1.150 +    0x0623, 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 
   1.151 +    0x0645, 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 
   1.152 +    0x0623, 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 
   1.153 +    0x0020, 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 
   1.154 +    0x064A, 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 
   1.155 +    0x0639, 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 
   1.156 +    0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 
   1.157 +    0x0647, 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 
   1.158 +    0x0020, 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 
   1.159 +    0x0022, 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 
   1.160 +    0x0022, 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 
   1.161 +    0x0646, 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 
   1.162 +    0x0020, 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 
   1.163 +    0x0020, 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 
   1.164 +    0x0020, 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 
   1.165 +    0x0647, 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 
   1.166 +    0x0642, 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 
   1.167 +    0x0627, 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 
   1.168 +    0x0020, 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 
   1.169 +    0x0627, 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 
   1.170 +    0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 
   1.171 +    0x062A, 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 
   1.172 +    0x062C, 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 
   1.173 +    0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 
   1.174 +    0x0631, 0x0648, 0x0631, 0x064A, 0x0629
   1.175 +    
   1.176 +    /* The next few sentences...
   1.177 +    0x002E, 0x0020, 0x0648, 
   1.178 +    0x0639, 0x0644, 0x0649, 0x0020, 0x0633, 0x0628, 0x064A, 0x0644, 
   1.179 +    0x0020, 0x0627, 0x0644, 0x0645, 0x062B, 0x0627, 0x0644, 0x060C, 
   1.180 +    0x0020, 0x0641, 0x0625, 0x0646, 0x0020, 0x0627, 0x0644, 0x0627, 
   1.181 +    0x062A, 0x062D, 0x0627, 0x062F, 0x0020, 0x0627, 0x0644, 0x0623, 
   1.182 +    0x0648, 0x0631, 0x0648, 0x0628, 0x064A, 0x0020, 0x0644, 0x0648, 
   1.183 +    0x062D, 0x062F, 0x0647, 0x060C, 0x0020, 0x0627, 0x062D, 0x062A, 
   1.184 +    0x0648, 0x0649, 0x0020, 0x0627, 0x0644, 0x0639, 0x062F, 0x064A, 
   1.185 +    0x062F, 0x0020, 0x0645, 0x0646, 0x0020, 0x0627, 0x0644, 0x0634, 
   1.186 +    0x0641, 0x0631, 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x0645, 
   1.187 +    0x062E, 0x062A, 0x0644, 0x0641, 0x0629, 0x0020, 0x0644, 0x064A, 
   1.188 +    0x063A, 0x0637, 0x064A, 0x0020, 0x062C, 0x0645, 0x064A, 0x0639, 
   1.189 +    0x0020, 0x0627, 0x0644, 0x0644, 0x063A, 0x0627, 0x062A, 0x0020, 
   1.190 +    0x0627, 0x0644, 0x0645, 0x0633, 0x062A, 0x062E, 0x062F, 0x0645, 
   1.191 +    0x0629, 0x0020, 0x0641, 0x064A, 0x0020, 0x0627, 0x0644, 0x0627, 
   1.192 +    0x062A, 0x062D, 0x0627, 0x062F, 0x002E, 0x0020, 0x0648, 0x062D, 
   1.193 +    0x062A, 0x0649, 0x0020, 0x0644, 0x0648, 0x0020, 0x0627, 0x0639, 
   1.194 +    0x062A, 0x0628, 0x0631, 0x0646, 0x0627, 0x0020, 0x0644, 0x063A, 
   1.195 +    0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0629, 0x060C, 
   1.196 +    0x0020, 0x0643, 0x0627, 0x0644, 0x0644, 0x063A, 0x0629, 0x0020, 
   1.197 +    0x0627, 0x0644, 0x0625, 0x0646, 0x062C, 0x0644, 0x064A, 0x0632, 
   1.198 +    0x064A, 0x0629, 0x060C, 0x0020, 0x0641, 0x0625, 0x0646, 0x0020, 
   1.199 +    0x062C, 0x062F, 0x0648, 0x0644, 0x0020, 0x0634, 0x0641, 0x0631, 
   1.200 +    0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0644, 
   1.201 +    0x0645, 0x0020, 0x064A, 0x0643, 0x0641, 0x0020, 0x0644, 0x0627, 
   1.202 +    0x0633, 0x062A, 0x064A, 0x0639, 0x0627, 0x0628, 0x0020, 0x062C, 
   1.203 +    0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0623, 0x062D, 
   1.204 +    0x0631, 0x0641, 0x0020, 0x0648, 0x0639, 0x0644, 0x0627, 0x0645, 
   1.205 +    0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x062A, 0x0631, 0x0642, 
   1.206 +    0x064A, 0x0645, 0x0020, 0x0648, 0x0627, 0x0644, 0x0631, 0x0645, 
   1.207 +    0x0648, 0x0632, 0x0020, 0x0627, 0x0644, 0x0641, 0x0646, 0x064A, 
   1.208 +    0x0629, 0x0020, 0x0648, 0x0627, 0x0644, 0x0639, 0x0644, 0x0645, 
   1.209 +    0x064A, 0x0629, 0x0020, 0x0627, 0x0644, 0x0634, 0x0627, 0x0626, 
   1.210 +    0x0639, 0x0629, 0x0020, 0x0627, 0x0644, 0x0627, 0x0633, 0x062A, 
   1.211 +    0x0639, 0x0645, 0x0627, 0x0644, 0x002E */
   1.212 +};
   1.213 +le_int32 arabTextLength = ARRAY_LENGTH(arabText);
   1.214 +
   1.215 +
   1.216 +LEUnicode thaiSample[] =
   1.217 +{
   1.218 +    0x0E1A, 0x0E17, 0x0E17, 0x0E35, 0x0E48, 0x0E51, 0x0E1E, 0x0E32,
   1.219 +    0x0E22, 0x0E38, 0x0E44, 0x0E0B, 0x0E42, 0x0E04, 0x0E25, 0x0E19,
   1.220 +    0x0E42, 0x0E14, 0x0E42, 0x0E23, 0x0E18, 0x0E35, 0x0E2D, 0x0E32, 
   1.221 +    0x0E28, 0x0E31, 0x0E22, 0x0E2D, 0x0E22, 0x0E39, 0x0E48, 0x0E17,
   1.222 +    0x0E48, 0x0E32, 0x0E21, 0x0E01, 0x0E25, 0x0E32, 0x0E07, 0x0E17,
   1.223 +    0x0E38, 0x0E48, 0x0E07, 0x0E43, 0x0E2B, 0x0E0D, 0x0E48, 0x0E43,
   1.224 +    0x0E19, 0x0E41, 0x0E04, 0x0E19, 0x0E0B, 0x0E31, 0x0E2A, 0x0E01, 
   1.225 +    0x0E31, 0x0E1A, 0x0E25, 0x0E38, 0x0E07, 0x0E40, 0x0E2E, 0x0E19,
   1.226 +    0x0E23, 0x0E35, 0x0E0A, 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48,
   1.227 +    0x0E41, 0x0E25, 0x0E30, 0x0E1B, 0x0E49, 0x0E32, 0x0E40, 0x0E2D,
   1.228 +    0x0E47, 0x0E21, 0x0E20, 0x0E23, 0x0E23, 0x0E22, 0x0E32, 0x0E0A,
   1.229 +    0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, 0x0E1A, 0x0E49, 0x0E32,
   1.230 +    0x0E19, 0x0E02, 0x0E2D, 0x0E07, 0x0E1E, 0x0E27, 0x0E01, 0x0E40, 
   1.231 +    0x0E02, 0x0E32, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, 0x0E40, 0x0E25,
   1.232 +    0x0E47, 0x0E01, 0x0E40, 0x0E1E, 0x0E23, 0x0E32, 0x0E30, 0x0E44,
   1.233 +    0x0E21, 0x0E49, 0x0E2A, 0x0E23, 0x0E49, 0x0E32, 0x0E07, 0x0E1A,
   1.234 +    0x0E49, 0x0E32, 0x0E19, 0x0E15, 0x0E49, 0x0E2D, 0x0E07, 0x0E02, 
   1.235 +    0x0E19, 0x0E21, 0x0E32, 0x0E14, 0x0E49, 0x0E27, 0x0E22, 0x0E40,
   1.236 +    0x0E01, 0x0E27, 0x0E35, 0x0E22, 0x0E19, 0x0E40, 0x0E1B, 0x0E47,
   1.237 +    0x0E19, 0x0E23, 0x0E30, 0x0E22, 0x0E30, 0x0E17, 0x0E32, 0x0E07,
   1.238 +    0x0E2B, 0x0E25, 0x0E32, 0x0E22, 0x0E44, 0x0E21, 0x0E25, 0x0E4C
   1.239 +    /* A few more lines...
   1.240 +    0x0E1A, 0x0E49, 0x0E32, 0x0E19, 0x0E21, 0x0E35, 0x0E2A, 0x0E35,
   1.241 +    0x0E48, 0x0E1D, 0x0E32, 0x0E21, 0x0E35, 0x0E1E, 0x0E37, 0x0E49,
   1.242 +    0x0E19, 0x0E01, 0x0E31, 0x0E1A, 0x0E2B, 0x0E25, 0x0E31, 0x0E07,
   1.243 +    0x0E04, 0x0E32, 0x0E23, 0x0E27, 0x0E21, 0x0E17, 0x0E33, 0x0E40,
   1.244 +    0x0E1B, 0x0E47, 0x0E19, 0x0E2B, 0x0E49, 0x0E2D, 0x0E07, 0x0E40,
   1.245 +    0x0E14, 0x0E35, 0x0E22, 0x0E27, 0x0E43, 0x0E19, 0x0E2B, 0x0E49, 
   1.246 +    0x0E2D, 0x0E07, 0x0E21, 0x0E35, 0x0E17, 0x0E31, 0x0E49, 0x0E07,
   1.247 +    0x0E40, 0x0E15, 0x0E32, 0x0E2B, 0x0E38, 0x0E07, 0x0E15, 0x0E49,
   1.248 +    0x0E21, 0x0E17, 0x0E35, 0x0E48, 0x0E2A, 0x0E19, 0x0E34, 0x0E21,
   1.249 +    0x0E14, 0x0E39, 0x0E02, 0x0E36, 0x0E49, 0x0E19, 0x0E40, 0x0E25,
   1.250 +    0x0E2D, 0x0E30, 0x0E21, 0x0E35, 0x0E15, 0x0E39, 0x0E49, 0x0E43, 
   1.251 +    0x0E2A, 0x0E48, 0x0E16, 0x0E49, 0x0E27, 0x0E22, 0x0E0A, 0x0E32,
   1.252 +    0x0E21, 0x0E42, 0x0E15, 0x0E4A, 0x0E30, 0x0E40, 0x0E01, 0x0E49,
   1.253 +    0x0E32, 0x0E2D, 0x0E35, 0x0E49, 0x0E2A, 0x0E32, 0x0E21, 0x0E2B,
   1.254 +    0x0E23
   1.255 +    */
   1.256 +};
   1.257 +
   1.258 +le_int32 thaiSampleLength = ARRAY_LENGTH(thaiSample);
   1.259 +
   1.260 +TestInput testInputs[] = {
   1.261 +    {"raghu.ttf",             devaText,   devaTextLength,   devaScriptCode, FALSE},
   1.262 +    {"CODE2000.TTF",             arabText,   arabTextLength,   arabScriptCode, TRUE},
   1.263 +    {"LucidaSansRegular.ttf", arabText,   arabTextLength,   arabScriptCode, TRUE},
   1.264 +    {"Thonburi.ttf",          thaiSample, thaiSampleLength, thaiScriptCode, FALSE}
   1.265 +};
   1.266 +
   1.267 +#define TEST_COUNT ARRAY_LENGTH(testInputs)
   1.268 +
   1.269 +le_int32 testCount = TEST_COUNT;
   1.270 +
   1.271 +void dumpShorts(FILE *file, char *label, le_int32 id, le_uint16 *shorts, le_int32 count) {
   1.272 +    char lineBuffer[8 * 8 + 2];
   1.273 +    le_int32 bufp = 0;
   1.274 +
   1.275 +    fprintf(file, label, id);
   1.276 +
   1.277 +    for (int i = 0; i < count; i += 1) {
   1.278 +        if (i % 8 == 0 && bufp != 0) {
   1.279 +            fprintf(file, "    %s\n", lineBuffer);
   1.280 +            bufp = 0;
   1.281 +        }
   1.282 +
   1.283 +        bufp += sprintf(&lineBuffer[bufp], "0x%4.4X, ", shorts[i]);
   1.284 +    }
   1.285 +
   1.286 +    if (bufp != 0) {
   1.287 +        lineBuffer[bufp - 2] = '\0';
   1.288 +        fprintf(file, "    %s\n", lineBuffer);
   1.289 +    }
   1.290 +
   1.291 +    fprintf(file, "};\n\n");
   1.292 +}
   1.293 +
   1.294 +void dumpLongs(FILE *file, char *label, le_int32 id, le_int32 *longs, le_int32 count) {
   1.295 +    char lineBuffer[8 * 12 + 2];
   1.296 +    le_int32 bufp = 0;
   1.297 +
   1.298 +    fprintf(file, label, id);
   1.299 +
   1.300 +    for (int i = 0; i < count; i += 1) {
   1.301 +        if (i % 8 == 0 && bufp != 0) {
   1.302 +            fprintf(file, "    %s\n", lineBuffer);
   1.303 +            bufp = 0;
   1.304 +        }
   1.305 +
   1.306 +        bufp += sprintf(&lineBuffer[bufp], "0x%8.8X, ", longs[i]);
   1.307 +    }
   1.308 +
   1.309 +    if (bufp != 0) {
   1.310 +        lineBuffer[bufp - 2] = '\0';
   1.311 +        fprintf(file, "    %s\n", lineBuffer);
   1.312 +    }
   1.313 +
   1.314 +    fprintf(file, "};\n\n");
   1.315 +}
   1.316 +
   1.317 +void dumpFloats(FILE *file, char *label, le_int32 id, float *floats, le_int32 count) {
   1.318 +    char lineBuffer[8 * 16 + 2];
   1.319 +    le_int32 bufp = 0;
   1.320 +
   1.321 +    fprintf(file, label, id);
   1.322 +
   1.323 +    for (int i = 0; i < count; i += 1) {
   1.324 +        if (i % 8 == 0 && bufp != 0) {
   1.325 +            fprintf(file, "    %s\n", lineBuffer);
   1.326 +            bufp = 0;
   1.327 +        }
   1.328 +
   1.329 +        bufp += sprintf(&lineBuffer[bufp], "%fF, ", floats[i]);
   1.330 +    }
   1.331 +
   1.332 +    if (bufp != 0) {
   1.333 +        lineBuffer[bufp - 2] = '\0';
   1.334 +        fprintf(file, "    %s\n", lineBuffer);
   1.335 +    }
   1.336 +
   1.337 +    fprintf(file, "};\n\n");
   1.338 +}
   1.339 +
   1.340 +const char *getShortName(le_int32 scriptCode)
   1.341 +{
   1.342 +    static char shortName[5];
   1.343 +    const char *name = uscript_getShortName((UScriptCode) scriptCode);
   1.344 +
   1.345 +    shortName[0] = tolower(name[0]);
   1.346 +    shortName[1] = tolower(name[1]);
   1.347 +    shortName[2] = tolower(name[2]);
   1.348 +    shortName[3] = tolower(name[3]);
   1.349 +    shortName[4] = '\0';
   1.350 +
   1.351 +    return shortName;
   1.352 +}
   1.353 +
   1.354 +int main(int argc, char *argv[])
   1.355 +{
   1.356 +    le_int32 test;
   1.357 +    FILE *outputFile = fopen(argv[1], "w");
   1.358 +
   1.359 +    fprintf(outputFile, header);
   1.360 +
   1.361 +    for (test = 0; test < testCount; test += 1) {
   1.362 +        LEErrorCode fontStatus = LE_NO_ERROR;
   1.363 +        PortableFontInstance fontInstance(testInputs[test].fontName, 12, fontStatus);
   1.364 +
   1.365 +        if (LE_FAILURE(fontStatus)) {
   1.366 +            printf("ERROR: test case %d, could not get a font instance for %s\n", test, testInputs[test].fontName);
   1.367 +            continue;
   1.368 +        }
   1.369 +
   1.370 +        LEErrorCode success = LE_NO_ERROR;
   1.371 +        LayoutEngine *engine = LayoutEngine::layoutEngineFactory(&fontInstance, testInputs[test].scriptCode, -1, success);
   1.372 +        le_uint32  glyphCount;
   1.373 +        LEGlyphID *glyphs;
   1.374 +        le_int32  *indices;
   1.375 +        float     *positions;
   1.376 +
   1.377 +        if (LE_FAILURE(success)) {
   1.378 +            printf("ERROR: test case %d, could not create a LayoutEngine for script %s.\n", test, uscript_getName((UScriptCode) testInputs[test].scriptCode));
   1.379 +            continue;
   1.380 +        }
   1.381 +
   1.382 +        glyphCount = engine->layoutChars(testInputs[test].text, 0, testInputs[test].textLength, testInputs[test].textLength, testInputs[test].rightToLeft, 0, 0, success);
   1.383 +
   1.384 +        glyphs    = new LEGlyphID[glyphCount];
   1.385 +        indices   = new le_int32[glyphCount];
   1.386 +        positions = new float[glyphCount * 2 + 2];
   1.387 +
   1.388 +        engine->getGlyphs(glyphs, success);
   1.389 +        engine->getCharIndices(indices, success);
   1.390 +        engine->getGlyphPositions(positions, success);
   1.391 +
   1.392 +        //fprintf(outputFile, "font: %s\n", testInputs[test].fontName);
   1.393 +        dumpShorts(outputFile, "LEUnicode inputText%d[] =\n{\n", test, testInputs[test].text, testInputs[test].textLength);
   1.394 +
   1.395 +        dumpLongs(outputFile, "LEGlyphID resultGlyphs%d[] =\n{\n", test, (le_int32 *) glyphs, glyphCount);
   1.396 +        fprintf(outputFile, "le_int32 resultGlyphCount%d = %d;\n\n", test, glyphCount);
   1.397 +
   1.398 +        dumpLongs(outputFile, "le_int32 resultIndices%d[] =\n{\n", test, indices, glyphCount);
   1.399 +
   1.400 +        dumpFloats(outputFile, "float resultPositions%d[] =\n{\n", test, positions, glyphCount * 2 + 2);
   1.401 +
   1.402 +        fprintf(outputFile, "\n");
   1.403 +
   1.404 +        delete[] positions;
   1.405 +        delete[] indices;
   1.406 +        delete[] glyphs;
   1.407 +        delete   engine;
   1.408 +    }
   1.409 +
   1.410 +    fprintf(outputFile, "TestInput testInputs[] = \n{\n");
   1.411 +
   1.412 +    for (test = 0; test < testCount; test += 1) {
   1.413 +        fprintf(outputFile, "    {\"%s\", inputText%d, %d, %sScriptCode, %s},\n",
   1.414 +            testInputs[test].fontName, test, testInputs[test].textLength, getShortName(testInputs[test].scriptCode),
   1.415 +            testInputs[test].rightToLeft? "TRUE" : "FALSE");
   1.416 +    }
   1.417 +
   1.418 +    fprintf(outputFile, "};\n\nle_int32 testCount = ARRAY_LENGTH(testInputs);\n\n");
   1.419 +
   1.420 +    fprintf(outputFile, "TestResult testResults[] = \n{\n");
   1.421 +
   1.422 +    for (test = 0; test < testCount; test += 1) {
   1.423 +        fprintf(outputFile, "    {resultGlyphCount%d, resultGlyphs%d, resultIndices%d, resultPositions%d},\n",
   1.424 +            test, test, test, test);
   1.425 +    }
   1.426 +
   1.427 +    fprintf(outputFile, "};\n\n");
   1.428 +
   1.429 +    fclose(outputFile);
   1.430 +    return 0;
   1.431 +}