2 *******************************************************************************
3 * Copyright (C) 1996-2005, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
9 package com.ibm.icu.dev.tool.layout;
11 import java.io.PrintStream;
13 import com.ibm.icu.lang.UCharacter;
14 import com.ibm.icu.lang.UProperty;
15 import com.ibm.icu.text.UnicodeSet;
20 * TODO To change the template for this generated type comment go to
21 * Window - Preferences - Java - Code Style - Code Templates
23 public class ShapingTypeBuilder extends OpenTypeTableWriter
25 private ClassTable classTable;
27 public ShapingTypeBuilder()
29 classTable = new ClassTable();
32 public void writeTable(PrintStream output)
34 classTable.writeClassTable(this);
35 output.println("const le_uint8 ArabicShaping::shapingTypeTable[] = {");
38 output.println("};\n");
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)
46 UnicodeSet shapingTypes = new UnicodeSet("[[\\P{Joining_Type=Non_Joining}] & [\\u0000-\\uFFFF]]");
47 int count = shapingTypes.size();
49 System.out.println("There are " + count + " characters with a joining type.");
51 for(int i = 0; i < count; i += 1) {
52 int ch = shapingTypes.charAt(i);
54 classTable.addMapping(ch, UCharacter.getIntPropertyValue(ch, UProperty.JOINING_TYPE));
57 LigatureModuleWriter writer = new LigatureModuleWriter();
58 String[] includeFiles = {"LETypes.h", "ArabicShaping.h"};
60 writer.openFile(filename);
61 writer.writeHeader(null, includeFiles);
62 writer.writeTable(this);
63 writer.writeTrailer();
67 public static void main(String[] args)
69 ShapingTypeBuilder stb = new ShapingTypeBuilder();
71 stb.buildShapingTypes(args[0]);