If bad (oddball) TM glyphs appear, then converting to TMW causes, by
default, all oddballs to appear once in the resulting document. This'll help me find the correct glyphs for the oddballs, and it'll prevent the average user from converting a document with oddballs.
This commit is contained in:
parent
d45f5ab8c8
commit
32831b698f
2 changed files with 29 additions and 2 deletions
|
@ -80,4 +80,13 @@ public class DuffData {
|
||||||
text = new String(chars);
|
text = new String(chars);
|
||||||
font = i;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,6 +452,7 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
Position endPos = createPosition(end);
|
Position endPos = createPosition(end);
|
||||||
DuffData[] equivalent = new DuffData[1];
|
DuffData[] equivalent = new DuffData[1];
|
||||||
equivalent[0] = new DuffData();
|
equivalent[0] = new DuffData();
|
||||||
|
int errorGlyphLocation = 0;
|
||||||
while (i < endPos.getOffset()) {
|
while (i < endPos.getOffset()) {
|
||||||
AttributeSet attr = getCharacterElement(i).getAttributes();
|
AttributeSet attr = getCharacterElement(i).getAttributes();
|
||||||
String fontName = StyleConstants.getFontFamily(attr);
|
String fontName = StyleConstants.getFontFamily(attr);
|
||||||
|
@ -494,7 +495,10 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
// this, details are ...]]>>" (For now, I'm
|
// this, details are ...]]>>" (For now, I'm
|
||||||
// inserting the alphabet in a big font in TMW
|
// inserting the alphabet in a big font in TMW
|
||||||
// to try and get some attention. And I've
|
// 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;
|
errorReturn = true;
|
||||||
CharacterInAGivenFont cgf
|
CharacterInAGivenFont cgf
|
||||||
|
@ -513,18 +517,32 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
if (toStdout) {
|
if (toStdout) {
|
||||||
System.out.print(err);
|
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
|
String trickyTMW
|
||||||
= "!-\"-#-$-%-&-'-(-)-*-+-,-.-/-0-1-2-3-4-5-6-7-8-9-:-;-<-=->-?-";
|
= "!-\"-#-$-%-&-'-(-)-*-+-,-.-/-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);
|
insertDuff(72, i, equivalent, true);
|
||||||
i += trickyTMW.length();
|
i += trickyTMW.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
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) {
|
} catch (BadLocationException ble) {
|
||||||
ble.printStackTrace();
|
ble.printStackTrace();
|
||||||
ThdlDebug.noteIffyCode();
|
ThdlDebug.noteIffyCode();
|
||||||
|
|
Loading…
Reference in a new issue