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