01: /*
02: *******************************************************************************
03: * Copyright (C) 1996-2005, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: *
07: */
08:
09: 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: private ClassTable classTable;
25:
26: public ShapingTypeBuilder() {
27: classTable = new ClassTable();
28: }
29:
30: public void writeTable(PrintStream output) {
31: classTable.writeClassTable(this );
32: output
33: .println("const le_uint8 ArabicShaping::shapingTypeTable[] = {");
34:
35: dumpTable(output, 8);
36: output.println("};\n");
37: }
38:
39: // TODO: The UnicodeSet is constrained to the BMP because the ClassTable data structure can
40: // only handle 16-bit entries. This is probably OK as long as there aren't any joining scripts
41: // outside of the BMP...
42: public void buildShapingTypes(String filename) {
43: UnicodeSet shapingTypes = new UnicodeSet(
44: "[[\\P{Joining_Type=Non_Joining}] & [\\u0000-\\uFFFF]]");
45: int count = shapingTypes.size();
46:
47: System.out.println("There are " + count
48: + " characters with a joining type.");
49:
50: for (int i = 0; i < count; i += 1) {
51: int ch = shapingTypes.charAt(i);
52:
53: classTable.addMapping(ch, UCharacter.getIntPropertyValue(
54: 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: ShapingTypeBuilder stb = new ShapingTypeBuilder();
69:
70: stb.buildShapingTypes(args[0]);
71: }
72: }
|