fontservices/textshaperplugin/test/letest/gendata.cpp
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2  *******************************************************************************
       
     3  *
       
     4  *   Copyright (C) 1999-2004, International Business Machines
       
     5  *   Corporation and others.  All Rights Reserved.
       
     6  *
       
     7  *******************************************************************************
       
     8  *   file name:  gendata.cpp
       
     9  *
       
    10  *   created on: 11/03/2000
       
    11  *   created by: Eric R. Mader
       
    12  */
       
    13 
       
    14 #include <stdio.h>
       
    15 #include <ctype.h>
       
    16 
       
    17 #include "LETypes.h"
       
    18 #include "LEScripts.h"
       
    19 #include "LayoutEngine.h"
       
    20 
       
    21 #include "PortableFontInstance.h"
       
    22 
       
    23 #include "unicode/uscript.h"
       
    24 
       
    25 U_NAMESPACE_USE
       
    26 
       
    27 #define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
       
    28 
       
    29 struct TestInput
       
    30 {
       
    31     char      *fontName;
       
    32     LEUnicode *text;
       
    33     le_int32   textLength;
       
    34     le_int32   scriptCode;
       
    35     le_bool    rightToLeft;
       
    36 };
       
    37 
       
    38 /* 
       
    39  * FIXME: should use the output file name and the current date.
       
    40  */
       
    41 char *header =
       
    42     "/*\n"
       
    43     " *******************************************************************************\n"
       
    44     " *\n"
       
    45     " *   Copyright (C) 1999-2004, International Business Machines\n"
       
    46     " *   Corporation and others.  All Rights Reserved.\n"
       
    47     " *\n"
       
    48     " *   WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT\n"
       
    49     " *   UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.\n"
       
    50     " *\n"
       
    51     " *******************************************************************************\n"
       
    52     " *\n"
       
    53     " *   file name:  testdata.cpp\n"
       
    54     " *   created on: 12/14/2000\n"
       
    55     " *   created by: gendata.cpp\n"
       
    56     " */\n"
       
    57     "\n"
       
    58     "#include \"LETypes.h\"\n"
       
    59     "#include \"LEScripts.h\"\n"
       
    60     "#include \"letest.h\"\n"
       
    61     "\n";
       
    62 
       
    63 #if 0
       
    64 char *scriptNames[] =
       
    65 {
       
    66       "USCRIPT_COMMON",      /* Zyyy */
       
    67       "USCRIPT_INHERITED",   /* Qaai */
       
    68       "USCRIPT_ARABIC",      /* Arab */
       
    69       "USCRIPT_ARMENIAN",    /* Armn */
       
    70       "USCRIPT_BENGALI",     /* Beng */
       
    71       "USCRIPT_BOPOMOFO",    /* Bopo */
       
    72       "USCRIPT_CHEROKEE",    /* Cher */
       
    73       "USCRIPT_COPTIC",      /* Qaac */
       
    74       "USCRIPT_CYRILLIC",    /* Cyrl (Cyrs) */
       
    75       "USCRIPT_DESERET",     /* Dsrt */
       
    76       "USCRIPT_DEVANAGARI",  /* Deva */
       
    77       "USCRIPT_ETHIOPIC",    /* Ethi */
       
    78       "USCRIPT_GEORGIAN",    /* Geor (Geon, Geoa) */
       
    79       "USCRIPT_GOTHIC",      /* Goth */
       
    80       "USCRIPT_GREEK",       /* Grek */
       
    81       "USCRIPT_GUJARATI",    /* Gujr */
       
    82       "USCRIPT_GURMUKHI",    /* Guru */
       
    83       "USCRIPT_HAN",         /* Hani */
       
    84       "USCRIPT_HANGUL",      /* Hang */
       
    85       "USCRIPT_HEBREW",      /* Hebr */
       
    86       "USCRIPT_HIRAGANA",    /* Hira */
       
    87       "USCRIPT_KANNADA",     /* Knda */
       
    88       "USCRIPT_KATAKANA",    /* Kana */
       
    89       "USCRIPT_KHMER",       /* Khmr */
       
    90       "USCRIPT_LAO",         /* Laoo */
       
    91       "USCRIPT_LATIN",       /* Latn (Latf, Latg) */
       
    92       "USCRIPT_MALAYALAM",   /* Mlym */
       
    93       "USCRIPT_MONGOLIAN",   /* Mong */
       
    94       "USCRIPT_MYANMAR",     /* Mymr */
       
    95       "USCRIPT_OGHAM",       /* Ogam */
       
    96       "USCRIPT_OLD_ITALIC",  /* Ital */
       
    97       "USCRIPT_ORIYA",       /* Orya */
       
    98       "USCRIPT_RUNIC",       /* Runr */
       
    99       "USCRIPT_SINHALA",     /* Sinh */
       
   100       "USCRIPT_SYRIAC",      /* Syrc (Syrj, Syrn, Syre) */
       
   101       "USCRIPT_TAMIL",       /* Taml */
       
   102       "USCRIPT_TELUGU",      /* Telu */
       
   103       "USCRIPT_THAANA",      /* Thaa */
       
   104       "USCRIPT_THAI",        /* Thai */
       
   105       "USCRIPT_TIBETAN",     /* Tibt */
       
   106       "USCRIPT_UCAS",        /* Cans */
       
   107       "USCRIPT_YI",          /* Yiii */
       
   108       "USCRIPT_TAGALOG",     /* Tglg */
       
   109       "USCRIPT_HANUNOO",     /* Hano */
       
   110       "USCRIPT_BUHID",       /* Buhd */
       
   111       "USCRIPT_TAGBANWA"     /* Tagb */
       
   112 };
       
   113 #endif
       
   114 
       
   115 LEUnicode devaText[] =
       
   116 {
       
   117     0x0936, 0x094d, 0x0930, 0x0940, 0x092e, 0x0926, 0x094d, 0x0020,
       
   118     0x092d, 0x0917, 0x0935, 0x0926, 0x094d, 0x0917, 0x0940, 0x0924,
       
   119     0x093e, 0x0020, 0x0905, 0x0927, 0x094d, 0x092f, 0x093e, 0x092f,
       
   120     0x0020, 0x0905, 0x0930, 0x094d, 0x091c, 0x0941, 0x0928, 0x0020,
       
   121     0x0935, 0x093f, 0x0937, 0x093e, 0x0926, 0x0020, 0x092f, 0x094b,
       
   122     0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 0x093e, 0x0937,
       
   123     0x094d, 0x091f, 0x094d, 0x0930, 0x0020, 0x0909, 0x0935, 0x093E,
       
   124     0x091A, 0x0943, 0x0020, 0x0927, 0x0930, 0x094d, 0x092e, 0x0915,
       
   125     0x094d, 0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 0x0947, 0x0020,
       
   126     0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094d, 0x0937, 0x0947,
       
   127     0x0924, 0x094d, 0x0930, 0x0947, 0x0020, 0x0938, 0x092e, 0x0935,
       
   128     0x0947, 0x0924, 0x093e, 0x0020, 0x092f, 0x0941, 0x092f, 0x0941,
       
   129     0x0924, 0x094d, 0x0938, 0x0935, 0x0903, 0x0020, 0x092e, 0x093e,
       
   130     0x092e, 0x0915, 0x093e, 0x0903, 0x0020, 0x092a, 0x093e, 0x0923,
       
   131     0x094d, 0x0921, 0x0935, 0x093e, 0x0936, 0x094d, 0x091a, 0x0948,
       
   132     0x0935, 0x0020, 0x0915, 0x093f, 0x092e, 0x0915, 0x0941, 0x0930,
       
   133     0x094d, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 0x091c, 0x0935
       
   134 };
       
   135 
       
   136 le_int32 devaTextLength = ARRAY_LENGTH(devaText);
       
   137 
       
   138 LEUnicode arabText[] =
       
   139 {
       
   140     0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020, 
       
   141     0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 
       
   142     0x0627, 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 
       
   143     0x0020, 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 
       
   144     0x0627, 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 
       
   145     0x0020, 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 
       
   146     0x062A, 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 
       
   147     0x0623, 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 
       
   148     0x0645, 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 
       
   149     0x0623, 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 
       
   150     0x0020, 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 
       
   151     0x064A, 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 
       
   152     0x0639, 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 
       
   153     0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 
       
   154     0x0647, 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 
       
   155     0x0020, 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 
       
   156     0x0022, 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 
       
   157     0x0022, 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 
       
   158     0x0646, 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 
       
   159     0x0020, 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 
       
   160     0x0020, 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 
       
   161     0x0020, 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 
       
   162     0x0647, 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 
       
   163     0x0642, 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 
       
   164     0x0627, 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 
       
   165     0x0020, 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 
       
   166     0x0627, 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 
       
   167     0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 
       
   168     0x062A, 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 
       
   169     0x062C, 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 
       
   170     0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 
       
   171     0x0631, 0x0648, 0x0631, 0x064A, 0x0629
       
   172     
       
   173     /* The next few sentences...
       
   174     0x002E, 0x0020, 0x0648, 
       
   175     0x0639, 0x0644, 0x0649, 0x0020, 0x0633, 0x0628, 0x064A, 0x0644, 
       
   176     0x0020, 0x0627, 0x0644, 0x0645, 0x062B, 0x0627, 0x0644, 0x060C, 
       
   177     0x0020, 0x0641, 0x0625, 0x0646, 0x0020, 0x0627, 0x0644, 0x0627, 
       
   178     0x062A, 0x062D, 0x0627, 0x062F, 0x0020, 0x0627, 0x0644, 0x0623, 
       
   179     0x0648, 0x0631, 0x0648, 0x0628, 0x064A, 0x0020, 0x0644, 0x0648, 
       
   180     0x062D, 0x062F, 0x0647, 0x060C, 0x0020, 0x0627, 0x062D, 0x062A, 
       
   181     0x0648, 0x0649, 0x0020, 0x0627, 0x0644, 0x0639, 0x062F, 0x064A, 
       
   182     0x062F, 0x0020, 0x0645, 0x0646, 0x0020, 0x0627, 0x0644, 0x0634, 
       
   183     0x0641, 0x0631, 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x0645, 
       
   184     0x062E, 0x062A, 0x0644, 0x0641, 0x0629, 0x0020, 0x0644, 0x064A, 
       
   185     0x063A, 0x0637, 0x064A, 0x0020, 0x062C, 0x0645, 0x064A, 0x0639, 
       
   186     0x0020, 0x0627, 0x0644, 0x0644, 0x063A, 0x0627, 0x062A, 0x0020, 
       
   187     0x0627, 0x0644, 0x0645, 0x0633, 0x062A, 0x062E, 0x062F, 0x0645, 
       
   188     0x0629, 0x0020, 0x0641, 0x064A, 0x0020, 0x0627, 0x0644, 0x0627, 
       
   189     0x062A, 0x062D, 0x0627, 0x062F, 0x002E, 0x0020, 0x0648, 0x062D, 
       
   190     0x062A, 0x0649, 0x0020, 0x0644, 0x0648, 0x0020, 0x0627, 0x0639, 
       
   191     0x062A, 0x0628, 0x0631, 0x0646, 0x0627, 0x0020, 0x0644, 0x063A, 
       
   192     0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0629, 0x060C, 
       
   193     0x0020, 0x0643, 0x0627, 0x0644, 0x0644, 0x063A, 0x0629, 0x0020, 
       
   194     0x0627, 0x0644, 0x0625, 0x0646, 0x062C, 0x0644, 0x064A, 0x0632, 
       
   195     0x064A, 0x0629, 0x060C, 0x0020, 0x0641, 0x0625, 0x0646, 0x0020, 
       
   196     0x062C, 0x062F, 0x0648, 0x0644, 0x0020, 0x0634, 0x0641, 0x0631, 
       
   197     0x0629, 0x0020, 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0644, 
       
   198     0x0645, 0x0020, 0x064A, 0x0643, 0x0641, 0x0020, 0x0644, 0x0627, 
       
   199     0x0633, 0x062A, 0x064A, 0x0639, 0x0627, 0x0628, 0x0020, 0x062C, 
       
   200     0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0623, 0x062D, 
       
   201     0x0631, 0x0641, 0x0020, 0x0648, 0x0639, 0x0644, 0x0627, 0x0645, 
       
   202     0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x062A, 0x0631, 0x0642, 
       
   203     0x064A, 0x0645, 0x0020, 0x0648, 0x0627, 0x0644, 0x0631, 0x0645, 
       
   204     0x0648, 0x0632, 0x0020, 0x0627, 0x0644, 0x0641, 0x0646, 0x064A, 
       
   205     0x0629, 0x0020, 0x0648, 0x0627, 0x0644, 0x0639, 0x0644, 0x0645, 
       
   206     0x064A, 0x0629, 0x0020, 0x0627, 0x0644, 0x0634, 0x0627, 0x0626, 
       
   207     0x0639, 0x0629, 0x0020, 0x0627, 0x0644, 0x0627, 0x0633, 0x062A, 
       
   208     0x0639, 0x0645, 0x0627, 0x0644, 0x002E */
       
   209 };
       
   210 le_int32 arabTextLength = ARRAY_LENGTH(arabText);
       
   211 
       
   212 
       
   213 LEUnicode thaiSample[] =
       
   214 {
       
   215     0x0E1A, 0x0E17, 0x0E17, 0x0E35, 0x0E48, 0x0E51, 0x0E1E, 0x0E32,
       
   216     0x0E22, 0x0E38, 0x0E44, 0x0E0B, 0x0E42, 0x0E04, 0x0E25, 0x0E19,
       
   217     0x0E42, 0x0E14, 0x0E42, 0x0E23, 0x0E18, 0x0E35, 0x0E2D, 0x0E32, 
       
   218     0x0E28, 0x0E31, 0x0E22, 0x0E2D, 0x0E22, 0x0E39, 0x0E48, 0x0E17,
       
   219     0x0E48, 0x0E32, 0x0E21, 0x0E01, 0x0E25, 0x0E32, 0x0E07, 0x0E17,
       
   220     0x0E38, 0x0E48, 0x0E07, 0x0E43, 0x0E2B, 0x0E0D, 0x0E48, 0x0E43,
       
   221     0x0E19, 0x0E41, 0x0E04, 0x0E19, 0x0E0B, 0x0E31, 0x0E2A, 0x0E01, 
       
   222     0x0E31, 0x0E1A, 0x0E25, 0x0E38, 0x0E07, 0x0E40, 0x0E2E, 0x0E19,
       
   223     0x0E23, 0x0E35, 0x0E0A, 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48,
       
   224     0x0E41, 0x0E25, 0x0E30, 0x0E1B, 0x0E49, 0x0E32, 0x0E40, 0x0E2D,
       
   225     0x0E47, 0x0E21, 0x0E20, 0x0E23, 0x0E23, 0x0E22, 0x0E32, 0x0E0A,
       
   226     0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, 0x0E1A, 0x0E49, 0x0E32,
       
   227     0x0E19, 0x0E02, 0x0E2D, 0x0E07, 0x0E1E, 0x0E27, 0x0E01, 0x0E40, 
       
   228     0x0E02, 0x0E32, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, 0x0E40, 0x0E25,
       
   229     0x0E47, 0x0E01, 0x0E40, 0x0E1E, 0x0E23, 0x0E32, 0x0E30, 0x0E44,
       
   230     0x0E21, 0x0E49, 0x0E2A, 0x0E23, 0x0E49, 0x0E32, 0x0E07, 0x0E1A,
       
   231     0x0E49, 0x0E32, 0x0E19, 0x0E15, 0x0E49, 0x0E2D, 0x0E07, 0x0E02, 
       
   232     0x0E19, 0x0E21, 0x0E32, 0x0E14, 0x0E49, 0x0E27, 0x0E22, 0x0E40,
       
   233     0x0E01, 0x0E27, 0x0E35, 0x0E22, 0x0E19, 0x0E40, 0x0E1B, 0x0E47,
       
   234     0x0E19, 0x0E23, 0x0E30, 0x0E22, 0x0E30, 0x0E17, 0x0E32, 0x0E07,
       
   235     0x0E2B, 0x0E25, 0x0E32, 0x0E22, 0x0E44, 0x0E21, 0x0E25, 0x0E4C
       
   236     /* A few more lines...
       
   237     0x0E1A, 0x0E49, 0x0E32, 0x0E19, 0x0E21, 0x0E35, 0x0E2A, 0x0E35,
       
   238     0x0E48, 0x0E1D, 0x0E32, 0x0E21, 0x0E35, 0x0E1E, 0x0E37, 0x0E49,
       
   239     0x0E19, 0x0E01, 0x0E31, 0x0E1A, 0x0E2B, 0x0E25, 0x0E31, 0x0E07,
       
   240     0x0E04, 0x0E32, 0x0E23, 0x0E27, 0x0E21, 0x0E17, 0x0E33, 0x0E40,
       
   241     0x0E1B, 0x0E47, 0x0E19, 0x0E2B, 0x0E49, 0x0E2D, 0x0E07, 0x0E40,
       
   242     0x0E14, 0x0E35, 0x0E22, 0x0E27, 0x0E43, 0x0E19, 0x0E2B, 0x0E49, 
       
   243     0x0E2D, 0x0E07, 0x0E21, 0x0E35, 0x0E17, 0x0E31, 0x0E49, 0x0E07,
       
   244     0x0E40, 0x0E15, 0x0E32, 0x0E2B, 0x0E38, 0x0E07, 0x0E15, 0x0E49,
       
   245     0x0E21, 0x0E17, 0x0E35, 0x0E48, 0x0E2A, 0x0E19, 0x0E34, 0x0E21,
       
   246     0x0E14, 0x0E39, 0x0E02, 0x0E36, 0x0E49, 0x0E19, 0x0E40, 0x0E25,
       
   247     0x0E2D, 0x0E30, 0x0E21, 0x0E35, 0x0E15, 0x0E39, 0x0E49, 0x0E43, 
       
   248     0x0E2A, 0x0E48, 0x0E16, 0x0E49, 0x0E27, 0x0E22, 0x0E0A, 0x0E32,
       
   249     0x0E21, 0x0E42, 0x0E15, 0x0E4A, 0x0E30, 0x0E40, 0x0E01, 0x0E49,
       
   250     0x0E32, 0x0E2D, 0x0E35, 0x0E49, 0x0E2A, 0x0E32, 0x0E21, 0x0E2B,
       
   251     0x0E23
       
   252     */
       
   253 };
       
   254 
       
   255 le_int32 thaiSampleLength = ARRAY_LENGTH(thaiSample);
       
   256 
       
   257 TestInput testInputs[] = {
       
   258     {"raghu.ttf",             devaText,   devaTextLength,   devaScriptCode, FALSE},
       
   259     {"CODE2000.TTF",             arabText,   arabTextLength,   arabScriptCode, TRUE},
       
   260     {"LucidaSansRegular.ttf", arabText,   arabTextLength,   arabScriptCode, TRUE},
       
   261     {"Thonburi.ttf",          thaiSample, thaiSampleLength, thaiScriptCode, FALSE}
       
   262 };
       
   263 
       
   264 #define TEST_COUNT ARRAY_LENGTH(testInputs)
       
   265 
       
   266 le_int32 testCount = TEST_COUNT;
       
   267 
       
   268 void dumpShorts(FILE *file, char *label, le_int32 id, le_uint16 *shorts, le_int32 count) {
       
   269     char lineBuffer[8 * 8 + 2];
       
   270     le_int32 bufp = 0;
       
   271 
       
   272     fprintf(file, label, id);
       
   273 
       
   274     for (int i = 0; i < count; i += 1) {
       
   275         if (i % 8 == 0 && bufp != 0) {
       
   276             fprintf(file, "    %s\n", lineBuffer);
       
   277             bufp = 0;
       
   278         }
       
   279 
       
   280         bufp += sprintf(&lineBuffer[bufp], "0x%4.4X, ", shorts[i]);
       
   281     }
       
   282 
       
   283     if (bufp != 0) {
       
   284         lineBuffer[bufp - 2] = '\0';
       
   285         fprintf(file, "    %s\n", lineBuffer);
       
   286     }
       
   287 
       
   288     fprintf(file, "};\n\n");
       
   289 }
       
   290 
       
   291 void dumpLongs(FILE *file, char *label, le_int32 id, le_int32 *longs, le_int32 count) {
       
   292     char lineBuffer[8 * 12 + 2];
       
   293     le_int32 bufp = 0;
       
   294 
       
   295     fprintf(file, label, id);
       
   296 
       
   297     for (int i = 0; i < count; i += 1) {
       
   298         if (i % 8 == 0 && bufp != 0) {
       
   299             fprintf(file, "    %s\n", lineBuffer);
       
   300             bufp = 0;
       
   301         }
       
   302 
       
   303         bufp += sprintf(&lineBuffer[bufp], "0x%8.8X, ", longs[i]);
       
   304     }
       
   305 
       
   306     if (bufp != 0) {
       
   307         lineBuffer[bufp - 2] = '\0';
       
   308         fprintf(file, "    %s\n", lineBuffer);
       
   309     }
       
   310 
       
   311     fprintf(file, "};\n\n");
       
   312 }
       
   313 
       
   314 void dumpFloats(FILE *file, char *label, le_int32 id, float *floats, le_int32 count) {
       
   315     char lineBuffer[8 * 16 + 2];
       
   316     le_int32 bufp = 0;
       
   317 
       
   318     fprintf(file, label, id);
       
   319 
       
   320     for (int i = 0; i < count; i += 1) {
       
   321         if (i % 8 == 0 && bufp != 0) {
       
   322             fprintf(file, "    %s\n", lineBuffer);
       
   323             bufp = 0;
       
   324         }
       
   325 
       
   326         bufp += sprintf(&lineBuffer[bufp], "%fF, ", floats[i]);
       
   327     }
       
   328 
       
   329     if (bufp != 0) {
       
   330         lineBuffer[bufp - 2] = '\0';
       
   331         fprintf(file, "    %s\n", lineBuffer);
       
   332     }
       
   333 
       
   334     fprintf(file, "};\n\n");
       
   335 }
       
   336 
       
   337 const char *getShortName(le_int32 scriptCode)
       
   338 {
       
   339     static char shortName[5];
       
   340     const char *name = uscript_getShortName((UScriptCode) scriptCode);
       
   341 
       
   342     shortName[0] = tolower(name[0]);
       
   343     shortName[1] = tolower(name[1]);
       
   344     shortName[2] = tolower(name[2]);
       
   345     shortName[3] = tolower(name[3]);
       
   346     shortName[4] = '\0';
       
   347 
       
   348     return shortName;
       
   349 }
       
   350 
       
   351 int main(int argc, char *argv[])
       
   352 {
       
   353     le_int32 test;
       
   354     FILE *outputFile = fopen(argv[1], "w");
       
   355 
       
   356     fprintf(outputFile, header);
       
   357 
       
   358     for (test = 0; test < testCount; test += 1) {
       
   359         LEErrorCode fontStatus = LE_NO_ERROR;
       
   360         PortableFontInstance fontInstance(testInputs[test].fontName, 12, fontStatus);
       
   361 
       
   362         if (LE_FAILURE(fontStatus)) {
       
   363             printf("ERROR: test case %d, could not get a font instance for %s\n", test, testInputs[test].fontName);
       
   364             continue;
       
   365         }
       
   366 
       
   367         LEErrorCode success = LE_NO_ERROR;
       
   368         LayoutEngine *engine = LayoutEngine::layoutEngineFactory(&fontInstance, testInputs[test].scriptCode, -1, success);
       
   369         le_uint32  glyphCount;
       
   370         LEGlyphID *glyphs;
       
   371         le_int32  *indices;
       
   372         float     *positions;
       
   373 
       
   374         if (LE_FAILURE(success)) {
       
   375             printf("ERROR: test case %d, could not create a LayoutEngine for script %s.\n", test, uscript_getName((UScriptCode) testInputs[test].scriptCode));
       
   376             continue;
       
   377         }
       
   378 
       
   379         glyphCount = engine->layoutChars(testInputs[test].text, 0, testInputs[test].textLength, testInputs[test].textLength, testInputs[test].rightToLeft, 0, 0, success);
       
   380 
       
   381         glyphs    = new LEGlyphID[glyphCount];
       
   382         indices   = new le_int32[glyphCount];
       
   383         positions = new float[glyphCount * 2 + 2];
       
   384 
       
   385         engine->getGlyphs(glyphs, success);
       
   386         engine->getCharIndices(indices, success);
       
   387         engine->getGlyphPositions(positions, success);
       
   388 
       
   389         //fprintf(outputFile, "font: %s\n", testInputs[test].fontName);
       
   390         dumpShorts(outputFile, "LEUnicode inputText%d[] =\n{\n", test, testInputs[test].text, testInputs[test].textLength);
       
   391 
       
   392         dumpLongs(outputFile, "LEGlyphID resultGlyphs%d[] =\n{\n", test, (le_int32 *) glyphs, glyphCount);
       
   393         fprintf(outputFile, "le_int32 resultGlyphCount%d = %d;\n\n", test, glyphCount);
       
   394 
       
   395         dumpLongs(outputFile, "le_int32 resultIndices%d[] =\n{\n", test, indices, glyphCount);
       
   396 
       
   397         dumpFloats(outputFile, "float resultPositions%d[] =\n{\n", test, positions, glyphCount * 2 + 2);
       
   398 
       
   399         fprintf(outputFile, "\n");
       
   400 
       
   401         delete[] positions;
       
   402         delete[] indices;
       
   403         delete[] glyphs;
       
   404         delete   engine;
       
   405     }
       
   406 
       
   407     fprintf(outputFile, "TestInput testInputs[] = \n{\n");
       
   408 
       
   409     for (test = 0; test < testCount; test += 1) {
       
   410         fprintf(outputFile, "    {\"%s\", inputText%d, %d, %sScriptCode, %s},\n",
       
   411             testInputs[test].fontName, test, testInputs[test].textLength, getShortName(testInputs[test].scriptCode),
       
   412             testInputs[test].rightToLeft? "TRUE" : "FALSE");
       
   413     }
       
   414 
       
   415     fprintf(outputFile, "};\n\nle_int32 testCount = ARRAY_LENGTH(testInputs);\n\n");
       
   416 
       
   417     fprintf(outputFile, "TestResult testResults[] = \n{\n");
       
   418 
       
   419     for (test = 0; test < testCount; test += 1) {
       
   420         fprintf(outputFile, "    {resultGlyphCount%d, resultGlyphs%d, resultIndices%d, resultPositions%d},\n",
       
   421             test, test, test, test);
       
   422     }
       
   423 
       
   424     fprintf(outputFile, "};\n\n");
       
   425 
       
   426     fclose(outputFile);
       
   427     return 0;
       
   428 }