Bad RTF now causes an error message to appear in the transcription
instead of causing a fatal exception. The error allows you to look up the DuffCode that caused the trouble.
This commit is contained in:
parent
8275afeb41
commit
8958366a07
2 changed files with 182 additions and 175 deletions
|
@ -20,6 +20,8 @@ package org.thdl.tib.text;
|
||||||
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.thdl.util.ThdlDebug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for the primitive data types
|
* A wrapper for the primitive data types
|
||||||
* that combine to represent a Tibetan glyph in the
|
* that combine to represent a Tibetan glyph in the
|
||||||
|
@ -71,17 +73,18 @@ public class DuffCode {
|
||||||
Integer num2 = new Integer(val2);
|
Integer num2 = new Integer(val2);
|
||||||
|
|
||||||
if (leftToRight) {
|
if (leftToRight) {
|
||||||
fontNum = num1.intValue();
|
setFontNum(num1.intValue());
|
||||||
charNum = num2.intValue();
|
charNum = num2.intValue();
|
||||||
character = (char)charNum;
|
character = (char)charNum;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fontNum = num2.intValue();
|
setFontNum(num2.intValue());
|
||||||
charNum = num1.intValue();
|
charNum = num1.intValue();
|
||||||
character = (char)charNum;
|
character = (char)charNum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
|
ThdlDebug.noteIffyCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,11 +96,16 @@ public class DuffCode {
|
||||||
* @param ch a character
|
* @param ch a character
|
||||||
*/
|
*/
|
||||||
public DuffCode(int font, char ch) {
|
public DuffCode(int font, char ch) {
|
||||||
fontNum = font;
|
setFontNum(font);
|
||||||
character = ch;
|
character = ch;
|
||||||
charNum = (int)ch;
|
charNum = (int)ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFontNum(int font) {
|
||||||
|
ThdlDebug.verify(font >= 1 && font <= 10);
|
||||||
|
fontNum = font;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the font number of this glyph.
|
* Gets the font number of this glyph.
|
||||||
* @return the identifying font number for this DuffCode
|
* @return the identifying font number for this DuffCode
|
||||||
|
@ -160,6 +168,8 @@ public class DuffCode {
|
||||||
* @return a string representation of this object
|
* @return a string representation of this object
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "fontNum="+fontNum+";charNum="+charNum+";character="+new Character(character).toString();
|
return "<duffcode font=" + TibetanMachineWeb.tmwFontNames[fontNum]
|
||||||
|
+ " charNum=" + charNum + " character="
|
||||||
|
+ new Character(character).toString() + "/>";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,7 @@ import javax.swing.text.*;
|
||||||
import java.awt.font.*;
|
import java.awt.font.*;
|
||||||
|
|
||||||
import org.thdl.util.ThdlDebug;
|
import org.thdl.util.ThdlDebug;
|
||||||
|
import org.thdl.util.ThdlLazyException;
|
||||||
import org.thdl.util.Trie;
|
import org.thdl.util.Trie;
|
||||||
import org.thdl.util.ThdlOptions;
|
import org.thdl.util.ThdlOptions;
|
||||||
|
|
||||||
|
@ -537,17 +538,10 @@ public static boolean isFormatting(char c) {
|
||||||
* false if not
|
* false if not
|
||||||
*/
|
*/
|
||||||
public static boolean isChar(String s) {
|
public static boolean isChar(String s) {
|
||||||
if (currentKeyboardIsExtendedWylie()) {
|
if (currentKeyboardIsExtendedWylie())
|
||||||
if (charSet.contains(s))
|
return charSet.contains(s);
|
||||||
return true;
|
|
||||||
else
|
else
|
||||||
return false;
|
return keyboard.isChar(s);
|
||||||
}
|
|
||||||
else
|
|
||||||
if (keyboard.isChar(s))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -934,6 +928,9 @@ public static String getWylieForGlyph(int font, int code) {
|
||||||
*/
|
*/
|
||||||
public static String getWylieForGlyph(DuffCode dc) {
|
public static String getWylieForGlyph(DuffCode dc) {
|
||||||
String hashKey = getHashKeyForGlyph(dc);
|
String hashKey = getHashKeyForGlyph(dc);
|
||||||
|
if (hashKey == null) {
|
||||||
|
return "<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode " + dc + " to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>>";
|
||||||
|
}
|
||||||
return wylieForGlyph(hashKey);
|
return wylieForGlyph(hashKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue