]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/tools/misc/src/com/ibm/icu/dev/tool/layout/ShapingTypeBuilder.java
Added flags.
[Dictionary.git] / jars / icu4j-52_1 / tools / misc / src / com / ibm / icu / dev / tool / layout / ShapingTypeBuilder.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2005, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  *
7  */
8
9 package com.ibm.icu.dev.tool.layout;
10
11 import java.io.PrintStream;
12
13 import com.ibm.icu.lang.UCharacter;
14 import com.ibm.icu.lang.UProperty;
15 import com.ibm.icu.text.UnicodeSet;
16
17 /**
18  * @author emader
19  *
20  * TODO To change the template for this generated type comment go to
21  * Window - Preferences - Java - Code Style - Code Templates
22  */
23 public class ShapingTypeBuilder extends OpenTypeTableWriter
24 {
25     private ClassTable classTable;
26     
27     public ShapingTypeBuilder()
28     {
29         classTable = new ClassTable();
30     }
31     
32     public void writeTable(PrintStream output)
33     {
34         classTable.writeClassTable(this);
35         output.println("const le_uint8 ArabicShaping::shapingTypeTable[] = {");
36         
37         dumpTable(output, 8);
38         output.println("};\n");
39     }
40     
41     // TODO: The UnicodeSet is constrained to the BMP because the ClassTable data structure can
42     // only handle 16-bit entries. This is probably OK as long as there aren't any joining scripts
43     // outside of the BMP...
44     public void buildShapingTypes(String filename)
45     {
46         UnicodeSet shapingTypes = new UnicodeSet("[[\\P{Joining_Type=Non_Joining}] & [\\u0000-\\uFFFF]]");
47         int count = shapingTypes.size();
48         
49         System.out.println("There are " + count + " characters with a joining type.");
50         
51         for(int i = 0; i < count; i += 1) {
52             int ch = shapingTypes.charAt(i);
53             
54             classTable.addMapping(ch, UCharacter.getIntPropertyValue(ch, UProperty.JOINING_TYPE));
55         }
56         
57         LigatureModuleWriter writer = new LigatureModuleWriter();
58         String[] includeFiles = {"LETypes.h", "ArabicShaping.h"};        
59         
60         writer.openFile(filename);
61         writer.writeHeader(null, includeFiles);
62         writer.writeTable(this);
63         writer.writeTrailer();
64         writer.closeFile();
65     }
66     
67     public static void main(String[] args)
68     {
69         ShapingTypeBuilder stb = new ShapingTypeBuilder();
70         
71         stb.buildShapingTypes(args[0]);
72     }
73 }