ICU-4890 Handle scripts whose short name is not the same as their OpenType tag.
X-SVN-Rev: 19348
This commit is contained in:
parent
5213dc5a7f
commit
f403ab514c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -68,6 +68,48 @@ public class ScriptData extends TagValueData
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Exceptions could be generated algorithmically
|
||||
private static class TagException
|
||||
{
|
||||
private String icuTag;
|
||||
private String otTag;
|
||||
|
||||
public TagException(String icu, String ot)
|
||||
{
|
||||
icuTag = icu;
|
||||
otTag = ot;
|
||||
}
|
||||
|
||||
public String getICUTag()
|
||||
{
|
||||
return icuTag;
|
||||
}
|
||||
|
||||
public String getOTTag()
|
||||
{
|
||||
return otTag;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: short name longer than long name, replace repeated chars w/ space...
|
||||
private ScriptData.TagException exceptions[] = {
|
||||
new ScriptData.TagException("laoo", "lao "),
|
||||
new ScriptData.TagException("yiii", "yi "),
|
||||
};
|
||||
|
||||
|
||||
// TODO: binary search the exceptions list?
|
||||
private String getException(String icu)
|
||||
{
|
||||
for(int i = 0; i < exceptions.length; i += 1) {
|
||||
if (exceptions[i].getICUTag().equals(icu)) {
|
||||
return exceptions[i].getOTTag();
|
||||
}
|
||||
}
|
||||
|
||||
return icu;
|
||||
}
|
||||
|
||||
//
|
||||
// Straight insertion sort from Knuth vol. III, pg. 81
|
||||
//
|
||||
@ -109,7 +151,7 @@ public class ScriptData extends TagValueData
|
||||
fScriptTags[script - fMinScript] = UScript.getShortName(script).toLowerCase();
|
||||
|
||||
if (script != commonScript) {
|
||||
UnicodeSet scriptSet = new UnicodeSet("\\p{" + fScriptTags[script] + "}");
|
||||
UnicodeSet scriptSet = new UnicodeSet("\\p{" + fScriptTags[script - fMinScript] + "}");
|
||||
UnicodeSetIterator it = new UnicodeSetIterator(scriptSet);
|
||||
|
||||
while (it.nextRange()) {
|
||||
@ -150,7 +192,7 @@ public class ScriptData extends TagValueData
|
||||
public String getTag(int value)
|
||||
{
|
||||
if (value >= fMinScript && value <= fMaxScript) {
|
||||
return fScriptTags[value - fMinScript];
|
||||
return getException(fScriptTags[value - fMinScript]);
|
||||
}
|
||||
|
||||
return "zyyx";
|
||||
@ -158,13 +200,19 @@ public class ScriptData extends TagValueData
|
||||
|
||||
public String getTagLabel(int value)
|
||||
{
|
||||
return getTag(value);
|
||||
if (value >= fMinScript && value <= fMaxScript) {
|
||||
return fScriptTags[value - fMinScript];
|
||||
}
|
||||
|
||||
return "zyyx";
|
||||
}
|
||||
|
||||
public String makeTag(int value)
|
||||
{
|
||||
if (value >= fMinScript && value <= fMaxScript) {
|
||||
return TagUtilities.makeTag(fScriptTags[value - fMinScript]);
|
||||
String tag = getException(fScriptTags[value - fMinScript]);
|
||||
|
||||
return TagUtilities.makeTag(tag);
|
||||
} else {
|
||||
return "0x00000000";
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -8,19 +8,6 @@ package com.ibm.icu.dev.tool.layout;
|
||||
|
||||
public class ScriptTagModuleWriter extends ScriptModuleWriter
|
||||
{
|
||||
|
||||
private int scriptTag(String tag)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < 4; i += 1) {
|
||||
result <<= 8;
|
||||
result += (int) (tag.charAt(i) & 0xFF);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ScriptTagModuleWriter(ScriptData theScriptData, LanguageData theLanguageData)
|
||||
{
|
||||
super(theScriptData, theLanguageData);
|
||||
|
Loading…
Reference in New Issue
Block a user