diff --git a/source/org/thdl/tib/text/DuffData.java b/source/org/thdl/tib/text/DuffData.java index 7b4258a..7f70c9f 100644 --- a/source/org/thdl/tib/text/DuffData.java +++ b/source/org/thdl/tib/text/DuffData.java @@ -80,4 +80,13 @@ public class DuffData { text = new String(chars); font = i; } + +/** Changes the text and font this DuffData represents. +* @param c a String of TibetanMachineWeb or TibetanMachine text +* @param i a TibetanMachineWeb or TibetanMachine font number +*/ + public void setData(String s, int i) { + text = s; + font = i; + } } diff --git a/source/org/thdl/tib/text/TibetanDocument.java b/source/org/thdl/tib/text/TibetanDocument.java index 6f94f7e..9ac3718 100644 --- a/source/org/thdl/tib/text/TibetanDocument.java +++ b/source/org/thdl/tib/text/TibetanDocument.java @@ -452,6 +452,7 @@ public class TibetanDocument extends DefaultStyledDocument { Position endPos = createPosition(end); DuffData[] equivalent = new DuffData[1]; equivalent[0] = new DuffData(); + int errorGlyphLocation = 0; while (i < endPos.getOffset()) { AttributeSet attr = getCharacterElement(i).getAttributes(); String fontName = StyleConstants.getFontFamily(attr); @@ -494,7 +495,10 @@ public class TibetanDocument extends DefaultStyledDocument { // this, details are ...]]>>" (For now, I'm // inserting the alphabet in a big font in TMW // to try and get some attention. And I've - // *documented* this on the website.) + // *documented* this on the website. I'm also + // putting the oddballs at the start of the + // document, but I haven't documented that + // (FIXME).) errorReturn = true; CharacterInAGivenFont cgf @@ -513,18 +517,32 @@ public class TibetanDocument extends DefaultStyledDocument { if (toStdout) { System.out.print(err); } + + // Now also put this problem glyph at + // the beginning of the document: + equivalent[0].setData(getText(i,1), fontNum); + insertDuff(72, errorGlyphLocation++, + equivalent, toTM); + ++i; } } String trickyTMW = "!-\"-#-$-%-&-'-(-)-*-+-,-.-/-0-1-2-3-4-5-6-7-8-9-:-;-<-=->-?-"; - equivalent[0] = new DuffData(trickyTMW, 1); + equivalent[0].setData(trickyTMW, 1); insertDuff(72, i, equivalent, true); i += trickyTMW.length(); } } i++; } + + if (!ThdlOptions.getBooleanOption("thdl.leave.bad.tm.tmw.conversions.in.place")) { + // Remove all characters other than the oddballs: + if (errorGlyphLocation > 0) { + remove(errorGlyphLocation, getLength()-errorGlyphLocation-1); + } + } } catch (BadLocationException ble) { ble.printStackTrace(); ThdlDebug.noteIffyCode();