From bff0e6b2fcfda4212aa4b8132084c8245cb2c629 Mon Sep 17 00:00:00 2001 From: dchandler Date: Fri, 25 Jun 2004 00:22:10 +0000 Subject: [PATCH] Fixed TMW->Wylie/ACIP when multiple font sizes are in use. I was not incrementing the offset at which I was inserting text properly. --- source/org/thdl/tib/text/TibetanDocument.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/source/org/thdl/tib/text/TibetanDocument.java b/source/org/thdl/tib/text/TibetanDocument.java index 238b569..a92be9f 100644 --- a/source/org/thdl/tib/text/TibetanDocument.java +++ b/source/org/thdl/tib/text/TibetanDocument.java @@ -1211,19 +1211,11 @@ public class TibetanDocument extends DefaultStyledDocument { = getCharacterElement(i).getAttributes(); String fontName = StyleConstants.getFontFamily(attr); int fontNum; - int iFontSize = 72; /* the failure ought to be obvious - at this size */ - try { - iFontSize - = ((Integer)attr.getAttribute(StyleConstants.FontSize)).intValue(); - } catch (Exception e) { - // leave it as 72 - } - if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) { if (i != start) { + if (i < start) throw new Error("Oops!"); SizedDuffCode[] sdc_array = (SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]); @@ -1237,17 +1229,30 @@ public class TibetanDocument extends DefaultStyledDocument { for (int j = 0; j < tb.length(); j++) { TranslitTuple tt = tb.get(j); int thisFontSize; + String ttt = tt.getTranslit(); insertString(start, - tt.getTranslit(), - getCopyOfRomanAttributeSet(thisFontSize = tt.getFontSize())); + ttt, + getCopyOfRomanAttributeSet(thisFontSize + = tt.getFontSize())); + start += ttt.length(); if (thisFontSize == lastFontSize) throw new Error("FIXME: make this an assertion"); lastFontSize = thisFontSize; } + i = start - 1; // i++ below will execute. dcs.clear(); + } else { + start = i+1; } - start = i+1; } else { + int iFontSize = 72; /* the failure ought to be obvious + at this size */ + try { + iFontSize + = ((Integer)attr.getAttribute(StyleConstants.FontSize)).intValue(); + } catch (Exception e) { + // leave it as 72 + } char ch = getText(i,1).charAt(0); dcs.add(new SizedDuffCode(new DuffCode(fontNum, ch), iFontSize));