Home | History | Annotate | Download | only in layout
      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) 1998-2005, International Business Machines Corporation and    *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  *
      9  * Created on Dec 3, 2003
     10  *
     11  *******************************************************************************
     12  */
     13 package com.ibm.icu.dev.tool.layout;
     14 
     15 import java.io.PrintStream;
     16 
     17 
     18 
     19 class GDEFWriter extends OpenTypeTableWriter
     20 {
     21     ClassTable classTable;
     22     ClassTable markClassTable;
     23     String scriptName;
     24 
     25     public GDEFWriter(String scriptName, ClassTable classTable, ClassTable markClassTable)
     26     {
     27         super(1024);
     28         this.classTable     = classTable;
     29         this.markClassTable = markClassTable;
     30         this.scriptName     = scriptName;
     31     }
     32 
     33     public void writeTable(PrintStream output)
     34     {
     35         System.out.println("Writing " + scriptName + " GDEF table...");
     36 
     37         // 0x0001000 (fixed1) version number
     38         writeData(0x0001);
     39         writeData(0x0000);
     40 
     41         int classDefOffset = getOutputIndex();
     42         writeData(0); // glyphClassDefOffset (will fix later);
     43         writeData(0); // attachListOffset
     44         writeData(0); // ligCaretListOffset
     45         writeData(0); // markAttachClassDefOffset
     46 
     47         fixOffset(classDefOffset++, 0);
     48 
     49         System.out.println("Writing glyph class definition table...");
     50         classTable.writeClassTable(this);
     51 
     52         // skip over attachListOffset, ligCaretListOffset
     53         classDefOffset += 2;
     54 
     55         if (markClassTable != null) {
     56             fixOffset(classDefOffset, 0);
     57 
     58             System.out.println("Writing mark attach class definition table...");
     59             markClassTable.writeClassTable(this);
     60         }
     61 
     62         output.print("const le_uint8 ");
     63         output.print(scriptName);
     64         output.println("Shaping::glyphDefinitionTable[] = {");
     65 
     66         dumpTable(output, 8);
     67         output.println("};\n");
     68     }
     69 }
     70