mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-19 03:34:38 +00:00
ICU-4172 Add Mark Attachments Class Definitions table to GDEF using combining classes. Generate correct copyright year; add date file generated.
X-SVN-Rev: 17245
This commit is contained in:
parent
4d1a2006ed
commit
ecd10dd518
6 changed files with 138 additions and 54 deletions
|
@ -353,6 +353,77 @@ public class CanonGSUBBuilder
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Best guess Hebrew mark order: dagesh < sin_and_shin_dots < points_5B0_5BB < meteg_and_rafe < others
|
||||
* Best guess Arabic mark order: hamza < combining_alef < madda < sukun < shadda < vowel_marks < qur'anic_marks
|
||||
*/
|
||||
public static ClassTable buildCombiningClassTable()
|
||||
{
|
||||
UnicodeSet markSet = new UnicodeSet("[\\P{CanonicalCombiningClass=0}]");
|
||||
ClassTable exceptions = new ClassTable();
|
||||
ClassTable combiningClasses = new ClassTable();
|
||||
int markCount = markSet.size();
|
||||
|
||||
exceptions.addMapping(0x05BC, 10); // HEBREW POINT DAGESH OR MAPIQ
|
||||
|
||||
exceptions.addMapping(0x05C1, 11); // HEBREW POINT SHIN DOT
|
||||
exceptions.addMapping(0x05C2, 11); // HEBREW POINT SIN DOT
|
||||
|
||||
exceptions.addMapping(0x05B0, 12); // HEBREW POINT SHEVA
|
||||
exceptions.addMapping(0x05B1, 12); // HEBREW POINT HATAF SEGOL
|
||||
exceptions.addMapping(0x05B2, 12); // HEBREW POINT HATAF PATAH
|
||||
exceptions.addMapping(0x05B3, 12); // HEBREW POINT HATAF QAMATS
|
||||
exceptions.addMapping(0x05B4, 12); // HEBREW POINT HIRIQ
|
||||
exceptions.addMapping(0x05B5, 12); // HEBREW POINT TSERE
|
||||
exceptions.addMapping(0x05B6, 12); // HEBREW POINT SEGOL
|
||||
exceptions.addMapping(0x05B7, 12); // HEBREW POINT PATAH
|
||||
exceptions.addMapping(0x05B8, 12); // HEBREW POINT QAMATS
|
||||
exceptions.addMapping(0x05B9, 12); // HEBREW POINT HOLAM
|
||||
exceptions.addMapping(0x05BB, 12); // HEBREW POINT QUBUTS
|
||||
|
||||
exceptions.addMapping(0x05BD, 13); // HEBREW POINT METEG
|
||||
exceptions.addMapping(0x05BF, 13); // HEBREW POINT RAFE
|
||||
|
||||
exceptions.addMapping(0x0655, 27); // ARABIC HAMZA BELOW
|
||||
exceptions.addMapping(0x0654, 27); // ARABIC HAMZA ABOVE
|
||||
|
||||
exceptions.addMapping(0x0656, 28); // ARABIC SUBSCRIPT ALEF
|
||||
exceptions.addMapping(0x0670, 28); // ARABIC LETTER SUPERSCRIPT ALEF
|
||||
|
||||
exceptions.addMapping(0x0653, 29); // ARABIC MADDAH ABOVE
|
||||
|
||||
exceptions.addMapping(0x0652, 30); // ARABIC SUKUN
|
||||
exceptions.addMapping(0x06E1, 30); // ARABIC SMALL HIGH DOTLESS HEAD OF KHAH
|
||||
|
||||
exceptions.addMapping(0x0651, 31); // ARABIC SHADDA
|
||||
|
||||
exceptions.addMapping(0x064D, 32); // ARABIC KASRATAN
|
||||
exceptions.addMapping(0x0650, 32); // ARABIC KASRA
|
||||
|
||||
exceptions.addMapping(0x064B, 33); // ARABIC FATHATAN
|
||||
exceptions.addMapping(0x064C, 33); // ARABIC DAMMATAN
|
||||
exceptions.addMapping(0x064E, 33); // ARABIC FATHA
|
||||
exceptions.addMapping(0x064F, 33); // ARABIC DAMMA
|
||||
exceptions.addMapping(0x0657, 33); // ARABIC INVERTED DAMMA
|
||||
exceptions.addMapping(0x0658, 33); // ARABIC MARK NOON GHUNNA
|
||||
|
||||
exceptions.snapshot();
|
||||
|
||||
for (int i = 0; i < markCount; i += 1) {
|
||||
int mark = markSet.charAt(i);
|
||||
int markClass = exceptions.getGlyphClassID(mark);
|
||||
|
||||
if (markClass == 0) {
|
||||
markClass = UCharacter.getCombiningClass(mark);
|
||||
}
|
||||
|
||||
combiningClasses.addMapping(mark, markClass);
|
||||
}
|
||||
|
||||
combiningClasses.snapshot();
|
||||
return combiningClasses;
|
||||
}
|
||||
|
||||
public static void buildDecompTables(String fileName)
|
||||
{
|
||||
UnicodeSet decompSet = new UnicodeSet("[[\\P{Hangul}] & [\\p{DecompositionType=Canonical}]]");
|
||||
|
@ -397,8 +468,10 @@ public class CanonGSUBBuilder
|
|||
|
||||
featureList.finalizeFeatureList();
|
||||
|
||||
ClassTable markClassTable = buildCombiningClassTable();
|
||||
|
||||
GSUBWriter gsubWriter = new GSUBWriter("Canon", scriptList, featureList, lookupList);
|
||||
GDEFWriter gdefWriter = new GDEFWriter("Canon", classTable);
|
||||
GDEFWriter gdefWriter = new GDEFWriter("Canon", classTable, markClassTable);
|
||||
String[] includeFiles = {"LETypes.h", "CanonShaping.h"};
|
||||
|
||||
LigatureModuleWriter writer = new LigatureModuleWriter();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -51,11 +51,7 @@ public class CanonicalCharacterData
|
|||
dumpEquivalents(character, equivs);
|
||||
}
|
||||
|
||||
for (int e = 0; e < nEquivalents; e += 1) {
|
||||
equivalents[e] = (String) equivs.elementAt(e);
|
||||
}
|
||||
|
||||
sortEquivalents(equivalents);
|
||||
sortEquivalents(equivalents, equivs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,24 +190,26 @@ public class CanonicalCharacterData
|
|||
//
|
||||
// Straight insertion sort from Knuth vol. III, pg. 81
|
||||
//
|
||||
private static void sortEquivalents(String[] table)
|
||||
private static void sortEquivalents(String[] equivalents, Vector unsorted)
|
||||
{
|
||||
for (int j = 1; j < table.length; j += 1) {
|
||||
int nEquivalents = equivalents.length;
|
||||
|
||||
for (int e = 0; e < nEquivalents; e += 1) {
|
||||
String v = (String) unsorted.elementAt(e);
|
||||
int i;
|
||||
String v = table[j];
|
||||
|
||||
for (i = j - 1; i >= 0; i -= 1) {
|
||||
if (compareEquivalents(v, table[i]) >= 0) {
|
||||
|
||||
for (i = e - 1; i >= 0; i -= 1) {
|
||||
if (compareEquivalents(v, equivalents[i]) >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
table[i + 1] = table[i];
|
||||
equivalents[i + 1] = equivalents[i];
|
||||
}
|
||||
|
||||
table[i + 1] = v;
|
||||
}
|
||||
equivalents[i + 1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Vector recordVectors[] = new Vector[UScript.CODE_LIMIT];
|
||||
private int maxEquivalents[] = new int[UScript.CODE_LIMIT];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -45,13 +45,13 @@ public class ClassTable implements LookupSubtable
|
|||
//
|
||||
// Straight insertion sort from Knuth vol. III, pg. 81
|
||||
//
|
||||
public static void sort(ClassEntry[] table)
|
||||
public static void sort(ClassEntry[] table, Vector unsorted)
|
||||
{
|
||||
for (int j = 1; j < table.length; j += 1) {
|
||||
for (int e = 0; e < table.length; e += 1) {
|
||||
int i;
|
||||
ClassEntry v = table[j];
|
||||
ClassEntry v = (ClassEntry) unsorted.elementAt(e);
|
||||
|
||||
for (i = j - 1; i >= 0; i -= 1) {
|
||||
for (i = e - 1; i >= 0; i -= 1) {
|
||||
if (v.compareTo(table[i]) >= 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -161,11 +161,7 @@ public class ClassTable implements LookupSubtable
|
|||
snapshotSize = classMap.size();
|
||||
classTable = new ClassEntry[snapshotSize];
|
||||
|
||||
for (int i = 0; i < snapshotSize; i += 1) {
|
||||
classTable[i] = (ClassEntry) classMap.elementAt(i);
|
||||
}
|
||||
|
||||
ClassEntry.sort(classTable);
|
||||
ClassEntry.sort(classTable, classMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -70,11 +70,11 @@ public class DecompTable implements LookupSubtable
|
|||
//
|
||||
// Straight insertion sort from Knuth vol. III, pg. 81
|
||||
//
|
||||
public static void sort(DecompEntry[] table)
|
||||
public static void sort(DecompEntry[] table, Vector decompVector)
|
||||
{
|
||||
for (int j = 1; j < table.length; j += 1) {
|
||||
for (int j = 0; j < table.length; j += 1) {
|
||||
int i;
|
||||
DecompEntry v = table[j];
|
||||
DecompEntry v = (DecompEntry) decompVector.elementAt(j);
|
||||
|
||||
for (i = j - 1; i >= 0; i -= 1) {
|
||||
if (v.compareTo(table[i]) >= 0) {
|
||||
|
@ -134,14 +134,8 @@ public class DecompTable implements LookupSubtable
|
|||
{
|
||||
if (snapshotSize != decompVector.size()) {
|
||||
snapshotSize = decompVector.size();
|
||||
|
||||
decompEntries = new DecompEntry[snapshotSize];
|
||||
|
||||
for (int i = 0; i < snapshotSize; i += 1) {
|
||||
decompEntries[i] = (DecompEntry) decompVector.elementAt(i);
|
||||
}
|
||||
|
||||
DecompEntry.sort(decompEntries);
|
||||
DecompEntry.sort(decompEntries, decompVector);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -17,13 +17,15 @@ import java.io.PrintStream;
|
|||
class GDEFWriter extends OpenTypeTableWriter
|
||||
{
|
||||
ClassTable classTable;
|
||||
ClassTable markClassTable;
|
||||
String scriptName;
|
||||
|
||||
public GDEFWriter(String scriptName, ClassTable classTable)
|
||||
public GDEFWriter(String scriptName, ClassTable classTable, ClassTable markClassTable)
|
||||
{
|
||||
super(1024);
|
||||
this.classTable = classTable;
|
||||
this.scriptName = scriptName;
|
||||
this.classTable = classTable;
|
||||
this.markClassTable = markClassTable;
|
||||
this.scriptName = scriptName;
|
||||
}
|
||||
|
||||
public void writeTable(PrintStream output)
|
||||
|
@ -40,9 +42,20 @@ class GDEFWriter extends OpenTypeTableWriter
|
|||
writeData(0); // ligCaretListOffset
|
||||
writeData(0); // markAttachClassDefOffset
|
||||
|
||||
fixOffset(classDefOffset, 0);
|
||||
fixOffset(classDefOffset++, 0);
|
||||
|
||||
System.out.println("Writing glyph class definition table...");
|
||||
classTable.writeClassTable(this);
|
||||
|
||||
// skip over attachListOffset, ligCaretListOffset
|
||||
classDefOffset += 2;
|
||||
|
||||
if (markClassTable != null) {
|
||||
fixOffset(classDefOffset, 0);
|
||||
|
||||
System.out.println("Writing mark attach class definition table...");
|
||||
markClassTable.writeClassTable(this);
|
||||
}
|
||||
|
||||
output.print("const le_uint8 ");
|
||||
output.print(scriptName);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -14,6 +14,9 @@ package com.ibm.icu.dev.tool.layout;
|
|||
import java.io.PrintStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
public class ModuleWriter
|
||||
{
|
||||
|
@ -37,8 +40,12 @@ public class ModuleWriter
|
|||
System.out.println("Writing module " + outputFileName + "...");
|
||||
}
|
||||
|
||||
public void writeHeader(String define, String[] includeFiles) {
|
||||
output.print(moduleHeader);
|
||||
public void writeHeader(String define, String[] includeFiles)
|
||||
{
|
||||
MessageFormat format = new MessageFormat(moduleHeader);
|
||||
Object args[] = {new Date(System.currentTimeMillis())};
|
||||
|
||||
output.print(format.format(args));
|
||||
|
||||
if (define != null) {
|
||||
wroteDefine = true;
|
||||
|
@ -82,14 +89,17 @@ public class ModuleWriter
|
|||
|
||||
protected PrintStream output;
|
||||
|
||||
protected static final String moduleHeader = "/*\n" +
|
||||
" *\n" +
|
||||
" * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.\n" +
|
||||
" *\n" +
|
||||
" * WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS\n" +
|
||||
" * YOU REALLY KNOW WHAT YOU'RE DOING.\n" +
|
||||
" */\n" +
|
||||
"\n";
|
||||
protected static final String moduleHeader =
|
||||
"/*\n" +
|
||||
" *\n" +
|
||||
" * (C) Copyright IBM Corp. 1998-{0,date,yyyy}. All Rights Reserved.\n" +
|
||||
" *\n" +
|
||||
" * WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS\n" +
|
||||
" * YOU REALLY KNOW WHAT YOU''RE DOING.\n" +
|
||||
" *\n" +
|
||||
" * Generated on: {0,date,MM/dd/yyyy hh:mm:ss a z}\n" +
|
||||
" */\n" +
|
||||
"\n";
|
||||
|
||||
protected static final String moduleBegin = "U_NAMESPACE_BEGIN\n\n";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue