ICU-2891 Use hex constants rather that the LE_MAKE_TAG macro to define tags. The macro isn't EBCDIC friendly.

X-SVN-Rev: 12035
This commit is contained in:
Eric Mader 2003-05-21 16:32:09 +00:00
parent 74b51c88c8
commit 780f1da7a9
3 changed files with 278 additions and 18 deletions

View File

@ -0,0 +1,238 @@
/*
*******************************************************************************
* Copyright (C) 1998-2003, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/layout/OpenTypeTagBuilder.java,v $
* $Date: 2003/05/21 16:32:09 $
* $Revision: 1.1 $
*/
package com.ibm.icu.dev.tool.layout;
/**
* @author emader
*
*/
public class OpenTypeTagBuilder
{
private static String[] tableTags = {
"acnt",
"avar",
"BASE",
"bdat",
"bhed",
"bloc",
"bsln",
"CFF ",
"cmap",
"cvar",
"cvt ",
"DSIG",
"EBDT",
"EBLC",
"EBSC",
"fdsc",
"feat",
"fmtx",
"fpgm",
"fvar",
"gasp",
"GDEF",
"glyf",
"GPOS",
"GSUB",
"gvar",
"hdmx",
"head",
"hhea",
"hmtx",
"hsty",
"just",
"JSTF",
"kern",
"lcar",
"loca",
"LTSH",
"maxp",
"mort",
"morx",
"name",
"opbd",
"OS/2",
"PCLT",
"post",
"prep",
"prop",
"trak",
"VDMX",
"vhea",
"vmtx",
"VORG",
"Zapf"
};
private static String[] featureTags = {
"aalt",
"abvf",
"abvm",
"abvs",
"afrc",
"akhn",
"blwf",
"blwm",
"blws",
"calt",
"case",
"ccmp",
"clig",
"cpsp",
"cswh",
"curs",
"c2sc",
"c2pc",
"dist",
"dlig",
"dnom",
"expt",
"falt",
"fin2",
"fin3",
"fina",
"frac",
"fwid",
"half",
"haln",
"halt",
"hist",
"hkna",
"hlig",
"hngl",
"hwid",
"init",
"isol",
"ital",
"jalt",
"jp78",
"jp83",
"jp90",
"kern",
"lfbd",
"liga",
"ljmo",
"lnum",
"locl",
"mark",
"med2",
"medi",
"mgrk",
"mkmk",
"mset",
"nalt",
"nlck",
"nukt",
"numr",
"onum",
"opbd",
"ordn",
"ornm",
"palt",
"pcap",
"pnum",
"pref",
"pres",
"pstf",
"psts",
"pwid",
"qwid",
"rand",
"rlig",
"rphf",
"rtbd",
"rtla",
"ruby",
"salt",
"sinf",
"size",
"smcp",
"smpl",
"ss01",
"ss02",
"ss03",
"ss04",
"ss05",
"ss06",
"ss07",
"ss08",
"ss09",
"ss10",
"ss11",
"ss12",
"ss13",
"ss14",
"ss15",
"ss16",
"ss17",
"ss18",
"ss19",
"ss20",
"subs",
"sups",
"swsh",
"titl",
"tjmo",
"tnam",
"tnum",
"trad",
"twid",
"unic",
"valt",
"vatu",
"vert",
"vhal",
"vjmo",
"vkna",
"vkrn",
"vpal",
"vrt2",
"zero"
};
private static String tagLabel(String tag)
{
StringBuffer result = new StringBuffer();
String upperTag = tag.toUpperCase();
for (int i = 0; i < upperTag.length(); i += 1) {
char ch = upperTag.charAt(i);
if ((ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9')) {
ch = '_';
}
result.append(ch);
}
return result.toString();
}
private static void dumpTags(String enumName, String[] tags)
{
System.out.println("enum LE" + enumName + "Tags {");
for (int i = 0; i < tags.length; i += 1) {
String tag = tags[i];
System.out.println(" LE_" + tagLabel(tag) + "_" + enumName.toUpperCase() +
"_TAG = " + TagUtilities.makeTag(tag) + "UL, /* '" + tag + "' */");
}
System.out.println("};");
}
public static void main(String[] args)
{
dumpTags("Table", tableTags);
dumpTags("Feature", featureTags);
}
}

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/layout/ScriptTagModuleWriter.java,v $
* $Date: 2003/05/14 18:36:30 $
* $Revision: 1.4 $
* $Date: 2003/05/21 16:32:08 $
* $Revision: 1.5 $
*
*******************************************************************************
*/
@ -46,9 +46,11 @@ public class ScriptTagModuleWriter extends ModuleWriter
output.print(scriptData.getScriptTagLabel(script));
output.print("ScriptTag = ");
output.print(scriptData.makeScriptTag(script));
output.print("; /* ");
output.print("; /* '");
output.print(scriptData.getScriptTag(script));
output.print("' (");
output.print(scriptData.getScriptName(script));
output.println(" */");
output.println(") */");
}
output.println(hScriptPostamble);
@ -61,9 +63,11 @@ public class ScriptTagModuleWriter extends ModuleWriter
output.print(languageData.getLanguageTagLabel(language));
output.print("LanguageTag = ");
output.print(languageData.makeLanguageTag(language));
output.print("; /* ");
output.print("; /* '");
output.print(languageData.getLanguageTag(language));
output.print("' (");
output.print(languageData.getLanguageName(language));
output.println(" */");
output.println(") */");
}
output.println(hPostamble);

View File

@ -6,12 +6,14 @@
*
* Created on Apr 14, 2003
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/layout/TagUtilities.java,v $ $Date: 2003/04/15 20:15:53 $ $Revision: 1.2 $
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/layout/TagUtilities.java,v $ $Date: 2003/05/21 16:32:08 $ $Revision: 1.3 $
*
*******************************************************************************
*/
package com.ibm.icu.dev.tool.layout;
import com.ibm.icu.impl.Utility;
/**
* This class contains utility methods for dealing with
* four-letter tags.
@ -27,23 +29,39 @@ public class TagUtilities
return "0x00000000";
}
StringBuffer result = new StringBuffer("LE_MAKE_TAG(");
int tagValue = 0;
for (int i = 0; i < 4; i += 1) {
if (i > 0) {
result.append(", ");
}
result.append('\'');
result.append(i < tag.length()? tag.charAt(i) : ' ');
result.append('\'');
tagValue <<= 8;
tagValue += (int) ((i < tag.length()? tag.charAt(i) : ' ') & 0xFF);
}
result.append(")");
return result.toString();
return "0x" + Utility.hex(tagValue, 8);
}
// public static String makeTagOld(String tag)
// {
// if (tag == null || tag.length() == 0) {
// return "0x00000000";
// }
//
// StringBuffer result = new StringBuffer("LE_MAKE_TAG(");
//
// for (int i = 0; i < 4; i += 1) {
// if (i > 0) {
// result.append(", ");
// }
//
// result.append('\'');
// result.append(i < tag.length()? tag.charAt(i) : ' ');
// result.append('\'');
// }
//
// result.append(")");
//
// return result.toString();
// }
public static String tagLabel(String tag)
{
if (tag == null || tag.length() == 0) {