From d8657abd4475ac822282b7953a57ba743abd0b48 Mon Sep 17 00:00:00 2001 From: dchandler Date: Sun, 7 Sep 2003 18:30:59 +0000 Subject: [PATCH] ACIP font shrinking as in {KA (GA)} is now supported. --- .../org/thdl/tib/text/ttt/ACIPConverter.java | 33 ++++++++++++++++--- source/org/thdl/tib/text/ttt/ACIPString.java | 3 ++ source/org/thdl/tib/text/ttt/PackageTest.java | 2 ++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/source/org/thdl/tib/text/ttt/ACIPConverter.java b/source/org/thdl/tib/text/ttt/ACIPConverter.java index 1966cd0..ced2d28 100644 --- a/source/org/thdl/tib/text/ttt/ACIPConverter.java +++ b/source/org/thdl/tib/text/ttt/ACIPConverter.java @@ -143,10 +143,6 @@ public class ACIPConverter { throws IOException { TibetanDocument tdoc = new TibetanDocument(); - tdoc.setRomanAttributeSet(ThdlOptions.getStringOption("thdl.acip.to.x.latin.font", - "Courier New"), - ThdlOptions.getIntegerOption("thdl.acip.to.x.latin.font.size", - 20)); boolean rv = convertToTMW(scan, tdoc, errors, warnings, writeWarningsToResult, warningLevel, colors); @@ -194,7 +190,7 @@ public class ACIPConverter { } else { return null; } - } catch (Exception e) { + } catch (IOException e) { throw new Error(e.toString()); } } @@ -258,6 +254,23 @@ public class ACIPConverter { boolean colors) throws IOException { + int smallFontSize = -1; + int regularFontSize = -1; + if (null != tdoc) { + String latinFont + = ThdlOptions.getStringOption("thdl.acip.to.x.latin.font", + "Courier New"); + int latinFontSize + = ThdlOptions.getIntegerOption("thdl.acip.to.x.latin.font.size", + 20); + tdoc.setRomanAttributeSet(latinFont, latinFontSize); + + regularFontSize = tdoc.getTibetanFontSize(); + smallFontSize = (int)(0.75*regularFontSize); + if (smallFontSize >= regularFontSize) + smallFontSize = regularFontSize - 1; + } + if (colors) tdoc.enableColors(); else @@ -481,6 +494,16 @@ public class ACIPConverter { } } } + } else if (stype == ACIPString.START_PAREN) { + if (null != tdoc) { + tdoc.setTibetanFontSize(smallFontSize); + } + continue; + } else if (stype == ACIPString.END_PAREN) { + if (null != tdoc) { + tdoc.setTibetanFontSize(regularFontSize); + } + continue; } else { throw new Error("forgot a case"); } diff --git a/source/org/thdl/tib/text/ttt/ACIPString.java b/source/org/thdl/tib/text/ttt/ACIPString.java index 83a4f1e..db299f8 100644 --- a/source/org/thdl/tib/text/ttt/ACIPString.java +++ b/source/org/thdl/tib/text/ttt/ACIPString.java @@ -35,6 +35,9 @@ public class ACIPString { public static boolean isLatin(int type) { return (type != TIBETAN_NON_PUNCTUATION && type != TIBETAN_PUNCTUATION + && type != TSHEG_BAR_ADORNMENT + && type != START_PAREN + && type != END_PAREN && type != START_SLASH && type != END_SLASH); } diff --git a/source/org/thdl/tib/text/ttt/PackageTest.java b/source/org/thdl/tib/text/ttt/PackageTest.java index c9989dd..3af248b 100644 --- a/source/org/thdl/tib/text/ttt/PackageTest.java +++ b/source/org/thdl/tib/text/ttt/PackageTest.java @@ -7083,6 +7083,8 @@ tstHelper("ZUR"); /** Tests {@link ACIPTshegBarScanner#scan(String, StringBuffer, int)}. */ public void testScanner() { + shelp("KA (KHA\nGA)", "", "[TIBETAN_NON_PUNCTUATION:{KA}, TIBETAN_PUNCTUATION:{ }, START_PAREN:{(}, TIBETAN_NON_PUNCTUATION:{KHA}, TIBETAN_PUNCTUATION:{ }, TIBETAN_NON_PUNCTUATION:{GA}, END_PAREN:{)}]"); + shelp("LA...SGRUB", "", "[TIBETAN_NON_PUNCTUATION:{LA}, TIBETAN_PUNCTUATION:{.}, TIBETAN_PUNCTUATION:{.}, TIBETAN_PUNCTUATION:{.}, TIBETAN_NON_PUNCTUATION:{SGRUB}]");