From 37ea66b1918a88490046c51ed1ac8acd49c661b7 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 9 Apr 2013 17:31:41 +0000 Subject: [PATCH] Cosmetics only: enabled Checkstyle ParenPad rule and fixed corresponding violations git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1466146 13f79535-47bb-0310-9956-ffa450edef68 --- checkstyle-5.5.xml | 4 +- .../bidi/GenerateBidiClass.java | 250 +- .../bidi/GenerateBidiTestData.java | 840 ++--- .../linebreak/GenerateLineBreakUtils.java | 2 +- .../org/apache/fop/afp/AFPBorderPainter.java | 82 +- .../apache/fop/afp/AFPRectanglePainter.java | 38 +- src/java/org/apache/fop/afp/Factory.java | 2 +- .../apache/fop/afp/modca/GraphicsObject.java | 4 +- .../afp/modca/triplets/EncodingTriplet.java | 2 +- .../fop/afp/util/DTDEntityResolver.java | 28 +- src/java/org/apache/fop/area/Area.java | 8 +- .../org/apache/fop/area/AreaTreeParser.java | 8 +- src/java/org/apache/fop/area/BodyRegion.java | 4 +- src/java/org/apache/fop/area/CTM.java | 2 +- src/java/org/apache/fop/area/LineArea.java | 8 +- .../org/apache/fop/area/LinkResolver.java | 8 +- .../org/apache/fop/area/MainReference.java | 4 +- .../org/apache/fop/area/PageViewport.java | 2 +- src/java/org/apache/fop/area/Span.java | 6 +- .../apache/fop/area/inline/BasicLinkArea.java | 2 +- .../apache/fop/area/inline/InlineArea.java | 22 +- .../apache/fop/area/inline/InlineParent.java | 24 +- .../org/apache/fop/area/inline/SpaceArea.java | 2 +- .../org/apache/fop/area/inline/TextArea.java | 42 +- .../fop/area/inline/UnresolvedPageNumber.java | 4 +- .../org/apache/fop/area/inline/WordArea.java | 106 +- .../fop/complexscripts/bidi/BidiClass.java | 20 +- .../fop/complexscripts/bidi/BidiResolver.java | 134 +- .../bidi/DelimitedTextRange.java | 92 +- .../fop/complexscripts/bidi/InlineRun.java | 148 +- .../fop/complexscripts/bidi/TextInterval.java | 68 +- .../bidi/UnflattenProcessor.java | 256 +- .../bidi/UnicodeBidiAlgorithm.java | 440 +-- .../fonts/GlyphClassMapping.java | 4 +- .../complexscripts/fonts/GlyphClassTable.java | 134 +- .../fonts/GlyphCoverageMapping.java | 2 +- .../fonts/GlyphCoverageTable.java | 104 +- .../complexscripts/fonts/GlyphDefinition.java | 2 +- .../fonts/GlyphDefinitionSubtable.java | 16 +- .../fonts/GlyphDefinitionTable.java | 180 +- .../fonts/GlyphMappingTable.java | 88 +- .../fonts/GlyphPositioning.java | 2 +- .../fonts/GlyphPositioningState.java | 58 +- .../fonts/GlyphPositioningSubtable.java | 36 +- .../fonts/GlyphPositioningTable.java | 1342 ++++---- .../fonts/GlyphProcessingState.java | 474 +-- .../fonts/GlyphSubstitution.java | 2 +- .../fonts/GlyphSubstitutionState.java | 96 +- .../fonts/GlyphSubstitutionSubtable.java | 36 +- .../fonts/GlyphSubstitutionTable.java | 886 ++--- .../complexscripts/fonts/GlyphSubtable.java | 86 +- .../fop/complexscripts/fonts/GlyphTable.java | 506 +-- .../OTFAdvancedTypographicTableReader.java | 1922 +++++------ .../complexscripts/fonts/Positionable.java | 4 +- .../complexscripts/fonts/Substitutable.java | 4 +- .../scripts/ArabicScriptProcessor.java | 252 +- .../scripts/DefaultScriptProcessor.java | 42 +- .../scripts/DevanagariScriptProcessor.java | 180 +- .../scripts/GujaratiScriptProcessor.java | 180 +- .../scripts/GurmukhiScriptProcessor.java | 184 +- .../scripts/IndicScriptProcessor.java | 244 +- .../scripts/ScriptProcessor.java | 82 +- .../fop/complexscripts/util/CharMirror.java | 14 +- .../fop/complexscripts/util/CharScript.java | 446 +-- .../util/GlyphContextTester.java | 2 +- .../complexscripts/util/GlyphSequence.java | 474 +-- .../fop/complexscripts/util/GlyphTester.java | 2 +- .../complexscripts/util/NumberConverter.java | 914 ++--- .../util/ScriptContextTester.java | 2 +- .../apache/fop/complexscripts/util/UTF32.java | 56 +- src/java/org/apache/fop/events/Event.java | 2 +- .../org/apache/fop/events/EventFormatter.java | 32 +- src/java/org/apache/fop/fo/FONode.java | 54 +- .../org/apache/fop/fo/FOPropertyMapping.java | 36 +- src/java/org/apache/fop/fo/FOText.java | 96 +- src/java/org/apache/fop/fo/FObj.java | 18 +- src/java/org/apache/fop/fo/PropertyList.java | 4 +- .../FromNearestSpecifiedValueFunction.java | 6 +- .../fop/fo/expr/FromParentFunction.java | 6 +- .../fop/fo/expr/FromTableColumnFunction.java | 6 +- .../org/apache/fop/fo/expr/FunctionBase.java | 10 +- .../fop/fo/expr/InheritedPropFunction.java | 6 +- .../apache/fop/fo/expr/PropertyParser.java | 16 +- .../apache/fop/fo/expr/PropertyTokenizer.java | 6 +- .../apache/fop/fo/flow/AbstractGraphics.java | 8 +- .../fo/flow/AbstractPageNumberCitation.java | 8 +- .../fop/fo/flow/AbstractRetrieveMarker.java | 2 +- .../org/apache/fop/fo/flow/BidiOverride.java | 24 +- .../apache/fop/fo/flow/BlockContainer.java | 2 +- .../org/apache/fop/fo/flow/Character.java | 8 +- .../apache/fop/fo/flow/InlineContainer.java | 4 +- .../org/apache/fop/fo/flow/InlineLevel.java | 2 +- src/java/org/apache/fop/fo/flow/Leader.java | 14 +- src/java/org/apache/fop/fo/flow/ListItem.java | 10 +- .../org/apache/fop/fo/flow/PageNumber.java | 2 +- src/java/org/apache/fop/fo/flow/Wrapper.java | 2 +- .../fo/flow/table/ColumnNumberManager.java | 2 +- .../fop/fo/flow/table/ConditionalBorder.java | 4 +- .../apache/fop/fo/flow/table/PendingSpan.java | 2 +- .../org/apache/fop/fo/flow/table/Table.java | 16 +- .../apache/fop/fo/flow/table/TableCell.java | 2 +- .../fo/pagination/PageNumberGenerator.java | 8 +- .../fop/fo/pagination/PageSequence.java | 30 +- .../apache/fop/fo/pagination/RegionAfter.java | 2 +- .../apache/fop/fo/pagination/RegionBA.java | 2 +- .../fop/fo/pagination/RegionBefore.java | 2 +- .../apache/fop/fo/pagination/RegionBody.java | 2 +- .../apache/fop/fo/pagination/RegionEnd.java | 2 +- .../apache/fop/fo/pagination/RegionSE.java | 2 +- .../apache/fop/fo/pagination/RegionStart.java | 2 +- .../fo/properties/DimensionPropertyMaker.java | 8 +- .../properties/FontWeightPropertyMaker.java | 2 +- .../fo/properties/IndentPropertyMaker.java | 6 +- .../fop/fo/properties/PropertyCache.java | 4 +- .../org/apache/fop/fonts/CMapSegment.java | 18 +- src/java/org/apache/fop/fonts/Font.java | 40 +- src/java/org/apache/fop/fonts/LazyFont.java | 34 +- .../org/apache/fop/fonts/MultiByteFont.java | 182 +- .../apache/fop/fonts/truetype/TTFFile.java | 36 +- .../fop/fonts/truetype/TTFFontLoader.java | 10 +- .../fop/fonts/truetype/TTFSubSetFile.java | 2 +- .../org/apache/fop/fonts/type1/AFMParser.java | 12 +- .../apache/fop/layoutmgr/AbstractBreaker.java | 4 +- .../fop/layoutmgr/AbstractLayoutManager.java | 2 +- .../BlockContainerLayoutManager.java | 10 +- .../fop/layoutmgr/BlockLayoutManager.java | 2 +- .../fop/layoutmgr/BreakingAlgorithm.java | 6 +- .../fop/layoutmgr/InlineKnuthSequence.java | 2 +- .../fop/layoutmgr/LayoutManagerMapping.java | 2 +- .../layoutmgr/PageSequenceLayoutManager.java | 12 +- .../inline/AbstractGraphicsLayoutManager.java | 2 +- .../inline/BasicLinkLayoutManager.java | 2 +- .../inline/CharacterLayoutManager.java | 2 +- .../inline/InlineStackingLayoutManager.java | 4 +- .../layoutmgr/inline/LeaderLayoutManager.java | 24 +- .../layoutmgr/inline/LineLayoutManager.java | 25 +- .../layoutmgr/inline/TextLayoutManager.java | 198 +- .../apache/fop/layoutmgr/table/CellPart.java | 3 +- .../table/CollapsingBorderModel.java | 2 +- .../fop/layoutmgr/table/ColumnSetup.java | 4 +- .../table/TableCellLayoutManager.java | 3 +- src/java/org/apache/fop/pdf/PDFCIDFont.java | 3 +- src/java/org/apache/fop/pdf/PDFFactory.java | 19 +- .../org/apache/fop/pdf/PDFFontDescriptor.java | 3 +- src/java/org/apache/fop/pdf/PDFFunction.java | 3 +- src/java/org/apache/fop/pdf/PDFPattern.java | 3 +- src/java/org/apache/fop/pdf/PDFShading.java | 12 +- src/java/org/apache/fop/pdf/PDFTextUtil.java | 6 +- .../render/AbstractPathOrientedRenderer.java | 29 +- .../apache/fop/render/AbstractRenderer.java | 30 +- .../org/apache/fop/render/afp/AFPPainter.java | 5 +- .../fop/render/awt/viewer/PreviewPanel.java | 2 +- .../intermediate/AbstractIFPainter.java | 2 +- .../render/intermediate/IFGraphicContext.java | 2 +- .../fop/render/intermediate/IFParser.java | 4 +- .../fop/render/intermediate/IFRenderer.java | 56 +- .../fop/render/intermediate/IFSerializer.java | 4 +- .../fop/render/intermediate/IFUtil.java | 62 +- .../fop/render/java2d/Java2DPainter.java | 2 +- .../fop/render/java2d/Java2DRenderer.java | 3 +- .../apache/fop/render/pcl/PCLGraphics2D.java | 2 +- .../org/apache/fop/render/pcl/PCLPainter.java | 7 +- .../pdf/PDFDocumentNavigationHandler.java | 2 +- .../org/apache/fop/render/pdf/PDFPainter.java | 50 +- .../ps/extensions/PSSetPageDeviceElement.java | 4 +- .../org/apache/fop/render/rtf/RTFHandler.java | 84 +- .../rtf/rtflib/rtfdoc/RtfExternalGraphic.java | 4 +- .../rtf/rtflib/rtfdoc/RtfExtraRowSet.java | 4 +- .../rtf/rtflib/rtfdoc/RtfParagraphBreak.java | 4 +- .../render/rtf/rtflib/rtfdoc/RtfSection.java | 2 +- .../rtf/rtflib/tools/PercentContext.java | 2 +- .../apache/fop/render/txt/TXTRenderer.java | 3 +- .../apache/fop/render/xml/XMLRenderer.java | 20 +- .../PDFDocumentGraphics2DConfigurator.java | 2 +- .../org/apache/fop/svg/PDFGraphics2D.java | 8 +- .../org/apache/fop/tools/anttasks/Fop.java | 8 +- src/java/org/apache/fop/traits/Direction.java | 4 +- .../org/apache/fop/traits/WritingMode.java | 18 +- .../apache/fop/traits/WritingModeTraits.java | 28 +- .../fop/traits/WritingModeTraitsSetter.java | 14 +- .../org/apache/fop/util/CharUtilities.java | 74 +- src/java/org/apache/fop/util/ColorExt.java | 3 +- src/java/org/apache/fop/util/XMLUtil.java | 68 +- .../org/apache/fop/render/mif/MIFHandler.java | 6 +- .../fop/afp/modca/AbstractAFPObjectTest.java | 2 +- .../bidi/BidiAlgorithmTestCase.java | 156 +- .../bidi/BidiClassTestCase.java | 20 +- .../fop/complexscripts/bidi/BidiTestData.java | 14 +- .../complexscripts/fonts/GDEFTestCase.java | 76 +- .../complexscripts/fonts/GPOSTestCase.java | 108 +- .../complexscripts/fonts/GSUBTestCase.java | 94 +- .../fop/complexscripts/fonts/ttx/TTXFile.java | 2958 ++++++++--------- .../fonts/ttx/TTXFileTestCase.java | 10 +- .../scripts/arabic/ArabicTestCase.java | 122 +- .../arabic/GenerateArabicTestData.java | 122 +- .../util/NumberConverterTestCase.java | 110 +- .../loader/batik/ImageLoaderTestCase.java | 2 +- 197 files changed, 8638 insertions(+), 8672 deletions(-) diff --git a/checkstyle-5.5.xml b/checkstyle-5.5.xml index 50e2a1a4c..5c79c0e88 100644 --- a/checkstyle-5.5.xml +++ b/checkstyle-5.5.xml @@ -155,7 +155,7 @@ - + @@ -206,7 +206,7 @@ - + diff --git a/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiClass.java b/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiClass.java index 172b169c9..ad8f6edc2 100644 --- a/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiClass.java +++ b/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiClass.java @@ -140,72 +140,72 @@ public final class GenerateBidiClass { String line; int lineNumber = 0; TreeSet intervals = new TreeSet(); - while ( ( line = b.readLine() ) != null ) { + while ((line = b.readLine()) != null) { lineNumber++; - if ( line.startsWith("#") ) { + if (line.startsWith("#")) { continue; - } else if ( line.length() == 0 ) { + } else if (line.length() == 0) { continue; } else { - if ( line.indexOf ( "#" ) != -1 ) { - line = ( line.split ( "#" ) ) [ 0 ]; + if (line.indexOf ("#") != -1) { + line = (line.split ("#")) [ 0 ]; } - String[] fa = line.split ( ";" ); - if ( fa.length == 2 ) { - int[] interval = parseInterval ( fa[0].trim() ); - byte bidiClass = (byte) parseBidiClass ( fa[1].trim() ); - if ( interval[1] == interval[0] ) { // singleton + String[] fa = line.split (";"); + if (fa.length == 2) { + int[] interval = parseInterval (fa[0].trim()); + byte bidiClass = (byte) parseBidiClass (fa[1].trim()); + if (interval[1] == interval[0]) { // singleton int c = interval[0]; - if ( c <= 0x00FF ) { - if ( bcL1 [ c - 0x0000 ] == 0 ) { + if (c <= 0x00FF) { + if (bcL1 [ c - 0x0000 ] == 0) { bcL1 [ c - 0x0000 ] = bidiClass; } else { - throw new Exception ( "duplicate singleton entry: " + c ); + throw new Exception ("duplicate singleton entry: " + c); } - } else if ( ( c >= 0x0590 ) && ( c <= 0x06FF ) ) { - if ( bcR1 [ c - 0x0590 ] == 0 ) { + } else if ((c >= 0x0590) && (c <= 0x06FF)) { + if (bcR1 [ c - 0x0590 ] == 0) { bcR1 [ c - 0x0590 ] = bidiClass; } else { - throw new Exception ( "duplicate singleton entry: " + c ); + throw new Exception ("duplicate singleton entry: " + c); } } else { - addInterval ( intervals, c, c, bidiClass ); + addInterval (intervals, c, c, bidiClass); } } else { // non-singleton int s = interval[0]; int e = interval[1]; // inclusive - if ( s <= 0x00FF ) { - for ( int i = s; i <= e; i++ ) { - if ( i <= 0x00FF ) { - if ( bcL1 [ i - 0x0000 ] == 0 ) { + if (s <= 0x00FF) { + for (int i = s; i <= e; i++) { + if (i <= 0x00FF) { + if (bcL1 [ i - 0x0000 ] == 0) { bcL1 [ i - 0x0000 ] = bidiClass; } else { - throw new Exception ( "duplicate singleton entry: " + i ); + throw new Exception ("duplicate singleton entry: " + i); } } else { - addInterval ( intervals, i, e, bidiClass ); + addInterval (intervals, i, e, bidiClass); break; } } - } else if ( ( s >= 0x0590 ) && ( s <= 0x06FF ) ) { - for ( int i = s; i <= e; i++ ) { - if ( i <= 0x06FF ) { - if ( bcR1 [ i - 0x0590 ] == 0 ) { + } else if ((s >= 0x0590) && (s <= 0x06FF)) { + for (int i = s; i <= e; i++) { + if (i <= 0x06FF) { + if (bcR1 [ i - 0x0590 ] == 0) { bcR1 [ i - 0x0590 ] = bidiClass; } else { - throw new Exception ( "duplicate singleton entry: " + i ); + throw new Exception ("duplicate singleton entry: " + i); } } else { - addInterval ( intervals, i, e, bidiClass ); + addInterval (intervals, i, e, bidiClass); break; } } } else { - addInterval ( intervals, s, e, bidiClass ); + addInterval (intervals, s, e, bidiClass); } } } else { - throw new Exception ( "bad syntax, line(" + lineNumber + "): " + line ); + throw new Exception ("bad syntax, line(" + lineNumber + "): " + line); } } } @@ -215,7 +215,7 @@ public final class GenerateBidiClass { bcS1 = new int [ niv ]; bcE1 = new int [ niv ]; bcC1 = new byte [ niv ]; - for ( Iterator it = intervals.iterator(); it.hasNext(); ivIndex++ ) { + for (Iterator it = intervals.iterator(); it.hasNext(); ivIndex++) { Interval iv = (Interval) it.next(); bcS1[ivIndex] = iv.start; bcE1[ivIndex] = iv.end; @@ -225,219 +225,219 @@ public final class GenerateBidiClass { test(); } - private static int[] parseInterval ( String interval ) throws Exception { + private static int[] parseInterval (String interval) throws Exception { int s; int e; String[] fa = interval.split("\\.\\."); - if ( fa.length == 1 ) { - s = Integer.parseInt ( fa[0], 16 ); + if (fa.length == 1) { + s = Integer.parseInt (fa[0], 16); e = s; - } else if ( fa.length == 2 ) { - s = Integer.parseInt ( fa[0], 16 ); - e = Integer.parseInt ( fa[1], 16 ); + } else if (fa.length == 2) { + s = Integer.parseInt (fa[0], 16); + e = Integer.parseInt (fa[1], 16); } else { - throw new Exception ( "bad interval syntax: " + interval ); + throw new Exception ("bad interval syntax: " + interval); } - if ( e < s ) { - throw new Exception ( "bad interval, start must be less than or equal to end: " + interval ); + if (e < s) { + throw new Exception ("bad interval, start must be less than or equal to end: " + interval); } return new int[] {s, e}; } - private static int parseBidiClass ( String bidiClass ) { + private static int parseBidiClass (String bidiClass) { int bc = 0; - if ( "L".equals ( bidiClass ) ) { + if ("L".equals (bidiClass)) { bc = BidiConstants.L; - } else if ( "LRE".equals ( bidiClass ) ) { + } else if ("LRE".equals (bidiClass)) { bc = BidiConstants.LRE; - } else if ( "LRO".equals ( bidiClass ) ) { + } else if ("LRO".equals (bidiClass)) { bc = BidiConstants.LRO; - } else if ( "R".equals ( bidiClass ) ) { + } else if ("R".equals (bidiClass)) { bc = BidiConstants.R; - } else if ( "AL".equals ( bidiClass ) ) { + } else if ("AL".equals (bidiClass)) { bc = BidiConstants.AL; - } else if ( "RLE".equals ( bidiClass ) ) { + } else if ("RLE".equals (bidiClass)) { bc = BidiConstants.RLE; - } else if ( "RLO".equals ( bidiClass ) ) { + } else if ("RLO".equals (bidiClass)) { bc = BidiConstants.RLO; - } else if ( "PDF".equals ( bidiClass ) ) { + } else if ("PDF".equals (bidiClass)) { bc = BidiConstants.PDF; - } else if ( "EN".equals ( bidiClass ) ) { + } else if ("EN".equals (bidiClass)) { bc = BidiConstants.EN; - } else if ( "ES".equals ( bidiClass ) ) { + } else if ("ES".equals (bidiClass)) { bc = BidiConstants.ES; - } else if ( "ET".equals ( bidiClass ) ) { + } else if ("ET".equals (bidiClass)) { bc = BidiConstants.ET; - } else if ( "AN".equals ( bidiClass ) ) { + } else if ("AN".equals (bidiClass)) { bc = BidiConstants.AN; - } else if ( "CS".equals ( bidiClass ) ) { + } else if ("CS".equals (bidiClass)) { bc = BidiConstants.CS; - } else if ( "NSM".equals ( bidiClass ) ) { + } else if ("NSM".equals (bidiClass)) { bc = BidiConstants.NSM; - } else if ( "BN".equals ( bidiClass ) ) { + } else if ("BN".equals (bidiClass)) { bc = BidiConstants.BN; - } else if ( "B".equals ( bidiClass ) ) { + } else if ("B".equals (bidiClass)) { bc = BidiConstants.B; - } else if ( "S".equals ( bidiClass ) ) { + } else if ("S".equals (bidiClass)) { bc = BidiConstants.S; - } else if ( "WS".equals ( bidiClass ) ) { + } else if ("WS".equals (bidiClass)) { bc = BidiConstants.WS; - } else if ( "ON".equals ( bidiClass ) ) { + } else if ("ON".equals (bidiClass)) { bc = BidiConstants.ON; } else { - throw new IllegalArgumentException ( "unknown bidi class: " + bidiClass ); + throw new IllegalArgumentException ("unknown bidi class: " + bidiClass); } return bc; } - private static void addInterval ( SortedSet intervals, int start, int end, int bidiClass ) { - intervals.add ( new Interval ( start, end, bidiClass ) ); + private static void addInterval (SortedSet intervals, int start, int end, int bidiClass) { + intervals.add (new Interval (start, end, bidiClass)); } - private static void dumpData ( PrintWriter out ) { + private static void dumpData (PrintWriter out) { boolean first; StringBuffer sb = new StringBuffer(); // bcL1 first = true; sb.setLength(0); - out.println ( "private static byte[] bcL1 = {" ); - for ( int i = 0; i < bcL1.length; i++ ) { - if ( ! first ) { - sb.append ( "," ); + out.println ("private static byte[] bcL1 = {"); + for (int i = 0; i < bcL1.length; i++) { + if (! first) { + sb.append (","); } else { first = false; } - sb.append ( bcL1[i] ); - if ( sb.length() > 120 ) { + sb.append (bcL1[i]); + if (sb.length() > 120) { sb.append(','); out.println(sb); first = true; sb.setLength(0); } } - if ( sb.length() > 0 ) { + if (sb.length() > 0) { out.println(sb); } - out.println ( "};" ); + out.println ("};"); out.println(); // bcR1 first = true; sb.setLength(0); - out.println ( "private static byte[] bcR1 = {" ); - for ( int i = 0; i < bcR1.length; i++ ) { - if ( ! first ) { - sb.append ( "," ); + out.println ("private static byte[] bcR1 = {"); + for (int i = 0; i < bcR1.length; i++) { + if (! first) { + sb.append (","); } else { first = false; } - sb.append ( bcR1[i] ); - if ( sb.length() > 120 ) { + sb.append (bcR1[i]); + if (sb.length() > 120) { sb.append(','); out.println(sb); first = true; sb.setLength(0); } } - if ( sb.length() > 0 ) { + if (sb.length() > 0) { out.println(sb); } - out.println ( "};" ); + out.println ("};"); out.println(); // bcS1 first = true; sb.setLength(0); - out.println ( "private static int[] bcS1 = {" ); - for ( int i = 0; i < bcS1.length; i++ ) { - if ( ! first ) { - sb.append ( "," ); + out.println ("private static int[] bcS1 = {"); + for (int i = 0; i < bcS1.length; i++) { + if (! first) { + sb.append (","); } else { first = false; } - sb.append ( bcS1[i] ); - if ( sb.length() > 120 ) { + sb.append (bcS1[i]); + if (sb.length() > 120) { sb.append(','); out.println(sb); first = true; sb.setLength(0); } } - if ( sb.length() > 0 ) { + if (sb.length() > 0) { out.println(sb); } - out.println ( "};" ); + out.println ("};"); out.println(); // bcE1 first = true; sb.setLength(0); - out.println ( "private static int[] bcE1 = {" ); - for ( int i = 0; i < bcE1.length; i++ ) { - if ( ! first ) { - sb.append ( "," ); + out.println ("private static int[] bcE1 = {"); + for (int i = 0; i < bcE1.length; i++) { + if (! first) { + sb.append (","); } else { first = false; } - sb.append ( bcE1[i] ); - if ( sb.length() > 120 ) { + sb.append (bcE1[i]); + if (sb.length() > 120) { sb.append(','); out.println(sb); first = true; sb.setLength(0); } } - if ( sb.length() > 0 ) { + if (sb.length() > 0) { out.println(sb); } - out.println ( "};" ); + out.println ("};"); out.println(); // bcC1 first = true; sb.setLength(0); - out.println ( "private static byte[] bcC1 = {" ); - for ( int i = 0; i < bcC1.length; i++ ) { - if ( ! first ) { - sb.append ( "," ); + out.println ("private static byte[] bcC1 = {"); + for (int i = 0; i < bcC1.length; i++) { + if (! first) { + sb.append (","); } else { first = false; } - sb.append ( bcC1[i] ); - if ( sb.length() > 120 ) { + sb.append (bcC1[i]); + if (sb.length() > 120) { sb.append(','); out.println(sb); first = true; sb.setLength(0); } } - if ( sb.length() > 0 ) { + if (sb.length() > 0) { out.println(sb); } - out.println ( "};" ); + out.println ("};"); out.println(); } - private static int getBidiClass ( int ch ) { - if ( ch <= 0x00FF ) { + private static int getBidiClass (int ch) { + if (ch <= 0x00FF) { return bcL1 [ ch - 0x0000 ]; - } else if ( ( ch >= 0x0590 ) && ( ch <= 0x06FF ) ) { + } else if ((ch >= 0x0590) && (ch <= 0x06FF)) { return bcR1 [ ch - 0x0590 ]; } else { - return getBidiClass ( ch, bcS1, bcE1, bcC1 ); + return getBidiClass (ch, bcS1, bcE1, bcC1); } } - private static int getBidiClass ( int ch, int[] sa, int[] ea, byte[] ca ) { - int k = Arrays.binarySearch ( sa, ch ); - if ( k >= 0 ) { + private static int getBidiClass (int ch, int[] sa, int[] ea, byte[] ca) { + int k = Arrays.binarySearch (sa, ch); + if (k >= 0) { return ca [ k ]; } else { - k = - ( k + 1 ); - if ( k == 0 ) { + k = - (k + 1); + if (k == 0) { return BidiConstants.L; - } else if ( ch <= ea [ k - 1 ] ) { + } else if (ch <= ea [ k - 1 ]) { return ca [ k - 1 ]; } else { return BidiConstants.L; @@ -495,12 +495,12 @@ public final class GenerateBidiClass { }; private static void test() throws Exception { - for ( int i = 0, n = testData.length / 2; i < n; i++ ) { + for (int i = 0, n = testData.length / 2; i < n; i++) { int ch = testData [ i * 2 + 0 ]; int tc = testData [ i * 2 + 1 ]; - int bc = getBidiClass ( ch ); - if ( bc != tc ) { - throw new Exception ( "test mapping failed for character (0x" + Integer.toHexString(ch) + "): expected " + tc + ", got " + bc ); + int bc = getBidiClass (ch); + if (bc != tc) { + throw new Exception ("test mapping failed for character (0x" + Integer.toHexString(ch) + "): expected " + tc + ", got " + bc); } } } @@ -548,20 +548,20 @@ public final class GenerateBidiClass { int start; // CSOK: VisibilityModifier int end; // CSOK: VisibilityModifier int bidiClass; // CSOK: VisibilityModifier - Interval ( int start, int end, int bidiClass ) { + Interval (int start, int end, int bidiClass) { this.start = start; this.end = end; this.bidiClass = bidiClass; } - public int compareTo ( Object o ) { + public int compareTo (Object o) { Interval iv = (Interval) o; - if ( start < iv.start ) { + if (start < iv.start) { return -1; - } else if ( start > iv.start ) { + } else if (start > iv.start) { return 1; - } else if ( end < iv.end ) { + } else if (end < iv.end) { return -1; - } else if ( end > iv.end ) { + } else if (end > iv.end) { return 1; } else { return 0; diff --git a/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java b/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java index ca2ed1d52..7ccf58196 100644 --- a/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java +++ b/src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java @@ -90,7 +90,7 @@ public final class GenerateBidiTestData { private static void convertBidiTestData(String ucdFileName, String bidiFileName, String outFileName) throws Exception { // read type data from UCD if ignoring deprecated type data - if ( ignoreDeprecatedTypeData ) { + if (ignoreDeprecatedTypeData) { readBidiTypeData(ucdFileName); } @@ -125,7 +125,7 @@ public final class GenerateBidiTestData { out.println(" private BidiTestData() {"); out.println(" }"); out.println(); - dumpData ( out, outFileName ); + dumpData (out, outFileName); out.println(" public static final int NUM_TEST_SEQUENCES = " + numTestSpecs + ";"); out.println(); out.println(" public static int[] readTestData ( String prefix, int index ) {"); @@ -169,145 +169,145 @@ public final class GenerateBidiTestData { Map/**/ sm = new HashMap/**/(); // interval map - derived from pair of block endpoint entries Map/**/ im = new HashMap/**/(); - if ( verbose ) { + if (verbose) { System.out.print("Reading bidi type data..."); } - for ( lineNumber = 0; ( line = b.readLine() ) != null; ) { + for (lineNumber = 0; (line = b.readLine()) != null; ) { lineNumber++; - if ( line.length() == 0 ) { + if (line.length() == 0) { continue; - } else if ( line.startsWith("#") ) { + } else if (line.startsWith("#")) { continue; } else { - parseTypeProperties ( line, sm, im ); + parseTypeProperties (line, sm, im); } } // extract type data list - List tdl = processTypeData ( sm, im, new ArrayList() ); + List tdl = processTypeData (sm, im, new ArrayList()); // dump instrumentation - if ( verbose ) { + if (verbose) { System.out.println(); - System.out.println("Read type ranges : " + numTypeRanges ); - System.out.println("Read lines : " + lineNumber ); + System.out.println("Read type ranges : " + numTypeRanges); + System.out.println("Read lines : " + lineNumber); } - td = (int[][]) tdl.toArray ( new int [ tdl.size() ] [] ); + td = (int[][]) tdl.toArray (new int [ tdl.size() ] []); } - private static void parseTypeProperties ( String line, Map/**/ sm, Map/**/ im ) { + private static void parseTypeProperties (String line, Map/**/ sm, Map/**/ im) { String[] sa = line.split(";"); - if ( sa.length >= 5 ) { - int uc = Integer.parseInt ( sa[0], 16 ); - int bc = parseBidiClassAny ( sa[4] ); - if ( bc >= 0 ) { + if (sa.length >= 5) { + int uc = Integer.parseInt (sa[0], 16); + int bc = parseBidiClassAny (sa[4]); + if (bc >= 0) { String ucName = sa[1]; - if ( isBlockStart ( ucName ) ) { - String ucBlock = getBlockName ( ucName ); - if ( ! im.containsKey ( ucBlock ) ) { - im.put ( ucBlock, new int[] { uc, -1, bc } ); + if (isBlockStart (ucName)) { + String ucBlock = getBlockName (ucName); + if (! im.containsKey (ucBlock)) { + im.put (ucBlock, new int[] { uc, -1, bc }); } else { - throw new IllegalArgumentException ( "duplicate start of block '" + ucBlock + "' at entry: " + line ); + throw new IllegalArgumentException ("duplicate start of block '" + ucBlock + "' at entry: " + line); } - } else if ( isBlockEnd ( ucName ) ) { - String ucBlock = getBlockName ( ucName ); - if ( im.containsKey ( ucBlock ) ) { - int[] ba = (int[]) im.get ( ucBlock ); + } else if (isBlockEnd (ucName)) { + String ucBlock = getBlockName (ucName); + if (im.containsKey (ucBlock)) { + int[] ba = (int[]) im.get (ucBlock); assert ba.length == 3; - if ( ba[1] < 0 ) { + if (ba[1] < 0) { ba[1] = uc; } else { - throw new IllegalArgumentException ( "duplicate end of block '" + ucBlock + "' at entry: " + line ); + throw new IllegalArgumentException ("duplicate end of block '" + ucBlock + "' at entry: " + line); } } else { - throw new IllegalArgumentException ( "missing start of block '" + ucBlock + "' at entry: " + line ); + throw new IllegalArgumentException ("missing start of block '" + ucBlock + "' at entry: " + line); } } else { - Integer k = Integer.valueOf ( bc ); + Integer k = Integer.valueOf (bc); List sl; - if ( ! sm.containsKey ( k ) ) { + if (! sm.containsKey (k)) { sl = new ArrayList(); - sm.put ( k, sl ); + sm.put (k, sl); } else { - sl = (List) sm.get ( k ); + sl = (List) sm.get (k); } assert sl != null; - sl.add ( Integer.valueOf ( uc ) ); + sl.add (Integer.valueOf (uc)); } } else { - throw new IllegalArgumentException ( "invalid bidi class '" + sa[4] + "' at entry: " + line ); + throw new IllegalArgumentException ("invalid bidi class '" + sa[4] + "' at entry: " + line); } } else { - throw new IllegalArgumentException ( "invalid unicode character database entry: " + line ); + throw new IllegalArgumentException ("invalid unicode character database entry: " + line); } } - private static boolean isBlockStart ( String s ) { + private static boolean isBlockStart (String s) { return s.startsWith("<") && s.endsWith("First>"); } - private static boolean isBlockEnd ( String s ) { + private static boolean isBlockEnd (String s) { return s.startsWith("<") && s.endsWith("Last>"); } - private static String getBlockName ( String s ) { - String[] sa = s.substring ( 1, s.length() - 1 ).split(","); - assert ( sa != null ) && ( sa.length > 0 ); + private static String getBlockName (String s) { + String[] sa = s.substring (1, s.length() - 1).split(","); + assert (sa != null) && (sa.length > 0); return sa[0].trim(); } - private static List processTypeData ( Map/**/ sm, Map/**/ im, List tdl ) { - for ( int i = BidiConstants.FIRST, k = BidiConstants.LAST; i <= k; i++ ) { + private static List processTypeData (Map/**/ sm, Map/**/ im, List tdl) { + for (int i = BidiConstants.FIRST, k = BidiConstants.LAST; i <= k; i++) { Map/**/ rm = new TreeMap/**/(); // populate intervals from singleton map - List sl = (List) sm.get ( Integer.valueOf ( i ) ); - if ( sl != null ) { - for ( Iterator it = sl.iterator(); it.hasNext(); ) { + List sl = (List) sm.get (Integer.valueOf (i)); + if (sl != null) { + for (Iterator it = sl.iterator(); it.hasNext(); ) { Integer s = (Integer) it.next(); int uc = s.intValue(); - rm.put ( Integer.valueOf ( uc ), Integer.valueOf ( uc + 1 ) ); + rm.put (Integer.valueOf (uc), Integer.valueOf (uc + 1)); } } // populate intervals from (block) interval map - if ( ! im.isEmpty() ) { - for ( Iterator it = im.values().iterator(); it.hasNext(); ) { + if (! im.isEmpty()) { + for (Iterator it = im.values().iterator(); it.hasNext(); ) { int[] ba = (int[]) it.next(); - assert ( ba != null ) && ( ba.length > 2 ); - if ( ba[2] == i ) { - rm.put ( Integer.valueOf ( ba[0] ), Integer.valueOf ( ba[1] + 1 ) ); + assert (ba != null) && (ba.length > 2); + if (ba[2] == i) { + rm.put (Integer.valueOf (ba[0]), Integer.valueOf (ba[1] + 1)); } } } - tdl.add ( createTypeData ( i, extractRanges ( rm ) ) ); + tdl.add (createTypeData (i, extractRanges (rm))); } return tdl; } - private static List extractRanges ( Map/**/ rm ) { + private static List extractRanges (Map/**/ rm) { List ranges = new ArrayList(); int sLast = 0; int eLast = 0; - for ( Iterator it = rm.entrySet().iterator(); it.hasNext(); ) { + for (Iterator it = rm.entrySet().iterator(); it.hasNext(); ) { Map.Entry/**/ me = (Map.Entry/**/) it.next(); int s = ((Integer) me.getKey()).intValue(); int e = ((Integer) me.getValue()).intValue(); - if ( s > eLast ) { - if ( eLast > sLast ) { - ranges.add ( new int[] { sLast, eLast } ); - if ( verbose ) { - if ( ( ++numTypeRanges % 10 ) == 0 ) { + if (s > eLast) { + if (eLast > sLast) { + ranges.add (new int[] { sLast, eLast }); + if (verbose) { + if ((++numTypeRanges % 10) == 0) { System.out.print("#"); } } } sLast = s; eLast = e; - } else if ( ( s >= sLast ) && ( e >= eLast ) ) { + } else if ((s >= sLast) && (e >= eLast)) { eLast = e; } } - if ( eLast > sLast ) { - ranges.add ( new int[] { sLast, eLast } ); - if ( verbose ) { - if ( ( ++numTypeRanges % 10 ) == 0 ) { + if (eLast > sLast) { + ranges.add (new int[] { sLast, eLast }); + if (verbose) { + if ((++numTypeRanges % 10) == 0) { System.out.print("#"); } } @@ -326,65 +326,65 @@ public final class GenerateBidiTestData { int n; List tdl = new ArrayList(); List ldl = new ArrayList(); - if ( verbose ) { + if (verbose) { System.out.print("Reading bidi test data..."); } - for ( lineNumber = 0; ( line = b.readLine() ) != null; ) { + for (lineNumber = 0; (line = b.readLine()) != null; ) { lineNumber++; - if ( line.length() == 0 ) { + if (line.length() == 0) { continue; - } else if ( line.startsWith("#") ) { + } else if (line.startsWith("#")) { continue; - } else if ( line.startsWith(PFX_TYPE) && ! ignoreDeprecatedTypeData ) { + } else if (line.startsWith(PFX_TYPE) && ! ignoreDeprecatedTypeData) { List lines = new ArrayList(); - if ( ( n = readType ( line, b, lines ) ) < 0 ) { + if ((n = readType (line, b, lines)) < 0) { break; } else { lineNumber += n; - tdl.add ( parseType ( lines ) ); + tdl.add (parseType (lines)); } - } else if ( line.startsWith(PFX_LEVELS) ) { + } else if (line.startsWith(PFX_LEVELS)) { List lines = new ArrayList(); - if ( ( n = readLevels ( line, b, lines ) ) < 0 ) { + if ((n = readLevels (line, b, lines)) < 0) { break; } else { lineNumber += n; - ldl.add ( parseLevels ( lines ) ); + ldl.add (parseLevels (lines)); } } } // dump instrumentation - if ( verbose ) { + if (verbose) { System.out.println(); - if ( ! ignoreDeprecatedTypeData ) { - System.out.println("Read type ranges : " + numTypeRanges ); + if (! ignoreDeprecatedTypeData) { + System.out.println("Read type ranges : " + numTypeRanges); } - System.out.println("Read level specs : " + numLevelSpecs ); - System.out.println("Read test specs : " + numTestSpecs ); - System.out.println("Read lines : " + lineNumber ); + System.out.println("Read level specs : " + numLevelSpecs); + System.out.println("Read test specs : " + numTestSpecs); + System.out.println("Read lines : " + lineNumber); } - if ( ! ignoreDeprecatedTypeData ) { - td = (int[][]) tdl.toArray ( new int [ tdl.size() ] [] ); + if (! ignoreDeprecatedTypeData) { + td = (int[][]) tdl.toArray (new int [ tdl.size() ] []); } - ld = (int[][]) ldl.toArray ( new int [ ldl.size() ] [] ); + ld = (int[][]) ldl.toArray (new int [ ldl.size() ] []); } - private static int readType ( String line, BufferedReader b, List lines ) throws IOException { - lines.add ( line ); + private static int readType (String line, BufferedReader b, List lines) throws IOException { + lines.add (line); return 0; } - private static int readLevels ( String line, BufferedReader b, List lines ) throws IOException { + private static int readLevels (String line, BufferedReader b, List lines) throws IOException { boolean done = false; int n = 0; - lines.add ( line ); - while ( ! done ) { - switch ( testPrefix ( b, PFX_LEVELS ) ) { + lines.add (line); + while (! done) { + switch (testPrefix (b, PFX_LEVELS)) { case 0: // within current levels - if ( ( line = b.readLine() ) != null ) { + if ((line = b.readLine()) != null) { n++; - if ( ( line.length() > 0 ) && ! line.startsWith("#") ) { - lines.add ( line ); + if ((line.length() > 0) && ! line.startsWith("#")) { + lines.add (line); } } else { done = true; @@ -400,16 +400,16 @@ public final class GenerateBidiTestData { return n; } - private static int testPrefix ( BufferedReader b, String pfx ) throws IOException { + private static int testPrefix (BufferedReader b, String pfx) throws IOException { int rv = 0; int pfxLen = pfx.length(); - b.mark ( pfxLen ); - for ( int i = 0, n = pfxLen; i < n; i++ ) { + b.mark (pfxLen); + for (int i = 0, n = pfxLen; i < n; i++) { int c = b.read(); - if ( c < 0 ) { + if (c < 0) { rv = -1; break; - } else if ( c != pfx.charAt ( i ) ) { + } else if (c != pfx.charAt (i)) { rv = 0; break; } else { @@ -420,29 +420,29 @@ public final class GenerateBidiTestData { return rv; } - private static int[] parseType ( List lines ) { - if ( ( lines != null ) && ( lines.size() >= 1 ) ) { + private static int[] parseType (List lines) { + if ((lines != null) && (lines.size() >= 1)) { String line = (String) lines.get(0); - if ( line.startsWith(PFX_TYPE) ) { + if (line.startsWith(PFX_TYPE)) { // @Type: BIDI_CLASS ':' LWSP CHARACTER_CLASS - String[] sa = line.split ( ":" ); - if ( sa.length == 3 ) { + String[] sa = line.split (":"); + if (sa.length == 3) { String bcs = sa[1].trim(); String crs = sa[2].trim(); - int bc = parseBidiClass ( bcs ); - List rl = parseCharacterRanges ( crs ); - return createTypeData ( bc, rl ); + int bc = parseBidiClass (bcs); + List rl = parseCharacterRanges (crs); + return createTypeData (bc, rl); } } } return null; } - private static int[] createTypeData ( int bc, List ranges ) { - int[] data = new int [ 1 + ( 2 * ranges.size() ) ]; + private static int[] createTypeData (int bc, List ranges) { + int[] data = new int [ 1 + (2 * ranges.size()) ]; int k = 0; data [ k++ ] = bc; - for ( Iterator it = ranges.iterator(); it.hasNext(); ) { + for (Iterator it = ranges.iterator(); it.hasNext(); ) { int[] r = (int[]) it.next(); data [ k++ ] = r [ 0 ]; data [ k++ ] = r [ 1 ]; @@ -450,104 +450,104 @@ public final class GenerateBidiTestData { return data; } - private static int parseBidiClass ( String bidiClass ) { + private static int parseBidiClass (String bidiClass) { int bc = 0; - if ( "L".equals ( bidiClass ) ) { + if ("L".equals (bidiClass)) { bc = BidiConstants.L; - } else if ( "LRE".equals ( bidiClass ) ) { + } else if ("LRE".equals (bidiClass)) { bc = BidiConstants.LRE; - } else if ( "LRO".equals ( bidiClass ) ) { + } else if ("LRO".equals (bidiClass)) { bc = BidiConstants.LRO; - } else if ( "R".equals ( bidiClass ) ) { + } else if ("R".equals (bidiClass)) { bc = BidiConstants.R; - } else if ( "AL".equals ( bidiClass ) ) { + } else if ("AL".equals (bidiClass)) { bc = BidiConstants.AL; - } else if ( "RLE".equals ( bidiClass ) ) { + } else if ("RLE".equals (bidiClass)) { bc = BidiConstants.RLE; - } else if ( "RLO".equals ( bidiClass ) ) { + } else if ("RLO".equals (bidiClass)) { bc = BidiConstants.RLO; - } else if ( "PDF".equals ( bidiClass ) ) { + } else if ("PDF".equals (bidiClass)) { bc = BidiConstants.PDF; - } else if ( "EN".equals ( bidiClass ) ) { + } else if ("EN".equals (bidiClass)) { bc = BidiConstants.EN; - } else if ( "ES".equals ( bidiClass ) ) { + } else if ("ES".equals (bidiClass)) { bc = BidiConstants.ES; - } else if ( "ET".equals ( bidiClass ) ) { + } else if ("ET".equals (bidiClass)) { bc = BidiConstants.ET; - } else if ( "AN".equals ( bidiClass ) ) { + } else if ("AN".equals (bidiClass)) { bc = BidiConstants.AN; - } else if ( "CS".equals ( bidiClass ) ) { + } else if ("CS".equals (bidiClass)) { bc = BidiConstants.CS; - } else if ( "NSM".equals ( bidiClass ) ) { + } else if ("NSM".equals (bidiClass)) { bc = BidiConstants.NSM; - } else if ( "BN".equals ( bidiClass ) ) { + } else if ("BN".equals (bidiClass)) { bc = BidiConstants.BN; - } else if ( "B".equals ( bidiClass ) ) { + } else if ("B".equals (bidiClass)) { bc = BidiConstants.B; - } else if ( "S".equals ( bidiClass ) ) { + } else if ("S".equals (bidiClass)) { bc = BidiConstants.S; - } else if ( "WS".equals ( bidiClass ) ) { + } else if ("WS".equals (bidiClass)) { bc = BidiConstants.WS; - } else if ( "ON".equals ( bidiClass ) ) { + } else if ("ON".equals (bidiClass)) { bc = BidiConstants.ON; } else { - throw new IllegalArgumentException ( "unknown bidi class: " + bidiClass ); + throw new IllegalArgumentException ("unknown bidi class: " + bidiClass); } return bc; } - private static int parseBidiClassAny ( String bidiClass ) { + private static int parseBidiClassAny (String bidiClass) { try { - return parseBidiClass ( bidiClass ); - } catch ( IllegalArgumentException e ) { + return parseBidiClass (bidiClass); + } catch (IllegalArgumentException e) { return -1; } } - private static List parseCharacterRanges ( String charRanges ) { + private static List parseCharacterRanges (String charRanges) { List ranges = new ArrayList(); - CharacterIterator ci = new StringCharacterIterator ( charRanges ); + CharacterIterator ci = new StringCharacterIterator (charRanges); // read initial list delimiter - skipSpace ( ci ); - if ( ! readStartOfList ( ci ) ) { - badRangeSpec ( "missing initial list delimiter", charRanges ); + skipSpace (ci); + if (! readStartOfList (ci)) { + badRangeSpec ("missing initial list delimiter", charRanges); } // read negation token if present boolean negated = false; - skipSpace ( ci ); - if ( maybeReadNext ( ci, '^' ) ) { + skipSpace (ci); + if (maybeReadNext (ci, '^')) { negated = true; } // read item int[] r; - skipSpace ( ci ); - if ( ( r = maybeReadItem ( ci ) ) != null ) { - ranges.add ( r ); - if ( verbose ) { - if ( ( ++numTypeRanges % 10 ) == 0 ) { + skipSpace (ci); + if ((r = maybeReadItem (ci)) != null) { + ranges.add (r); + if (verbose) { + if ((++numTypeRanges % 10) == 0) { System.out.print("#"); } } } else { - badRangeSpec ( "must contain at least one item", charRanges ); + badRangeSpec ("must contain at least one item", charRanges); } // read more items if present boolean more = true; - while ( more ) { + while (more) { // read separator if present String s; - skipSpace ( ci ); - if ( ( s = maybeReadSeparator ( ci ) ) != null ) { - if ( ( s.length() != 0 ) && ! s.equals("||") ) { - badRangeSpec ( "invalid item separator \"" + s + "\"", charRanges ); + skipSpace (ci); + if ((s = maybeReadSeparator (ci)) != null) { + if ((s.length() != 0) && ! s.equals("||")) { + badRangeSpec ("invalid item separator \"" + s + "\"", charRanges); } } // read item - skipSpace ( ci ); - if ( ( r = maybeReadItem ( ci ) ) != null ) { - ranges.add ( r ); - if ( verbose ) { - if ( ( ++numTypeRanges % 10 ) == 0 ) { + skipSpace (ci); + if ((r = maybeReadItem (ci)) != null) { + ranges.add (r); + if (verbose) { + if ((++numTypeRanges % 10) == 0) { System.out.print("#"); } } @@ -556,31 +556,31 @@ public final class GenerateBidiTestData { } } // read terminating list delimiter - skipSpace ( ci ); - if ( ! readEndOfList ( ci ) ) { - badRangeSpec ( "missing terminating list delimiter", charRanges ); + skipSpace (ci); + if (! readEndOfList (ci)) { + badRangeSpec ("missing terminating list delimiter", charRanges); } - if ( ! atEnd ( ci ) ) { - badRangeSpec ( "extraneous content prior to end of line", ci ); + if (! atEnd (ci)) { + badRangeSpec ("extraneous content prior to end of line", ci); } - if ( negated ) { - ranges = complementRanges ( ranges ); + if (negated) { + ranges = complementRanges (ranges); } - return removeSurrogates ( ranges ); + return removeSurrogates (ranges); } - private static boolean atEnd ( CharacterIterator ci ) { + private static boolean atEnd (CharacterIterator ci) { return ci.getIndex() >= ci.getEndIndex(); } - private static boolean readStartOfList ( CharacterIterator ci ) { - return maybeReadNext ( ci, '[' ); + private static boolean readStartOfList (CharacterIterator ci) { + return maybeReadNext (ci, '['); } - private static void skipSpace ( CharacterIterator ci ) { - while ( ! atEnd ( ci ) ) { + private static void skipSpace (CharacterIterator ci) { + while (! atEnd (ci)) { char c = ci.current(); - if ( ! Character.isWhitespace ( c ) ) { + if (! Character.isWhitespace (c)) { break; } else { ci.next(); @@ -588,10 +588,10 @@ public final class GenerateBidiTestData { } } - private static boolean maybeReadNext ( CharacterIterator ci, char next ) { - while ( ! atEnd ( ci ) ) { + private static boolean maybeReadNext (CharacterIterator ci, char next) { + while (! atEnd (ci)) { char c = ci.current(); - if ( c == next ) { + if (c == next) { ci.next(); return true; } else { @@ -601,52 +601,52 @@ public final class GenerateBidiTestData { return false; } - private static int[] maybeReadItem ( CharacterIterator ci ) { + private static int[] maybeReadItem (CharacterIterator ci) { // read first code point int p1 = -1; - skipSpace ( ci ); - if ( ( p1 = maybeReadCodePoint ( ci ) ) < 0 ) { + skipSpace (ci); + if ((p1 = maybeReadCodePoint (ci)) < 0) { return null; } // read second code point if present int p2 = -1; - skipSpace ( ci ); - if ( maybeReadNext ( ci, '-' ) ) { - skipSpace ( ci ); - if ( ( p2 = maybeReadCodePoint ( ci ) ) < 0 ) { - badRangeSpec ( "incomplete item range, requires second item", ci ); + skipSpace (ci); + if (maybeReadNext (ci, '-')) { + skipSpace (ci); + if ((p2 = maybeReadCodePoint (ci)) < 0) { + badRangeSpec ("incomplete item range, requires second item", ci); } } - if ( p2 < 0 ) { + if (p2 < 0) { return new int[] { p1, p1 + 1 }; // convert to half open interval [ P1, P1+1 ) - } else if ( p1 <= p2 ) { + } else if (p1 <= p2) { return new int[] { p1, p2 + 1 }; // convert to half open interval [ P1, P2+2 ) } else { - badRangeSpec ( "invalid item range, second item must be greater than or equal to first item", ci ); + badRangeSpec ("invalid item range, second item must be greater than or equal to first item", ci); return null; } } - private static int maybeReadCodePoint ( CharacterIterator ci ) { - if ( maybeReadNext ( ci, '\\' ) ) { - if ( maybeReadNext ( ci, 'u' ) ) { - String s = maybeReadHexDigits ( ci, 4 ); - if ( s != null ) { - return Integer.parseInt ( s, 16 ); + private static int maybeReadCodePoint (CharacterIterator ci) { + if (maybeReadNext (ci, '\\')) { + if (maybeReadNext (ci, 'u')) { + String s = maybeReadHexDigits (ci, 4); + if (s != null) { + return Integer.parseInt (s, 16); } else { - badRangeSpec ( "incomplete escaped code point, requires 4 hex digits", ci ); + badRangeSpec ("incomplete escaped code point, requires 4 hex digits", ci); } - } else if ( maybeReadNext ( ci, 'U' ) ) { - String s = maybeReadHexDigits ( ci, 8 ); - if ( s != null ) { - return Integer.parseInt ( s, 16 ); + } else if (maybeReadNext (ci, 'U')) { + String s = maybeReadHexDigits (ci, 8); + if (s != null) { + return Integer.parseInt (s, 16); } else { - badRangeSpec ( "incomplete escaped code point, requires 8 hex digits", ci ); + badRangeSpec ("incomplete escaped code point, requires 8 hex digits", ci); } } else { char c = ci.current(); - if ( c == CharacterIterator.DONE ) { - badRangeSpec ( "incomplete escaped code point", ci ); + if (c == CharacterIterator.DONE) { + badRangeSpec ("incomplete escaped code point", ci); } else { ci.next(); return (int) c; @@ -654,7 +654,7 @@ public final class GenerateBidiTestData { } } else { char c = ci.current(); - if ( ( c == CharacterIterator.DONE ) || ( c == ']' ) ) { + if ((c == CharacterIterator.DONE) || (c == ']')) { return -1; } else { ci.next(); @@ -664,14 +664,14 @@ public final class GenerateBidiTestData { return -1; } - private static String maybeReadHexDigits ( CharacterIterator ci, int numDigits ) { + private static String maybeReadHexDigits (CharacterIterator ci, int numDigits) { StringBuffer sb = new StringBuffer(); - while ( ( numDigits < 0 ) || ( sb.length() < numDigits ) ) { + while ((numDigits < 0) || (sb.length() < numDigits)) { char c = ci.current(); - if ( c != CharacterIterator.DONE ) { - if ( isHexDigit ( c ) ) { + if (c != CharacterIterator.DONE) { + if (isHexDigit (c)) { ci.next(); - sb.append ( c ); + sb.append (c); } else { break; } @@ -679,20 +679,20 @@ public final class GenerateBidiTestData { break; } } - if ( ( ( numDigits < 0 ) && ( sb.length() > 0 ) ) || ( sb.length() == numDigits ) ) { + if (((numDigits < 0) && (sb.length() > 0)) || (sb.length() == numDigits)) { return sb.toString(); } else { return null; } } - private static boolean isHexDigit ( char c ) { - return ( ( c >= '0' ) && ( c <= '9' ) ) || ( ( c >= 'a' ) && ( c <= 'f' ) ) || ( ( c >= 'A' ) && ( c <= 'F' ) ); + private static boolean isHexDigit (char c) { + return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F')); } - private static String maybeReadSeparator ( CharacterIterator ci ) { - if ( maybeReadNext ( ci, '|' ) ) { - if ( maybeReadNext ( ci, '|' ) ) { + private static String maybeReadSeparator (CharacterIterator ci) { + if (maybeReadNext (ci, '|')) { + if (maybeReadNext (ci, '|')) { return "||"; } else { return "|"; @@ -702,47 +702,47 @@ public final class GenerateBidiTestData { } } - private static boolean readEndOfList ( CharacterIterator ci ) { - return maybeReadNext ( ci, ']' ); + private static boolean readEndOfList (CharacterIterator ci) { + return maybeReadNext (ci, ']'); } - private static List complementRanges ( List ranges ) { + private static List complementRanges (List ranges) { Map/**/ rm = new TreeMap/**/(); - for ( Iterator it = ranges.iterator(); it.hasNext(); ) { + for (Iterator it = ranges.iterator(); it.hasNext(); ) { int[] r = (int[]) it.next(); - rm.put ( Integer.valueOf ( r[0] ), Integer.valueOf ( r[1] ) ); + rm.put (Integer.valueOf (r[0]), Integer.valueOf (r[1])); } // add complement ranges save last int s; int e; int cs = 0; - List compRanges = new ArrayList ( rm.size() + 1 ); - for ( Iterator it = rm.entrySet().iterator(); it.hasNext(); ) { + List compRanges = new ArrayList (rm.size() + 1); + for (Iterator it = rm.entrySet().iterator(); it.hasNext(); ) { Map.Entry/**/ me = (Map.Entry/**/) it.next(); - s = ( (Integer) me.getKey() ).intValue(); - e = ( (Integer) me.getValue() ).intValue(); - if ( s > cs ) { - compRanges.add ( new int[] { cs, s } ); + s = ((Integer) me.getKey()).intValue(); + e = ((Integer) me.getValue()).intValue(); + if (s > cs) { + compRanges.add (new int[] { cs, s }); } cs = e; } // add trailing complement range - if ( cs < 0x110000 ) { - compRanges.add ( new int[] { cs, 0x110000 } ); + if (cs < 0x110000) { + compRanges.add (new int[] { cs, 0x110000 }); } return compRanges; } private static final int[] SURROGATES = new int[] { 0xD800, 0xE000 }; - private static List removeSurrogates ( List ranges ) { - List rsl = new ArrayList ( ranges.size() ); - for ( Iterator it = ranges.iterator(); it.hasNext(); ) { + private static List removeSurrogates (List ranges) { + List rsl = new ArrayList (ranges.size()); + for (Iterator it = ranges.iterator(); it.hasNext(); ) { int[] r = (int[]) it.next(); - if ( intersectsRange ( r, SURROGATES ) ) { - rsl.addAll ( removeRange ( r, SURROGATES ) ); + if (intersectsRange (r, SURROGATES)) { + rsl.addAll (removeRange (r, SURROGATES)); } else { - rsl.add ( r ); + rsl.add (r); } } return rsl; @@ -751,16 +751,16 @@ public final class GenerateBidiTestData { /** * Determine if range r2 intersects with range r1. */ - private static boolean intersectsRange ( int[] r1, int[] r2 ) { - if ( r1[1] <= r2[0] ) { // r1 precedes r2 or abuts r2 on right + private static boolean intersectsRange (int[] r1, int[] r2) { + if (r1[1] <= r2[0]) { // r1 precedes r2 or abuts r2 on right return false; - } else if ( r1[0] >= r2[1] ) { // r2 precedes r1 or abuts r1 on left + } else if (r1[0] >= r2[1]) { // r2 precedes r1 or abuts r1 on left return false; - } else if ( ( r1[0] < r2[0] ) && ( r1[1] > r2[1] ) ) { // r1 encloses r2 + } else if ((r1[0] < r2[0]) && (r1[1] > r2[1])) { // r1 encloses r2 return true; - } else if ( r1[0] < r2[0] ) { // r1 precedes and overlaps r2 + } else if (r1[0] < r2[0]) { // r1 precedes and overlaps r2 return true; - } else if ( r2[1] < r1[1] ) { // r2 precedes and overlaps r1 + } else if (r2[1] < r1[1]) { // r2 precedes and overlaps r1 return true; } else { // r2 encloses r1 return true; @@ -771,42 +771,42 @@ public final class GenerateBidiTestData { * Remove range r2 from range r1, leaving zero, one, or two * remaining ranges. */ - private static List removeRange ( int[] r1, int[] r2 ) { + private static List removeRange (int[] r1, int[] r2) { List rl = new ArrayList(); - if ( r1[1] <= r2[0] ) { // r1 precedes r2 or abuts r2 on right - rl.add ( r1 ); - } else if ( r1[0] >= r2[1] ) { // r2 precedes r1 or abuts r1 on left - rl.add ( r1 ); - } else if ( ( r1[0] < r2[0] ) && ( r1[1] > r2[1] ) ) { // r1 encloses r2 - rl.add ( new int[] { r1[0], r2[0] } ); - rl.add ( new int[] { r2[1], r1[1] } ); - } else if ( r1[0] < r2[0] ) { // r1 precedes and overlaps r2 - rl.add ( new int[] { r1[0], r2[0] } ); - } else if ( r2[1] < r1[1] ) { // r2 precedes and overlaps r1 - rl.add ( new int[] { r2[1], r1[1] } ); + if (r1[1] <= r2[0]) { // r1 precedes r2 or abuts r2 on right + rl.add (r1); + } else if (r1[0] >= r2[1]) { // r2 precedes r1 or abuts r1 on left + rl.add (r1); + } else if ((r1[0] < r2[0]) && (r1[1] > r2[1])) { // r1 encloses r2 + rl.add (new int[] { r1[0], r2[0] }); + rl.add (new int[] { r2[1], r1[1] }); + } else if (r1[0] < r2[0]) { // r1 precedes and overlaps r2 + rl.add (new int[] { r1[0], r2[0] }); + } else if (r2[1] < r1[1]) { // r2 precedes and overlaps r1 + rl.add (new int[] { r2[1], r1[1] }); } return rl; } - private static void badRangeSpec ( String reason, String charRanges ) throws IllegalArgumentException { - if ( verbose ) { + private static void badRangeSpec (String reason, String charRanges) throws IllegalArgumentException { + if (verbose) { System.out.println(); } - throw new IllegalArgumentException ( "bad range specification: " + reason + ": \"" + charRanges + "\"" ); + throw new IllegalArgumentException ("bad range specification: " + reason + ": \"" + charRanges + "\""); } - private static void badRangeSpec ( String reason, CharacterIterator ci ) throws IllegalArgumentException { - if ( verbose ) { + private static void badRangeSpec (String reason, CharacterIterator ci) throws IllegalArgumentException { + if (verbose) { System.out.println(); } - throw new IllegalArgumentException ( "bad range specification: " + reason + ": starting at \"" + remainder ( ci ) + "\"" ); + throw new IllegalArgumentException ("bad range specification: " + reason + ": starting at \"" + remainder (ci) + "\""); } - private static String remainder ( CharacterIterator ci ) { + private static String remainder (CharacterIterator ci) { StringBuffer sb = new StringBuffer(); - for ( char c; ( c = ci.current() ) != CharacterIterator.DONE; ) { + for (char c; (c = ci.current()) != CharacterIterator.DONE; ) { ci.next(); - sb.append ( c ); + sb.append (c); } return sb.toString(); } @@ -818,78 +818,78 @@ public final class GenerateBidiTestData { * REORDER_SPEC \n * ( TEST_SPEC \n )+ */ - private static int[] parseLevels ( List lines ) { + private static int[] parseLevels (List lines) { int[] la = null; // levels array int[] ra = null; // reorder array List tal = new ArrayList(); - if ( ( lines != null ) && ( lines.size() >= 3 ) ) { - for ( Iterator it = lines.iterator(); it.hasNext(); ) { + if ((lines != null) && (lines.size() >= 3)) { + for (Iterator it = lines.iterator(); it.hasNext(); ) { String line = (String) it.next(); - if ( line.startsWith(PFX_LEVELS) ) { - if ( la == null ) { - la = parseLevelSpec ( line ); - if ( verbose ) { - if ( ( ++numLevelSpecs % 10 ) == 0 ) { + if (line.startsWith(PFX_LEVELS)) { + if (la == null) { + la = parseLevelSpec (line); + if (verbose) { + if ((++numLevelSpecs % 10) == 0) { System.out.print("&"); } } } else { - throw new IllegalArgumentException ( "redundant levels array: \"" + line + "\"" ); + throw new IllegalArgumentException ("redundant levels array: \"" + line + "\""); } - } else if ( line.startsWith(PFX_REORDER) ) { - if ( la == null ) { - throw new IllegalArgumentException ( "missing levels array before: \"" + line + "\"" ); - } else if ( ra == null ) { - ra = parseReorderSpec ( line, la ); + } else if (line.startsWith(PFX_REORDER)) { + if (la == null) { + throw new IllegalArgumentException ("missing levels array before: \"" + line + "\""); + } else if (ra == null) { + ra = parseReorderSpec (line, la); } else { - throw new IllegalArgumentException ( "redundant reorder array: \"" + line + "\"" ); + throw new IllegalArgumentException ("redundant reorder array: \"" + line + "\""); } - } else if ( ( la != null ) && ( ra != null ) ) { - int[] ta = parseTestSpec ( line, la ); - if ( ta != null ) { - if ( verbose ) { - if ( ( ++numTestSpecs % 100 ) == 0 ) { + } else if ((la != null) && (ra != null)) { + int[] ta = parseTestSpec (line, la); + if (ta != null) { + if (verbose) { + if ((++numTestSpecs % 100) == 0) { System.out.print("!"); } } - tal.add ( ta ); + tal.add (ta); } - } else if ( la == null ) { - throw new IllegalArgumentException ( "missing levels array before: \"" + line + "\"" ); - } else if ( ra == null ) { - throw new IllegalArgumentException ( "missing reorder array before: \"" + line + "\"" ); + } else if (la == null) { + throw new IllegalArgumentException ("missing levels array before: \"" + line + "\""); + } else if (ra == null) { + throw new IllegalArgumentException ("missing reorder array before: \"" + line + "\""); } } } - if ( ( la != null ) && ( ra != null ) ) { - return createLevelData ( la, ra, tal ); + if ((la != null) && (ra != null)) { + return createLevelData (la, ra, tal); } else { return null; } } - private static int[] createLevelData ( int[] la, int[] ra, List tal ) { + private static int[] createLevelData (int[] la, int[] ra, List tal) { int nl = la.length; - int[] data = new int [ 1 + nl * 2 + ( ( nl + 1 ) * tal.size() ) ]; + int[] data = new int [ 1 + nl * 2 + ((nl + 1) * tal.size()) ]; int k = 0; data [ k++ ] = nl; - for ( int i = 0, n = nl; i < n; i++ ) { + for (int i = 0, n = nl; i < n; i++) { data [ k++ ] = la [ i ]; } int nr = ra.length; - for ( int i = 0, n = nr; i < n; i++ ) { + for (int i = 0, n = nr; i < n; i++) { data [ k++ ] = ra [ i ]; } - for ( Iterator it = tal.iterator(); it.hasNext(); ) { + for (Iterator it = tal.iterator(); it.hasNext(); ) { int[] ta = (int[]) it.next(); - if ( ta == null ) { - throw new IllegalStateException ( "null test array" ); - } else if ( ta.length == ( nl + 1 ) ) { - for ( int i = 0, n = ta.length; i < n; i++ ) { + if (ta == null) { + throw new IllegalStateException ("null test array"); + } else if (ta.length == (nl + 1)) { + for (int i = 0, n = ta.length; i < n; i++) { data [ k++ ] = ta [ i ]; } } else { - throw new IllegalStateException ( "test array length error, expected " + ( nl + 1 ) + " entries, got " + ta.length + " entries" ); + throw new IllegalStateException ("test array length error, expected " + (nl + 1) + " entries, got " + ta.length + " entries"); } } assert k == data.length; @@ -901,98 +901,98 @@ public final class GenerateBidiTestData { * * @Levels: ( LWSP ( NUMBER | 'x' ) )+ */ - private static int[] parseLevelSpec ( String line ) { - CharacterIterator ci = new StringCharacterIterator ( line ); + private static int[] parseLevelSpec (String line) { + CharacterIterator ci = new StringCharacterIterator (line); List ll = new ArrayList(); // read prefix - skipSpace ( ci ); - if ( ! maybeReadToken ( ci, PFX_LEVELS ) ) { - badLevelSpec ( "missing prefix \"" + PFX_LEVELS + "\"", ci ); + skipSpace (ci); + if (! maybeReadToken (ci, PFX_LEVELS)) { + badLevelSpec ("missing prefix \"" + PFX_LEVELS + "\"", ci); } // read level values boolean more = true; - while ( more ) { + while (more) { Integer l; - skipSpace ( ci ); - if ( ( l = maybeReadInteger ( ci ) ) != null ) { - ll.add ( l ); - } else if ( maybeReadToken ( ci, "x" ) ) { - ll.add ( Integer.valueOf ( -1 ) ); + skipSpace (ci); + if ((l = maybeReadInteger (ci)) != null) { + ll.add (l); + } else if (maybeReadToken (ci, "x")) { + ll.add (Integer.valueOf (-1)); } else { more = false; } } // read to end of line - skipSpace ( ci ); - if ( ! atEnd ( ci ) ) { - badLevelSpec ( "extraneous content prior to end of line", ci ); + skipSpace (ci); + if (! atEnd (ci)) { + badLevelSpec ("extraneous content prior to end of line", ci); } - if ( ll.size() == 0 ) { - badLevelSpec ( "must have at least one level value", ci ); + if (ll.size() == 0) { + badLevelSpec ("must have at least one level value", ci); } - return createLevelsArray ( ll ); + return createLevelsArray (ll); } - private static Integer maybeReadInteger ( CharacterIterator ci ) { + private static Integer maybeReadInteger (CharacterIterator ci) { // read optional minus sign if present boolean negative; - if ( maybeReadNext ( ci, '-' ) ) { + if (maybeReadNext (ci, '-')) { negative = true; } else { negative = false; } // read digits StringBuffer sb = new StringBuffer(); - while ( true ) { + while (true) { char c = ci.current(); - if ( ( c != CharacterIterator.DONE ) && isDigit ( c ) ) { + if ((c != CharacterIterator.DONE) && isDigit (c)) { ci.next(); - sb.append ( c ); + sb.append (c); } else { break; } } - if ( sb.length() == 0 ) { + if (sb.length() == 0) { return null; } else { - int value = Integer.parseInt ( sb.toString() ); - if ( negative ) { + int value = Integer.parseInt (sb.toString()); + if (negative) { value = -value; } - return Integer.valueOf ( value ); + return Integer.valueOf (value); } } - private static boolean isDigit ( char c ) { - return ( ( c >= '0' ) && ( c <= '9' ) ); + private static boolean isDigit (char c) { + return ((c >= '0') && (c <= '9')); } - private static boolean maybeReadToken ( CharacterIterator ci, String s ) { + private static boolean maybeReadToken (CharacterIterator ci, String s) { int startIndex = ci.getIndex(); - for ( int i = 0, n = s.length(); i < n; i++ ) { - char c = s.charAt ( i ); - if ( ci.current() == c ) { + for (int i = 0, n = s.length(); i < n; i++) { + char c = s.charAt (i); + if (ci.current() == c) { ci.next(); } else { - ci.setIndex ( startIndex ); + ci.setIndex (startIndex); return false; } } return true; } - private static void badLevelSpec ( String reason, CharacterIterator ci ) throws IllegalArgumentException { - if ( verbose ) { + private static void badLevelSpec (String reason, CharacterIterator ci) throws IllegalArgumentException { + if (verbose) { System.out.println(); } - throw new IllegalArgumentException ( "bad level specification: " + reason + ": starting at \"" + remainder ( ci ) + "\"" ); + throw new IllegalArgumentException ("bad level specification: " + reason + ": starting at \"" + remainder (ci) + "\""); } - private static int[] createLevelsArray ( List levels ) { + private static int[] createLevelsArray (List levels) { int[] la = new int [ levels.size() ]; int k = 0; - for ( Iterator it = levels.iterator(); it.hasNext(); ) { - la [ k++ ] = ( (Integer) it.next() ).intValue(); + for (Iterator it = levels.iterator(); it.hasNext(); ) { + la [ k++ ] = ((Integer) it.next()).intValue(); } return la; } @@ -1002,58 +1002,58 @@ public final class GenerateBidiTestData { * * @Reorder: ( LWSP NUMBER )* */ - private static int[] parseReorderSpec ( String line, int[] levels ) { - CharacterIterator ci = new StringCharacterIterator ( line ); + private static int[] parseReorderSpec (String line, int[] levels) { + CharacterIterator ci = new StringCharacterIterator (line); List rl = new ArrayList(); // read prefix - skipSpace ( ci ); - if ( ! maybeReadToken ( ci, PFX_REORDER ) ) { - badReorderSpec ( "missing prefix \"" + PFX_REORDER + "\"", ci ); + skipSpace (ci); + if (! maybeReadToken (ci, PFX_REORDER)) { + badReorderSpec ("missing prefix \"" + PFX_REORDER + "\"", ci); } // read reorder values boolean more = true; - while ( more ) { - skipSpace ( ci ); + while (more) { + skipSpace (ci); Integer l; - if ( ( l = maybeReadInteger ( ci ) ) != null ) { - rl.add ( l ); + if ((l = maybeReadInteger (ci)) != null) { + rl.add (l); } else { more = false; } } // read to end of line - skipSpace ( ci ); - if ( ! atEnd ( ci ) ) { - badReorderSpec ( "extraneous content prior to end of line", ci ); + skipSpace (ci); + if (! atEnd (ci)) { + badReorderSpec ("extraneous content prior to end of line", ci); } - return createReorderArray ( rl, levels ); + return createReorderArray (rl, levels); } - private static void badReorderSpec ( String reason, CharacterIterator ci ) throws IllegalArgumentException { - if ( verbose ) { + private static void badReorderSpec (String reason, CharacterIterator ci) throws IllegalArgumentException { + if (verbose) { System.out.println(); } - throw new IllegalArgumentException ( "bad reorder specification: " + reason + ": starting at \"" + remainder ( ci ) + "\"" ); + throw new IllegalArgumentException ("bad reorder specification: " + reason + ": starting at \"" + remainder (ci) + "\""); } - private static int[] createReorderArray ( List reorders, int[] levels ) { + private static int[] createReorderArray (List reorders, int[] levels) { int nr = reorders.size(); int nl = levels.length; - if ( nr <= nl ) { + if (nr <= nl) { int[] ra = new int [ nl ]; Iterator it = reorders.iterator(); - for ( int i = 0, n = nl; i < n; i++ ) { + for (int i = 0, n = nl; i < n; i++) { int r = -1; - if ( levels [ i ] >= 0 ) { - if ( it.hasNext() ) { - r = ( (Integer) it.next() ).intValue(); + if (levels [ i ] >= 0) { + if (it.hasNext()) { + r = ((Integer) it.next()).intValue(); } } ra [ i ] = r; } return ra; } else { - throw new IllegalArgumentException ( "excessive number of reorder array entries, expected no more than " + nl + ", but got " + nr + " entries" ); + throw new IllegalArgumentException ("excessive number of reorder array entries, expected no more than " + nl + ", but got " + nr + " entries"); } } @@ -1062,102 +1062,102 @@ public final class GenerateBidiTestData { * * BIDI_CLASS ( LWSP BIDI_CLASS )+ ';' LWSP NUMBER */ - private static int[] parseTestSpec ( String line, int[] levels ) { - CharacterIterator ci = new StringCharacterIterator ( line ); + private static int[] parseTestSpec (String line, int[] levels) { + CharacterIterator ci = new StringCharacterIterator (line); List cl = new ArrayList(); // read bidi class identifier sequence - while ( ! atEnd ( ci ) && ! maybeReadNext ( ci, ';' ) ) { - skipSpace ( ci ); + while (! atEnd (ci) && ! maybeReadNext (ci, ';')) { + skipSpace (ci); int bc; - if ( ( bc = maybeReadBidiClass ( ci ) ) >= 0 ) { - cl.add ( Integer.valueOf ( bc ) ); + if ((bc = maybeReadBidiClass (ci)) >= 0) { + cl.add (Integer.valueOf (bc)); } else { break; } } // read bit set - skipSpace ( ci ); + skipSpace (ci); String s; int bs = 0; - if ( ( s = maybeReadHexDigits ( ci, -1 ) ) != null ) { - bs = Integer.parseInt ( s, 16 ); + if ((s = maybeReadHexDigits (ci, -1)) != null) { + bs = Integer.parseInt (s, 16); } else { - badTestSpec ( "missing bit set", ci ); + badTestSpec ("missing bit set", ci); } // read to end of line - skipSpace ( ci ); - if ( ! atEnd ( ci ) ) { - badTestSpec ( "extraneous content prior to end of line", ci ); + skipSpace (ci); + if (! atEnd (ci)) { + badTestSpec ("extraneous content prior to end of line", ci); } - return createTestArray ( cl, bs, levels ); + return createTestArray (cl, bs, levels); } - private static String maybeReadIdentifier ( CharacterIterator ci ) { + private static String maybeReadIdentifier (CharacterIterator ci) { // read keyword chars ([A-Z]) StringBuffer sb = new StringBuffer(); - while ( true ) { + while (true) { char c = ci.current(); - if ( c == CharacterIterator.DONE ) { + if (c == CharacterIterator.DONE) { break; - } else if ( sb.length() == 0 ) { - if ( Character.isUnicodeIdentifierStart ( c ) ) { + } else if (sb.length() == 0) { + if (Character.isUnicodeIdentifierStart (c)) { ci.next(); - sb.append ( c ); + sb.append (c); } else { break; } } else { - if ( Character.isUnicodeIdentifierPart ( c ) ) { + if (Character.isUnicodeIdentifierPart (c)) { ci.next(); - sb.append ( c ); + sb.append (c); } else { break; } } } - if ( sb.length() == 0 ) { + if (sb.length() == 0) { return null; } else { return sb.toString(); } } - private static int maybeReadBidiClass ( CharacterIterator ci ) { + private static int maybeReadBidiClass (CharacterIterator ci) { int bc = -1; int i = ci.getIndex(); String s; - if ( ( s = maybeReadIdentifier ( ci ) ) != null ) { + if ((s = maybeReadIdentifier (ci)) != null) { try { - bc = parseBidiClass ( s ); - } catch ( IllegalArgumentException e ) { + bc = parseBidiClass (s); + } catch (IllegalArgumentException e) { throw e; } } - if ( bc < 0 ) { - ci.setIndex ( i ); + if (bc < 0) { + ci.setIndex (i); } return bc; } - private static void badTestSpec ( String reason, CharacterIterator ci ) throws IllegalArgumentException { - if ( verbose ) { + private static void badTestSpec (String reason, CharacterIterator ci) throws IllegalArgumentException { + if (verbose) { System.out.println(); } - throw new IllegalArgumentException ( "bad test specification: " + reason + ": starting at \"" + remainder ( ci ) + "\"" ); + throw new IllegalArgumentException ("bad test specification: " + reason + ": starting at \"" + remainder (ci) + "\""); } - private static int[] createTestArray ( List classes, int bitset, int[] levels ) { + private static int[] createTestArray (List classes, int bitset, int[] levels) { int nc = classes.size(); - if ( nc <= levels.length ) { + if (nc <= levels.length) { int[] ta = new int [ 1 + nc ]; int k = 0; ta [ k++ ] = bitset; - for ( Iterator it = classes.iterator(); it.hasNext(); ) { - ta [ k++ ] = ( (Integer) it.next() ).intValue(); + for (Iterator it = classes.iterator(); it.hasNext(); ) { + ta [ k++ ] = ((Integer) it.next()).intValue(); } return ta; } else { - throw new IllegalArgumentException ( "excessive number of test array entries, expected no more than " + levels.length + ", but got " + nc + " entries" ); + throw new IllegalArgumentException ("excessive number of test array entries, expected no more than " + levels.length + ", but got " + nc + " entries"); } } @@ -1166,42 +1166,42 @@ public final class GenerateBidiTestData { * @param out - bidi test data java class file print writer * @param outFileName - (full path) name of bidi test data java class file */ - private static void dumpData ( PrintWriter out, String outFileName ) throws IOException { - File f = new File ( outFileName ); + private static void dumpData (PrintWriter out, String outFileName) throws IOException { + File f = new File (outFileName); File p = f.getParentFile(); - if ( td != null ) { + if (td != null) { String pfxTD = "TD"; - dumpResourcesDescriptor ( out, pfxTD, td.length ); - dumpResourcesData ( p, f.getName(), pfxTD, td ); + dumpResourcesDescriptor (out, pfxTD, td.length); + dumpResourcesData (p, f.getName(), pfxTD, td); } - if ( ld != null ) { + if (ld != null) { String pfxTD = "LD"; - dumpResourcesDescriptor ( out, pfxTD, ld.length ); - dumpResourcesData ( p, f.getName(), pfxTD, ld ); + dumpResourcesDescriptor (out, pfxTD, ld.length); + dumpResourcesData (p, f.getName(), pfxTD, ld); } } - private static void dumpResourcesDescriptor ( PrintWriter out, String prefix, int numResources ) { - out.println ( " public static final String " + prefix + "_PFX = \"" + prefix + "\";" ); - out.println ( " public static final int " + prefix + "_CNT = " + numResources + ";" ); + private static void dumpResourcesDescriptor (PrintWriter out, String prefix, int numResources) { + out.println (" public static final String " + prefix + "_PFX = \"" + prefix + "\";"); + out.println (" public static final int " + prefix + "_CNT = " + numResources + ";"); out.println(""); } - private static void dumpResourcesData ( File btcDir, String btcName, String prefix, int[][] data ) throws IOException { - String btdName = extractDataFileName ( btcName ); - for ( int i = 0, n = data.length; i < n; i++ ) { - File f = new File ( btcDir, btdName + "$" + prefix + i + ".ser" ); - ObjectOutputStream os = new ObjectOutputStream ( new FileOutputStream ( f ) ); - os.writeObject ( data[i] ); + private static void dumpResourcesData (File btcDir, String btcName, String prefix, int[][] data) throws IOException { + String btdName = extractDataFileName (btcName); + for (int i = 0, n = data.length; i < n; i++) { + File f = new File (btcDir, btdName + "$" + prefix + i + ".ser"); + ObjectOutputStream os = new ObjectOutputStream (new FileOutputStream (f)); + os.writeObject (data[i]); os.close(); } } private static final String JAVA_EXT = ".java"; - private static String extractDataFileName ( String btcName ) { - if ( btcName.endsWith ( JAVA_EXT ) ) { - return btcName.substring ( 0, btcName.length() - JAVA_EXT.length() ); + private static String extractDataFileName (String btcName) { + if (btcName.endsWith (JAVA_EXT)) { + return btcName.substring (0, btcName.length() - JAVA_EXT.length()); } else { return btcName; } @@ -1216,16 +1216,16 @@ public final class GenerateBidiTestData { String ucdFileName = "http://www.unicode.org/Public/UNIDATA/BidiTest.txt"; String outFileName = "BidiTestData.java"; boolean ok = true; - for (int i = 0; ok && ( i < args.length ); i++) { + for (int i = 0; ok && (i < args.length); i++) { String opt = args[i]; if ("-b".equals(opt)) { - if ( ( i + 1 ) <= args.length ) { + if ((i + 1) <= args.length) { bidiFileName = args[++i]; } else { ok = false; } } else if ("-d".equals(opt)) { - if ( ( i + 1 ) <= args.length ) { + if ((i + 1) <= args.length) { ucdFileName = args[++i]; } else { ok = false; @@ -1233,7 +1233,7 @@ public final class GenerateBidiTestData { } else if ("-i".equals(opt)) { ignoreDeprecatedTypeData = true; } else if ("-o".equals(opt)) { - if ( ( i + 1 ) <= args.length ) { + if ((i + 1) <= args.length) { outFileName = args[++i]; } else { ok = false; @@ -1244,10 +1244,10 @@ public final class GenerateBidiTestData { ok = false; } } - if ( ! ok ) { + if (! ok) { System.out.println("Usage: GenerateBidiTestData [-v] [-i] [-d ] [-b ] [-o ]"); System.out.println(" defaults:"); - if ( ignoreDeprecatedTypeData ) { + if (ignoreDeprecatedTypeData) { System.out.println(" : " + ucdFileName); } System.out.println(" : " + bidiFileName); @@ -1256,12 +1256,12 @@ public final class GenerateBidiTestData { try { convertBidiTestData(ucdFileName, bidiFileName, outFileName); System.out.println("Generated " + outFileName + " from"); - if ( ignoreDeprecatedTypeData ) { + if (ignoreDeprecatedTypeData) { System.out.println(" : " + ucdFileName); } System.out.println(" : " + bidiFileName); } catch (Exception e) { - System.out.println("An unexpected error occured at line: " + lineNumber ); + System.out.println("An unexpected error occured at line: " + lineNumber); e.printStackTrace(); } } diff --git a/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java b/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java index 9541f16ea..472e86396 100644 --- a/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java +++ b/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java @@ -83,7 +83,7 @@ public final class GenerateLineBreakUtils { * @param outFileName Name of the output file. * @throws Exception in case anything goes wrong. */ - private static void convertLineBreakProperties( // CSOK: MethodLength + private static void convertLineBreakProperties(// CSOK: MethodLength String lineBreakFileName, String propertyValueFileName, String breakPairFileName, diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java index 0e293bf45..b39970b87 100644 --- a/src/java/org/apache/fop/afp/AFPBorderPainter.java +++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java @@ -91,8 +91,8 @@ public class AFPBorderPainter extends AbstractAFPPainter { AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); lineDataInfo.setColor(borderPaintInfo.getColor()); lineDataInfo.setRotation(paintingState.getRotation()); - lineDataInfo.setX1 ( Math.round(x1) ); - lineDataInfo.setY1 ( Math.round(y1) ); + lineDataInfo.setX1 (Math.round(x1)); + lineDataInfo.setY1 (Math.round(y1)); float thickness; if (borderPaintInfo.isHorizontal()) { thickness = y2 - y1; @@ -107,68 +107,68 @@ public class AFPBorderPainter extends AbstractAFPPainter { int thickness3 = (int)Math.floor(thickness / 3f); lineDataInfo.setThickness(thickness3); if (borderPaintInfo.isHorizontal()) { - lineDataInfo.setX2 ( Math.round(x2) ); - lineDataInfo.setY2 ( lineDataInfo.getY1() ); + lineDataInfo.setX2 (Math.round(x2)); + lineDataInfo.setY2 (lineDataInfo.getY1()); dataStream.createLine(lineDataInfo); int distance = thickness3 * 2; lineDataInfo = new AFPLineDataInfo(lineDataInfo); - lineDataInfo.setY1 ( lineDataInfo.getY1() + distance ); - lineDataInfo.setY2 ( lineDataInfo.getY2() + distance ); + lineDataInfo.setY1 (lineDataInfo.getY1() + distance); + lineDataInfo.setY2 (lineDataInfo.getY2() + distance); dataStream.createLine(lineDataInfo); } else { - lineDataInfo.setX2 ( lineDataInfo.getX1() ); - lineDataInfo.setY2 ( Math.round(y2) ); + lineDataInfo.setX2 (lineDataInfo.getX1()); + lineDataInfo.setY2 (Math.round(y2)); dataStream.createLine(lineDataInfo); int distance = thickness3 * 2; lineDataInfo = new AFPLineDataInfo(lineDataInfo); - lineDataInfo.setX1 ( lineDataInfo.getX1() + distance ); - lineDataInfo.setX2 ( lineDataInfo.getX2() + distance ); + lineDataInfo.setX1 (lineDataInfo.getX1() + distance); + lineDataInfo.setX2 (lineDataInfo.getX2() + distance); dataStream.createLine(lineDataInfo); } break; case Constants.EN_DASHED: if (borderPaintInfo.isHorizontal()) { int dashWidth = (int) unitConv.pt2units(BorderPainter.dashWidthCalculator(w, h)); - lineDataInfo.setX2 ( lineDataInfo.getX1() + dashWidth ); - lineDataInfo.setY2 ( lineDataInfo.getY1() ); + lineDataInfo.setX2 (lineDataInfo.getX1() + dashWidth); + lineDataInfo.setY2 (lineDataInfo.getY1()); int ex2 = Math.round(x2); int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); while (lineDataInfo.getX2() <= ex2) { dataStream.createLine(lineDataInfo); - lineDataInfo.setX1 ( lineDataInfo.getX2() + spaceWidth ); - lineDataInfo.setX2 ( lineDataInfo.getX1() + dashWidth ); + lineDataInfo.setX1 (lineDataInfo.getX2() + spaceWidth); + lineDataInfo.setX2 (lineDataInfo.getX1() + dashWidth); } } else { int dashWidth = (int) unitConv.pt2units(BorderPainter.dashWidthCalculator(h, w)); - lineDataInfo.setX2 ( lineDataInfo.getX1() ); - lineDataInfo.setY2 ( lineDataInfo.getY1() + dashWidth ); + lineDataInfo.setX2 (lineDataInfo.getX1()); + lineDataInfo.setY2 (lineDataInfo.getY1() + dashWidth); int ey2 = Math.round(y2); int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); while (lineDataInfo.getY2() <= ey2) { dataStream.createLine(lineDataInfo); - lineDataInfo.setY1 ( lineDataInfo.getY2() + spaceWidth ); - lineDataInfo.setY2 ( lineDataInfo.getY1() + dashWidth ); + lineDataInfo.setY1 (lineDataInfo.getY2() + spaceWidth); + lineDataInfo.setY2 (lineDataInfo.getY1() + dashWidth); } } break; case Constants.EN_DOTTED: if (borderPaintInfo.isHorizontal()) { - lineDataInfo.setX2 ( lineDataInfo.getX1() + lineDataInfo.getThickness() ); - lineDataInfo.setY2 ( lineDataInfo.getY1() ); + lineDataInfo.setX2 (lineDataInfo.getX1() + lineDataInfo.getThickness()); + lineDataInfo.setY2 (lineDataInfo.getY1()); int ex2 = Math.round(x2); while (lineDataInfo.getX1() + lineDataInfo.getThickness() < ex2) { dataStream.createLine(lineDataInfo); - lineDataInfo.setX1 ( lineDataInfo.getX1() + 3 * lineDataInfo.getThickness() ); - lineDataInfo.setX2 ( lineDataInfo.getX1() + lineDataInfo.getThickness() ); + lineDataInfo.setX1 (lineDataInfo.getX1() + 3 * lineDataInfo.getThickness()); + lineDataInfo.setX2 (lineDataInfo.getX1() + lineDataInfo.getThickness()); } } else { - lineDataInfo.setX2 ( lineDataInfo.getX1() ); - lineDataInfo.setY2 ( lineDataInfo.getY1() + lineDataInfo.getThickness() ); + lineDataInfo.setX2 (lineDataInfo.getX1()); + lineDataInfo.setY2 (lineDataInfo.getY1() + lineDataInfo.getThickness()); int ey2 = Math.round(y2); while (lineDataInfo.getY1() + lineDataInfo.getThickness() < ey2) { dataStream.createLine(lineDataInfo); - lineDataInfo.setY1 ( lineDataInfo.getY1() + 3 * lineDataInfo.getThickness() ); - lineDataInfo.setY2 ( lineDataInfo.getY1() + lineDataInfo.getThickness() ); + lineDataInfo.setY1 (lineDataInfo.getY1() + 3 * lineDataInfo.getThickness()); + lineDataInfo.setY2 (lineDataInfo.getY1() + lineDataInfo.getThickness()); } } break; @@ -176,25 +176,25 @@ public class AFPBorderPainter extends AbstractAFPPainter { case Constants.EN_RIDGE: //TODO int yNew; - lineDataInfo.setX2 ( Math.round(x2) ); + lineDataInfo.setX2 (Math.round(x2)); float colFactor = (borderPaintInfo.getStyle() == Constants.EN_GROOVE ? 0.4f : -0.4f); float h3 = (y2 - y1) / 3; lineDataInfo.setColor - ( ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor) ); - lineDataInfo.setThickness ( Math.round(h3) ); + (ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor)); + lineDataInfo.setThickness (Math.round(h3)); yNew = Math.round(y1); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); dataStream.createLine(lineDataInfo); - lineDataInfo.setColor ( borderPaintInfo.getColor() ); + lineDataInfo.setColor (borderPaintInfo.getColor()); yNew = Math.round(y1 + h3); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); dataStream.createLine(lineDataInfo); - lineDataInfo.setColor ( ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor) ); + lineDataInfo.setColor (ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor)); yNew = Math.round(y1 + h3 + h3); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); dataStream.createLine(lineDataInfo); break; case Constants.EN_HIDDEN: @@ -204,11 +204,11 @@ public class AFPBorderPainter extends AbstractAFPPainter { case Constants.EN_SOLID: default: if (borderPaintInfo.isHorizontal()) { - lineDataInfo.setX2 ( Math.round(x2) ); - lineDataInfo.setY2 ( lineDataInfo.getY1() ); + lineDataInfo.setX2 (Math.round(x2)); + lineDataInfo.setY2 (lineDataInfo.getY1()); } else { - lineDataInfo.setX2 ( lineDataInfo.getX1() ); - lineDataInfo.setY2 ( Math.round(y2) ); + lineDataInfo.setX2 (lineDataInfo.getX1()); + lineDataInfo.setY2 (Math.round(y2)); } dataStream.createLine(lineDataInfo); } diff --git a/src/java/org/apache/fop/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/afp/AFPRectanglePainter.java index 38aa337ee..4a57bb125 100644 --- a/src/java/org/apache/fop/afp/AFPRectanglePainter.java +++ b/src/java/org/apache/fop/afp/AFPRectanglePainter.java @@ -53,39 +53,39 @@ public class AFPRectanglePainter extends AbstractAFPPainter { AffineTransform at = paintingState.getData().getTransform(); AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); - lineDataInfo.setColor ( paintingState.getColor() ); - lineDataInfo.setRotation ( paintingState.getRotation() ); - lineDataInfo.setThickness ( Math.round(height) ); + lineDataInfo.setColor (paintingState.getColor()); + lineDataInfo.setRotation (paintingState.getRotation()); + lineDataInfo.setThickness (Math.round(height)); switch (lineDataInfo.getRotation()) { case 90: - lineDataInfo.setX1 ( Math.round((float)at.getTranslateY() + x) ); + lineDataInfo.setX1 (Math.round((float)at.getTranslateY() + x)); yNew = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); - lineDataInfo.setX2 ( Math.round(width + (float)at.getTranslateY() + x) ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); + lineDataInfo.setX2 (Math.round(width + (float)at.getTranslateY() + x)); break; case 180: - lineDataInfo.setX1 ( pageWidth - Math.round((float)at.getTranslateX() - x) ); + lineDataInfo.setX1 (pageWidth - Math.round((float)at.getTranslateX() - x)); yNew = pageHeight - Math.round((float)at.getTranslateY() - y); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); - lineDataInfo.setX2 ( pageWidth - Math.round((float)at.getTranslateX() - x - width) ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); + lineDataInfo.setX2 (pageWidth - Math.round((float)at.getTranslateX() - x - width)); break; case 270: - lineDataInfo.setX1 ( pageHeight - Math.round((float)at.getTranslateY() - x) ); + lineDataInfo.setX1 (pageHeight - Math.round((float)at.getTranslateY() - x)); yNew = Math.round((float)at.getTranslateX() + y); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); - lineDataInfo.setX2 ( pageHeight - Math.round((float)at.getTranslateY() - x - width) ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); + lineDataInfo.setX2 (pageHeight - Math.round((float)at.getTranslateY() - x - width)); break; case 0: default: - lineDataInfo.setX1 ( Math.round((float)at.getTranslateX() + x) ); + lineDataInfo.setX1 (Math.round((float)at.getTranslateX() + x)); yNew = Math.round((float)at.getTranslateY() + y); - lineDataInfo.setY1 ( yNew ); - lineDataInfo.setY2 ( yNew ); - lineDataInfo.setX2 ( Math.round((float)at.getTranslateX() + x + width) ); + lineDataInfo.setY1 (yNew); + lineDataInfo.setY2 (yNew); + lineDataInfo.setX2 (Math.round((float)at.getTranslateX() + x + width)); break; } dataStream.createLine(lineDataInfo); diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java index f3e75c1af..279abcd34 100644 --- a/src/java/org/apache/fop/afp/Factory.java +++ b/src/java/org/apache/fop/afp/Factory.java @@ -234,7 +234,7 @@ public class Factory { public ActiveEnvironmentGroup createActiveEnvironmentGroup( int width, int height, int widthRes, int heightRes) { String name = ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++activeEnvironmentGroupCount ), '0', 5); + + StringUtils.lpad(String.valueOf(++activeEnvironmentGroupCount), '0', 5); return new ActiveEnvironmentGroup(this, name, width, height, widthRes, heightRes); } diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java index 7284c69f3..e48e636c2 100644 --- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -195,8 +195,8 @@ public class GraphicsObject extends AbstractDataObject { * @param lineWidth the line width multiplier */ public void setLineWidth(float lineWidth) { - float epsilon = Float.intBitsToFloat ( 0x00800000 ); // Float.MIN_NORMAL (JDK1.6) - if ( Math.abs ( graphicsState.lineWidth - lineWidth ) > epsilon ) { + float epsilon = Float.intBitsToFloat (0x00800000); // Float.MIN_NORMAL (JDK1.6) + if (Math.abs (graphicsState.lineWidth - lineWidth) > epsilon) { addObject(new GraphicsSetFractionalLineWidth(lineWidth)); graphicsState.lineWidth = lineWidth; } diff --git a/src/java/org/apache/fop/afp/modca/triplets/EncodingTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/EncodingTriplet.java index 05e56e5ae..03b0bedf4 100644 --- a/src/java/org/apache/fop/afp/modca/triplets/EncodingTriplet.java +++ b/src/java/org/apache/fop/afp/modca/triplets/EncodingTriplet.java @@ -35,7 +35,7 @@ public class EncodingTriplet extends AbstractTriplet { /** * @param encoding the CCSID character set encoding */ - public EncodingTriplet( int encoding) { + public EncodingTriplet(int encoding) { super(CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER); this.encoding = encoding; } diff --git a/src/java/org/apache/fop/afp/util/DTDEntityResolver.java b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java index 1f9f55ee6..8df25a1cc 100644 --- a/src/java/org/apache/fop/afp/util/DTDEntityResolver.java +++ b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java @@ -77,23 +77,23 @@ public class DTDEntityResolver implements EntityResolver { throws IOException { URL resource = null; - if ( AFP_DTD_1_2_ID.equals(publicId) ) { - resource = getResource( AFP_DTD_1_2_RESOURCE ); - } else if ( AFP_DTD_1_1_ID.equals(publicId) ) { - resource = getResource( AFP_DTD_1_1_RESOURCE ); - } else if ( AFP_DTD_1_0_ID.equals(publicId) ) { + if (AFP_DTD_1_2_ID.equals(publicId)) { + resource = getResource(AFP_DTD_1_2_RESOURCE); + } else if (AFP_DTD_1_1_ID.equals(publicId)) { + resource = getResource(AFP_DTD_1_1_RESOURCE); + } else if (AFP_DTD_1_0_ID.equals(publicId)) { throw new FontRuntimeException( - "The AFP Installed Font Definition 1.0 DTD is not longer supported" ); - } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) { + "The AFP Installed Font Definition 1.0 DTD is not longer supported"); + } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0) { throw new FontRuntimeException( - "The AFP Installed Font Definition DTD must be specified using the public id" ); + "The AFP Installed Font Definition DTD must be specified using the public id"); } else { return null; } - InputSource inputSource = new InputSource( resource.openStream() ); - inputSource.setPublicId( publicId ); - inputSource.setSystemId( systemId ); + InputSource inputSource = new InputSource(resource.openStream()); + inputSource.setPublicId(publicId); + inputSource.setSystemId(systemId); return inputSource; } @@ -111,10 +111,10 @@ public class DTDEntityResolver implements EntityResolver { cl = ClassLoader.getSystemClassLoader(); } - URL resource = cl.getResource( resourcePath ); + URL resource = cl.getResource(resourcePath); if (resource == null) { - throw new FontRuntimeException( "Resource " + resourcePath - + "could not be found on the classpath" ); + throw new FontRuntimeException("Resource " + resourcePath + + "could not be found on the classpath"); } return resource; diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index 240a0ab10..5ba111790 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -225,7 +225,7 @@ public class Area extends AreaTreeObject implements Serializable { * * @param bidiLevel the bidirectional embedding level */ - public void setBidiLevel ( int bidiLevel ) { + public void setBidiLevel (int bidiLevel) { this.bidiLevel = bidiLevel; } @@ -412,9 +412,9 @@ public class Area extends AreaTreeObject implements Serializable { * * @param traits the map of traits */ - public void setTraits ( Map traits ) { - if ( traits != null ) { - this.traits = new TreeMap( traits ); + public void setTraits (Map traits) { + if (traits != null) { + this.traits = new TreeMap(traits); } else { this.traits = null; } diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index a606f9727..fed2a8316 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -798,8 +798,8 @@ public class AreaTreeParser { = XMLUtil.getAttributeAsPositionAdjustments(lastAttributes, "position-adjust"); content.flip(); WordArea word = new WordArea - ( offset, level, content.toString().trim(), letterAdjust, - null, gposAdjustments, reversed ); + (offset, level, content.toString().trim(), letterAdjust, + null, gposAdjustments, reversed); AbstractTextArea text = getCurrentText(); word.setParentArea(text); text.addChildArea(word); @@ -851,7 +851,7 @@ public class AreaTreeParser { setTraits(attributes, leader, SUBSET_COLOR); setTraits(attributes, leader, SUBSET_FONT); leader.setBlockProgressionOffset - ( XMLUtil.getAttributeAsInt(attributes, "offset", 0) ); + (XMLUtil.getAttributeAsInt(attributes, "offset", 0)); String ruleStyle = attributes.getValue("ruleStyle"); if (ruleStyle != null) { leader.setRuleStyle(ruleStyle); @@ -876,7 +876,7 @@ public class AreaTreeParser { viewport.setContentPosition(XMLUtil.getAttributeAsRectangle2D(attributes, "pos")); viewport.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clip", false)); viewport.setBlockProgressionOffset - ( XMLUtil.getAttributeAsInt(attributes, "offset", 0) ); + (XMLUtil.getAttributeAsInt(attributes, "offset", 0)); Area parent = (Area)areaStack.peek(); parent.addChildArea(viewport); areaStack.push(viewport); diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 8621fce8c..56c71ac59 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -146,8 +146,8 @@ public class BodyRegion extends RegionReference { * @param wmtg a WM traits getter */ public void setWritingModeTraits(WritingModeTraitsGetter wmtg) { - if ( getMainReference() != null ) { - getMainReference().setWritingModeTraits ( wmtg ); + if (getMainReference() != null) { + getMainReference().setWritingModeTraits (wmtg); } } diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java index 3979bce56..4a35af9aa 100644 --- a/src/java/org/apache/fop/area/CTM.java +++ b/src/java/org/apache/fop/area/CTM.java @@ -341,7 +341,7 @@ public class CTM implements Serializable { * can set ipd and bpd appropriately based on the writing mode. */ - switch ( writingMode.getEnumValue() ) { + switch (writingMode.getEnumValue()) { case EN_TB_LR: case EN_TB_RL: reldims.ipd = height; diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index ac5322f96..ccd290a36 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -130,12 +130,12 @@ public class LineArea extends Area { *

Used by bidirectional processing after line area consituent reordering.

* @param inlineAreas the list of inline areas */ - public void setInlineAreas ( List inlineAreas ) { - for ( Iterator it = inlineAreas.iterator(); it.hasNext();) { + public void setInlineAreas (List inlineAreas) { + for (Iterator it = inlineAreas.iterator(); it.hasNext();) { InlineArea ia = it.next(); Area pa = ia.getParentArea(); - if ( pa == null ) { - ia.setParentArea ( this ); + if (pa == null) { + ia.setParentArea (this); } else { assert pa == this; } diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java index 1c711a18e..576914a97 100644 --- a/src/java/org/apache/fop/area/LinkResolver.java +++ b/src/java/org/apache/fop/area/LinkResolver.java @@ -80,7 +80,7 @@ public class LinkResolver implements Resolvable, Serializable { public void resolveIDRef(String id, PageViewport pv) { if (idRef.equals(id) && pv != null) { resolved = true; - if ( area != null ) { + if (area != null) { Trait.InternalLink iLink = new Trait.InternalLink(pv.getKey(), idRef); area.addTrait(Trait.INTERNAL_LINK, iLink); area = null; // break circular reference from basic link area to this resolver @@ -95,17 +95,17 @@ public class LinkResolver implements Resolvable, Serializable { * @param dependent resolvable */ public void addDependent(Resolvable dependent) { - if ( dependents == null ) { + if (dependents == null) { dependents = new ArrayList(); } dependents.add(dependent); } private void resolveDependents(String id, PageViewport pv) { - if ( dependents != null ) { + if (dependents != null) { List pages = new ArrayList(); pages.add(pv); - for ( Resolvable r : dependents ) { + for (Resolvable r : dependents) { r.resolveIDRef(id, pages); } } diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java index 58c0b2eaf..57c430754 100644 --- a/src/java/org/apache/fop/area/MainReference.java +++ b/src/java/org/apache/fop/area/MainReference.java @@ -131,8 +131,8 @@ public class MainReference extends Area { * @param wmtg a WM traits getter */ public void setWritingModeTraits(WritingModeTraitsGetter wmtg) { - for ( Span s : getSpans() ) { - s.setWritingModeTraits ( wmtg ); + for (Span s : getSpans()) { + s.setWritingModeTraits (wmtg); } } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index 8165864dd..b5f73b4c6 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -519,7 +519,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable { * @param wmtg a WM traits getter */ public void setWritingModeTraits(WritingModeTraitsGetter wmtg) { - if ( page != null ) { + if (page != null) { page.setWritingModeTraits(wmtg); } } diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index f25140097..e0f8633be 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.java @@ -193,16 +193,16 @@ public class Span extends Area { * @param wmtg a WM traits getter */ public void setWritingModeTraits(WritingModeTraitsGetter wmtg) { - switch ( wmtg.getColumnProgressionDirection().getEnumValue() ) { + switch (wmtg.getColumnProgressionDirection().getEnumValue()) { case Constants.EN_RL: setBidiLevel(1); - for ( Iterator it = flowAreas.iterator(); it.hasNext();) { + for (Iterator it = flowAreas.iterator(); it.hasNext();) { it.next().setBidiLevel(1); } break; default: resetBidiLevel(); - for ( Iterator it = flowAreas.iterator(); it.hasNext();) { + for (Iterator it = flowAreas.iterator(); it.hasNext();) { it.next().resetBidiLevel(); } break; diff --git a/src/java/org/apache/fop/area/inline/BasicLinkArea.java b/src/java/org/apache/fop/area/inline/BasicLinkArea.java index c91181946..68af92319 100644 --- a/src/java/org/apache/fop/area/inline/BasicLinkArea.java +++ b/src/java/org/apache/fop/area/inline/BasicLinkArea.java @@ -58,7 +58,7 @@ public class BasicLinkArea extends InlineParent { * @param resolver the link resolver that will resolve this basic link or null */ public void setResolver(LinkResolver resolver) { - assert ( resolver == null ) || ( this.resolver == null ); + assert (resolver == null) || (this.resolver == null); this.resolver = resolver; } diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 399bd1f1e..826f7a8c1 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -106,7 +106,7 @@ public class InlineArea extends Area { * Default constructor for inline area. */ public InlineArea() { - this ( 0, -1 ); + this (0, -1); } /** @@ -114,7 +114,7 @@ public class InlineArea extends Area { * @param blockProgressionOffset a block progression offset or zero * @param bidiLevel a resolved bidi level or -1 */ - protected InlineArea ( int blockProgressionOffset, int bidiLevel ) { + protected InlineArea (int blockProgressionOffset, int bidiLevel) { this.blockProgressionOffset = blockProgressionOffset; setBidiLevel(bidiLevel); } @@ -311,9 +311,9 @@ public class InlineArea extends Area { * @param runs current list of inline runs * @return modified list of inline runs, having appended new run */ - public List collectInlineRuns ( List runs ) { + public List collectInlineRuns (List runs) { assert runs != null; - runs.add ( new InlineRun ( this, new int[] {getBidiLevel()}) ); + runs.add (new InlineRun (this, new int[] {getBidiLevel()})); return runs; } @@ -322,8 +322,8 @@ public class InlineArea extends Area { * @param ia inline area to test * @return true if specified inline area is an ancestor or same as this area */ - public boolean isAncestorOrSelf ( InlineArea ia ) { - return ( ia == this ) || isAncestor ( ia ); + public boolean isAncestorOrSelf (InlineArea ia) { + return (ia == this) || isAncestor (ia); } /** @@ -331,12 +331,12 @@ public class InlineArea extends Area { * @param ia inline area to test * @return true if specified inline area is an ancestor of this area */ - public boolean isAncestor ( InlineArea ia ) { - for ( Area p = getParentArea(); p != null;) { - if ( p == ia ) { + public boolean isAncestor (InlineArea ia) { + for (Area p = getParentArea(); p != null;) { + if (p == ia) { return true; - } else if ( p instanceof InlineArea ) { - p = ( (InlineArea) p ).getParentArea(); + } else if (p instanceof InlineArea) { + p = ((InlineArea) p).getParentArea(); } else { p = null; } diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 1be3aff0f..cc2dd577c 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -64,7 +64,7 @@ public class InlineParent extends InlineArea { if (autoSize) { increaseIPD(childArea.getAllocIPD()); } - updateLevel ( childArea.getBidiLevel() ); + updateLevel (childArea.getBidiLevel()); int childOffset = childArea.getVirtualOffset(); minChildOffset = Math.min(minChildOffset, childOffset); maxAfterEdge = Math.max(maxAfterEdge, childOffset + childArea.getVirtualBPD()); @@ -114,10 +114,10 @@ public class InlineParent extends InlineArea { } @Override - public List collectInlineRuns ( List runs ) { - for ( Iterator it = getChildAreas().iterator(); it.hasNext();) { + public List collectInlineRuns (List runs) { + for (Iterator it = getChildAreas().iterator(); it.hasNext();) { InlineArea ia = it.next(); - runs = ia.collectInlineRuns ( runs ); + runs = ia.collectInlineRuns (runs); } return runs; } @@ -127,20 +127,20 @@ public class InlineParent extends InlineArea { * signalling that they will inherit the level of their parent text area. */ public void resetChildrenLevel() { - for ( Iterator it = inlines.iterator(); it.hasNext();) { - ( (InlineArea) it.next() ) .resetBidiLevel(); + for (Iterator it = inlines.iterator(); it.hasNext();) { + ((InlineArea) it.next()) .resetBidiLevel(); } } - private void updateLevel ( int newLevel ) { - if ( newLevel >= 0 ) { + private void updateLevel (int newLevel) { + if (newLevel >= 0) { int curLevel = getBidiLevel(); - if ( curLevel >= 0 ) { - if ( newLevel < curLevel ) { - setBidiLevel ( newLevel ); + if (curLevel >= 0) { + if (newLevel < curLevel) { + setBidiLevel (newLevel); } } else { - setBidiLevel ( newLevel ); + setBidiLevel (newLevel); } } } diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index c3786ec0d..6ee89cbf4 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -44,7 +44,7 @@ public class SpaceArea extends InlineArea { * @param bidiLevel the bidirectional embedding level (or -1 if not defined) */ public SpaceArea(int blockProgressionOffset, int bidiLevel, char space, boolean adjustable) { - super ( blockProgressionOffset, bidiLevel ); + super (blockProgressionOffset, bidiLevel); this.space = space; this.isAdjustable = adjustable; } diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index 66854f7f2..a0ca5717a 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.java @@ -89,12 +89,12 @@ public class TextArea extends AbstractTextArea { * @param blockProgressionOffset the offset for the next area */ public void addWord - ( String word, int ipd, int[] letterAdjust, int[] levels, - int[][] gposAdjustments, int blockProgressionOffset ) { - int minWordLevel = findMinLevel ( levels ); + (String word, int ipd, int[] letterAdjust, int[] levels, + int[][] gposAdjustments, int blockProgressionOffset) { + int minWordLevel = findMinLevel (levels); WordArea wordArea = new WordArea - ( blockProgressionOffset, minWordLevel, word, letterAdjust, levels, gposAdjustments ); - wordArea.setIPD ( ipd ); + (blockProgressionOffset, minWordLevel, word, letterAdjust, levels, gposAdjustments); + wordArea.setIPD (ipd); addChildArea(wordArea); wordArea.setParentArea(this); updateLevel(minWordLevel); @@ -110,9 +110,9 @@ public class TextArea extends AbstractTextArea { * @param level resolved bidirection level of space character */ public void addSpace - ( char space, int ipd, boolean adjustable, int blockProgressionOffset, int level ) { + (char space, int ipd, boolean adjustable, int blockProgressionOffset, int level) { SpaceArea spaceArea = new SpaceArea(blockProgressionOffset, level, space, adjustable); - spaceArea.setIPD ( ipd ); + spaceArea.setIPD (ipd); addChildArea(spaceArea); spaceArea.setParentArea(this); updateLevel(level); @@ -167,29 +167,29 @@ public class TextArea extends AbstractTextArea { return sb.toString(); } - private void updateLevel ( int newLevel ) { - if ( newLevel >= 0 ) { + private void updateLevel (int newLevel) { + if (newLevel >= 0) { int curLevel = getBidiLevel(); - if ( curLevel >= 0 ) { - if ( newLevel < curLevel ) { - setBidiLevel ( newLevel ); + if (curLevel >= 0) { + if (newLevel < curLevel) { + setBidiLevel (newLevel); } } else { - setBidiLevel ( newLevel ); + setBidiLevel (newLevel); } } } - private static int findMinLevel ( int[] levels ) { - if ( levels != null ) { + private static int findMinLevel (int[] levels) { + if (levels != null) { int lMin = Integer.MAX_VALUE; - for ( int i = 0, n = levels.length; i < n; i++ ) { + for (int i = 0, n = levels.length; i < n; i++) { int l = levels [ i ]; - if ( ( l >= 0 ) && ( l < lMin ) ) { + if ((l >= 0) && (l < lMin)) { lMin = l; } } - if ( lMin == Integer.MAX_VALUE ) { + if (lMin == Integer.MAX_VALUE) { return -1; } else { return lMin; @@ -199,10 +199,10 @@ public class TextArea extends AbstractTextArea { } } - private int[] makeLevels ( int level, int count ) { - if ( level >= 0 ) { + private int[] makeLevels (int level, int count) { + if (level >= 0) { int[] levels = new int [ count ]; - Arrays.fill ( levels, level ); + Arrays.fill (levels, level); return levels; } else { return null; diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index 71a3dfa62..87fc80d67 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -162,9 +162,9 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { * @return modified list of inline runs, having appended new run */ @Override - public List collectInlineRuns ( List runs ) { + public List collectInlineRuns (List runs) { assert runs != null; - runs.add ( new InlineRun ( this, new int[] {getBidiLevel()}) ); + runs.add (new InlineRun (this, new int[] {getBidiLevel()})); return runs; } } diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java index 00ddc9e1d..443fcbf21 100644 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ b/src/java/org/apache/fop/area/inline/WordArea.java @@ -67,14 +67,14 @@ public class WordArea extends InlineArea { * @param reversed true if word is known to be reversed at construction time */ public WordArea - ( int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, - int[][] gposAdjustments, boolean reversed ) { - super ( blockProgressionOffset, level ); - int length = ( word != null ) ? word.length() : 0; + (int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, + int[][] gposAdjustments, boolean reversed) { + super (blockProgressionOffset, level); + int length = (word != null) ? word.length() : 0; this.word = word; - this.letterAdjust = maybeAdjustLength ( letterAdjust, length ); - this.levels = maybePopulateLevels ( levels, level, length ); - this.gposAdjustments = maybeAdjustLength ( gposAdjustments, length ); + this.letterAdjust = maybeAdjustLength (letterAdjust, length); + this.levels = maybePopulateLevels (levels, level, length); + this.gposAdjustments = maybeAdjustLength (gposAdjustments, length); this.reversed = reversed; } @@ -89,9 +89,9 @@ public class WordArea extends InlineArea { * @param gposAdjustments array of general position adjustments or null if none apply */ public WordArea - ( int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, - int[][] gposAdjustments ) { - this ( blockProgressionOffset, level, word, letterAdjust, levels, gposAdjustments, false ); + (int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, + int[][] gposAdjustments) { + this (blockProgressionOffset, level, word, letterAdjust, levels, gposAdjustments, false); } /** @return Returns the word. */ @@ -120,12 +120,12 @@ public class WordArea extends InlineArea { * @return a (possibly null) array of per-character (glyph) levels over the specified * sequence */ - public int[] getBidiLevels ( int start, int end ) { + public int[] getBidiLevels (int start, int end) { assert start <= end; - if ( this.levels != null ) { + if (this.levels != null) { int n = end - start; int[] levels = new int [ n ]; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { levels[i] = this.levels [ start + i ]; } return levels; @@ -141,10 +141,10 @@ public class WordArea extends InlineArea { * level * @return a resolved bidirectional level or, if not specified, then -1 */ - public int bidiLevelAt ( int position ) { - if ( position > word.length() ) { + public int bidiLevelAt (int position) { + if (position > word.length()) { throw new IndexOutOfBoundsException(); - } else if ( levels != null ) { + } else if (levels != null) { return levels [ position ]; } else { return -1; @@ -152,15 +152,15 @@ public class WordArea extends InlineArea { } @Override - public List collectInlineRuns ( List runs ) { + public List collectInlineRuns (List runs) { assert runs != null; InlineRun r; - if ( getBidiLevels() != null ) { - r = new InlineRun ( this, getBidiLevels() ); + if (getBidiLevels() != null) { + r = new InlineRun (this, getBidiLevels()); } else { - r = new InlineRun ( this, -1, word.length() ); + r = new InlineRun (this, -1, word.length()); } - runs.add ( r ); + runs.add (r); return runs; } @@ -180,10 +180,10 @@ public class WordArea extends InlineArea { * level * @return an array of adjustments or null if none applies */ - public int[] glyphPositionAdjustmentsAt ( int position ) { - if ( position > word.length() ) { + public int[] glyphPositionAdjustmentsAt (int position) { + if (position > word.length()) { throw new IndexOutOfBoundsException(); - } else if ( gposAdjustments != null ) { + } else if (gposAdjustments != null) { return gposAdjustments [ position ]; } else { return null; @@ -195,18 +195,18 @@ public class WordArea extends InlineArea { * adjustments.

* @param mirror if true, then perform mirroring if mirrorred characters */ - public void reverse ( boolean mirror ) { - if ( word.length() > 0 ) { - word = ( ( new StringBuffer ( word ) ) .reverse() ) .toString(); - if ( levels != null ) { - reverse ( levels ); + public void reverse (boolean mirror) { + if (word.length() > 0) { + word = ((new StringBuffer (word)) .reverse()) .toString(); + if (levels != null) { + reverse (levels); } - if ( gposAdjustments != null ) { - reverse ( gposAdjustments ); + if (gposAdjustments != null) { + reverse (gposAdjustments); } reversed = !reversed; - if ( mirror ) { - word = CharMirror.mirror ( word ); + if (mirror) { + word = CharMirror.mirror (word); } } } @@ -215,8 +215,8 @@ public class WordArea extends InlineArea { *

Perform mirroring on mirrorable characters.

*/ public void mirror() { - if ( word.length() > 0 ) { - word = CharMirror.mirror ( word ); + if (word.length() > 0) { + word = CharMirror.mirror (word); } } @@ -236,14 +236,14 @@ public class WordArea extends InlineArea { * If int[] array is not of specified length, then create * a new copy of the first length entries. */ - private static int[] maybeAdjustLength ( int[] ia, int length ) { - if ( ia != null ) { - if ( ia.length == length ) { + private static int[] maybeAdjustLength (int[] ia, int length) { + if (ia != null) { + if (ia.length == length) { return ia; } else { int[] iaNew = new int [ length ]; - for ( int i = 0, n = ia.length; i < n; i++ ) { - if ( i < length ) { + for (int i = 0, n = ia.length; i < n; i++) { + if (i < length) { iaNew [ i ] = ia [ i ]; } else { break; @@ -260,14 +260,14 @@ public class WordArea extends InlineArea { * If int[][] matrix is not of specified length, then create * a new shallow copy of the first length entries. */ - private static int[][] maybeAdjustLength ( int[][] im, int length ) { - if ( im != null ) { - if ( im.length == length ) { + private static int[][] maybeAdjustLength (int[][] im, int length) { + if (im != null) { + if (im.length == length) { return im; } else { int[][] imNew = new int [ length ][]; - for ( int i = 0, n = im.length; i < n; i++ ) { - if ( i < length ) { + for (int i = 0, n = im.length; i < n; i++) { + if (i < length) { imNew [ i ] = im [ i ]; } else { break; @@ -280,16 +280,16 @@ public class WordArea extends InlineArea { } } - private static int[] maybePopulateLevels ( int[] levels, int level, int count ) { - if ( ( levels == null ) && ( level >= 0 ) ) { + private static int[] maybePopulateLevels (int[] levels, int level, int count) { + if ((levels == null) && (level >= 0)) { levels = new int[count]; - Arrays.fill ( levels, level ); + Arrays.fill (levels, level); } - return maybeAdjustLength ( levels, count ); + return maybeAdjustLength (levels, count); } - private static void reverse ( int[] a ) { - for ( int i = 0, n = a.length, m = n / 2; i < m; i++ ) { + private static void reverse (int[] a) { + for (int i = 0, n = a.length, m = n / 2; i < m; i++) { int k = n - i - 1; int t = a [ k ]; a [ k ] = a [ i ]; @@ -297,8 +297,8 @@ public class WordArea extends InlineArea { } } - private static void reverse ( int[][] aa ) { - for ( int i = 0, n = aa.length, m = n / 2; i < m; i++ ) { + private static void reverse (int[][] aa) { + for (int i = 0, n = aa.length, m = n / 2; i < m; i++) { int k = n - i - 1; int[] t = aa [ k ]; aa [ k ] = aa [ i ]; diff --git a/src/java/org/apache/fop/complexscripts/bidi/BidiClass.java b/src/java/org/apache/fop/complexscripts/bidi/BidiClass.java index d2c2bd2b9..f2a8462e7 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/BidiClass.java +++ b/src/java/org/apache/fop/complexscripts/bidi/BidiClass.java @@ -241,25 +241,25 @@ private static byte[] bcC1 = { * @param ch a unicode scalar value * @return bidi class */ -public static int getBidiClass ( int ch ) { - if ( ch <= 0x00FF ) { +public static int getBidiClass (int ch) { + if (ch <= 0x00FF) { return bcL1 [ ch - 0x0000 ]; - } else if ( ( ch >= 0x0590 ) && ( ch <= 0x06FF ) ) { + } else if ((ch >= 0x0590) && (ch <= 0x06FF)) { return bcR1 [ ch - 0x0590 ]; } else { - return getBidiClass ( ch, bcS1, bcE1, bcC1 ); + return getBidiClass (ch, bcS1, bcE1, bcC1); } } -private static int getBidiClass ( int ch, int[] sa, int[] ea, byte[] ca ) { - int k = Arrays.binarySearch ( sa, ch ); - if ( k >= 0 ) { +private static int getBidiClass (int ch, int[] sa, int[] ea, byte[] ca) { + int k = Arrays.binarySearch (sa, ch); + if (k >= 0) { return ca [ k ]; } else { - k = - ( k + 1 ); - if ( k == 0 ) { + k = - (k + 1); + if (k == 0) { return BidiConstants.L; - } else if ( ch <= ea [ k - 1 ] ) { + } else if (ch <= ea [ k - 1 ]) { return ca [ k - 1 ]; } else { return BidiConstants.L; diff --git a/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java b/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java index 97a9f0b52..66d26a83f 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java +++ b/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java @@ -57,183 +57,183 @@ public final class BidiResolver { * Resolve inline directionality. * @param ps a page sequence FO instance */ - public static void resolveInlineDirectionality ( PageSequence ps ) { + public static void resolveInlineDirectionality (PageSequence ps) { if (log.isDebugEnabled()) { - log.debug ( "BD: RESOLVE: " + ps ); + log.debug ("BD: RESOLVE: " + ps); } - List ranges = pruneEmptyRanges ( ps.collectDelimitedTextRanges ( new Stack() ) ); - resolveInlineDirectionality ( ranges ); + List ranges = pruneEmptyRanges (ps.collectDelimitedTextRanges (new Stack())); + resolveInlineDirectionality (ranges); } /** * Reorder line area. * @param la a line area instance */ - public static void reorder ( LineArea la ) { + public static void reorder (LineArea la) { // 1. collect inline levels - List runs = collectRuns ( la.getInlineAreas(), new Vector() ); + List runs = collectRuns (la.getInlineAreas(), new Vector()); if (log.isDebugEnabled()) { - dumpRuns ( "BD: REORDER: INPUT:", runs ); + dumpRuns ("BD: REORDER: INPUT:", runs); } // 2. split heterogeneous inlines - runs = splitRuns ( runs ); + runs = splitRuns (runs); if (log.isDebugEnabled()) { - dumpRuns ( "BD: REORDER: SPLIT INLINES:", runs ); + dumpRuns ("BD: REORDER: SPLIT INLINES:", runs); } // 3. determine minimum and maximum levels - int[] mm = computeMinMaxLevel ( runs, null ); + int[] mm = computeMinMaxLevel (runs, null); if (log.isDebugEnabled()) { - log.debug( "BD: REORDER: { min = " + mm[0] + ", max = " + mm[1] + "}" ); + log.debug("BD: REORDER: { min = " + mm[0] + ", max = " + mm[1] + "}"); } // 4. reorder from maximum level to minimum odd level int mn = mm[0]; int mx = mm[1]; - if ( mx > 0 ) { - for ( int l1 = mx, l2 = ( ( mn & 1 ) == 0 ) ? ( mn + 1 ) : mn; l1 >= l2; l1-- ) { - runs = reorderRuns ( runs, l1 ); + if (mx > 0) { + for (int l1 = mx, l2 = ((mn & 1) == 0) ? (mn + 1) : mn; l1 >= l2; l1--) { + runs = reorderRuns (runs, l1); } } if (log.isDebugEnabled()) { - dumpRuns ( "BD: REORDER: REORDERED RUNS:", runs ); + dumpRuns ("BD: REORDER: REORDERED RUNS:", runs); } // 5. reverse word consituents (characters and glyphs) while mirroring boolean mirror = true; - reverseWords ( runs, mirror ); + reverseWords (runs, mirror); if (log.isDebugEnabled()) { - dumpRuns ( "BD: REORDER: REORDERED WORDS:", runs ); + dumpRuns ("BD: REORDER: REORDERED WORDS:", runs); } // 6. replace line area's inline areas with reordered runs' inline areas - replaceInlines ( la, replicateSplitWords ( runs ) ); + replaceInlines (la, replicateSplitWords (runs)); } - private static void resolveInlineDirectionality ( List ranges ) { - for ( Iterator it = ranges.iterator(); it.hasNext(); ) { + private static void resolveInlineDirectionality (List ranges) { + for (Iterator it = ranges.iterator(); it.hasNext(); ) { DelimitedTextRange r = (DelimitedTextRange) it.next(); r.resolve(); if (log.isDebugEnabled()) { - log.debug ( r ); + log.debug (r); } } } - private static List collectRuns ( List inlines, List runs ) { - for ( Iterator it = inlines.iterator(); it.hasNext(); ) { + private static List collectRuns (List inlines, List runs) { + for (Iterator it = inlines.iterator(); it.hasNext(); ) { InlineArea ia = (InlineArea) it.next(); - runs = ia.collectInlineRuns ( runs ); + runs = ia.collectInlineRuns (runs); } return runs; } - private static List splitRuns ( List runs ) { + private static List splitRuns (List runs) { List runsNew = new Vector(); - for ( Iterator it = runs.iterator(); it.hasNext(); ) { + for (Iterator it = runs.iterator(); it.hasNext(); ) { InlineRun ir = (InlineRun) it.next(); - if ( ir.isHomogenous() ) { - runsNew.add ( ir ); + if (ir.isHomogenous()) { + runsNew.add (ir); } else { - runsNew.addAll ( ir.split() ); + runsNew.addAll (ir.split()); } } - if ( ! runsNew.equals ( runs ) ) { + if (! runsNew.equals (runs)) { runs = runsNew; } return runs; } - private static int[] computeMinMaxLevel ( List runs, int[] mm ) { - if ( mm == null ) { + private static int[] computeMinMaxLevel (List runs, int[] mm) { + if (mm == null) { mm = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE}; } - for ( Iterator it = runs.iterator(); it.hasNext(); ) { + for (Iterator it = runs.iterator(); it.hasNext(); ) { InlineRun ir = (InlineRun) it.next(); - ir.updateMinMax ( mm ); + ir.updateMinMax (mm); } return mm; } - private static List reorderRuns ( List runs, int level ) { + private static List reorderRuns (List runs, int level) { assert level >= 0; List runsNew = new Vector(); - for ( int i = 0, n = runs.size(); i < n; i++ ) { + for (int i = 0, n = runs.size(); i < n; i++) { InlineRun iri = (InlineRun) runs.get(i); - if ( iri.getMinLevel() < level ) { - runsNew.add ( iri ); + if (iri.getMinLevel() < level) { + runsNew.add (iri); } else { int s = i; int e = s; - while ( e < n ) { + while (e < n) { InlineRun ire = (InlineRun) runs.get(e); - if ( ire.getMinLevel() < level ) { + if (ire.getMinLevel() < level) { break; } else { e++; } } - if ( s < e ) { - runsNew.addAll ( reverseRuns ( runs, s, e ) ); + if (s < e) { + runsNew.addAll (reverseRuns (runs, s, e)); } i = e - 1; } } - if ( ! runsNew.equals ( runs ) ) { + if (! runsNew.equals (runs)) { runs = runsNew; } return runs; } - private static List reverseRuns ( List runs, int s, int e ) { + private static List reverseRuns (List runs, int s, int e) { int n = e - s; - Vector runsNew = new Vector ( n ); - if ( n > 0 ) { - for ( int i = 0; i < n; i++ ) { - int k = ( n - i - 1 ); + Vector runsNew = new Vector (n); + if (n > 0) { + for (int i = 0; i < n; i++) { + int k = (n - i - 1); InlineRun ir = (InlineRun) runs.get(s + k); ir.reverse(); - runsNew.add ( ir ); + runsNew.add (ir); } } return runsNew; } - private static void reverseWords ( List runs, boolean mirror ) { - for ( Iterator it = runs.iterator(); it.hasNext(); ) { + private static void reverseWords (List runs, boolean mirror) { + for (Iterator it = runs.iterator(); it.hasNext(); ) { InlineRun ir = (InlineRun) it.next(); - ir.maybeReverseWord ( mirror ); + ir.maybeReverseWord (mirror); } } - private static List replicateSplitWords ( List runs ) { + private static List replicateSplitWords (List runs) { // [TBD] for each run which inline word area appears multiple times in // runs, replicate that word return runs; } - private static void replaceInlines ( LineArea la, List runs ) { + private static void replaceInlines (LineArea la, List runs) { List inlines = new ArrayList(); - for ( Iterator it = runs.iterator(); it.hasNext(); ) { + for (Iterator it = runs.iterator(); it.hasNext(); ) { InlineRun ir = (InlineRun) it.next(); - inlines.add ( ir.getInline() ); + inlines.add (ir.getInline()); } - la.setInlineAreas ( unflattenInlines ( inlines ) ); + la.setInlineAreas (unflattenInlines (inlines)); } - private static List unflattenInlines ( List inlines ) { - return new UnflattenProcessor ( inlines ) .unflatten(); + private static List unflattenInlines (List inlines) { + return new UnflattenProcessor (inlines) .unflatten(); } - private static void dumpRuns ( String header, List runs ) { - log.debug ( header ); - for ( Iterator it = runs.iterator(); it.hasNext(); ) { + private static void dumpRuns (String header, List runs) { + log.debug (header); + for (Iterator it = runs.iterator(); it.hasNext(); ) { InlineRun ir = (InlineRun) it.next(); - log.debug ( ir ); + log.debug (ir); } } - private static List pruneEmptyRanges ( Stack ranges ) { + private static List pruneEmptyRanges (Stack ranges) { Vector rv = new Vector(); - for ( Iterator it = ranges.iterator(); it.hasNext(); ) { + for (Iterator it = ranges.iterator(); it.hasNext(); ) { DelimitedTextRange r = (DelimitedTextRange) it.next(); - if ( ! r.isEmpty() ) { - rv.add ( r ); + if (! r.isEmpty()) { + rv.add (r); } } return rv; diff --git a/src/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java b/src/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java index 9654b74d5..bbcd4ff7a 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java +++ b/src/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java @@ -54,7 +54,7 @@ public class DelimitedTextRange { * Primary constructor. * @param fn node that generates this text range */ - public DelimitedTextRange ( FONode fn ) { + public DelimitedTextRange (FONode fn) { this.fn = fn; this.buffer = new StringBuffer(); this.intervals = new Vector(); @@ -71,16 +71,16 @@ public class DelimitedTextRange { * @param it character iterator * @param fn node that generates interval being appended */ - public void append ( CharIterator it, FONode fn ) { - if ( it != null ) { + public void append (CharIterator it, FONode fn) { + if (it != null) { int s = buffer.length(); int e = s; - while ( it.hasNext() ) { + while (it.hasNext()) { char c = it.nextChar(); - buffer.append ( c ); + buffer.append (c); e++; } - intervals.add ( new TextInterval ( fn, s, e ) ); + intervals.add (new TextInterval (fn, s, e)); } } /** @@ -88,12 +88,12 @@ public class DelimitedTextRange { * @param c character * @param fn node that generates interval being appended */ - public void append ( char c, FONode fn ) { - if ( c != 0 ) { + public void append (char c, FONode fn) { + if (c != 0) { int s = buffer.length(); int e = s + 1; - buffer.append ( c ); - intervals.add ( new TextInterval ( fn, s, e ) ); + buffer.append (c); + intervals.add (new TextInterval (fn, s, e)); } } /** @@ -108,32 +108,32 @@ public class DelimitedTextRange { */ public void resolve() { WritingModeTraitsGetter tg; - if ( ( tg = WritingModeTraits.getWritingModeTraitsGetter ( getNode() ) ) != null ) { - resolve ( tg.getInlineProgressionDirection() ); + if ((tg = WritingModeTraits.getWritingModeTraitsGetter (getNode())) != null) { + resolve (tg.getInlineProgressionDirection()); } } @Override public String toString() { - StringBuffer sb = new StringBuffer ( "DR: " + fn.getLocalName() + " { <" + CharUtilities.toNCRefs ( buffer.toString() ) + ">" ); - sb.append ( ", intervals <" ); + StringBuffer sb = new StringBuffer ("DR: " + fn.getLocalName() + " { <" + CharUtilities.toNCRefs (buffer.toString()) + ">"); + sb.append (", intervals <"); boolean first = true; - for ( Iterator it = intervals.iterator(); it.hasNext(); ) { + for (Iterator it = intervals.iterator(); it.hasNext(); ) { TextInterval ti = (TextInterval) it.next(); - if ( first ) { + if (first) { first = false; } else { sb.append(','); } - sb.append ( ti.toString() ); + sb.append (ti.toString()); } sb.append("> }"); return sb.toString(); } - private void resolve ( Direction paragraphEmbeddingLevel ) { + private void resolve (Direction paragraphEmbeddingLevel) { int [] levels; - if ( ( levels = UnicodeBidiAlgorithm.resolveLevels ( buffer, paragraphEmbeddingLevel ) ) != null ) { - assignLevels ( levels ); - assignBlockLevel ( paragraphEmbeddingLevel ); + if ((levels = UnicodeBidiAlgorithm.resolveLevels (buffer, paragraphEmbeddingLevel)) != null) { + assignLevels (levels); + assignBlockLevel (paragraphEmbeddingLevel); assignTextLevels(); } } @@ -145,13 +145,13 @@ public class DelimitedTextRange { * @param levels array of levels each corresponding to each index of the delimited * text range */ - private void assignLevels ( int[] levels ) { - Vector intervalsNew = new Vector ( intervals.size() ); - for ( Iterator it = intervals.iterator(); it.hasNext(); ) { + private void assignLevels (int[] levels) { + Vector intervalsNew = new Vector (intervals.size()); + for (Iterator it = intervals.iterator(); it.hasNext(); ) { TextInterval ti = (TextInterval) it.next(); - intervalsNew.addAll ( assignLevels ( ti, levels ) ); + intervalsNew.addAll (assignLevels (ti, levels)); } - if ( ! intervalsNew.equals ( intervals ) ) { + if (! intervalsNew.equals (intervals)) { intervals = intervalsNew; } } @@ -167,30 +167,30 @@ public class DelimitedTextRange { * @return a list of text intervals as described above */ private static final Log log = LogFactory.getLog(BidiResolver.class); // CSOK: ConstantNameCheck - private List assignLevels ( TextInterval ti, int[] levels ) { + private List assignLevels (TextInterval ti, int[] levels) { Vector tiv = new Vector(); FONode fn = ti.getNode(); int fnStart = ti.getStart(); // start of node's text in delimited text range - for ( int i = fnStart, n = ti.getEnd(); i < n; ) { + for (int i = fnStart, n = ti.getEnd(); i < n; ) { int s = i; // inclusive start index of interval in delimited text range int e = s; // exclusive end index of interval in delimited text range int l = levels [ s ]; // current run level - while ( e < n ) { // skip to end of run level or end of interval - if ( levels [ e ] != l ) { + while (e < n) { // skip to end of run level or end of interval + if (levels [ e ] != l) { break; } else { e++; } } - if ( ( ti.getStart() == s ) && ( ti.getEnd() == e ) ) { - ti.setLevel ( l ); // reuse interval, assigning it single level + if ((ti.getStart() == s) && (ti.getEnd() == e)) { + ti.setLevel (l); // reuse interval, assigning it single level } else { - ti = new TextInterval ( fn, fnStart, s, e, l ); // subdivide interval + ti = new TextInterval (fn, fnStart, s, e, l); // subdivide interval } if (log.isDebugEnabled()) { - log.debug ( "AL(" + l + "): " + ti ); + log.debug ("AL(" + l + "): " + ti); } - tiv.add ( ti ); + tiv.add (ti); i = e; } return tiv; @@ -199,25 +199,25 @@ public class DelimitedTextRange { *

Assign resolved levels for each interval to source #PCDATA in the associated FOText.

*/ private void assignTextLevels() { - for ( Iterator it = intervals.iterator(); it.hasNext(); ) { + for (Iterator it = intervals.iterator(); it.hasNext(); ) { TextInterval ti = (TextInterval) it.next(); ti.assignTextLevels(); } } - private void assignBlockLevel ( Direction paragraphEmbeddingLevel ) { - int defaultLevel = ( paragraphEmbeddingLevel == Direction.RL ) ? 1 : 0; - for ( Iterator it = intervals.iterator(); it.hasNext(); ) { + private void assignBlockLevel (Direction paragraphEmbeddingLevel) { + int defaultLevel = (paragraphEmbeddingLevel == Direction.RL) ? 1 : 0; + for (Iterator it = intervals.iterator(); it.hasNext(); ) { TextInterval ti = (TextInterval) it.next(); - assignBlockLevel ( ti.getNode(), defaultLevel ); + assignBlockLevel (ti.getNode(), defaultLevel); } } - private void assignBlockLevel ( FONode node, int defaultLevel ) { - for ( FONode fn = node; fn != null; fn = fn.getParent() ) { - if ( fn instanceof FObj ) { + private void assignBlockLevel (FONode node, int defaultLevel) { + for (FONode fn = node; fn != null; fn = fn.getParent()) { + if (fn instanceof FObj) { FObj fo = (FObj) fn; - if ( fo.isBidiRangeBlockItem() ) { - if ( fo.getBidiLevel() < 0 ) { - fo.setBidiLevel ( defaultLevel ); + if (fo.isBidiRangeBlockItem()) { + if (fo.getBidiLevel() < 0) { + fo.setBidiLevel (defaultLevel); } break; } diff --git a/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java b/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java index 19c4119fd..174576533 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java +++ b/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java @@ -57,12 +57,12 @@ public class InlineRun { * @param inline which generated this inline run * @param levels levels array */ - public InlineRun ( InlineArea inline, int[] levels ) { + public InlineRun (InlineArea inline, int[] levels) { assert inline != null; assert levels != null; this.inline = inline; this.levels = levels; - setMinMax ( levels ); + setMinMax (levels); } /** * Alternate constructor. @@ -70,8 +70,8 @@ public class InlineRun { * @param level for each index * @param count of indices */ - public InlineRun ( InlineArea inline, int level, int count ) { - this ( inline, makeLevels ( level, count ) ); + public InlineRun (InlineArea inline, int level, int count) { + this (inline, makeLevels (level, count)); } /** * Obtain inline area that generated this inline run. @@ -94,16 +94,16 @@ public class InlineRun { public int getMaxLevel() { return maxLevel; } - private void setMinMax ( int[] levels ) { + private void setMinMax (int[] levels) { int mn = Integer.MAX_VALUE; int mx = Integer.MIN_VALUE; - if ( ( levels != null ) && ( levels.length > 0 ) ) { - for ( int i = 0, n = levels.length; i < n; i++ ) { + if ((levels != null) && (levels.length > 0)) { + for (int i = 0, n = levels.length; i < n; i++) { int l = levels [ i ]; - if ( l < mn ) { + if (l < mn) { mn = l; } - if ( l > mx ) { + if (l > mx) { mx = l; } } @@ -126,19 +126,19 @@ public class InlineRun { */ public List split() { List runs = new Vector(); - for ( int i = 0, n = levels.length; i < n; ) { + for (int i = 0, n = levels.length; i < n; ) { int l = levels [ i ]; int s = i; int e = s; - while ( e < n ) { - if ( levels [ e ] != l ) { + while (e < n) { + if (levels [ e ] != l) { break; } else { e++; } } - if ( s < e ) { - runs.add ( new InlineRun ( inline, l, e - s ) ); + if (s < e) { + runs.add (new InlineRun (inline, l, e - s)); } i = e; } @@ -149,11 +149,11 @@ public class InlineRun { * Update a min/max array to correspond with this run's min/max values. * @param mm reference to min/max array */ - public void updateMinMax ( int[] mm ) { - if ( minLevel < mm[0] ) { + public void updateMinMax (int[] mm) { + if (minLevel < mm[0]) { mm[0] = minLevel; } - if ( maxLevel > mm[1] ) { + if (maxLevel > mm[1]) { mm[1] = maxLevel; } } @@ -162,7 +162,7 @@ public class InlineRun { * @return true if run is homogenous and odd (i.e., right to left) */ public boolean maybeNeedsMirroring() { - return ( minLevel == maxLevel ) && ( ( minLevel & 1 ) != 0 ); + return (minLevel == maxLevel) && ((minLevel & 1) != 0); } /** * Reverse run (by incrementing reversal count, not actually reversing). @@ -175,41 +175,41 @@ public class InlineRun { * reversal. * @param mirror if true then also mirror characters */ - public void maybeReverseWord ( boolean mirror ) { - if ( inline instanceof WordArea ) { + public void maybeReverseWord (boolean mirror) { + if (inline instanceof WordArea) { WordArea w = (WordArea) inline; // if not already reversed, then reverse now - if ( ! w.isReversed() ) { - if ( ( reversals & 1 ) != 0 ) { - w.reverse ( mirror ); - } else if ( mirror && maybeNeedsMirroring() ) { + if (! w.isReversed()) { + if ((reversals & 1) != 0) { + w.reverse (mirror); + } else if (mirror && maybeNeedsMirroring()) { w.mirror(); } } } } @Override - public boolean equals ( Object o ) { - if ( o instanceof InlineRun ) { + public boolean equals (Object o) { + if (o instanceof InlineRun) { InlineRun ir = (InlineRun) o; - if ( ir.inline != inline ) { + if (ir.inline != inline) { return false; - } else if ( ir.minLevel != minLevel ) { + } else if (ir.minLevel != minLevel) { return false; - } else if ( ir.maxLevel != maxLevel ) { + } else if (ir.maxLevel != maxLevel) { return false; - } else if ( ( ir.levels != null ) && ( levels != null ) ) { - if ( ir.levels.length != levels.length ) { + } else if ((ir.levels != null) && (levels != null)) { + if (ir.levels.length != levels.length) { return false; } else { - for ( int i = 0, n = levels.length; i < n; i++ ) { - if ( ir.levels[i] != levels[i] ) { + for (int i = 0, n = levels.length; i < n; i++) { + if (ir.levels[i] != levels[i]) { return false; } } return true; } - } else if ( ( ir.levels == null ) && ( levels == null ) ) { + } else if ((ir.levels == null) && (levels == null)) { return true; } else { return false; @@ -220,88 +220,88 @@ public class InlineRun { } @Override public int hashCode() { - int l = ( inline != null ) ? inline.hashCode() : 0; - l = ( l ^ minLevel ) + ( l << 19 ); - l = ( l ^ maxLevel ) + ( l << 11 ); + int l = (inline != null) ? inline.hashCode() : 0; + l = (l ^ minLevel) + (l << 19); + l = (l ^ maxLevel) + (l << 11); return l; } @Override public String toString() { - StringBuffer sb = new StringBuffer( "RR: { type = \'" ); + StringBuffer sb = new StringBuffer("RR: { type = \'"); char c; String content = null; - if ( inline instanceof WordArea ) { + if (inline instanceof WordArea) { c = 'W'; - content = ( (WordArea) inline ) .getWord(); - } else if ( inline instanceof SpaceArea ) { + content = ((WordArea) inline) .getWord(); + } else if (inline instanceof SpaceArea) { c = 'S'; - content = ( (SpaceArea) inline ) .getSpace(); - } else if ( inline instanceof Anchor ) { + content = ((SpaceArea) inline) .getSpace(); + } else if (inline instanceof Anchor) { c = 'A'; - } else if ( inline instanceof Leader ) { + } else if (inline instanceof Leader) { c = 'L'; - } else if ( inline instanceof Space ) { + } else if (inline instanceof Space) { c = 'S'; - } else if ( inline instanceof UnresolvedPageNumber ) { + } else if (inline instanceof UnresolvedPageNumber) { c = '#'; - content = ( (UnresolvedPageNumber) inline ) .getText(); - } else if ( inline instanceof InlineBlockParent ) { + content = ((UnresolvedPageNumber) inline) .getText(); + } else if (inline instanceof InlineBlockParent) { c = 'B'; - } else if ( inline instanceof InlineViewport ) { + } else if (inline instanceof InlineViewport) { c = 'V'; - } else if ( inline instanceof InlineParent ) { + } else if (inline instanceof InlineParent) { c = 'I'; } else { c = '?'; } - sb.append ( c ); - sb.append ( "\', levels = \'" ); - sb.append ( generateLevels ( levels ) ); - sb.append ( "\', min = " ); - sb.append ( minLevel ); - sb.append ( ", max = " ); - sb.append ( maxLevel ); - sb.append ( ", reversals = " ); - sb.append ( reversals ); - sb.append ( ", content = <" ); - sb.append ( CharUtilities.toNCRefs ( content ) ); - sb.append ( "> }" ); + sb.append (c); + sb.append ("\', levels = \'"); + sb.append (generateLevels (levels)); + sb.append ("\', min = "); + sb.append (minLevel); + sb.append (", max = "); + sb.append (maxLevel); + sb.append (", reversals = "); + sb.append (reversals); + sb.append (", content = <"); + sb.append (CharUtilities.toNCRefs (content)); + sb.append ("> }"); return sb.toString(); } - private String generateLevels ( int[] levels ) { + private String generateLevels (int[] levels) { StringBuffer lb = new StringBuffer(); int maxLevel = -1; int numLevels = levels.length; - for ( int i = 0; i < numLevels; i++ ) { + for (int i = 0; i < numLevels; i++) { int l = levels [ i ]; - if ( l > maxLevel ) { + if (l > maxLevel) { maxLevel = l; } } - if ( maxLevel < 0 ) { + if (maxLevel < 0) { // leave level buffer empty - } else if ( maxLevel < 10 ) { + } else if (maxLevel < 10) { // use string of decimal digits - for ( int i = 0; i < numLevels; i++ ) { - lb.append ( (char) ( '0' + levels [ i ] ) ); + for (int i = 0; i < numLevels; i++) { + lb.append ((char) ('0' + levels [ i ])); } } else { // use comma separated list boolean first = true; - for ( int i = 0; i < numLevels; i++ ) { - if ( first ) { + for (int i = 0; i < numLevels; i++) { + if (first) { first = false; } else { lb.append(','); } - lb.append ( levels [ i ] ); + lb.append (levels [ i ]); } } return lb.toString(); } - private static int[] makeLevels ( int level, int count ) { + private static int[] makeLevels (int level, int count) { int[] levels = new int [ count ]; - Arrays.fill ( levels, level ); + Arrays.fill (levels, level); return levels; } } diff --git a/src/java/org/apache/fop/complexscripts/bidi/TextInterval.java b/src/java/org/apache/fop/complexscripts/bidi/TextInterval.java index 6130da97b..ec1fdeec9 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/TextInterval.java +++ b/src/java/org/apache/fop/complexscripts/bidi/TextInterval.java @@ -42,10 +42,10 @@ class TextInterval { private int start; // starting index within delimited text range private int end; // ending index within delimited text range private int level; // resolved level or default (-1) - TextInterval ( FONode fn, int start, int end ) { - this ( fn, start, start, end, -1 ); + TextInterval (FONode fn, int start, int end) { + this (fn, start, start, end, -1); } - TextInterval ( FONode fn, int textStart, int start, int end, int level ) { + TextInterval (FONode fn, int textStart, int start, int end, int level) { this.fn = fn; this.textStart = textStart; this.start = start; @@ -67,42 +67,42 @@ class TextInterval { int getLevel() { return level; } - void setLevel ( int level ) { + void setLevel (int level) { this.level = level; } public int length() { return end - start; } public String getText() { - if ( fn instanceof FOText ) { - return ( (FOText) fn ) .getCharSequence() .toString(); - } else if ( fn instanceof Character ) { - return new String ( new char[] {( (Character) fn ) .getCharacter()} ); + if (fn instanceof FOText) { + return ((FOText) fn) .getCharSequence() .toString(); + } else if (fn instanceof Character) { + return new String (new char[] {((Character) fn) .getCharacter()}); } else { return null; } } public void assignTextLevels() { - if ( fn instanceof FOText ) { - ( (FOText) fn ) .setBidiLevel ( level, start - textStart, end - textStart ); - } else if ( fn instanceof Character ) { - ( (Character) fn ) .setBidiLevel ( level ); - } else if ( fn instanceof AbstractPageNumberCitation ) { - ( (AbstractPageNumberCitation) fn ) .setBidiLevel ( level ); - } else if ( fn instanceof AbstractGraphics ) { - ( (AbstractGraphics) fn ) .setBidiLevel ( level ); - } else if ( fn instanceof Leader ) { - ( (Leader) fn ) .setBidiLevel ( level ); + if (fn instanceof FOText) { + ((FOText) fn) .setBidiLevel (level, start - textStart, end - textStart); + } else if (fn instanceof Character) { + ((Character) fn) .setBidiLevel (level); + } else if (fn instanceof AbstractPageNumberCitation) { + ((AbstractPageNumberCitation) fn) .setBidiLevel (level); + } else if (fn instanceof AbstractGraphics) { + ((AbstractGraphics) fn) .setBidiLevel (level); + } else if (fn instanceof Leader) { + ((Leader) fn) .setBidiLevel (level); } } - public boolean equals ( Object o ) { - if ( o instanceof TextInterval ) { + public boolean equals (Object o) { + if (o instanceof TextInterval) { TextInterval ti = (TextInterval) o; - if ( ti.getNode() != fn ) { + if (ti.getNode() != fn) { return false; - } else if ( ti.getStart() != start ) { + } else if (ti.getStart() != start) { return false; - } else if ( ti.getEnd() != end ) { + } else if (ti.getEnd() != end) { return false; } else { return true; @@ -112,31 +112,31 @@ class TextInterval { } } public int hashCode() { - int l = ( fn != null ) ? fn.hashCode() : 0; - l = ( l ^ start ) + ( l << 19 ); - l = ( l ^ end ) + ( l << 11 ); + int l = (fn != null) ? fn.hashCode() : 0; + l = (l ^ start) + (l << 19); + l = (l ^ end) + (l << 11); return l; } public String toString() { StringBuffer sb = new StringBuffer(); char c; - if ( fn instanceof FOText ) { + if (fn instanceof FOText) { c = 'T'; - } else if ( fn instanceof Character ) { + } else if (fn instanceof Character) { c = 'C'; - } else if ( fn instanceof BidiOverride ) { + } else if (fn instanceof BidiOverride) { c = 'B'; - } else if ( fn instanceof AbstractPageNumberCitation ) { + } else if (fn instanceof AbstractPageNumberCitation) { c = '#'; - } else if ( fn instanceof AbstractGraphics ) { + } else if (fn instanceof AbstractGraphics) { c = 'G'; - } else if ( fn instanceof Leader ) { + } else if (fn instanceof Leader) { c = 'L'; } else { c = '?'; } - sb.append ( c ); - sb.append ( "[" + start + "," + end + "][" + textStart + "](" + level + ")" ); + sb.append (c); + sb.append ("[" + start + "," + end + "][" + textStart + "](" + level + ")"); return sb.toString(); } } diff --git a/src/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java b/src/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java index eb842a771..d20bd692f 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java +++ b/src/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java @@ -54,7 +54,7 @@ class UnflattenProcessor { private TextArea tcNew; // new text area container being constructed private Stack icOrig; // stack of original inline parent containers private Stack icNew; // stack of new inline parent containers being constructed - UnflattenProcessor ( List inlines ) { + UnflattenProcessor (List inlines) { this.il = inlines; this.ilNew = new ArrayList(); this.iaLevelLast = -1; @@ -62,90 +62,90 @@ class UnflattenProcessor { this.icNew = new Stack(); } List unflatten() { - if ( il != null ) { - for ( Iterator it = il.iterator(); it.hasNext(); ) { - process ( it.next() ); + if (il != null) { + for (Iterator it = il.iterator(); it.hasNext(); ) { + process (it.next()); } } finishAll(); return ilNew; } - private void process ( InlineArea ia ) { - process ( findInlineContainers ( ia ), findTextContainer ( ia ), ia ); + private void process (InlineArea ia) { + process (findInlineContainers (ia), findTextContainer (ia), ia); } - private void process ( List ich, TextArea tc, InlineArea ia ) { - if ( ( tcNew == null ) || ( tc != tcNew ) ) { - maybeFinishTextContainer ( tc, ia ); - maybeFinishInlineContainers ( ich, tc, ia ); - update ( ich, tc, ia ); + private void process (List ich, TextArea tc, InlineArea ia) { + if ((tcNew == null) || (tc != tcNew)) { + maybeFinishTextContainer (tc, ia); + maybeFinishInlineContainers (ich, tc, ia); + update (ich, tc, ia); } else { // skip inline area whose text container is the current new text container, // which occurs in the context of the inline runs produced by a filled area } } - private boolean shouldFinishTextContainer ( TextArea tc, InlineArea ia ) { - if ( ( tcOrig != null ) && ( tc != tcOrig ) ) { + private boolean shouldFinishTextContainer (TextArea tc, InlineArea ia) { + if ((tcOrig != null) && (tc != tcOrig)) { return true; - } else if ( ( iaLevelLast != -1 ) && ( ia.getBidiLevel() != iaLevelLast ) ) { + } else if ((iaLevelLast != -1) && (ia.getBidiLevel() != iaLevelLast)) { return true; } else { return false; } } private void finishTextContainer() { - finishTextContainer ( null, null ); + finishTextContainer (null, null); } - private void finishTextContainer ( TextArea tc, InlineArea ia ) { - if ( tcNew != null ) { - updateIPD ( tcNew ); - if ( ! icNew.empty() ) { - icNew.peek().addChildArea ( tcNew ); + private void finishTextContainer (TextArea tc, InlineArea ia) { + if (tcNew != null) { + updateIPD (tcNew); + if (! icNew.empty()) { + icNew.peek().addChildArea (tcNew); } else { - ilNew.add ( tcNew ); + ilNew.add (tcNew); } } tcNew = null; } - private void maybeFinishTextContainer ( TextArea tc, InlineArea ia ) { - if ( shouldFinishTextContainer ( tc, ia ) ) { - finishTextContainer ( tc, ia ); + private void maybeFinishTextContainer (TextArea tc, InlineArea ia) { + if (shouldFinishTextContainer (tc, ia)) { + finishTextContainer (tc, ia); } } - private boolean shouldFinishInlineContainer ( List ich, TextArea tc, InlineArea ia ) { - if ( ( ich == null ) || ich.isEmpty() ) { + private boolean shouldFinishInlineContainer (List ich, TextArea tc, InlineArea ia) { + if ((ich == null) || ich.isEmpty()) { return ! icOrig.empty(); } else { - if ( ! icOrig.empty() ) { + if (! icOrig.empty()) { InlineParent ic = ich.get(0); InlineParent ic0 = icOrig.peek(); - return ( ic != ic0 ) && ! isInlineParentOf ( ic, ic0 ); + return (ic != ic0) && ! isInlineParentOf (ic, ic0); } else { return false; } } } private void finishInlineContainer() { - finishInlineContainer ( null, null, null ); + finishInlineContainer (null, null, null); } - private void finishInlineContainer ( List ich, TextArea tc, InlineArea ia ) { - if ( ( ich != null ) && ! ich.isEmpty() ) { // finish non-matching inner inline container(s) - for ( Iterator it = ich.iterator(); it.hasNext(); ) { + private void finishInlineContainer (List ich, TextArea tc, InlineArea ia) { + if ((ich != null) && ! ich.isEmpty()) { // finish non-matching inner inline container(s) + for (Iterator it = ich.iterator(); it.hasNext(); ) { InlineParent ic = it.next(); InlineParent ic0 = icOrig.empty() ? null : icOrig.peek(); - if ( ic0 == null ) { + if (ic0 == null) { assert icNew.empty(); - } else if ( ic != ic0 ) { + } else if (ic != ic0) { assert ! icNew.empty(); InlineParent icO0 = icOrig.pop(); InlineParent icN0 = icNew.pop(); assert icO0 != null; assert icN0 != null; - if ( icNew.empty() ) { - ilNew.add ( icN0 ); + if (icNew.empty()) { + ilNew.add (icN0); } else { - icNew.peek().addChildArea ( icN0 ); + icNew.peek().addChildArea (icN0); } - if ( ! icOrig.empty() && ( icOrig.peek() == ic ) ) { + if (! icOrig.empty() && (icOrig.peek() == ic)) { break; } } else { @@ -153,184 +153,184 @@ class UnflattenProcessor { } } } else { // finish all inline containers - while ( ! icNew.empty() ) { + while (! icNew.empty()) { InlineParent icO0 = icOrig.pop(); InlineParent icN0 = icNew.pop(); assert icO0 != null; assert icN0 != null; - if ( icNew.empty() ) { - ilNew.add ( icN0 ); + if (icNew.empty()) { + ilNew.add (icN0); } else { - icNew.peek().addChildArea ( icN0 ); + icNew.peek().addChildArea (icN0); } } } } - private void maybeFinishInlineContainers ( List ich, TextArea tc, InlineArea ia ) { - if ( shouldFinishInlineContainer ( ich, tc, ia ) ) { - finishInlineContainer ( ich, tc, ia ); + private void maybeFinishInlineContainers (List ich, TextArea tc, InlineArea ia) { + if (shouldFinishInlineContainer (ich, tc, ia)) { + finishInlineContainer (ich, tc, ia); } } private void finishAll() { finishTextContainer(); finishInlineContainer(); } - private void update ( List ich, TextArea tc, InlineArea ia ) { - if ( ! alreadyUnflattened ( ia ) ) { - if ( ( ich != null ) && ! ich.isEmpty() ) { - pushInlineContainers ( ich ); + private void update (List ich, TextArea tc, InlineArea ia) { + if (! alreadyUnflattened (ia)) { + if ((ich != null) && ! ich.isEmpty()) { + pushInlineContainers (ich); } - if ( tc != null ) { - pushTextContainer ( tc, ia ); + if (tc != null) { + pushTextContainer (tc, ia); } else { - pushNonTextInline ( ia ); + pushNonTextInline (ia); } iaLevelLast = ia.getBidiLevel(); tcOrig = tc; - } else if ( tcNew != null ) { + } else if (tcNew != null) { finishTextContainer(); tcOrig = null; } else { tcOrig = null; } } - private boolean alreadyUnflattened ( InlineArea ia ) { - for ( Iterator it = ilNew.iterator(); it.hasNext(); ) { - if ( ia.isAncestorOrSelf ( it.next() ) ) { + private boolean alreadyUnflattened (InlineArea ia) { + for (Iterator it = ilNew.iterator(); it.hasNext(); ) { + if (ia.isAncestorOrSelf (it.next())) { return true; } } return false; } - private void pushInlineContainers ( List ich ) { + private void pushInlineContainers (List ich) { LinkedList icl = new LinkedList(); - for ( Iterator it = ich.iterator(); it.hasNext(); ) { + for (Iterator it = ich.iterator(); it.hasNext(); ) { InlineParent ic = it.next(); - if ( icOrig.search ( ic ) >= 0 ) { + if (icOrig.search (ic) >= 0) { break; } else { - icl.addFirst ( ic ); + icl.addFirst (ic); } } - for ( Iterator it = icl.iterator(); it.hasNext(); ) { + for (Iterator it = icl.iterator(); it.hasNext(); ) { InlineParent ic = it.next(); - icOrig.push ( ic ); - icNew.push ( generateInlineContainer ( ic ) ); + icOrig.push (ic); + icNew.push (generateInlineContainer (ic)); } } - private void pushTextContainer ( TextArea tc, InlineArea ia ) { - if ( tc instanceof UnresolvedPageNumber ) { + private void pushTextContainer (TextArea tc, InlineArea ia) { + if (tc instanceof UnresolvedPageNumber) { tcNew = tc; } else { - if ( tcNew == null ) { - tcNew = generateTextContainer ( tc ); + if (tcNew == null) { + tcNew = generateTextContainer (tc); } - tcNew.addChildArea ( ia ); + tcNew.addChildArea (ia); } } - private void pushNonTextInline ( InlineArea ia ) { - if ( icNew.empty() ) { - ilNew.add ( ia ); + private void pushNonTextInline (InlineArea ia) { + if (icNew.empty()) { + ilNew.add (ia); } else { - icNew.peek().addChildArea ( ia ); + icNew.peek().addChildArea (ia); } } - private InlineParent generateInlineContainer ( InlineParent i ) { - if ( i instanceof BasicLinkArea ) { - return generateBasicLinkArea ( (BasicLinkArea) i ); - } else if ( i instanceof FilledArea ) { - return generateFilledArea ( (FilledArea) i ); + private InlineParent generateInlineContainer (InlineParent i) { + if (i instanceof BasicLinkArea) { + return generateBasicLinkArea ((BasicLinkArea) i); + } else if (i instanceof FilledArea) { + return generateFilledArea ((FilledArea) i); } else { - return generateInlineContainer0 ( i ); + return generateInlineContainer0 (i); } } - private InlineParent generateBasicLinkArea ( BasicLinkArea l ) { + private InlineParent generateBasicLinkArea (BasicLinkArea l) { BasicLinkArea lc = new BasicLinkArea(); - if ( l != null ) { - initializeInlineContainer ( lc, l ); - initializeLinkArea ( lc, l ); + if (l != null) { + initializeInlineContainer (lc, l); + initializeLinkArea (lc, l); } return lc; } - private void initializeLinkArea ( BasicLinkArea lc, BasicLinkArea l ) { + private void initializeLinkArea (BasicLinkArea lc, BasicLinkArea l) { assert lc != null; assert l != null; LinkResolver r = l.getResolver(); - if ( r != null ) { + if (r != null) { String[] idrefs = r.getIDRefs(); - if ( idrefs.length > 0 ) { + if (idrefs.length > 0) { String idref = idrefs[0]; - LinkResolver lr = new LinkResolver ( idref, lc ); - lc.setResolver ( lr ); - r.addDependent ( lr ); + LinkResolver lr = new LinkResolver (idref, lc); + lc.setResolver (lr); + r.addDependent (lr); } } } - private InlineParent generateFilledArea ( FilledArea f ) { + private InlineParent generateFilledArea (FilledArea f) { FilledArea fc = new FilledArea(); - if ( f != null ) { - initializeInlineContainer ( fc, f ); - initializeFilledArea ( fc, f ); + if (f != null) { + initializeInlineContainer (fc, f); + initializeFilledArea (fc, f); } return fc; } - private void initializeFilledArea ( FilledArea fc, FilledArea f ) { + private void initializeFilledArea (FilledArea fc, FilledArea f) { assert fc != null; assert f != null; - fc.setIPD ( f.getIPD() ); - fc.setUnitWidth ( f.getUnitWidth() ); - fc.setAdjustingInfo( f.getAdjustingInfo() ); + fc.setIPD (f.getIPD()); + fc.setUnitWidth (f.getUnitWidth()); + fc.setAdjustingInfo(f.getAdjustingInfo()); } - private InlineParent generateInlineContainer0 ( InlineParent i ) { + private InlineParent generateInlineContainer0 (InlineParent i) { InlineParent ic = new InlineParent(); - if ( i != null ) { - initializeInlineContainer ( ic, i ); + if (i != null) { + initializeInlineContainer (ic, i); } return ic; } - private void initializeInlineContainer ( InlineParent ic, InlineParent i ) { + private void initializeInlineContainer (InlineParent ic, InlineParent i) { assert ic != null; assert i != null; - ic.setTraits ( i.getTraits() ); - ic.setBPD ( i.getBPD() ); - ic.setBlockProgressionOffset ( i.getBlockProgressionOffset() ); + ic.setTraits (i.getTraits()); + ic.setBPD (i.getBPD()); + ic.setBlockProgressionOffset (i.getBlockProgressionOffset()); } - private TextArea generateTextContainer ( TextArea t ) { + private TextArea generateTextContainer (TextArea t) { TextArea tc = new TextArea(); - if ( t != null ) { - tc.setTraits ( t.getTraits() ); - tc.setBPD ( t.getBPD() ); - tc.setBlockProgressionOffset ( t.getBlockProgressionOffset() ); - tc.setBaselineOffset ( t.getBaselineOffset() ); - tc.setTextWordSpaceAdjust ( t.getTextWordSpaceAdjust() ); - tc.setTextLetterSpaceAdjust ( t.getTextLetterSpaceAdjust() ); + if (t != null) { + tc.setTraits (t.getTraits()); + tc.setBPD (t.getBPD()); + tc.setBlockProgressionOffset (t.getBlockProgressionOffset()); + tc.setBaselineOffset (t.getBaselineOffset()); + tc.setTextWordSpaceAdjust (t.getTextWordSpaceAdjust()); + tc.setTextLetterSpaceAdjust (t.getTextLetterSpaceAdjust()); } return tc; } - private void updateIPD ( TextArea tc ) { + private void updateIPD (TextArea tc) { int numAdjustable = 0; - for ( Iterator it = tc.getChildAreas().iterator(); it.hasNext(); ) { + for (Iterator it = tc.getChildAreas().iterator(); it.hasNext(); ) { InlineArea ia = (InlineArea) it.next(); - if ( ia instanceof SpaceArea ) { + if (ia instanceof SpaceArea) { SpaceArea sa = (SpaceArea) ia; - if ( sa.isAdjustable() ) { + if (sa.isAdjustable()) { numAdjustable++; } } } - if ( numAdjustable > 0 ) { - tc.setIPD ( tc.getIPD() + ( numAdjustable * tc.getTextWordSpaceAdjust() ) ); + if (numAdjustable > 0) { + tc.setIPD (tc.getIPD() + (numAdjustable * tc.getTextWordSpaceAdjust())); } } - private TextArea findTextContainer ( InlineArea ia ) { + private TextArea findTextContainer (InlineArea ia) { assert ia != null; TextArea t = null; - while ( t == null ) { - if ( ia instanceof TextArea ) { + while (t == null) { + if (ia instanceof TextArea) { t = (TextArea) ia; } else { Area p = ia.getParentArea(); - if ( p instanceof InlineArea ) { + if (p instanceof InlineArea) { ia = (InlineArea) p; } else { break; @@ -339,23 +339,23 @@ class UnflattenProcessor { } return t; } - private List findInlineContainers ( InlineArea ia ) { + private List findInlineContainers (InlineArea ia) { assert ia != null; List ich = new ArrayList(); Area a = ia.getParentArea(); - while ( a != null ) { - if ( a instanceof InlineArea ) { - if ( ( a instanceof InlineParent ) && ! ( a instanceof TextArea ) ) { - ich.add ( (InlineParent) a ); + while (a != null) { + if (a instanceof InlineArea) { + if ((a instanceof InlineParent) && ! (a instanceof TextArea)) { + ich.add ((InlineParent) a); } - a = ( (InlineArea) a ) .getParentArea(); + a = ((InlineArea) a) .getParentArea(); } else { a = null; } } return ich; } - private boolean isInlineParentOf ( InlineParent ic0, InlineParent ic1 ) { + private boolean isInlineParentOf (InlineParent ic0, InlineParent ic1) { assert ic0 != null; return ic0.getParentArea() == ic1; } diff --git a/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java b/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java index a12d24aae..75b6d19ff 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java +++ b/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java @@ -59,10 +59,10 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @param cs input character sequence representing a UTF-16 encoded string * @param defaultLevel the default paragraph level, which must be zero (LR) or one (RL) */ - public static int[] resolveLevels ( CharSequence cs, Direction defaultLevel ) { + public static int[] resolveLevels (CharSequence cs, Direction defaultLevel) { int[] chars = new int [ cs.length() ]; - if ( convertToScalar ( cs, chars ) || ( defaultLevel == Direction.RL ) ) { - return resolveLevels ( chars, ( defaultLevel == Direction.RL ) ? 1 : 0, new int [ chars.length ] ); + if (convertToScalar (cs, chars) || (defaultLevel == Direction.RL)) { + return resolveLevels (chars, (defaultLevel == Direction.RL) ? 1 : 0, new int [ chars.length ]); } else { return null; } @@ -78,8 +78,8 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @param defaultLevel the default paragraph level, which must be zero (LR) or one (RL) * @param levels array to receive levels, one for each character in chars array */ - public static int[] resolveLevels ( int[] chars, int defaultLevel, int[] levels ) { - return resolveLevels ( chars, getClasses ( chars ), defaultLevel, levels, false ); + public static int[] resolveLevels (int[] chars, int defaultLevel, int[] levels) { + return resolveLevels (chars, getClasses (chars), defaultLevel, levels, false); } /** @@ -94,47 +94,47 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @param levels array to receive levels, one for each character in chars array * @param useRuleL1 true if rule L1 should be used */ - public static int[] resolveLevels ( int[] chars, int[] classes, int defaultLevel, int[] levels, boolean useRuleL1 ) { + public static int[] resolveLevels (int[] chars, int[] classes, int defaultLevel, int[] levels, boolean useRuleL1) { int[] ica = classes; - int[] wca = copySequence ( ica ); + int[] wca = copySequence (ica); int[] ea = new int [ levels.length ]; - resolveExplicit ( wca, defaultLevel, ea ); - resolveRuns ( wca, defaultLevel, ea, levelsFromEmbeddings ( ea, levels ) ); - if ( useRuleL1 ) { - resolveSeparators ( ica, wca, defaultLevel, levels ); + resolveExplicit (wca, defaultLevel, ea); + resolveRuns (wca, defaultLevel, ea, levelsFromEmbeddings (ea, levels)); + if (useRuleL1) { + resolveSeparators (ica, wca, defaultLevel, levels); } - dump ( "RL: CC(" + ( ( chars != null ) ? chars.length : -1 ) + ")", chars, classes, defaultLevel, levels ); + dump ("RL: CC(" + ((chars != null) ? chars.length : -1) + ")", chars, classes, defaultLevel, levels); return levels; } - private static int[] copySequence ( int[] ta ) { + private static int[] copySequence (int[] ta) { int[] na = new int [ ta.length ]; - System.arraycopy ( ta, 0, na, 0, na.length ); + System.arraycopy (ta, 0, na, 0, na.length); return na; } - private static void resolveExplicit ( int[] wca, int defaultLevel, int[] ea ) { + private static void resolveExplicit (int[] wca, int defaultLevel, int[] ea) { int[] es = new int [ MAX_LEVELS ]; /* embeddings stack */ int ei = 0; /* embeddings stack index */ int ec = defaultLevel; /* current embedding level */ - for ( int i = 0, n = wca.length; i < n; i++ ) { + for (int i = 0, n = wca.length; i < n; i++) { int bc = wca [ i ]; /* bidi class of current char */ int el; /* embedding level to assign to current char */ - switch ( bc ) { + switch (bc) { case LRE: // start left-to-right embedding case RLE: // start right-to-left embedding case LRO: // start left-to-right override case RLO: // start right-to-left override { int en; /* new embedding level */ - if ( ( bc == RLE ) || ( bc == RLO ) ) { - en = ( ( ec & ~OVERRIDE ) + 1 ) | 1; + if ((bc == RLE) || (bc == RLO)) { + en = ((ec & ~OVERRIDE) + 1) | 1; } else { - en = ( ( ec & ~OVERRIDE ) + 2 ) & ~1; + en = ((ec & ~OVERRIDE) + 2) & ~1; } - if ( en < ( MAX_LEVELS + 1 ) ) { + if (en < (MAX_LEVELS + 1)) { es [ ei++ ] = ec; - if ( ( bc == LRO ) || ( bc == RLO ) ) { + if ((bc == LRO) || (bc == RLO)) { ec = en | OVERRIDE; } else { ec = en & ~OVERRIDE; @@ -148,7 +148,7 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { case PDF: // pop directional formatting { el = ec; - if ( ei > 0 ) { + if (ei > 0) { ec = es [ --ei ]; } else { // ignore isolated PDF @@ -167,15 +167,15 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { break; } } - switch ( bc ) { + switch (bc) { case BN: break; case LRE: case RLE: case LRO: case RLO: case PDF: wca [ i ] = BN; break; default: - if ( ( el & OVERRIDE ) != 0 ) { - wca [ i ] = directionOfLevel ( el ); + if ((el & OVERRIDE) != 0) { + wca [ i ] = directionOfLevel (el); } break; } @@ -183,38 +183,38 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static int directionOfLevel ( int level ) { - return ( ( level & 1 ) != 0 ) ? R : L; + private static int directionOfLevel (int level) { + return ((level & 1) != 0) ? R : L; } - private static int levelOfEmbedding ( int embedding ) { + private static int levelOfEmbedding (int embedding) { return embedding & ~OVERRIDE; } - private static int[] levelsFromEmbeddings ( int[] ea, int[] la ) { + private static int[] levelsFromEmbeddings (int[] ea, int[] la) { assert ea != null; assert la != null; assert la.length == ea.length; - for ( int i = 0, n = la.length; i < n; i++ ) { - la [ i ] = levelOfEmbedding ( ea [ i ] ); + for (int i = 0, n = la.length; i < n; i++) { + la [ i ] = levelOfEmbedding (ea [ i ]); } return la; } - private static void resolveRuns ( int[] wca, int defaultLevel, int[] ea, int[] la ) { - if ( la.length != wca.length ) { - throw new IllegalArgumentException ( "levels sequence length must match classes sequence length" ); - } else if ( la.length != ea.length ) { - throw new IllegalArgumentException ( "levels sequence length must match embeddings sequence length" ); + private static void resolveRuns (int[] wca, int defaultLevel, int[] ea, int[] la) { + if (la.length != wca.length) { + throw new IllegalArgumentException ("levels sequence length must match classes sequence length"); + } else if (la.length != ea.length) { + throw new IllegalArgumentException ("levels sequence length must match embeddings sequence length"); } else { - for ( int i = 0, n = ea.length, lPrev = defaultLevel; i < n; ) { + for (int i = 0, n = ea.length, lPrev = defaultLevel; i < n; ) { int s = i; int e = s; - int l = findNextNonRetainedFormattingLevel ( wca, ea, s, lPrev ); - while ( e < n ) { - if ( la [ e ] != l ) { - if ( startsWithRetainedFormattingRun ( wca, ea, e ) ) { - e += getLevelRunLength ( ea, e ); + int l = findNextNonRetainedFormattingLevel (wca, ea, s, lPrev); + while (e < n) { + if (la [ e ] != l) { + if (startsWithRetainedFormattingRun (wca, ea, e)) { + e += getLevelRunLength (ea, e); } else { break; } @@ -222,34 +222,34 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { e++; } } - lPrev = resolveRun ( wca, defaultLevel, ea, la, s, e, l, lPrev ); + lPrev = resolveRun (wca, defaultLevel, ea, la, s, e, l, lPrev); i = e; } } } - private static int findNextNonRetainedFormattingLevel ( int[] wca, int[] ea, int start, int lPrev ) { + private static int findNextNonRetainedFormattingLevel (int[] wca, int[] ea, int start, int lPrev) { int s = start; int e = wca.length; - while ( s < e ) { - if ( startsWithRetainedFormattingRun ( wca, ea, s ) ) { - s += getLevelRunLength ( ea, s ); + while (s < e) { + if (startsWithRetainedFormattingRun (wca, ea, s)) { + s += getLevelRunLength (ea, s); } else { break; } } - if ( s < e ) { - return levelOfEmbedding ( ea [ s ] ); + if (s < e) { + return levelOfEmbedding (ea [ s ]); } else { return lPrev; } } - private static int getLevelRunLength ( int[] ea, int start ) { + private static int getLevelRunLength (int[] ea, int start) { assert start < ea.length; int nl = 0; - for ( int s = start, e = ea.length, l0 = levelOfEmbedding ( ea [ start ] ); s < e; s++ ) { - if ( levelOfEmbedding ( ea [ s ] ) == l0 ) { + for (int s = start, e = ea.length, l0 = levelOfEmbedding (ea [ start ]); s < e; s++) { + if (levelOfEmbedding (ea [ s ]) == l0) { nl++; } else { break; @@ -258,21 +258,21 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { return nl; } - private static boolean startsWithRetainedFormattingRun ( int[] wca, int[] ea, int start ) { - int nl = getLevelRunLength ( ea, start ); - if ( nl > 0 ) { - int nc = getRetainedFormattingRunLength ( wca, start ); - return ( nc >= nl ); + private static boolean startsWithRetainedFormattingRun (int[] wca, int[] ea, int start) { + int nl = getLevelRunLength (ea, start); + if (nl > 0) { + int nc = getRetainedFormattingRunLength (wca, start); + return (nc >= nl); } else { return false; } } - private static int getRetainedFormattingRunLength ( int[] wca, int start ) { + private static int getRetainedFormattingRunLength (int[] wca, int start) { assert start < wca.length; int nc = 0; - for ( int s = start, e = wca.length; s < e; s++ ) { - if ( wca [ s ] == BidiConstants.BN ) { + for (int s = start, e = wca.length; s < e; s++) { + if (wca [ s ] == BidiConstants.BN) { nc++; } else { break; @@ -281,209 +281,209 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { return nc; } - private static int resolveRun ( int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int levelPrev ) { + private static int resolveRun (int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int levelPrev) { // determine start of run direction - int sor = directionOfLevel ( max ( levelPrev, level ) ); + int sor = directionOfLevel (max (levelPrev, level)); // determine end of run direction int le = -1; - if ( end == wca.length ) { - le = max ( level, defaultLevel ); + if (end == wca.length) { + le = max (level, defaultLevel); } else { - for ( int i = end; i < wca.length; i++ ) { - if ( wca [ i ] != BidiConstants.BN ) { - le = max ( level, la [ i ] ); + for (int i = end; i < wca.length; i++) { + if (wca [ i ] != BidiConstants.BN) { + le = max (level, la [ i ]); break; } } - if ( le < 0 ) { - le = max ( level, defaultLevel ); + if (le < 0) { + le = max (level, defaultLevel); } } - int eor = directionOfLevel ( le ); + int eor = directionOfLevel (le); if (log.isDebugEnabled()) { - log.debug ( "BR[" + padLeft ( start, 3 ) + "," + padLeft ( end, 3 ) + "] :" + padLeft ( level, 2 ) + ": SOR(" + getClassName(sor) + "), EOR(" + getClassName(eor) + ")" ); + log.debug ("BR[" + padLeft (start, 3) + "," + padLeft (end, 3) + "] :" + padLeft (level, 2) + ": SOR(" + getClassName(sor) + "), EOR(" + getClassName(eor) + ")"); } - resolveWeak ( wca, defaultLevel, ea, la, start, end, level, sor, eor ); - resolveNeutrals ( wca, defaultLevel, ea, la, start, end, level, sor, eor ); - resolveImplicit ( wca, defaultLevel, ea, la, start, end, level, sor, eor ); + resolveWeak (wca, defaultLevel, ea, la, start, end, level, sor, eor); + resolveNeutrals (wca, defaultLevel, ea, la, start, end, level, sor, eor); + resolveImplicit (wca, defaultLevel, ea, la, start, end, level, sor, eor); // if this run is all retained formatting, then return prior level, otherwise this run's level - return isRetainedFormatting ( wca, start, end ) ? levelPrev : level; + return isRetainedFormatting (wca, start, end) ? levelPrev : level; } - private static void resolveWeak ( int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor ) { + private static void resolveWeak (int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor) { // W1 - X BN* NSM -> X BN* X - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( bc == NSM ) { + if (bc == NSM) { wca [ i ] = bcPrev; - } else if ( bc != BN ) { + } else if (bc != BN) { bcPrev = bc; } } // W2 - AL ... EN -> AL ... AN - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( bc == EN ) { - if ( bcPrev == AL ) { + if (bc == EN) { + if (bcPrev == AL) { wca [ i ] = AN; } - } else if ( isStrong ( bc ) ) { + } else if (isStrong (bc)) { bcPrev = bc; } } // W3 - AL -> R - for ( int i = start, n = end; i < n; i++ ) { + for (int i = start, n = end; i < n; i++) { int bc = wca [ i ]; - if ( bc == AL ) { + if (bc == AL) { wca [ i ] = R; } } // W4 - EN BN* ES BN* EN -> EN BN* EN BN* EN; XN BN* CS BN* XN -> XN BN* XN BN* XN - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( bc == ES ) { + if (bc == ES) { int bcNext = eor; - for ( int j = i + 1; j < n; j++ ) { - if ( ( bc = wca [ j ] ) != BN ) { + for (int j = i + 1; j < n; j++) { + if ((bc = wca [ j ]) != BN) { bcNext = bc; break; } } - if ( ( bcPrev == EN ) && ( bcNext == EN ) ) { + if ((bcPrev == EN) && (bcNext == EN)) { wca [ i ] = EN; } - } else if ( bc == CS ) { + } else if (bc == CS) { int bcNext = eor; - for ( int j = i + 1; j < n; j++ ) { - if ( ( bc = wca [ j ] ) != BN ) { + for (int j = i + 1; j < n; j++) { + if ((bc = wca [ j ]) != BN) { bcNext = bc; break; } } - if ( ( bcPrev == EN ) && ( bcNext == EN ) ) { + if ((bcPrev == EN) && (bcNext == EN)) { wca [ i ] = EN; - } else if ( ( bcPrev == AN ) && ( bcNext == AN ) ) { + } else if ((bcPrev == AN) && (bcNext == AN)) { wca [ i ] = AN; } } - if ( bc != BN ) { + if (bc != BN) { bcPrev = bc; } } // W5 - EN (ET|BN)* -> EN (EN|BN)*; (ET|BN)* EN -> (EN|BN)* EN - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( bc == ET ) { + if (bc == ET) { int bcNext = eor; - for ( int j = i + 1; j < n; j++ ) { + for (int j = i + 1; j < n; j++) { bc = wca [ j ]; - if ( ( bc != BN ) && ( bc != ET ) ) { + if ((bc != BN) && (bc != ET)) { bcNext = bc; break; } } - if ( ( bcPrev == EN ) || ( bcNext == EN ) ) { + if ((bcPrev == EN) || (bcNext == EN)) { wca [ i ] = EN; } - } else if ( ( bc != BN ) && ( bc != ET ) ) { + } else if ((bc != BN) && (bc != ET)) { bcPrev = bc; } } // W6 - BN* (ET|ES|CS) BN* -> ON* ON ON* - for ( int i = start, n = end; i < n; i++ ) { + for (int i = start, n = end; i < n; i++) { int bc = wca [ i ]; - if ( ( bc == ET ) || ( bc == ES ) || ( bc == CS ) ) { + if ((bc == ET) || (bc == ES) || (bc == CS)) { wca [ i ] = ON; - resolveAdjacentBoundaryNeutrals ( wca, start, end, i, ON ); + resolveAdjacentBoundaryNeutrals (wca, start, end, i, ON); } } // W7 - L ... EN -> L ... L - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( bc == EN ) { - if ( bcPrev == L ) { + if (bc == EN) { + if (bcPrev == L) { wca [ i ] = L; } - } else if ( ( bc == L ) || ( bc == R ) ) { + } else if ((bc == L) || (bc == R)) { bcPrev = bc; } } } - private static void resolveNeutrals ( int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor ) { + private static void resolveNeutrals (int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor) { // N1 - (L|R) N+ (L|R) -> L L+ L | R R+ R; (AN|EN) N+ R -> (AN|EN) R+ R; R N+ (AN|EN) -> R R+ (AN|EN) - for ( int i = start, n = end, bcPrev = sor; i < n; i++ ) { + for (int i = start, n = end, bcPrev = sor; i < n; i++) { int bc = wca [ i ]; - if ( isNeutral ( bc ) ) { + if (isNeutral (bc)) { int bcNext = eor; - for ( int j = i + 1; j < n; j++ ) { + for (int j = i + 1; j < n; j++) { bc = wca [ j ]; - if ( ( bc == L ) || ( bc == R ) ) { + if ((bc == L) || (bc == R)) { bcNext = bc; break; - } else if ( ( bc == AN ) || ( bc == EN ) ) { + } else if ((bc == AN) || (bc == EN)) { bcNext = R; break; - } else if ( isNeutral ( bc ) ) { + } else if (isNeutral (bc)) { continue; - } else if ( isRetainedFormatting ( bc ) ) { + } else if (isRetainedFormatting (bc)) { continue; } else { break; } } - if ( bcPrev == bcNext ) { + if (bcPrev == bcNext) { wca [ i ] = bcPrev; - resolveAdjacentBoundaryNeutrals ( wca, start, end, i, bcPrev ); + resolveAdjacentBoundaryNeutrals (wca, start, end, i, bcPrev); } - } else if ( ( bc == L ) || ( bc == R ) ) { + } else if ((bc == L) || (bc == R)) { bcPrev = bc; - } else if ( ( bc == AN ) || ( bc == EN ) ) { + } else if ((bc == AN) || (bc == EN)) { bcPrev = R; } } // N2 - N -> embedding level - for ( int i = start, n = end; i < n; i++ ) { + for (int i = start, n = end; i < n; i++) { int bc = wca [ i ]; - if ( isNeutral ( bc ) ) { - int bcEmbedding = directionOfLevel ( levelOfEmbedding ( ea [ i ] ) ); + if (isNeutral (bc)) { + int bcEmbedding = directionOfLevel (levelOfEmbedding (ea [ i ])); wca [ i ] = bcEmbedding; - resolveAdjacentBoundaryNeutrals ( wca, start, end, i, bcEmbedding ); + resolveAdjacentBoundaryNeutrals (wca, start, end, i, bcEmbedding); } } } - private static void resolveAdjacentBoundaryNeutrals ( int[] wca, int start, int end, int index, int bcNew ) { - if ( ( index < start ) || ( index >= end ) ) { + private static void resolveAdjacentBoundaryNeutrals (int[] wca, int start, int end, int index, int bcNew) { + if ((index < start) || (index >= end)) { throw new IllegalArgumentException(); } else { - for ( int i = index - 1; i >= start; i-- ) { + for (int i = index - 1; i >= start; i--) { int bc = wca [ i ]; - if ( bc == BN ) { + if (bc == BN) { wca [ i ] = bcNew; } else { break; } } - for ( int i = index + 1; i < end; i++ ) { + for (int i = index + 1; i < end; i++) { int bc = wca [ i ]; - if ( bc == BN ) { + if (bc == BN) { wca [ i ] = bcNew; } else { break; @@ -492,25 +492,25 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static void resolveImplicit ( int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor ) { - for ( int i = start, n = end; i < n; i++ ) { + private static void resolveImplicit (int[] wca, int defaultLevel, int[] ea, int[] la, int start, int end, int level, int sor, int eor) { + for (int i = start, n = end; i < n; i++) { int bc = wca [ i ]; // bidi class int el = la [ i ]; // embedding level int ed = 0; // embedding level delta - if ( ( el & 1 ) == 0 ) { // even - if ( bc == R ) { + if ((el & 1) == 0) { // even + if (bc == R) { ed = 1; - } else if ( bc == AN ) { + } else if (bc == AN) { ed = 2; - } else if ( bc == EN ) { + } else if (bc == EN) { ed = 2; } } else { // odd - if ( bc == L ) { + if (bc == L) { ed = 1; - } else if ( bc == EN ) { + } else if (bc == EN) { ed = 1; - } else if ( bc == AN ) { + } else if (bc == AN) { ed = 1; } } @@ -526,17 +526,17 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @param dl default paragraph level * @param la array of output levels to be adjusted, as produced by bidi algorithm */ - private static void resolveSeparators ( int[] ica, int[] wca, int dl, int[] la ) { + private static void resolveSeparators (int[] ica, int[] wca, int dl, int[] la) { // steps (1) through (3) - for ( int i = 0, n = ica.length; i < n; i++ ) { + for (int i = 0, n = ica.length; i < n; i++) { int ic = ica[i]; - if ( ( ic == BidiConstants.S ) || ( ic == BidiConstants.B ) ) { + if ((ic == BidiConstants.S) || (ic == BidiConstants.B)) { la[i] = dl; - for ( int k = i - 1; k >= 0; k-- ) { + for (int k = i - 1; k >= 0; k--) { int pc = ica[k]; - if ( isRetainedFormatting ( pc ) ) { + if (isRetainedFormatting (pc)) { continue; - } else if ( pc == BidiConstants.WS ) { + } else if (pc == BidiConstants.WS) { la[k] = dl; } else { break; @@ -545,22 +545,22 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } // step (4) - consider end of input sequence to be end of line, but skip any trailing boundary neutrals and retained formatting codes - for ( int i = ica.length; i > 0; i-- ) { + for (int i = ica.length; i > 0; i--) { int k = i - 1; int ic = ica[k]; - if ( isRetainedFormatting ( ic ) ) { + if (isRetainedFormatting (ic)) { continue; - } else if ( ic == BidiConstants.WS ) { + } else if (ic == BidiConstants.WS) { la[k] = dl; } else { break; } } // step (5) - per section 5.2 - for ( int i = 0, n = ica.length; i < n; i++ ) { + for (int i = 0, n = ica.length; i < n; i++) { int ic = ica[i]; - if ( isRetainedFormatting ( ic ) ) { - if ( i == 0 ) { + if (isRetainedFormatting (ic)) { + if (i == 0) { la[i] = dl; } else { la[i] = la [ i - 1 ]; @@ -569,8 +569,8 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static boolean isStrong ( int bc ) { - switch ( bc ) { + private static boolean isStrong (int bc) { + switch (bc) { case L: case R: case AL: @@ -580,8 +580,8 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static boolean isNeutral ( int bc ) { - switch ( bc ) { + private static boolean isNeutral (int bc) { + switch (bc) { case WS: case ON: case S: @@ -592,8 +592,8 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static boolean isRetainedFormatting ( int bc ) { - switch ( bc ) { + private static boolean isRetainedFormatting (int bc) { + switch (bc) { case LRE: case LRO: case RLE: @@ -606,30 +606,30 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static boolean isRetainedFormatting ( int[] ca, int s, int e ) { - for ( int i = s; i < e; i++ ) { - if ( ! isRetainedFormatting ( ca[i] ) ) { + private static boolean isRetainedFormatting (int[] ca, int s, int e) { + for (int i = s; i < e; i++) { + if (! isRetainedFormatting (ca[i])) { return false; } } return true; } - private static int max ( int x, int y ) { - if ( x > y ) { + private static int max (int x, int y) { + if (x > y) { return x; } else { return y; } } - private static int[] getClasses ( int[] chars ) { + private static int[] getClasses (int[] chars) { int[] classes = new int [ chars.length ]; int bc; - for ( int i = 0, n = chars.length; i < n; i++ ) { + for (int i = 0, n = chars.length; i < n; i++) { int ch = chars [ i ]; - if ( ch >= 0 ) { - bc = BidiClass.getBidiClass ( chars [ i ] ); + if (ch >= 0) { + bc = BidiClass.getBidiClass (chars [ i ]); } else { bc = SURROGATE; } @@ -652,38 +652,38 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @throws IllegalArgumentException if the input sequence is not a valid UTF-16 string, e.g., * if it contains an isolated UTF-16 surrogate */ - private static boolean convertToScalar ( CharSequence cs, int[] chars ) throws IllegalArgumentException { + private static boolean convertToScalar (CharSequence cs, int[] chars) throws IllegalArgumentException { boolean triggered = false; - if ( chars.length != cs.length() ) { - throw new IllegalArgumentException ( "characters array length must match input sequence length" ); + if (chars.length != cs.length()) { + throw new IllegalArgumentException ("characters array length must match input sequence length"); } - for ( int i = 0, n = chars.length; i < n; ) { - int chIn = cs.charAt ( i ); + for (int i = 0, n = chars.length; i < n; ) { + int chIn = cs.charAt (i); int chOut; - if ( chIn < 0xD800 ) { + if (chIn < 0xD800) { chOut = chIn; - } else if ( chIn < 0xDC00 ) { + } else if (chIn < 0xDC00) { int chHi = chIn; int chLo; - if ( ( i + 1 ) < n ) { - chLo = cs.charAt ( i + 1 ); - if ( ( chLo >= 0xDC00 ) && ( chLo <= 0xDFFF ) ) { - chOut = convertToScalar ( chHi, chLo ); + if ((i + 1) < n) { + chLo = cs.charAt (i + 1); + if ((chLo >= 0xDC00) && (chLo <= 0xDFFF)) { + chOut = convertToScalar (chHi, chLo); } else { - throw new IllegalArgumentException ( "isolated high surrogate" ); + throw new IllegalArgumentException ("isolated high surrogate"); } } else { - throw new IllegalArgumentException ( "truncated surrogate pair" ); + throw new IllegalArgumentException ("truncated surrogate pair"); } - } else if ( chIn < 0xE000 ) { - throw new IllegalArgumentException ( "isolated low surrogate" ); + } else if (chIn < 0xE000) { + throw new IllegalArgumentException ("isolated low surrogate"); } else { chOut = chIn; } - if ( ! triggered && triggersBidi ( chOut ) ) { + if (! triggered && triggersBidi (chOut)) { triggered = true; } - if ( ( chOut & 0xFF0000 ) == 0 ) { + if ((chOut & 0xFF0000) == 0) { chars [ i++ ] = chOut; } else { chars [ i++ ] = chOut; @@ -700,13 +700,13 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @param chLo low (least significant or second) surrogate * @throws IllegalArgumentException if one of the input surrogates is not valid */ - private static int convertToScalar ( int chHi, int chLo ) { - if ( ( chHi < 0xD800 ) || ( chHi > 0xDBFF ) ) { - throw new IllegalArgumentException ( "bad high surrogate" ); - } else if ( ( chLo < 0xDC00 ) || ( chLo > 0xDFFF ) ) { - throw new IllegalArgumentException ( "bad low surrogate" ); + private static int convertToScalar (int chHi, int chLo) { + if ((chHi < 0xD800) || (chHi > 0xDBFF)) { + throw new IllegalArgumentException ("bad high surrogate"); + } else if ((chLo < 0xDC00) || (chLo > 0xDFFF)) { + throw new IllegalArgumentException ("bad low surrogate"); } else { - return ( ( ( chHi & 0x03FF ) << 10 ) | ( chLo & 0x03FF ) ) + 0x10000; + return (((chHi & 0x03FF) << 10) | (chLo & 0x03FF)) + 0x10000; } } @@ -718,8 +718,8 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { * @return true if character triggers bidirectional processing * @param ch a unicode scalar value */ - private static boolean triggersBidi ( int ch ) { - switch ( BidiClass.getBidiClass ( ch ) ) { + private static boolean triggersBidi (int ch) { + switch (BidiClass.getBidiClass (ch)) { case R: case AL: case AN: @@ -731,39 +731,39 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static void dump ( String header, int[] chars, int[] classes, int defaultLevel, int[] levels ) { - log.debug ( header ); - log.debug ( "BD: default level(" + defaultLevel + ")" ); + private static void dump (String header, int[] chars, int[] classes, int defaultLevel, int[] levels) { + log.debug (header); + log.debug ("BD: default level(" + defaultLevel + ")"); StringBuffer sb = new StringBuffer(); - if ( chars != null ) { - for ( int i = 0, n = chars.length; i < n; i++ ) { + if (chars != null) { + for (int i = 0, n = chars.length; i < n; i++) { int ch = chars [ i ]; sb.setLength(0); - if ( ( ch > 0x20 ) && ( ch < 0x7F ) ) { - sb.append ( (char) ch ); + if ((ch > 0x20) && (ch < 0x7F)) { + sb.append ((char) ch); } else { - sb.append ( CharUtilities.charToNCRef ( ch ) ); + sb.append (CharUtilities.charToNCRef (ch)); } - for ( int k = sb.length(); k < 12; k++ ) { - sb.append ( ' ' ); + for (int k = sb.length(); k < 12; k++) { + sb.append (' '); } - sb.append ( ": " + padRight ( getClassName ( classes[i] ), 4 ) + " " + levels[i] ); - log.debug ( sb ); + sb.append (": " + padRight (getClassName (classes[i]), 4) + " " + levels[i]); + log.debug (sb); } } else { - for ( int i = 0, n = classes.length; i < n; i++ ) { + for (int i = 0, n = classes.length; i < n; i++) { sb.setLength(0); - for ( int k = sb.length(); k < 12; k++ ) { - sb.append ( ' ' ); + for (int k = sb.length(); k < 12; k++) { + sb.append (' '); } - sb.append ( ": " + padRight ( getClassName ( classes[i] ), 4 ) + " " + levels[i] ); - log.debug ( sb ); + sb.append (": " + padRight (getClassName (classes[i]), 4) + " " + levels[i]); + log.debug (sb); } } } - private static String getClassName ( int bc ) { - switch ( bc ) { + private static String getClassName (int bc) { + switch (bc) { case L: // left-to-right return "L"; case LRE: // left-to-right embedding @@ -809,16 +809,16 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } } - private static String padLeft ( int n, int width ) { - return padLeft ( Integer.toString ( n ), width ); + private static String padLeft (int n, int width) { + return padLeft (Integer.toString (n), width); } - private static String padLeft ( String s, int width ) { + private static String padLeft (String s, int width) { StringBuffer sb = new StringBuffer(); - for ( int i = s.length(); i < width; i++ ) { + for (int i = s.length(); i < width; i++) { sb.append(' '); } - sb.append ( s ); + sb.append (s); return sb.toString(); } @@ -828,9 +828,9 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { } */ - private static String padRight ( String s, int width ) { - StringBuffer sb = new StringBuffer ( s ); - for ( int i = sb.length(); i < width; i++ ) { + private static String padRight (String s, int width) { + StringBuffer sb = new StringBuffer (s); + for (int i = sb.length(); i < width; i++) { sb.append(' '); } return sb.toString(); diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphClassMapping.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphClassMapping.java index 9a94c7be0..2223ba98a 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphClassMapping.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphClassMapping.java @@ -35,7 +35,7 @@ public interface GlyphClassMapping { * @param set for coverage set based class mappings, indicates set index, otherwise ignored * @return size of class table */ - int getClassSize ( int set ); + int getClassSize (int set); /** * Map glyph identifier (code) to coverge index. Returns -1 if glyph identifier is not in the domain of @@ -44,6 +44,6 @@ public interface GlyphClassMapping { * @param set for coverage set based class mappings, indicates set index, otherwise ignored * @return non-negative glyph class index or -1 if glyph identifiers is not mapped by table */ - int getClassIndex ( int gid, int set ); + int getClassIndex (int gid, int set); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java index 07d64eb98..9a42d04c4 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java @@ -46,7 +46,7 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla private GlyphClassMapping cm; - private GlyphClassTable ( GlyphClassMapping cm ) { + private GlyphClassTable (GlyphClassMapping cm) { assert cm != null; assert cm instanceof GlyphMappingTable; this.cm = cm; @@ -54,22 +54,22 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla /** {@inheritDoc} */ public int getType() { - return ( (GlyphMappingTable) cm ) .getType(); + return ((GlyphMappingTable) cm) .getType(); } /** {@inheritDoc} */ public List getEntries() { - return ( (GlyphMappingTable) cm ) .getEntries(); + return ((GlyphMappingTable) cm) .getEntries(); } /** {@inheritDoc} */ - public int getClassSize ( int set ) { - return cm.getClassSize ( set ); + public int getClassSize (int set) { + return cm.getClassSize (set); } /** {@inheritDoc} */ - public int getClassIndex ( int gid, int set ) { - return cm.getClassIndex ( gid, set ); + public int getClassIndex (int gid, int set) { + return cm.getClassIndex (gid, set); } /** @@ -77,30 +77,30 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla * @param entries list of mapped or ranged class entries, or null or empty list * @return a new covera table instance */ - public static GlyphClassTable createClassTable ( List entries ) { + public static GlyphClassTable createClassTable (List entries) { GlyphClassMapping cm; - if ( ( entries == null ) || ( entries.size() == 0 ) ) { - cm = new EmptyClassTable ( entries ); - } else if ( isMappedClass ( entries ) ) { - cm = new MappedClassTable ( entries ); - } else if ( isRangeClass ( entries ) ) { - cm = new RangeClassTable ( entries ); - } else if ( isCoverageSetClass ( entries ) ) { - cm = new CoverageSetClassTable ( entries ); + if ((entries == null) || (entries.size() == 0)) { + cm = new EmptyClassTable (entries); + } else if (isMappedClass (entries)) { + cm = new MappedClassTable (entries); + } else if (isRangeClass (entries)) { + cm = new RangeClassTable (entries); + } else if (isCoverageSetClass (entries)) { + cm = new CoverageSetClassTable (entries); } else { cm = null; } assert cm != null : "unknown class type"; - return new GlyphClassTable ( cm ); + return new GlyphClassTable (cm); } - private static boolean isMappedClass ( List entries ) { - if ( ( entries == null ) || ( entries.size() == 0 ) ) { + private static boolean isMappedClass (List entries) { + if ((entries == null) || (entries.size() == 0)) { return false; } else { - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( ! ( o instanceof Integer ) ) { + if (! (o instanceof Integer)) { return false; } } @@ -108,13 +108,13 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla } } - private static boolean isRangeClass ( List entries ) { - if ( ( entries == null ) || ( entries.size() == 0 ) ) { + private static boolean isRangeClass (List entries) { + if ((entries == null) || (entries.size() == 0)) { return false; } else { - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( ! ( o instanceof MappingRange ) ) { + if (! (o instanceof MappingRange)) { return false; } } @@ -122,13 +122,13 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla } } - private static boolean isCoverageSetClass ( List entries ) { - if ( ( entries == null ) || ( entries.size() == 0 ) ) { + private static boolean isCoverageSetClass (List entries) { + if ((entries == null) || (entries.size() == 0)) { return false; } else { - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( ! ( o instanceof GlyphCoverageTable ) ) { + if (! (o instanceof GlyphCoverageTable)) { return false; } } @@ -137,15 +137,15 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla } private static class EmptyClassTable extends GlyphMappingTable.EmptyMappingTable implements GlyphClassMapping { - public EmptyClassTable ( List entries ) { - super ( entries ); + public EmptyClassTable (List entries) { + super (entries); } /** {@inheritDoc} */ - public int getClassSize ( int set ) { + public int getClassSize (int set) { return 0; } /** {@inheritDoc} */ - public int getClassIndex ( int gid, int set ) { + public int getClassIndex (int gid, int set) { return -1; } } @@ -154,16 +154,16 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla private int firstGlyph; private int[] gca; private int gcMax = -1; - public MappedClassTable ( List entries ) { - populate ( entries ); + public MappedClassTable (List entries) { + populate (entries); } /** {@inheritDoc} */ public List getEntries() { List entries = new java.util.ArrayList(); - entries.add ( Integer.valueOf ( firstGlyph ) ); - if ( gca != null ) { - for ( int i = 0, n = gca.length; i < n; i++ ) { - entries.add ( Integer.valueOf ( gca [ i ] ) ); + entries.add (Integer.valueOf (firstGlyph)); + if (gca != null) { + for (int i = 0, n = gca.length; i < n; i++) { + entries.add (Integer.valueOf (gca [ i ])); } } return entries; @@ -173,33 +173,33 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla return gcMax + 1; } /** {@inheritDoc} */ - public int getMappedIndex ( int gid ) { + public int getMappedIndex (int gid) { int i = gid - firstGlyph; - if ( ( i >= 0 ) && ( i < gca.length ) ) { + if ((i >= 0) && (i < gca.length)) { return gca [ i ]; } else { return -1; } } /** {@inheritDoc} */ - public int getClassSize ( int set ) { + public int getClassSize (int set) { return getMappingSize(); } /** {@inheritDoc} */ - public int getClassIndex ( int gid, int set ) { - return getMappedIndex ( gid ); + public int getClassIndex (int gid, int set) { + return getMappedIndex (gid); } - private void populate ( List entries ) { + private void populate (List entries) { // obtain entries iterator Iterator it = entries.iterator(); // extract first glyph int firstGlyph = 0; - if ( it.hasNext() ) { + if (it.hasNext()) { Object o = it.next(); - if ( o instanceof Integer ) { - firstGlyph = ( (Integer) o ) . intValue(); + if (o instanceof Integer) { + firstGlyph = ((Integer) o) . intValue(); } else { - throw new AdvancedTypographicTableFormatException ( "illegal entry, first entry must be Integer denoting first glyph value, but is: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal entry, first entry must be Integer denoting first glyph value, but is: " + o); } } // extract glyph class array @@ -207,16 +207,16 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla int n = entries.size() - 1; int gcMax = -1; int[] gca = new int [ n ]; - while ( it.hasNext() ) { + while (it.hasNext()) { Object o = it.next(); - if ( o instanceof Integer ) { - int gc = ( (Integer) o ) . intValue(); + if (o instanceof Integer) { + int gc = ((Integer) o) . intValue(); gca [ i++ ] = gc; - if ( gc > gcMax ) { + if (gc > gcMax) { gcMax = gc; } } else { - throw new AdvancedTypographicTableFormatException ( "illegal mapping entry, must be Integer: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal mapping entry, must be Integer: " + o); } } assert i == n; @@ -229,11 +229,11 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla public String toString() { StringBuffer sb = new StringBuffer(); sb.append("{ firstGlyph = " + firstGlyph + ", classes = {"); - for ( int i = 0, n = gca.length; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = gca.length; i < n; i++) { + if (i > 0) { sb.append(','); } - sb.append ( Integer.toString ( gca [ i ] ) ); + sb.append (Integer.toString (gca [ i ])); } sb.append("} }"); return sb.toString(); @@ -241,37 +241,37 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla } private static class RangeClassTable extends GlyphMappingTable.RangeMappingTable implements GlyphClassMapping { - public RangeClassTable ( List entries ) { - super ( entries ); + public RangeClassTable (List entries) { + super (entries); } /** {@inheritDoc} */ - public int getMappedIndex ( int gid, int s, int m ) { + public int getMappedIndex (int gid, int s, int m) { return m; } /** {@inheritDoc} */ - public int getClassSize ( int set ) { + public int getClassSize (int set) { return getMappingSize(); } /** {@inheritDoc} */ - public int getClassIndex ( int gid, int set ) { - return getMappedIndex ( gid ); + public int getClassIndex (int gid, int set) { + return getMappedIndex (gid); } } private static class CoverageSetClassTable extends GlyphMappingTable.EmptyMappingTable implements GlyphClassMapping { - public CoverageSetClassTable ( List entries ) { - throw new UnsupportedOperationException ( "coverage set class table not yet supported" ); + public CoverageSetClassTable (List entries) { + throw new UnsupportedOperationException ("coverage set class table not yet supported"); } /** {@inheritDoc} */ public int getType() { return GLYPH_CLASS_TYPE_COVERAGE_SET; } /** {@inheritDoc} */ - public int getClassSize ( int set ) { + public int getClassSize (int set) { return 0; } /** {@inheritDoc} */ - public int getClassIndex ( int gid, int set ) { + public int getClassIndex (int gid, int set) { return -1; } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageMapping.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageMapping.java index 999876088..8f5b2b552 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageMapping.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageMapping.java @@ -42,6 +42,6 @@ public interface GlyphCoverageMapping { * @param gid glyph identifier (code) * @return non-negative glyph coverage index or -1 if glyph identifiers is not mapped by table */ - int getCoverageIndex ( int gid ); + int getCoverageIndex (int gid); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java index dfad57738..101126be6 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java @@ -51,7 +51,7 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph private GlyphCoverageMapping cm; - private GlyphCoverageTable ( GlyphCoverageMapping cm ) { + private GlyphCoverageTable (GlyphCoverageMapping cm) { assert cm != null; assert cm instanceof GlyphMappingTable; this.cm = cm; @@ -59,12 +59,12 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph /** {@inheritDoc} */ public int getType() { - return ( (GlyphMappingTable) cm ) .getType(); + return ((GlyphMappingTable) cm) .getType(); } /** {@inheritDoc} */ public List getEntries() { - return ( (GlyphMappingTable) cm ) .getEntries(); + return ((GlyphMappingTable) cm) .getEntries(); } /** {@inheritDoc} */ @@ -73,8 +73,8 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph } /** {@inheritDoc} */ - public int getCoverageIndex ( int gid ) { - return cm.getCoverageIndex ( gid ); + public int getCoverageIndex (int gid) { + return cm.getCoverageIndex (gid); } /** @@ -82,28 +82,28 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph * @param entries list of mapped or ranged coverage entries, or null or empty list * @return a new covera table instance */ - public static GlyphCoverageTable createCoverageTable ( List entries ) { + public static GlyphCoverageTable createCoverageTable (List entries) { GlyphCoverageMapping cm; - if ( ( entries == null ) || ( entries.size() == 0 ) ) { - cm = new EmptyCoverageTable ( entries ); - } else if ( isMappedCoverage ( entries ) ) { - cm = new MappedCoverageTable ( entries ); - } else if ( isRangeCoverage ( entries ) ) { - cm = new RangeCoverageTable ( entries ); + if ((entries == null) || (entries.size() == 0)) { + cm = new EmptyCoverageTable (entries); + } else if (isMappedCoverage (entries)) { + cm = new MappedCoverageTable (entries); + } else if (isRangeCoverage (entries)) { + cm = new RangeCoverageTable (entries); } else { cm = null; } assert cm != null : "unknown coverage type"; - return new GlyphCoverageTable ( cm ); + return new GlyphCoverageTable (cm); } - private static boolean isMappedCoverage ( List entries ) { - if ( ( entries == null ) || ( entries.size() == 0 ) ) { + private static boolean isMappedCoverage (List entries) { + if ((entries == null) || (entries.size() == 0)) { return false; } else { - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( ! ( o instanceof Integer ) ) { + if (! (o instanceof Integer)) { return false; } } @@ -111,13 +111,13 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph } } - private static boolean isRangeCoverage ( List entries ) { - if ( ( entries == null ) || ( entries.size() == 0 ) ) { + private static boolean isRangeCoverage (List entries) { + if ((entries == null) || (entries.size() == 0)) { return false; } else { - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( ! ( o instanceof MappingRange ) ) { + if (! (o instanceof MappingRange)) { return false; } } @@ -126,41 +126,41 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph } private static class EmptyCoverageTable extends GlyphMappingTable.EmptyMappingTable implements GlyphCoverageMapping { - public EmptyCoverageTable ( List entries ) { - super ( entries ); + public EmptyCoverageTable (List entries) { + super (entries); } /** {@inheritDoc} */ public int getCoverageSize() { return 0; } /** {@inheritDoc} */ - public int getCoverageIndex ( int gid ) { + public int getCoverageIndex (int gid) { return -1; } } private static class MappedCoverageTable extends GlyphMappingTable.MappedMappingTable implements GlyphCoverageMapping { private int[] map; - public MappedCoverageTable ( List entries ) { - populate ( entries ); + public MappedCoverageTable (List entries) { + populate (entries); } /** {@inheritDoc} */ public List getEntries() { List entries = new java.util.ArrayList(); - if ( map != null ) { - for ( int i = 0, n = map.length; i < n; i++ ) { - entries.add ( Integer.valueOf ( map [ i ] ) ); + if (map != null) { + for (int i = 0, n = map.length; i < n; i++) { + entries.add (Integer.valueOf (map [ i ])); } } return entries; } /** {@inheritDoc} */ public int getMappingSize() { - return ( map != null ) ? map.length : 0; + return (map != null) ? map.length : 0; } - public int getMappedIndex ( int gid ) { + public int getMappedIndex (int gid) { int i; - if ( ( i = Arrays.binarySearch ( map, gid ) ) >= 0 ) { + if ((i = Arrays.binarySearch (map, gid)) >= 0) { return i; } else { return -1; @@ -171,34 +171,34 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph return getMappingSize(); } /** {@inheritDoc} */ - public int getCoverageIndex ( int gid ) { - return getMappedIndex ( gid ); + public int getCoverageIndex (int gid) { + return getMappedIndex (gid); } - private void populate ( List entries ) { + private void populate (List entries) { int i = 0; int skipped = 0; int n = entries.size(); int gidMax = -1; int[] map = new int [ n ]; - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof Integer ) { - int gid = ( (Integer) o ) . intValue(); - if ( ( gid >= 0 ) && ( gid < 65536 ) ) { - if ( gid > gidMax ) { + if (o instanceof Integer) { + int gid = ((Integer) o) . intValue(); + if ((gid >= 0) && (gid < 65536)) { + if (gid > gidMax) { map [ i++ ] = gidMax = gid; } else { - log.info ( "ignoring out of order or duplicate glyph index: " + gid ); + log.info ("ignoring out of order or duplicate glyph index: " + gid); skipped++; } } else { - throw new AdvancedTypographicTableFormatException ( "illegal glyph index: " + gid ); + throw new AdvancedTypographicTableFormatException ("illegal glyph index: " + gid); } } else { - throw new AdvancedTypographicTableFormatException ( "illegal coverage entry, must be Integer: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal coverage entry, must be Integer: " + o); } } - assert ( i + skipped ) == n; + assert (i + skipped) == n; assert this.map == null; this.map = map; } @@ -206,11 +206,11 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph public String toString() { StringBuffer sb = new StringBuffer(); sb.append('{'); - for ( int i = 0, n = map.length; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = map.length; i < n; i++) { + if (i > 0) { sb.append(','); } - sb.append ( Integer.toString ( map [ i ] ) ); + sb.append (Integer.toString (map [ i ])); } sb.append('}'); return sb.toString(); @@ -218,11 +218,11 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph } private static class RangeCoverageTable extends GlyphMappingTable.RangeMappingTable implements GlyphCoverageMapping { - public RangeCoverageTable ( List entries ) { - super ( entries ); + public RangeCoverageTable (List entries) { + super (entries); } /** {@inheritDoc} */ - public int getMappedIndex ( int gid, int s, int m ) { + public int getMappedIndex (int gid, int s, int m) { return m + gid - s; } /** {@inheritDoc} */ @@ -230,8 +230,8 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph return getMappingSize(); } /** {@inheritDoc} */ - public int getCoverageIndex ( int gid ) { - return getMappedIndex ( gid ); + public int getCoverageIndex (int gid) { + return getMappedIndex (gid); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinition.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinition.java index 268e00fdd..2e1ccf9e9 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinition.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinition.java @@ -34,6 +34,6 @@ public interface GlyphDefinition { * @param gi a glyph index * @return true if some (unspecified) definition is available for the specified glyph */ - boolean hasDefinition ( int gi ); + boolean hasDefinition (int gi); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionSubtable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionSubtable.java index 94829425e..a09287cff 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionSubtable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionSubtable.java @@ -38,8 +38,8 @@ public abstract class GlyphDefinitionSubtable extends GlyphSubtable implements G * @param format subtable format * @param mapping subtable coverage table */ - protected GlyphDefinitionSubtable ( String id, int sequence, int flags, int format, GlyphMappingTable mapping ) { - super ( id, sequence, flags, format, mapping ); + protected GlyphDefinitionSubtable (String id, int sequence, int flags, int format, GlyphMappingTable mapping) { + super (id, sequence, flags, format, mapping); } /** {@inheritDoc} */ @@ -49,7 +49,7 @@ public abstract class GlyphDefinitionSubtable extends GlyphSubtable implements G /** {@inheritDoc} */ public String getTypeName() { - return GlyphDefinitionTable.getLookupTypeName ( getType() ); + return GlyphDefinitionTable.getLookupTypeName (getType()); } /** {@inheritDoc} */ @@ -58,16 +58,16 @@ public abstract class GlyphDefinitionSubtable extends GlyphSubtable implements G } /** {@inheritDoc} */ - public boolean hasDefinition ( int gi ) { + public boolean hasDefinition (int gi) { GlyphCoverageMapping cvm; - if ( ( cvm = getCoverage() ) != null ) { - if ( cvm.getCoverageIndex ( gi ) >= 0 ) { + if ((cvm = getCoverage()) != null) { + if (cvm.getCoverageIndex (gi) >= 0) { return true; } } GlyphClassMapping clm; - if ( ( clm = getClasses() ) != null ) { - if ( clm.getClassIndex ( gi, 0 ) >= 0 ) { + if ((clm = getClasses()) != null) { + if (clm.getClassIndex (gi, 0) >= 0) { return true; } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java index ca57ca67f..0bcc68c64 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java @@ -74,17 +74,17 @@ public class GlyphDefinitionTable extends GlyphTable { * Instantiate a GlyphDefinitionTable object using the specified subtables. * @param subtables a list of identified subtables */ - public GlyphDefinitionTable ( List subtables ) { - super ( null, new HashMap(0) ); - if ( ( subtables == null ) || ( subtables.size() == 0 ) ) { - throw new AdvancedTypographicTableFormatException ( "subtables must be non-empty" ); + public GlyphDefinitionTable (List subtables) { + super (null, new HashMap(0)); + if ((subtables == null) || (subtables.size() == 0)) { + throw new AdvancedTypographicTableFormatException ("subtables must be non-empty"); } else { - for ( Iterator it = subtables.iterator(); it.hasNext();) { + for (Iterator it = subtables.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof GlyphDefinitionSubtable ) { - addSubtable ( (GlyphSubtable) o ); + if (o instanceof GlyphDefinitionSubtable) { + addSubtable ((GlyphSubtable) o); } else { - throw new AdvancedTypographicTableFormatException ( "subtable must be a glyph definition subtable" ); + throw new AdvancedTypographicTableFormatException ("subtable must be a glyph definition subtable"); } } freezeSubtables(); @@ -102,25 +102,25 @@ public class GlyphDefinitionTable extends GlyphTable { * @param language a language identifier * @return the reordered (output) glyph sequence */ - public GlyphSequence reorderCombiningMarks ( GlyphSequence gs, int[][] gpa, String script, String language ) { - ScriptProcessor sp = ScriptProcessor.getInstance ( script ); - return sp.reorderCombiningMarks ( this, gs, gpa, script, language ); + public GlyphSequence reorderCombiningMarks (GlyphSequence gs, int[][] gpa, String script, String language) { + ScriptProcessor sp = ScriptProcessor.getInstance (script); + return sp.reorderCombiningMarks (this, gs, gpa, script, language); } /** {@inheritDoc} */ - protected void addSubtable ( GlyphSubtable subtable ) { - if ( subtable instanceof GlyphClassSubtable ) { + protected void addSubtable (GlyphSubtable subtable) { + if (subtable instanceof GlyphClassSubtable) { this.gct = (GlyphClassSubtable) subtable; - } else if ( subtable instanceof AttachmentPointSubtable ) { + } else if (subtable instanceof AttachmentPointSubtable) { // TODO - not yet used // this.apt = (AttachmentPointSubtable) subtable; - } else if ( subtable instanceof LigatureCaretSubtable ) { + } else if (subtable instanceof LigatureCaretSubtable) { // TODO - not yet used // this.lct = (LigatureCaretSubtable) subtable; - } else if ( subtable instanceof MarkAttachmentSubtable ) { + } else if (subtable instanceof MarkAttachmentSubtable) { this.mat = (MarkAttachmentSubtable) subtable; } else { - throw new UnsupportedOperationException ( "unsupported glyph definition subtable type: " + subtable ); + throw new UnsupportedOperationException ("unsupported glyph definition subtable type: " + subtable); } } @@ -130,9 +130,9 @@ public class GlyphDefinitionTable extends GlyphTable { * @param gc a pre-defined glyph class (GLYPH_CLASS_BASE|GLYPH_CLASS_LIGATURE|GLYPH_CLASS_MARK|GLYPH_CLASS_COMPONENT). * @return true if glyph belongs to specified glyph class */ - public boolean isGlyphClass ( int gid, int gc ) { - if ( gct != null ) { - return gct.isGlyphClass ( gid, gc ); + public boolean isGlyphClass (int gid, int gc) { + if (gct != null) { + return gct.isGlyphClass (gid, gc); } else { return false; } @@ -143,9 +143,9 @@ public class GlyphDefinitionTable extends GlyphTable { * @param gid a glyph identifier (index) * @return a pre-defined glyph class (GLYPH_CLASS_BASE|GLYPH_CLASS_LIGATURE|GLYPH_CLASS_MARK|GLYPH_CLASS_COMPONENT). */ - public int getGlyphClass ( int gid ) { - if ( gct != null ) { - return gct.getGlyphClass ( gid ); + public int getGlyphClass (int gid) { + if (gct != null) { + return gct.getGlyphClass (gid); } else { return -1; } @@ -157,9 +157,9 @@ public class GlyphDefinitionTable extends GlyphTable { * @param mac a (font specific) mark attachment class * @return true if glyph belongs to specified mark attachment class */ - public boolean isMarkAttachClass ( int gid, int mac ) { - if ( mat != null ) { - return mat.isMarkAttachClass ( gid, mac ); + public boolean isMarkAttachClass (int gid, int mac) { + if (mat != null) { + return mat.isMarkAttachClass (gid, mac); } else { return false; } @@ -170,9 +170,9 @@ public class GlyphDefinitionTable extends GlyphTable { * @param gid a glyph identifier (index) * @return a non-negative mark attachment class, or -1 if no class defined */ - public int getMarkAttachClass ( int gid ) { - if ( mat != null ) { - return mat.getMarkAttachClass ( gid ); + public int getMarkAttachClass (int gid) { + if (mat != null) { + return mat.getMarkAttachClass (gid); } else { return -1; } @@ -183,16 +183,16 @@ public class GlyphDefinitionTable extends GlyphTable { * @param name lookup type name * @return lookup type */ - public static int getLookupTypeFromName ( String name ) { + public static int getLookupTypeFromName (String name) { int t; String s = name.toLowerCase(); - if ( "glyphclass".equals ( s ) ) { + if ("glyphclass".equals (s)) { t = GDEF_LOOKUP_TYPE_GLYPH_CLASS; - } else if ( "attachmentpoint".equals ( s ) ) { + } else if ("attachmentpoint".equals (s)) { t = GDEF_LOOKUP_TYPE_ATTACHMENT_POINT; - } else if ( "ligaturecaret".equals ( s ) ) { + } else if ("ligaturecaret".equals (s)) { t = GDEF_LOOKUP_TYPE_LIGATURE_CARET; - } else if ( "markattachment".equals ( s ) ) { + } else if ("markattachment".equals (s)) { t = GDEF_LOOKUP_TYPE_MARK_ATTACHMENT; } else { t = -1; @@ -205,9 +205,9 @@ public class GlyphDefinitionTable extends GlyphTable { * @param type lookup type * @return lookup type name */ - public static String getLookupTypeName ( int type ) { + public static String getLookupTypeName (int type) { String tn = null; - switch ( type ) { + switch (type) { case GDEF_LOOKUP_TYPE_GLYPH_CLASS: tn = "glyphclass"; break; @@ -238,20 +238,20 @@ public class GlyphDefinitionTable extends GlyphTable { * @param entries subtable entries * @return a glyph subtable instance */ - public static GlyphSubtable createSubtable ( int type, String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { + public static GlyphSubtable createSubtable (int type, String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { GlyphSubtable st = null; - switch ( type ) { + switch (type) { case GDEF_LOOKUP_TYPE_GLYPH_CLASS: - st = GlyphClassSubtable.create ( id, sequence, flags, format, mapping, entries ); + st = GlyphClassSubtable.create (id, sequence, flags, format, mapping, entries); break; case GDEF_LOOKUP_TYPE_ATTACHMENT_POINT: - st = AttachmentPointSubtable.create ( id, sequence, flags, format, mapping, entries ); + st = AttachmentPointSubtable.create (id, sequence, flags, format, mapping, entries); break; case GDEF_LOOKUP_TYPE_LIGATURE_CARET: - st = LigatureCaretSubtable.create ( id, sequence, flags, format, mapping, entries ); + st = LigatureCaretSubtable.create (id, sequence, flags, format, mapping, entries); break; case GDEF_LOOKUP_TYPE_MARK_ATTACHMENT: - st = MarkAttachmentSubtable.create ( id, sequence, flags, format, mapping, entries ); + st = MarkAttachmentSubtable.create (id, sequence, flags, format, mapping, entries); break; default: break; @@ -260,8 +260,8 @@ public class GlyphDefinitionTable extends GlyphTable { } private abstract static class GlyphClassSubtable extends GlyphDefinitionSubtable { - GlyphClassSubtable ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping ); + GlyphClassSubtable (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping); } /** {@inheritDoc} */ public int getType() { @@ -273,16 +273,16 @@ public class GlyphDefinitionTable extends GlyphTable { * @param gc a pre-defined glyph class (GLYPH_CLASS_BASE|GLYPH_CLASS_LIGATURE|GLYPH_CLASS_MARK|GLYPH_CLASS_COMPONENT). * @return true if glyph belongs to specified glyph class */ - public abstract boolean isGlyphClass ( int gid, int gc ); + public abstract boolean isGlyphClass (int gid, int gc); /** * Determine glyph class. * @param gid a glyph identifier (index) * @return a pre-defined glyph class (GLYPH_CLASS_BASE|GLYPH_CLASS_LIGATURE|GLYPH_CLASS_MARK|GLYPH_CLASS_COMPONENT). */ - public abstract int getGlyphClass ( int gid ); - static GlyphDefinitionSubtable create ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - if ( format == 1 ) { - return new GlyphClassSubtableFormat1 ( id, sequence, flags, format, mapping, entries ); + public abstract int getGlyphClass (int gid); + static GlyphDefinitionSubtable create (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + if (format == 1) { + return new GlyphClassSubtableFormat1 (id, sequence, flags, format, mapping, entries); } else { throw new UnsupportedOperationException(); } @@ -290,31 +290,31 @@ public class GlyphDefinitionTable extends GlyphTable { } private static class GlyphClassSubtableFormat1 extends GlyphClassSubtable { - GlyphClassSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping, entries ); + GlyphClassSubtableFormat1 (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping, entries); } /** {@inheritDoc} */ public List getEntries() { return null; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof GlyphClassSubtable; } /** {@inheritDoc} */ - public boolean isGlyphClass ( int gid, int gc ) { + public boolean isGlyphClass (int gid, int gc) { GlyphClassMapping cm = getClasses(); - if ( cm != null ) { - return cm.getClassIndex ( gid, 0 ) == gc; + if (cm != null) { + return cm.getClassIndex (gid, 0) == gc; } else { return false; } } /** {@inheritDoc} */ - public int getGlyphClass ( int gid ) { + public int getGlyphClass (int gid) { GlyphClassMapping cm = getClasses(); - if ( cm != null ) { - return cm.getClassIndex ( gid, 0 ); + if (cm != null) { + return cm.getClassIndex (gid, 0); } else { return -1; } @@ -322,16 +322,16 @@ public class GlyphDefinitionTable extends GlyphTable { } private abstract static class AttachmentPointSubtable extends GlyphDefinitionSubtable { - AttachmentPointSubtable ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping ); + AttachmentPointSubtable (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping); } /** {@inheritDoc} */ public int getType() { return GDEF_LOOKUP_TYPE_ATTACHMENT_POINT; } - static GlyphDefinitionSubtable create ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - if ( format == 1 ) { - return new AttachmentPointSubtableFormat1 ( id, sequence, flags, format, mapping, entries ); + static GlyphDefinitionSubtable create (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + if (format == 1) { + return new AttachmentPointSubtableFormat1 (id, sequence, flags, format, mapping, entries); } else { throw new UnsupportedOperationException(); } @@ -339,30 +339,30 @@ public class GlyphDefinitionTable extends GlyphTable { } private static class AttachmentPointSubtableFormat1 extends AttachmentPointSubtable { - AttachmentPointSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping, entries ); + AttachmentPointSubtableFormat1 (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping, entries); } /** {@inheritDoc} */ public List getEntries() { return null; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof AttachmentPointSubtable; } } private abstract static class LigatureCaretSubtable extends GlyphDefinitionSubtable { - LigatureCaretSubtable ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping ); + LigatureCaretSubtable (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping); } /** {@inheritDoc} */ public int getType() { return GDEF_LOOKUP_TYPE_LIGATURE_CARET; } - static GlyphDefinitionSubtable create ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - if ( format == 1 ) { - return new LigatureCaretSubtableFormat1 ( id, sequence, flags, format, mapping, entries ); + static GlyphDefinitionSubtable create (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + if (format == 1) { + return new LigatureCaretSubtableFormat1 (id, sequence, flags, format, mapping, entries); } else { throw new UnsupportedOperationException(); } @@ -370,22 +370,22 @@ public class GlyphDefinitionTable extends GlyphTable { } private static class LigatureCaretSubtableFormat1 extends LigatureCaretSubtable { - LigatureCaretSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping, entries ); + LigatureCaretSubtableFormat1 (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping, entries); } /** {@inheritDoc} */ public List getEntries() { return null; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof LigatureCaretSubtable; } } private abstract static class MarkAttachmentSubtable extends GlyphDefinitionSubtable { - MarkAttachmentSubtable ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping ); + MarkAttachmentSubtable (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping); } /** {@inheritDoc} */ public int getType() { @@ -397,16 +397,16 @@ public class GlyphDefinitionTable extends GlyphTable { * @param mac a (font specific) mark attachment class * @return true if glyph belongs to specified mark attachment class */ - public abstract boolean isMarkAttachClass ( int gid, int mac ); + public abstract boolean isMarkAttachClass (int gid, int mac); /** * Determine mark attachment class. * @param gid a glyph identifier (index) * @return a non-negative mark attachment class, or -1 if no class defined */ - public abstract int getMarkAttachClass ( int gid ); - static GlyphDefinitionSubtable create ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - if ( format == 1 ) { - return new MarkAttachmentSubtableFormat1 ( id, sequence, flags, format, mapping, entries ); + public abstract int getMarkAttachClass (int gid); + static GlyphDefinitionSubtable create (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + if (format == 1) { + return new MarkAttachmentSubtableFormat1 (id, sequence, flags, format, mapping, entries); } else { throw new UnsupportedOperationException(); } @@ -414,31 +414,31 @@ public class GlyphDefinitionTable extends GlyphTable { } private static class MarkAttachmentSubtableFormat1 extends MarkAttachmentSubtable { - MarkAttachmentSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries ) { - super ( id, sequence, flags, format, mapping, entries ); + MarkAttachmentSubtableFormat1 (String id, int sequence, int flags, int format, GlyphMappingTable mapping, List entries) { + super (id, sequence, flags, format, mapping, entries); } /** {@inheritDoc} */ public List getEntries() { return null; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof MarkAttachmentSubtable; } /** {@inheritDoc} */ - public boolean isMarkAttachClass ( int gid, int mac ) { + public boolean isMarkAttachClass (int gid, int mac) { GlyphClassMapping cm = getClasses(); - if ( cm != null ) { - return cm.getClassIndex ( gid, 0 ) == mac; + if (cm != null) { + return cm.getClassIndex (gid, 0) == mac; } else { return false; } } /** {@inheritDoc} */ - public int getMarkAttachClass ( int gid ) { + public int getMarkAttachClass (int gid) { GlyphClassMapping cm = getClasses(); - if ( cm != null ) { - return cm.getClassIndex ( gid, 0 ); + if (cm != null) { + return cm.getClassIndex (gid, 0); } else { return -1; } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java index f8e430537..17f1b78fa 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java @@ -76,7 +76,7 @@ public class GlyphMappingTable { * @param gid glyph identifier (code) * @return non-negative glyph mapping index or -1 if glyph identifiers is not mapped by table */ - public int getMappedIndex ( int gid ) { + public int getMappedIndex (int gid) { return -1; } @@ -86,13 +86,13 @@ public class GlyphMappingTable { * Construct empty mapping table. */ public EmptyMappingTable() { - this ( (List) null ); + this ((List) null); } /** * Construct empty mapping table with entries (ignored). * @param entries list of entries (ignored) */ - public EmptyMappingTable ( List entries ) { + public EmptyMappingTable (List entries) { } /** {@inheritDoc} */ public int getType() { @@ -107,7 +107,7 @@ public class GlyphMappingTable { return 0; } /** {@inheritDoc} */ - public int getMappedIndex ( int gid ) { + public int getMappedIndex (int gid) { return -1; } } @@ -135,8 +135,8 @@ public class GlyphMappingTable { * Construct range mapping table. * @param entries of mapping ranges */ - public RangeMappingTable ( List entries ) { - populate ( entries ); + public RangeMappingTable (List entries) { + populate (entries); } /** {@inheritDoc} */ public int getType() { @@ -145,9 +145,9 @@ public class GlyphMappingTable { /** {@inheritDoc} */ public List getEntries() { List entries = new java.util.ArrayList(); - if ( sa != null ) { - for ( int i = 0, n = sa.length; i < n; i++ ) { - entries.add ( new MappingRange ( sa [ i ], ea [ i ], ma [ i ] ) ); + if (sa != null) { + for (int i = 0, n = sa.length; i < n; i++) { + entries.add (new MappingRange (sa [ i ], ea [ i ], ma [ i ])); } } return entries; @@ -157,17 +157,17 @@ public class GlyphMappingTable { return miMax + 1; } /** {@inheritDoc} */ - public int getMappedIndex ( int gid ) { + public int getMappedIndex (int gid) { int i; int mi; - if ( ( i = Arrays.binarySearch ( sa, gid ) ) >= 0 ) { - mi = getMappedIndex ( gid, sa [ i ], ma [ i ] ); // matches start of (some) range - } else if ( ( i = - ( i + 1 ) ) == 0 ) { + if ((i = Arrays.binarySearch (sa, gid)) >= 0) { + mi = getMappedIndex (gid, sa [ i ], ma [ i ]); // matches start of (some) range + } else if ((i = - (i + 1)) == 0) { mi = -1; // precedes first range - } else if ( gid > ea [ --i ] ) { + } else if (gid > ea [ --i ]) { mi = -1; // follows preceding (or last) range } else { - mi = getMappedIndex ( gid, sa [ i ], ma [ i ] ); // intersects (some) range + mi = getMappedIndex (gid, sa [ i ], ma [ i ]); // intersects (some) range } return mi; } @@ -179,8 +179,8 @@ public class GlyphMappingTable { * @param m mapping value * @return non-negative glyph mapping index or -1 if glyph identifiers is not mapped by table */ - public abstract int getMappedIndex ( int gid, int s, int m ); - private void populate ( List entries ) { + public abstract int getMappedIndex (int gid, int s, int m); + private void populate (List entries) { int i = 0; int n = entries.size(); int gidMax = -1; @@ -188,35 +188,35 @@ public class GlyphMappingTable { int[] sa = new int [ n ]; int[] ea = new int [ n ]; int[] ma = new int [ n ]; - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof MappingRange ) { + if (o instanceof MappingRange) { MappingRange r = (MappingRange) o; int gs = r.getStart(); int ge = r.getEnd(); int mi = r.getIndex(); - if ( ( gs < 0 ) || ( gs > 65535 ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal glyph range: [" + gs + "," + ge + "]: bad start index" ); - } else if ( ( ge < 0 ) || ( ge > 65535 ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal glyph range: [" + gs + "," + ge + "]: bad end index" ); - } else if ( gs > ge ) { - throw new AdvancedTypographicTableFormatException ( "illegal glyph range: [" + gs + "," + ge + "]: start index exceeds end index" ); - } else if ( gs < gidMax ) { - throw new AdvancedTypographicTableFormatException ( "out of order glyph range: [" + gs + "," + ge + "]" ); - } else if ( mi < 0 ) { - throw new AdvancedTypographicTableFormatException ( "illegal mapping index: " + mi ); + if ((gs < 0) || (gs > 65535)) { + throw new AdvancedTypographicTableFormatException ("illegal glyph range: [" + gs + "," + ge + "]: bad start index"); + } else if ((ge < 0) || (ge > 65535)) { + throw new AdvancedTypographicTableFormatException ("illegal glyph range: [" + gs + "," + ge + "]: bad end index"); + } else if (gs > ge) { + throw new AdvancedTypographicTableFormatException ("illegal glyph range: [" + gs + "," + ge + "]: start index exceeds end index"); + } else if (gs < gidMax) { + throw new AdvancedTypographicTableFormatException ("out of order glyph range: [" + gs + "," + ge + "]"); + } else if (mi < 0) { + throw new AdvancedTypographicTableFormatException ("illegal mapping index: " + mi); } else { int miLast; sa [ i ] = gs; ea [ i ] = gidMax = ge; ma [ i ] = mi; - if ( ( miLast = mi + ( ge - gs ) ) > miMax ) { + if ((miLast = mi + (ge - gs)) > miMax) { miMax = miLast; } i++; } } else { - throw new AdvancedTypographicTableFormatException ( "illegal mapping entry, must be Integer: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal mapping entry, must be Integer: " + o); } } assert i == n; @@ -232,15 +232,15 @@ public class GlyphMappingTable { public String toString() { StringBuffer sb = new StringBuffer(); sb.append('{'); - for ( int i = 0, n = sa.length; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = sa.length; i < n; i++) { + if (i > 0) { sb.append(','); } - sb.append ( '[' ); - sb.append ( Integer.toString ( sa [ i ] ) ); - sb.append ( Integer.toString ( ea [ i ] ) ); - sb.append ( "]:" ); - sb.append ( Integer.toString ( ma [ i ] ) ); + sb.append ('['); + sb.append (Integer.toString (sa [ i ])); + sb.append (Integer.toString (ea [ i ])); + sb.append ("]:"); + sb.append (Integer.toString (ma [ i ])); } sb.append('}'); return sb.toString(); @@ -261,7 +261,7 @@ public class GlyphMappingTable { * Instantiate a mapping range. */ public MappingRange() { - this ( 0, 0, 0 ); + this (0, 0, 0); } /** @@ -270,10 +270,10 @@ public class GlyphMappingTable { * @param gidEnd end of range * @param index mapping index */ - public MappingRange ( int gidStart, int gidEnd, int index ) { - if ( ( gidStart < 0 ) || ( gidEnd < 0 ) || ( index < 0 ) ) { + public MappingRange (int gidStart, int gidEnd, int index) { + if ((gidStart < 0) || (gidEnd < 0) || (index < 0)) { throw new AdvancedTypographicTableFormatException(); - } else if ( gidStart > gidEnd ) { + } else if (gidStart > gidEnd) { throw new AdvancedTypographicTableFormatException(); } else { this.gidStart = gidStart; @@ -307,8 +307,8 @@ public class GlyphMappingTable { * @param interval an array of length two or greater or null * @return interval as a pair of integers, filled into specified array */ - public int[] getInterval ( int[] interval ) { - if ( ( interval == null ) || ( interval.length != 2 ) ) { + public int[] getInterval (int[] interval) { + if ((interval == null) || (interval.length != 2)) { throw new IllegalArgumentException(); } else { interval[0] = gidStart; diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioning.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioning.java index 2ebc4d0a5..984361655 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioning.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioning.java @@ -39,6 +39,6 @@ public interface GlyphPositioning { * adjustment occurred; it only means that no further glyph subtables for the current lookup table * should be applied. */ - boolean position ( GlyphPositioningState ps ); + boolean position (GlyphPositioningState ps); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java index fafcf5614..0cd8fc1e4 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java @@ -60,8 +60,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param adjustments positioning adjustments to which positioning is applied * @param sct script context tester (or null) */ - public GlyphPositioningState ( GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - super ( gs, script, language, feature, sct ); + public GlyphPositioningState (GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct) { + super (gs, script, language, feature, sct); this.fontSize = fontSize; this.widths = widths; this.adjustments = adjustments; @@ -72,8 +72,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * except as follows: input glyph sequence is copied deep except for its characters array. * @param ps existing positioning state to copy from */ - public GlyphPositioningState ( GlyphPositioningState ps ) { - super ( ps ); + public GlyphPositioningState (GlyphPositioningState ps) { + super (ps); this.fontSize = ps.fontSize; this.widths = ps.widths; this.adjustments = ps.adjustments; @@ -90,8 +90,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param adjustments positioning adjustments to which positioning is applied * @param sct script context tester (or null) */ - public GlyphPositioningState reset ( GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - super.reset ( gs, script, language, feature, sct ); + public GlyphPositioningState reset (GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct) { + super.reset (gs, script, language, feature, sct); this.fontSize = fontSize; this.widths = widths; this.adjustments = adjustments; @@ -104,8 +104,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param gi glyph index * @return design advancement, or zero if glyph index is not present */ - public int getWidth ( int gi ) { - if ( ( widths != null ) && ( gi < widths.length ) ) { + public int getWidth (int gi) { + if ((widths != null) && (gi < widths.length)) { return widths [ gi ]; } else { return 0; @@ -117,8 +117,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param v value containing adjustments * @return true if a non-zero adjustment was made */ - public boolean adjust ( GlyphPositioningTable.Value v ) { - return adjust ( v, 0 ); + public boolean adjust (GlyphPositioningTable.Value v) { + return adjust (v, 0); } /** @@ -127,10 +127,10 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param offset from current position index * @return true if a non-zero adjustment was made */ - public boolean adjust ( GlyphPositioningTable.Value v, int offset ) { + public boolean adjust (GlyphPositioningTable.Value v, int offset) { assert v != null; - if ( ( index + offset ) < indexLast ) { - return v.adjust ( adjustments [ index + offset ], fontSize ); + if ((index + offset) < indexLast) { + return v.adjust (adjustments [ index + offset ], fontSize); } else { throw new IndexOutOfBoundsException(); } @@ -141,7 +141,7 @@ public class GlyphPositioningState extends GlyphProcessingState { * @return array of adjustments (int[4]) at current position */ public int[] getAdjustment() { - return getAdjustment ( 0 ); + return getAdjustment (0); } /** @@ -150,8 +150,8 @@ public class GlyphPositioningState extends GlyphProcessingState { * @return array of adjustments (int[4]) at specified offset * @throws IndexOutOfBoundsException if offset is invalid */ - public int[] getAdjustment ( int offset ) throws IndexOutOfBoundsException { - if ( ( index + offset ) < indexLast ) { + public int[] getAdjustment (int offset) throws IndexOutOfBoundsException { + if ((index + offset) < indexLast) { return adjustments [ index + offset ]; } else { throw new IndexOutOfBoundsException(); @@ -165,10 +165,10 @@ public class GlyphPositioningState extends GlyphProcessingState { * @return true if subtable applied, or false if it did not (e.g., its * input coverage table did not match current input context) */ - public boolean apply ( GlyphPositioningSubtable st ) { + public boolean apply (GlyphPositioningSubtable st) { assert st != null; - updateSubtableState ( st ); - boolean applied = st.position ( this ); + updateSubtableState (st); + boolean applied = st.position (this); return applied; } @@ -182,24 +182,24 @@ public class GlyphPositioningState extends GlyphProcessingState { * the lookups are to apply, and to be consumed once the application has finished * @return true if lookups are non-null and non-empty; otherwise, false */ - public boolean apply ( GlyphTable.RuleLookup[] lookups, int nig ) { - if ( ( lookups != null ) && ( lookups.length > 0 ) ) { + public boolean apply (GlyphTable.RuleLookup[] lookups, int nig) { + if ((lookups != null) && (lookups.length > 0)) { // apply each rule lookup to extracted input glyph array - for ( int i = 0, n = lookups.length; i < n; i++ ) { + for (int i = 0, n = lookups.length; i < n; i++) { GlyphTable.RuleLookup l = lookups [ i ]; - if ( l != null ) { + if (l != null) { GlyphTable.LookupTable lt = l.getLookup(); - if ( lt != null ) { + if (lt != null) { // perform positioning on a copy of previous state - GlyphPositioningState ps = new GlyphPositioningState ( this ); + GlyphPositioningState ps = new GlyphPositioningState (this); // apply lookup table positioning - if ( lt.position ( ps, l.getSequenceIndex() ) ) { - setAdjusted ( true ); + if (lt.position (ps, l.getSequenceIndex())) { + setAdjusted (true); } } } } - consume ( nig ); + consume (nig); return true; } else { return false; @@ -218,7 +218,7 @@ public class GlyphPositioningState extends GlyphProcessingState { * @param adjusted true if to set adjusted state, otherwise false to * clear adjusted state */ - public void setAdjusted ( boolean adjusted ) { + public void setAdjusted (boolean adjusted) { this.adjusted = adjusted; } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningSubtable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningSubtable.java index d1dae3275..e1bf6adcb 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningSubtable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningSubtable.java @@ -44,8 +44,8 @@ public abstract class GlyphPositioningSubtable extends GlyphSubtable implements * @param format subtable format * @param coverage subtable coverage table */ - protected GlyphPositioningSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage ) { - super ( id, sequence, flags, format, coverage ); + protected GlyphPositioningSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ @@ -55,11 +55,11 @@ public abstract class GlyphPositioningSubtable extends GlyphSubtable implements /** {@inheritDoc} */ public String getTypeName() { - return GlyphPositioningTable.getLookupTypeName ( getType() ); + return GlyphPositioningTable.getLookupTypeName (getType()); } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof GlyphPositioningSubtable; } @@ -69,7 +69,7 @@ public abstract class GlyphPositioningSubtable extends GlyphSubtable implements } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { return false; } @@ -85,24 +85,24 @@ public abstract class GlyphPositioningSubtable extends GlyphSubtable implements * @param sequenceIndex if non negative, then apply subtables only at specified sequence index * @return true if a non-zero adjustment occurred */ - public static final boolean position ( GlyphPositioningState ps, GlyphPositioningSubtable[] sta, int sequenceIndex ) { + public static final boolean position (GlyphPositioningState ps, GlyphPositioningSubtable[] sta, int sequenceIndex) { int sequenceStart = ps.getPosition(); boolean appliedOneShot = false; - while ( ps.hasNext() ) { + while (ps.hasNext()) { boolean applied = false; - if ( ! appliedOneShot && ps.maybeApplicable() ) { - for ( int i = 0, n = sta.length; ! applied && ( i < n ); i++ ) { - if ( sequenceIndex < 0 ) { - applied = ps.apply ( sta [ i ] ); - } else if ( ps.getPosition() == ( sequenceStart + sequenceIndex ) ) { - applied = ps.apply ( sta [ i ] ); - if ( applied ) { + if (! appliedOneShot && ps.maybeApplicable()) { + for (int i = 0, n = sta.length; ! applied && (i < n); i++) { + if (sequenceIndex < 0) { + applied = ps.apply (sta [ i ]); + } else if (ps.getPosition() == (sequenceStart + sequenceIndex)) { + applied = ps.apply (sta [ i ]); + if (applied) { appliedOneShot = true; } } } } - if ( ! applied || ! ps.didConsume() ) { + if (! applied || ! ps.didConsume()) { ps.applyDefault(); } ps.next(); @@ -123,9 +123,9 @@ public abstract class GlyphPositioningSubtable extends GlyphSubtable implements * @param sct script context tester * @return true if a non-zero adjustment occurred */ - public static final boolean position ( GlyphSequence gs, String script, String language, String feature, int fontSize, GlyphPositioningSubtable[] sta, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - synchronized ( state ) { - return position ( state.reset ( gs, script, language, feature, fontSize, widths, adjustments, sct ), sta, -1 ); + public static final boolean position (GlyphSequence gs, String script, String language, String feature, int fontSize, GlyphPositioningSubtable[] sta, int[] widths, int[][] adjustments, ScriptContextTester sct) { + synchronized (state) { + return position (state.reset (gs, script, language, feature, fontSize, widths, adjustments, sct), sta, -1); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java index 30fd13d62..f0840f5cf 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java @@ -74,17 +74,17 @@ public class GlyphPositioningTable extends GlyphTable { * @param lookups a map of lookup specifications to subtable identifier strings * @param subtables a list of identified subtables */ - public GlyphPositioningTable ( GlyphDefinitionTable gdef, Map lookups, List subtables ) { - super ( gdef, lookups ); - if ( ( subtables == null ) || ( subtables.size() == 0 ) ) { - throw new AdvancedTypographicTableFormatException ( "subtables must be non-empty" ); + public GlyphPositioningTable (GlyphDefinitionTable gdef, Map lookups, List subtables) { + super (gdef, lookups); + if ((subtables == null) || (subtables.size() == 0)) { + throw new AdvancedTypographicTableFormatException ("subtables must be non-empty"); } else { - for ( Iterator it = subtables.iterator(); it.hasNext();) { + for (Iterator it = subtables.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof GlyphPositioningSubtable ) { - addSubtable ( (GlyphSubtable) o ); + if (o instanceof GlyphPositioningSubtable) { + addSubtable ((GlyphSubtable) o); } else { - throw new AdvancedTypographicTableFormatException ( "subtable must be a glyph positioning subtable" ); + throw new AdvancedTypographicTableFormatException ("subtable must be a glyph positioning subtable"); } } freezeSubtables(); @@ -96,26 +96,26 @@ public class GlyphPositioningTable extends GlyphTable { * @param name lookup type name * @return lookup type */ - public static int getLookupTypeFromName ( String name ) { + public static int getLookupTypeFromName (String name) { int t; String s = name.toLowerCase(); - if ( "single".equals ( s ) ) { + if ("single".equals (s)) { t = GPOS_LOOKUP_TYPE_SINGLE; - } else if ( "pair".equals ( s ) ) { + } else if ("pair".equals (s)) { t = GPOS_LOOKUP_TYPE_PAIR; - } else if ( "cursive".equals ( s ) ) { + } else if ("cursive".equals (s)) { t = GPOS_LOOKUP_TYPE_CURSIVE; - } else if ( "marktobase".equals ( s ) ) { + } else if ("marktobase".equals (s)) { t = GPOS_LOOKUP_TYPE_MARK_TO_BASE; - } else if ( "marktoligature".equals ( s ) ) { + } else if ("marktoligature".equals (s)) { t = GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE; - } else if ( "marktomark".equals ( s ) ) { + } else if ("marktomark".equals (s)) { t = GPOS_LOOKUP_TYPE_MARK_TO_MARK; - } else if ( "contextual".equals ( s ) ) { + } else if ("contextual".equals (s)) { t = GPOS_LOOKUP_TYPE_CONTEXTUAL; - } else if ( "chainedcontextual".equals ( s ) ) { + } else if ("chainedcontextual".equals (s)) { t = GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL; - } else if ( "extensionpositioning".equals ( s ) ) { + } else if ("extensionpositioning".equals (s)) { t = GPOS_LOOKUP_TYPE_EXTENSION_POSITIONING; } else { t = -1; @@ -128,9 +128,9 @@ public class GlyphPositioningTable extends GlyphTable { * @param type lookup type * @return lookup type name */ - public static String getLookupTypeName ( int type ) { + public static String getLookupTypeName (int type) { String tn; - switch ( type ) { + switch (type) { case GPOS_LOOKUP_TYPE_SINGLE: tn = "single"; break; @@ -176,32 +176,32 @@ public class GlyphPositioningTable extends GlyphTable { * @param entries subtable entries * @return a glyph subtable instance */ - public static GlyphSubtable createSubtable ( int type, String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { + public static GlyphSubtable createSubtable (int type, String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { GlyphSubtable st = null; - switch ( type ) { + switch (type) { case GPOS_LOOKUP_TYPE_SINGLE: - st = SingleSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = SingleSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_PAIR: - st = PairSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = PairSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_CURSIVE: - st = CursiveSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = CursiveSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_MARK_TO_BASE: - st = MarkToBaseSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = MarkToBaseSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE: - st = MarkToLigatureSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = MarkToLigatureSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_MARK_TO_MARK: - st = MarkToMarkSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = MarkToMarkSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_CONTEXTUAL: - st = ContextualSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = ContextualSubtable.create (id, sequence, flags, format, coverage, entries); break; case GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL: - st = ChainedContextualSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = ChainedContextualSubtable.create (id, sequence, flags, format, coverage, entries); break; default: break; @@ -220,8 +220,8 @@ public class GlyphPositioningTable extends GlyphTable { * @param entries subtable entries * @return a glyph subtable instance */ - public static GlyphSubtable createSubtable ( int type, String id, int sequence, int flags, int format, List coverage, List entries ) { - return createSubtable ( type, id, sequence, flags, format, GlyphCoverageTable.createCoverageTable ( coverage ), entries ); + public static GlyphSubtable createSubtable (int type, String id, int sequence, int flags, int format, List coverage, List entries) { + return createSubtable (type, id, sequence, flags, format, GlyphCoverageTable.createCoverageTable (coverage), entries); } /** @@ -235,39 +235,39 @@ public class GlyphPositioningTable extends GlyphTable { * with one 4-tuple for each element of glyph sequence * @return true if some adjustment is not zero; otherwise, false */ - public boolean position ( GlyphSequence gs, String script, String language, int fontSize, int[] widths, int[][] adjustments ) { - Map/*>*/ lookups = matchLookups ( script, language, "*" ); - if ( ( lookups != null ) && ( lookups.size() > 0 ) ) { - ScriptProcessor sp = ScriptProcessor.getInstance ( script ); - return sp.position ( this, gs, script, language, fontSize, lookups, widths, adjustments ); + public boolean position (GlyphSequence gs, String script, String language, int fontSize, int[] widths, int[][] adjustments) { + Map/*>*/ lookups = matchLookups (script, language, "*"); + if ((lookups != null) && (lookups.size() > 0)) { + ScriptProcessor sp = ScriptProcessor.getInstance (script); + return sp.position (this, gs, script, language, fontSize, lookups, widths, adjustments); } else { return false; } } private abstract static class SingleSubtable extends GlyphPositioningSubtable { - SingleSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + SingleSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_SINGLE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof SingleSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { int gi = ps.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { - Value v = getValue ( ci, gi ); - if ( v != null ) { - if ( ps.adjust(v) ) { - ps.setAdjusted ( true ); + Value v = getValue (ci, gi); + if (v != null) { + if (ps.adjust(v)) { + ps.setAdjusted (true); } ps.consume(1); } @@ -280,12 +280,12 @@ public class GlyphPositioningTable extends GlyphTable { * @param gi input glyph index * @return positioning value or null if none applies */ - public abstract Value getValue ( int ci, int gi ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new SingleSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new SingleSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); + public abstract Value getValue (int ci, int gi); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new SingleSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new SingleSubtableFormat2 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -295,38 +295,38 @@ public class GlyphPositioningTable extends GlyphTable { private static class SingleSubtableFormat1 extends SingleSubtable { private Value value; private int ciMax; - SingleSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + SingleSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( value != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( value ); + if (value != null) { + List entries = new ArrayList (1); + entries.add (value); return entries; } else { return null; } } /** {@inheritDoc} */ - public Value getValue ( int ci, int gi ) { - if ( ( value != null ) && ( ci <= ciMax ) ) { + public Value getValue (int ci, int gi) { + if ((value != null) && (ci <= ciMax)) { return value; } else { return null; } } - private void populate ( List entries ) { - if ( ( entries == null ) || ( entries.size() != 1 ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null and contain exactly one entry" ); + private void populate (List entries) { + if ((entries == null) || (entries.size() != 1)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null and contain exactly one entry"); } else { Value v; Object o = entries.get(0); - if ( o instanceof Value ) { + if (o instanceof Value) { v = (Value) o; } else { - throw new AdvancedTypographicTableFormatException ( "illegal entries entry, must be Value, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + throw new AdvancedTypographicTableFormatException ("illegal entries entry, must be Value, but is: " + ((o != null) ? o.getClass() : null)); } assert this.value == null; this.value = v; @@ -337,16 +337,16 @@ public class GlyphPositioningTable extends GlyphTable { private static class SingleSubtableFormat2 extends SingleSubtable { private Value[] values; - SingleSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + SingleSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( values != null ) { - List entries = new ArrayList ( values.length ); - for ( int i = 0, n = values.length; i < n; i++ ) { - entries.add ( values[i] ); + if (values != null) { + List entries = new ArrayList (values.length); + for (int i = 0, n = values.length; i < n; i++) { + entries.add (values[i]); } return entries; } else { @@ -354,26 +354,26 @@ public class GlyphPositioningTable extends GlyphTable { } } /** {@inheritDoc} */ - public Value getValue ( int ci, int gi ) { - if ( ( values != null ) && ( ci < values.length ) ) { + public Value getValue (int ci, int gi) { + if ((values != null) && (ci < values.length)) { return values [ ci ]; } else { return null; } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof Value[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, single entry must be a Value[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof Value[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, single entry must be a Value[], but is: " + ((o != null) ? o.getClass() : null)); } else { Value[] va = (Value[]) o; - if ( va.length != getCoverageSize() ) { - throw new AdvancedTypographicTableFormatException ( "illegal values array, " + entries.size() + " values present, but requires " + getCoverageSize() + " values" ); + if (va.length != getCoverageSize()) { + throw new AdvancedTypographicTableFormatException ("illegal values array, " + entries.size() + " values present, but requires " + getCoverageSize() + " values"); } else { assert this.values == null; this.values = va; @@ -384,35 +384,35 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class PairSubtable extends GlyphPositioningSubtable { - PairSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + PairSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_PAIR; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof PairSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int gi = ps.getGlyph(0); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) >= 0 ) { - int[] counts = ps.getGlyphsAvailable ( 0 ); + if ((ci = getCoverageIndex (gi)) >= 0) { + int[] counts = ps.getGlyphsAvailable (0); int nga = counts[0]; - if ( nga > 1 ) { - int[] iga = ps.getGlyphs ( 0, 2, null, counts ); - if ( ( iga != null ) && ( iga.length == 2 ) ) { - PairValues pv = getPairValues ( ci, iga[0], iga[1] ); - if ( pv != null ) { + if (nga > 1) { + int[] iga = ps.getGlyphs (0, 2, null, counts); + if ((iga != null) && (iga.length == 2)) { + PairValues pv = getPairValues (ci, iga[0], iga[1]); + if (pv != null) { int offset = 0; int offsetLast = counts[0] + counts[1]; // skip any ignored glyphs prior to first non-ignored glyph - for ( ; offset < offsetLast; ++offset ) { - if ( ! ps.isIgnoredGlyph ( offset ) ) { + for ( ; offset < offsetLast; ++offset) { + if (! ps.isIgnoredGlyph (offset)) { break; } else { ps.consume(1); @@ -420,16 +420,16 @@ public class GlyphPositioningTable extends GlyphTable { } // adjust first non-ignored glyph if first value isn't null Value v1 = pv.getValue1(); - if ( v1 != null ) { - if ( ps.adjust(v1, offset) ) { - ps.setAdjusted ( true ); + if (v1 != null) { + if (ps.adjust(v1, offset)) { + ps.setAdjusted (true); } ps.consume(1); // consume first non-ignored glyph ++offset; } // skip any ignored glyphs prior to second non-ignored glyph - for ( ; offset < offsetLast; ++offset ) { - if ( ! ps.isIgnoredGlyph ( offset ) ) { + for ( ; offset < offsetLast; ++offset) { + if (! ps.isIgnoredGlyph (offset)) { break; } else { ps.consume(1); @@ -437,9 +437,9 @@ public class GlyphPositioningTable extends GlyphTable { } // adjust second non-ignored glyph if second value isn't null Value v2 = pv.getValue2(); - if ( v2 != null ) { - if ( ps.adjust(v2, offset) ) { - ps.setAdjusted ( true ); + if (v2 != null) { + if (ps.adjust(v2, offset)) { + ps.setAdjusted (true); } ps.consume(1); // consume second non-ignored glyph ++offset; @@ -458,12 +458,12 @@ public class GlyphPositioningTable extends GlyphTable { * @param gi2 second input glyph index * @return pair values or null if none applies */ - public abstract PairValues getPairValues ( int ci, int gi1, int gi2 ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new PairSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new PairSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); + public abstract PairValues getPairValues (int ci, int gi1, int gi2); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new PairSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new PairSubtableFormat2 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -472,31 +472,31 @@ public class GlyphPositioningTable extends GlyphTable { private static class PairSubtableFormat1 extends PairSubtable { private PairValues[][] pvm; // pair values matrix - PairSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + PairSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( pvm != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( pvm ); + if (pvm != null) { + List entries = new ArrayList (1); + entries.add (pvm); return entries; } else { return null; } } /** {@inheritDoc} */ - public PairValues getPairValues ( int ci, int gi1, int gi2 ) { - if ( ( pvm != null ) && ( ci < pvm.length ) ) { + public PairValues getPairValues (int ci, int gi1, int gi2) { + if ((pvm != null) && (ci < pvm.length)) { PairValues[] pvt = pvm [ ci ]; - for ( int i = 0, n = pvt.length; i < n; i++ ) { + for (int i = 0, n = pvt.length; i < n; i++) { PairValues pv = pvt [ i ]; - if ( pv != null ) { + if (pv != null) { int g = pv.getGlyph(); - if ( g < gi2 ) { + if (g < gi2) { continue; - } else if ( g == gi2 ) { + } else if (g == gi2) { return pv; } else { break; @@ -506,15 +506,15 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof PairValues[][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first (and only) entry must be a PairValues[][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof PairValues[][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first (and only) entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); } else { pvm = (PairValues[][]) o; } @@ -528,33 +528,33 @@ public class GlyphPositioningTable extends GlyphTable { private int nc1; // class 1 count private int nc2; // class 2 count private PairValues[][] pvm; // pair values matrix - PairSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + PairSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( pvm != null ) { - List entries = new ArrayList ( 5 ); - entries.add ( cdt1 ); - entries.add ( cdt2 ); - entries.add ( Integer.valueOf ( nc1 ) ); - entries.add ( Integer.valueOf ( nc2 ) ); - entries.add ( pvm ); + if (pvm != null) { + List entries = new ArrayList (5); + entries.add (cdt1); + entries.add (cdt2); + entries.add (Integer.valueOf (nc1)); + entries.add (Integer.valueOf (nc2)); + entries.add (pvm); return entries; } else { return null; } } /** {@inheritDoc} */ - public PairValues getPairValues ( int ci, int gi1, int gi2 ) { - if ( pvm != null ) { - int c1 = cdt1.getClassIndex ( gi1, 0 ); - if ( ( c1 >= 0 ) && ( c1 < nc1 ) && ( c1 < pvm.length ) ) { + public PairValues getPairValues (int ci, int gi1, int gi2) { + if (pvm != null) { + int c1 = cdt1.getClassIndex (gi1, 0); + if ((c1 >= 0) && (c1 < nc1) && (c1 < pvm.length)) { PairValues[] pvt = pvm [ c1 ]; - if ( pvt != null ) { - int c2 = cdt2.getClassIndex ( gi2, 0 ); - if ( ( c2 >= 0 ) && ( c2 < nc2 ) && ( c2 < pvt.length ) ) { + if (pvt != null) { + int c2 = cdt2.getClassIndex (gi2, 0); + if ((c2 >= 0) && (c2 < nc2) && (c2 < pvt.length)) { return pvt [ c2 ]; } } @@ -562,35 +562,35 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 5 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 5 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 5) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { cdt1 = (GlyphClassTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { cdt2 = (GlyphClassTable) o; } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { nc1 = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { nc2 = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(4) ) == null ) || ! ( o instanceof PairValues[][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fifth entry must be a PairValues[][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(4)) == null) || ! (o instanceof PairValues[][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fifth entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); } else { pvm = (PairValues[][]) o; } @@ -599,47 +599,47 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class CursiveSubtable extends GlyphPositioningSubtable { - CursiveSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + CursiveSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_CURSIVE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof CursiveSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int gi = ps.getGlyph(0); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) >= 0 ) { - int[] counts = ps.getGlyphsAvailable ( 0 ); + if ((ci = getCoverageIndex (gi)) >= 0) { + int[] counts = ps.getGlyphsAvailable (0); int nga = counts[0]; - if ( nga > 1 ) { - int[] iga = ps.getGlyphs ( 0, 2, null, counts ); - if ( ( iga != null ) && ( iga.length == 2 ) ) { + if (nga > 1) { + int[] iga = ps.getGlyphs (0, 2, null, counts); + if ((iga != null) && (iga.length == 2)) { // int gi1 = gi; int ci1 = ci; int gi2 = iga [ 1 ]; - int ci2 = getCoverageIndex ( gi2 ); - Anchor[] aa = getExitEntryAnchors ( ci1, ci2 ); - if ( aa != null ) { + int ci2 = getCoverageIndex (gi2); + Anchor[] aa = getExitEntryAnchors (ci1, ci2); + if (aa != null) { Anchor exa = aa [ 0 ]; Anchor ena = aa [ 1 ]; // int exw = ps.getWidth ( gi1 ); - int enw = ps.getWidth ( gi2 ); - if ( ( exa != null ) && ( ena != null ) ) { - Value v = ena.getAlignmentAdjustment ( exa ); - v.adjust ( - enw, 0, 0, 0 ); - if ( ps.adjust ( v ) ) { - ps.setAdjusted ( true ); + int enw = ps.getWidth (gi2); + if ((exa != null) && (ena != null)) { + Value v = ena.getAlignmentAdjustment (exa); + v.adjust (- enw, 0, 0, 0); + if (ps.adjust (v)) { + ps.setAdjusted (true); } } // consume only first glyph of exit/entry glyph pair - ps.consume ( 1 ); + ps.consume (1); applied = true; } } @@ -656,10 +656,10 @@ public class GlyphPositioningTable extends GlyphTable { * missing, where the first entry is the exit anchor of the first glyph and the second entry is the * entry anchor of the second glyph */ - public abstract Anchor[] getExitEntryAnchors ( int ci1, int ci2 ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new CursiveSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract Anchor[] getExitEntryAnchors (int ci1, int ci2); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new CursiveSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -668,46 +668,46 @@ public class GlyphPositioningTable extends GlyphTable { private static class CursiveSubtableFormat1 extends CursiveSubtable { private Anchor[] aa; // anchor array, where even entries are entry anchors, and odd entries are exit anchors - CursiveSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + CursiveSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( aa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( aa ); + if (aa != null) { + List entries = new ArrayList (1); + entries.add (aa); return entries; } else { return null; } } /** {@inheritDoc} */ - public Anchor[] getExitEntryAnchors ( int ci1, int ci2 ) { - if ( ( ci1 >= 0 ) && ( ci2 >= 0 ) ) { - int ai1 = ( ci1 * 2 ) + 1; // ci1 denotes glyph with exit anchor - int ai2 = ( ci2 * 2 ) + 0; // ci2 denotes glyph with entry anchor - if ( ( aa != null ) && ( ai1 < aa.length ) && ( ai2 < aa.length ) ) { + public Anchor[] getExitEntryAnchors (int ci1, int ci2) { + if ((ci1 >= 0) && (ci2 >= 0)) { + int ai1 = (ci1 * 2) + 1; // ci1 denotes glyph with exit anchor + int ai2 = (ci2 * 2) + 0; // ci2 denotes glyph with entry anchor + if ((aa != null) && (ai1 < aa.length) && (ai2 < aa.length)) { Anchor exa = aa [ ai1 ]; Anchor ena = aa [ ai2 ]; - if ( ( exa != null ) && ( ena != null ) ) { + if ((exa != null) && (ena != null)) { return new Anchor[] { exa, ena }; } } } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof Anchor[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first (and only) entry must be a Anchor[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); - } else if ( ( ( (Anchor[]) o ) . length % 2 ) != 0 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, Anchor[] array must have an even number of entries, but has: " + ( (Anchor[]) o ) . length ); + if (((o = entries.get(0)) == null) || ! (o instanceof Anchor[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first (and only) entry must be a Anchor[], but is: " + ((o != null) ? o.getClass() : null)); + } else if ((((Anchor[]) o) . length % 2) != 0) { + throw new AdvancedTypographicTableFormatException ("illegal entries, Anchor[] array must have an even number of entries, but has: " + ((Anchor[]) o) . length); } else { aa = (Anchor[]) o; } @@ -716,41 +716,41 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class MarkToBaseSubtable extends GlyphPositioningSubtable { - MarkToBaseSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + MarkToBaseSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_MARK_TO_BASE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof MarkToBaseSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int giMark = ps.getGlyph(); int ciMark; - if ( ( ciMark = getCoverageIndex ( giMark ) ) >= 0 ) { - MarkAnchor ma = getMarkAnchor ( ciMark, giMark ); - if ( ma != null ) { - for ( int i = 0, n = ps.getPosition(); i < n; i++ ) { - int gi = ps.getGlyph ( - ( i + 1 ) ); - if ( ps.isMark ( gi ) ) { + if ((ciMark = getCoverageIndex (giMark)) >= 0) { + MarkAnchor ma = getMarkAnchor (ciMark, giMark); + if (ma != null) { + for (int i = 0, n = ps.getPosition(); i < n; i++) { + int gi = ps.getGlyph (- (i + 1)); + if (ps.isMark (gi)) { continue; } else { - Anchor a = getBaseAnchor ( gi, ma.getMarkClass() ); - if ( a != null ) { - Value v = a.getAlignmentAdjustment ( ma ); + Anchor a = getBaseAnchor (gi, ma.getMarkClass()); + if (a != null) { + Value v = a.getAlignmentAdjustment (ma); // start experimental fix for END OF AYAH in Lateef/Scheherazade int[] aa = ps.getAdjustment(); - if ( aa[2] == 0 ) { - v.adjust ( 0, 0, - ps.getWidth ( giMark ), 0 ); + if (aa[2] == 0) { + v.adjust (0, 0, - ps.getWidth (giMark), 0); } // end experimental fix for END OF AYAH in Lateef/Scheherazade - if ( ps.adjust ( v ) ) { - ps.setAdjusted ( true ); + if (ps.adjust (v)) { + ps.setAdjusted (true); } } ps.consume(1); @@ -768,17 +768,17 @@ public class GlyphPositioningTable extends GlyphTable { * @param giMark input glyph index of mark glyph * @return mark anchor or null if none applies */ - public abstract MarkAnchor getMarkAnchor ( int ciMark, int giMark ); + public abstract MarkAnchor getMarkAnchor (int ciMark, int giMark); /** * Obtain anchor associated with base glyph index and mark class. * @param giBase input glyph index of base glyph * @param markClass class number of mark glyph * @return anchor or null if none applies */ - public abstract Anchor getBaseAnchor ( int giBase, int markClass ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new MarkToBaseSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract Anchor getBaseAnchor (int giBase, int markClass); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new MarkToBaseSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -790,68 +790,68 @@ public class GlyphPositioningTable extends GlyphTable { private int nmc; // mark class count private MarkAnchor[] maa; // mark anchor array, ordered by mark coverage index private Anchor[][] bam; // base anchor matrix, ordered by base coverage index, then by mark class - MarkToBaseSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + MarkToBaseSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( ( bct != null ) && ( maa != null ) && ( nmc > 0 ) && ( bam != null ) ) { - List entries = new ArrayList ( 4 ); - entries.add ( bct ); - entries.add ( Integer.valueOf ( nmc ) ); - entries.add ( maa ); - entries.add ( bam ); + if ((bct != null) && (maa != null) && (nmc > 0) && (bam != null)) { + List entries = new ArrayList (4); + entries.add (bct); + entries.add (Integer.valueOf (nmc)); + entries.add (maa); + entries.add (bam); return entries; } else { return null; } } /** {@inheritDoc} */ - public MarkAnchor getMarkAnchor ( int ciMark, int giMark ) { - if ( ( maa != null ) && ( ciMark < maa.length ) ) { + public MarkAnchor getMarkAnchor (int ciMark, int giMark) { + if ((maa != null) && (ciMark < maa.length)) { return maa [ ciMark ]; } else { return null; } } /** {@inheritDoc} */ - public Anchor getBaseAnchor ( int giBase, int markClass ) { + public Anchor getBaseAnchor (int giBase, int markClass) { int ciBase; - if ( ( bct != null ) && ( ( ciBase = bct.getCoverageIndex ( giBase ) ) >= 0 ) ) { - if ( ( bam != null ) && ( ciBase < bam.length ) ) { + if ((bct != null) && ((ciBase = bct.getCoverageIndex (giBase)) >= 0)) { + if ((bam != null) && (ciBase < bam.length)) { Anchor[] ba = bam [ ciBase ]; - if ( ( ba != null ) && ( markClass < ba.length ) ) { + if ((ba != null) && (markClass < ba.length)) { return ba [ markClass ]; } } } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 4 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 4 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 4) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphCoverageTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphCoverageTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); } else { bct = (GlyphCoverageTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { nmc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof MarkAnchor[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be a MarkAnchor[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof MarkAnchor[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); } else { maa = (MarkAnchor[]) o; } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof Anchor[][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be a Anchor[][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof Anchor[][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be a Anchor[][], but is: " + ((o != null) ? o.getClass() : null)); } else { bam = (Anchor[][]) o; } @@ -860,35 +860,35 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class MarkToLigatureSubtable extends GlyphPositioningSubtable { - MarkToLigatureSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + MarkToLigatureSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof MarkToLigatureSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int giMark = ps.getGlyph(); int ciMark; - if ( ( ciMark = getCoverageIndex ( giMark ) ) >= 0 ) { - MarkAnchor ma = getMarkAnchor ( ciMark, giMark ); + if ((ciMark = getCoverageIndex (giMark)) >= 0) { + MarkAnchor ma = getMarkAnchor (ciMark, giMark); int mxc = getMaxComponentCount(); - if ( ma != null ) { - for ( int i = 0, n = ps.getPosition(); i < n; i++ ) { - int gi = ps.getGlyph ( - ( i + 1 ) ); - if ( ps.isMark ( gi ) ) { + if (ma != null) { + for (int i = 0, n = ps.getPosition(); i < n; i++) { + int gi = ps.getGlyph (- (i + 1)); + if (ps.isMark (gi)) { continue; } else { - Anchor a = getLigatureAnchor ( gi, mxc, i, ma.getMarkClass() ); - if ( a != null ) { - if ( ps.adjust ( a.getAlignmentAdjustment ( ma ) ) ) { - ps.setAdjusted ( true ); + Anchor a = getLigatureAnchor (gi, mxc, i, ma.getMarkClass()); + if (a != null) { + if (ps.adjust (a.getAlignmentAdjustment (ma))) { + ps.setAdjusted (true); } } ps.consume(1); @@ -906,7 +906,7 @@ public class GlyphPositioningTable extends GlyphTable { * @param giMark input glyph index of mark glyph * @return mark anchor or null if none applies */ - public abstract MarkAnchor getMarkAnchor ( int ciMark, int giMark ); + public abstract MarkAnchor getMarkAnchor (int ciMark, int giMark); /** * Obtain maximum component count. * @return maximum component count (>=0) @@ -920,10 +920,10 @@ public class GlyphPositioningTable extends GlyphTable { * @param markClass class number of mark glyph * @return anchor or null if none applies */ - public abstract Anchor getLigatureAnchor ( int giLig, int maxComponents, int component, int markClass ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new MarkToLigatureSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract Anchor getLigatureAnchor (int giLig, int maxComponents, int component, int markClass); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new MarkToLigatureSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -936,27 +936,27 @@ public class GlyphPositioningTable extends GlyphTable { private int mxc; // maximum ligature component count private MarkAnchor[] maa; // mark anchor array, ordered by mark coverage index private Anchor[][][] lam; // ligature anchor matrix, ordered by ligature coverage index, then ligature component, then mark class - MarkToLigatureSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + MarkToLigatureSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( lam != null ) { - List entries = new ArrayList ( 5 ); - entries.add ( lct ); - entries.add ( Integer.valueOf ( nmc ) ); - entries.add ( Integer.valueOf ( mxc ) ); - entries.add ( maa ); - entries.add ( lam ); + if (lam != null) { + List entries = new ArrayList (5); + entries.add (lct); + entries.add (Integer.valueOf (nmc)); + entries.add (Integer.valueOf (mxc)); + entries.add (maa); + entries.add (lam); return entries; } else { return null; } } /** {@inheritDoc} */ - public MarkAnchor getMarkAnchor ( int ciMark, int giMark ) { - if ( ( maa != null ) && ( ciMark < maa.length ) ) { + public MarkAnchor getMarkAnchor (int ciMark, int giMark) { + if ((maa != null) && (ciMark < maa.length)) { return maa [ ciMark ]; } else { return null; @@ -967,14 +967,14 @@ public class GlyphPositioningTable extends GlyphTable { return mxc; } /** {@inheritDoc} */ - public Anchor getLigatureAnchor ( int giLig, int maxComponents, int component, int markClass ) { + public Anchor getLigatureAnchor (int giLig, int maxComponents, int component, int markClass) { int ciLig; - if ( ( lct != null ) && ( ( ciLig = lct.getCoverageIndex ( giLig ) ) >= 0 ) ) { - if ( ( lam != null ) && ( ciLig < lam.length ) ) { + if ((lct != null) && ((ciLig = lct.getCoverageIndex (giLig)) >= 0)) { + if ((lam != null) && (ciLig < lam.length)) { Anchor[][] lcm = lam [ ciLig ]; - if ( component < maxComponents ) { + if (component < maxComponents) { Anchor[] la = lcm [ component ]; - if ( ( la != null ) && ( markClass < la.length ) ) { + if ((la != null) && (markClass < la.length)) { return la [ markClass ]; } } @@ -982,35 +982,35 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 5 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 5 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 5) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphCoverageTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphCoverageTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); } else { lct = (GlyphCoverageTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { nmc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { mxc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof MarkAnchor[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be a MarkAnchor[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof MarkAnchor[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); } else { maa = (MarkAnchor[]) o; } - if ( ( ( o = entries.get(4) ) == null ) || ! ( o instanceof Anchor[][][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fifth entry must be a Anchor[][][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(4)) == null) || ! (o instanceof Anchor[][][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fifth entry must be a Anchor[][][], but is: " + ((o != null) ? o.getClass() : null)); } else { lam = (Anchor[][][]) o; } @@ -1019,30 +1019,30 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class MarkToMarkSubtable extends GlyphPositioningSubtable { - MarkToMarkSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + MarkToMarkSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_MARK_TO_MARK; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof MarkToMarkSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int giMark1 = ps.getGlyph(); int ciMark1; - if ( ( ciMark1 = getCoverageIndex ( giMark1 ) ) >= 0 ) { - MarkAnchor ma = getMark1Anchor ( ciMark1, giMark1 ); - if ( ma != null ) { - if ( ps.hasPrev() ) { - Anchor a = getMark2Anchor ( ps.getGlyph(-1), ma.getMarkClass() ); - if ( a != null ) { - if ( ps.adjust ( a.getAlignmentAdjustment ( ma ) ) ) { - ps.setAdjusted ( true ); + if ((ciMark1 = getCoverageIndex (giMark1)) >= 0) { + MarkAnchor ma = getMark1Anchor (ciMark1, giMark1); + if (ma != null) { + if (ps.hasPrev()) { + Anchor a = getMark2Anchor (ps.getGlyph(-1), ma.getMarkClass()); + if (a != null) { + if (ps.adjust (a.getAlignmentAdjustment (ma))) { + ps.setAdjusted (true); } } ps.consume(1); @@ -1058,17 +1058,17 @@ public class GlyphPositioningTable extends GlyphTable { * @param giMark1 input glyph index of mark 1 glyph * @return mark 1 anchor or null if none applies */ - public abstract MarkAnchor getMark1Anchor ( int ciMark1, int giMark1 ); + public abstract MarkAnchor getMark1Anchor (int ciMark1, int giMark1); /** * Obtain anchor associated with mark 2 glyph index and mark 1 class. * @param giMark2 input glyph index of mark 2 glyph * @param markClass class number of mark 1 glyph * @return anchor or null if none applies */ - public abstract Anchor getMark2Anchor ( int giBase, int markClass ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new MarkToMarkSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract Anchor getMark2Anchor (int giBase, int markClass); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new MarkToMarkSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -1080,68 +1080,68 @@ public class GlyphPositioningTable extends GlyphTable { private int nmc; // mark class count private MarkAnchor[] maa; // mark1 anchor array, ordered by mark1 coverage index private Anchor[][] mam; // mark2 anchor matrix, ordered by mark2 coverage index, then by mark1 class - MarkToMarkSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + MarkToMarkSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( ( mct2 != null ) && ( maa != null ) && ( nmc > 0 ) && ( mam != null ) ) { - List entries = new ArrayList ( 4 ); - entries.add ( mct2 ); - entries.add ( Integer.valueOf ( nmc ) ); - entries.add ( maa ); - entries.add ( mam ); + if ((mct2 != null) && (maa != null) && (nmc > 0) && (mam != null)) { + List entries = new ArrayList (4); + entries.add (mct2); + entries.add (Integer.valueOf (nmc)); + entries.add (maa); + entries.add (mam); return entries; } else { return null; } } /** {@inheritDoc} */ - public MarkAnchor getMark1Anchor ( int ciMark1, int giMark1 ) { - if ( ( maa != null ) && ( ciMark1 < maa.length ) ) { + public MarkAnchor getMark1Anchor (int ciMark1, int giMark1) { + if ((maa != null) && (ciMark1 < maa.length)) { return maa [ ciMark1 ]; } else { return null; } } /** {@inheritDoc} */ - public Anchor getMark2Anchor ( int giMark2, int markClass ) { + public Anchor getMark2Anchor (int giMark2, int markClass) { int ciMark2; - if ( ( mct2 != null ) && ( ( ciMark2 = mct2.getCoverageIndex ( giMark2 ) ) >= 0 ) ) { - if ( ( mam != null ) && ( ciMark2 < mam.length ) ) { + if ((mct2 != null) && ((ciMark2 = mct2.getCoverageIndex (giMark2)) >= 0)) { + if ((mam != null) && (ciMark2 < mam.length)) { Anchor[] ma = mam [ ciMark2 ]; - if ( ( ma != null ) && ( markClass < ma.length ) ) { + if ((ma != null) && (markClass < ma.length)) { return ma [ markClass ]; } } } return null; } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 4 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 4 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 4) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphCoverageTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphCoverageTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); } else { mct2 = (GlyphCoverageTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { nmc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof MarkAnchor[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be a MarkAnchor[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof MarkAnchor[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); } else { maa = (MarkAnchor[]) o; } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof Anchor[][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be a Anchor[][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof Anchor[][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be a Anchor[][], but is: " + ((o != null) ? o.getClass() : null)); } else { mam = (Anchor[][]) o; } @@ -1150,27 +1150,27 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class ContextualSubtable extends GlyphPositioningSubtable { - ContextualSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + ContextualSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_CONTEXTUAL; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof ContextualSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int gi = ps.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) >= 0 ) { + if ((ci = getCoverageIndex (gi)) >= 0) { int[] rv = new int[1]; - RuleLookup[] la = getLookups ( ci, gi, ps, rv ); - if ( la != null ) { - ps.apply ( la, rv[0] ); + RuleLookup[] la = getLookups (ci, gi, ps, rv); + if (la != null) { + ps.apply (la, rv[0]); applied = true; } } @@ -1185,14 +1185,14 @@ public class GlyphPositioningTable extends GlyphTable { * where the first entry is used to return the input sequence length of the matched rule * @return array of rule lookups or null if none applies */ - public abstract RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new ContextualSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new ContextualSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 3 ) { - return new ContextualSubtableFormat3 ( id, sequence, flags, format, coverage, entries ); + public abstract RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new ContextualSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new ContextualSubtableFormat2 (id, sequence, flags, format, coverage, entries); + } else if (format == 3) { + return new ContextualSubtableFormat3 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -1201,39 +1201,39 @@ public class GlyphPositioningTable extends GlyphTable { private static class ContextualSubtableFormat1 extends ContextualSubtable { private RuleSet[] rsa; // rule set array, ordered by glyph coverage index - ContextualSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedGlyphSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; - int[] iga = cr.getGlyphs ( gi ); - if ( matches ( ps, iga, 0, rv ) ) { + int[] iga = cr.getGlyphs (gi); + if (matches (ps, iga, 0, rv)) { return r.getLookups(); } } @@ -1242,40 +1242,40 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - static boolean matches ( GlyphPositioningState ps, int[] glyphs, int offset, int[] rv ) { - if ( ( glyphs == null ) || ( glyphs.length == 0 ) ) { + static boolean matches (GlyphPositioningState ps, int[] glyphs, int offset, int[] rv) { + if ((glyphs == null) || (glyphs.length == 0)) { return true; // match null or empty glyph sequence } else { boolean reverse = offset < 0; GlyphTester ignores = ps.getIgnoreDefault(); - int[] counts = ps.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ps.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = glyphs.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ps.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { - if ( ga [ k ] != glyphs [ k ] ) { + int[] ga = ps.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { + if (ga [ k ] != glyphs [ k ]) { return false; // match fails at ga [ k ] } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1287,41 +1287,41 @@ public class GlyphPositioningTable extends GlyphTable { private GlyphClassTable cdt; // class def table private int ngc; // class set count private RuleSet[] rsa; // rule set array, ordered by class number [0...ngc - 1] - ContextualSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 3 ); - entries.add ( cdt ); - entries.add ( Integer.valueOf ( ngc ) ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (3); + entries.add (cdt); + entries.add (Integer.valueOf (ngc)); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedClassSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedClassSequenceRule)) { ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; - int[] ca = cr.getClasses ( cdt.getClassIndex ( gi, ps.getClassMatchSet ( gi ) ) ); - if ( matches ( ps, cdt, ca, 0, rv ) ) { + int[] ca = cr.getClasses (cdt.getClassIndex (gi, ps.getClassMatchSet (gi))); + if (matches (ps, cdt, ca, 0, rv)) { return r.getLookups(); } } @@ -1330,59 +1330,59 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - static boolean matches ( GlyphPositioningState ps, GlyphClassTable cdt, int[] classes, int offset, int[] rv ) { - if ( ( cdt == null ) || ( classes == null ) || ( classes.length == 0 ) ) { + static boolean matches (GlyphPositioningState ps, GlyphClassTable cdt, int[] classes, int offset, int[] rv) { + if ((cdt == null) || (classes == null) || (classes.length == 0)) { return true; // match null class definitions, null or empty class sequence } else { boolean reverse = offset < 0; GlyphTester ignores = ps.getIgnoreDefault(); - int[] counts = ps.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ps.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = classes.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ps.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { + int[] ga = ps.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { int gi = ga [ k ]; - int ms = ps.getClassMatchSet ( gi ); - int gc = cdt.getClassIndex ( gi, ms ); - if ( ( gc < 0 ) || ( gc >= cdt.getClassSize ( ms ) ) ) { + int ms = ps.getClassMatchSet (gi); + int gc = cdt.getClassIndex (gi, ms); + if ((gc < 0) || (gc >= cdt.getClassSize (ms))) { return false; // none or invalid class fails mat ch - } else if ( gc != classes [ k ] ) { + } else if (gc != classes [ k ]) { return false; // match fails at ga [ k ] } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 3 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 3 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 3) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { cdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { ngc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; - if ( rsa.length != ngc ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes" ); + if (rsa.length != ngc) { + throw new AdvancedTypographicTableFormatException ("illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes"); } } } @@ -1391,39 +1391,39 @@ public class GlyphPositioningTable extends GlyphTable { private static class ContextualSubtableFormat3 extends ContextualSubtable { private RuleSet[] rsa; // rule set array, containing a single rule set - ContextualSubtableFormat3 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat3 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedCoverageSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; GlyphCoverageTable[] gca = cr.getCoverages(); - if ( matches ( ps, gca, 0, rv ) ) { + if (matches (ps, gca, 0, rv)) { return r.getLookups(); } } @@ -1432,43 +1432,43 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - static boolean matches ( GlyphPositioningState ps, GlyphCoverageTable[] gca, int offset, int[] rv ) { - if ( ( gca == null ) || ( gca.length == 0 ) ) { + static boolean matches (GlyphPositioningState ps, GlyphCoverageTable[] gca, int offset, int[] rv) { + if ((gca == null) || (gca.length == 0)) { return true; // match null or empty coverage array } else { boolean reverse = offset < 0; GlyphTester ignores = ps.getIgnoreDefault(); - int[] counts = ps.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ps.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = gca.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ps.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { + int[] ga = ps.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { GlyphCoverageTable ct = gca [ k ]; - if ( ct != null ) { - if ( ct.getCoverageIndex ( ga [ k ] ) < 0 ) { + if (ct != null) { + if (ct.getCoverageIndex (ga [ k ]) < 0) { return false; // match fails at ga [ k ] } } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1477,27 +1477,27 @@ public class GlyphPositioningTable extends GlyphTable { } private abstract static class ChainedContextualSubtable extends GlyphPositioningSubtable { - ChainedContextualSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + ChainedContextualSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof ChainedContextualSubtable; } /** {@inheritDoc} */ - public boolean position ( GlyphPositioningState ps ) { + public boolean position (GlyphPositioningState ps) { boolean applied = false; int gi = ps.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) >= 0 ) { + if ((ci = getCoverageIndex (gi)) >= 0) { int[] rv = new int[1]; - RuleLookup[] la = getLookups ( ci, gi, ps, rv ); - if ( la != null ) { - ps.apply ( la, rv[0] ); + RuleLookup[] la = getLookups (ci, gi, ps, rv); + if (la != null) { + ps.apply (la, rv[0]); applied = true; } } @@ -1512,14 +1512,14 @@ public class GlyphPositioningTable extends GlyphTable { * where the first entry is used to return the input sequence length of the matched rule * @return array of rule lookups or null if none applies */ - public abstract RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ); - static GlyphPositioningSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new ChainedContextualSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new ChainedContextualSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 3 ) { - return new ChainedContextualSubtableFormat3 ( id, sequence, flags, format, coverage, entries ); + public abstract RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv); + static GlyphPositioningSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new ChainedContextualSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new ChainedContextualSubtableFormat2 (id, sequence, flags, format, coverage, entries); + } else if (format == 3) { + return new ChainedContextualSubtableFormat3 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -1528,43 +1528,43 @@ public class GlyphPositioningTable extends GlyphTable { private static class ChainedContextualSubtableFormat1 extends ChainedContextualSubtable { private RuleSet[] rsa; // rule set array, ordered by glyph coverage index - ChainedContextualSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedGlyphSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; - int[] iga = cr.getGlyphs ( gi ); - if ( matches ( ps, iga, 0, rv ) ) { + int[] iga = cr.getGlyphs (gi); + if (matches (ps, iga, 0, rv)) { int[] bga = cr.getBacktrackGlyphs(); - if ( matches ( ps, bga, -1, null ) ) { + if (matches (ps, bga, -1, null)) { int[] lga = cr.getLookaheadGlyphs(); - if ( matches ( ps, lga, rv[0], null ) ) { + if (matches (ps, lga, rv[0], null)) { return r.getLookups(); } } @@ -1575,18 +1575,18 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private boolean matches ( GlyphPositioningState ps, int[] glyphs, int offset, int[] rv ) { - return ContextualSubtableFormat1.matches ( ps, glyphs, offset, rv ); + private boolean matches (GlyphPositioningState ps, int[] glyphs, int offset, int[] rv) { + return ContextualSubtableFormat1.matches (ps, glyphs, offset, rv); } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1600,47 +1600,47 @@ public class GlyphPositioningTable extends GlyphTable { private GlyphClassTable lcdt; // lookahead class def table private int ngc; // class set count private RuleSet[] rsa; // rule set array, ordered by class number [0...ngc - 1] - ChainedContextualSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 5 ); - entries.add ( icdt ); - entries.add ( bcdt ); - entries.add ( lcdt ); - entries.add ( Integer.valueOf ( ngc ) ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (5); + entries.add (icdt); + entries.add (bcdt); + entries.add (lcdt); + entries.add (Integer.valueOf (ngc)); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedClassSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedClassSequenceRule)) { ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; - int[] ica = cr.getClasses ( icdt.getClassIndex ( gi, ps.getClassMatchSet ( gi ) ) ); - if ( matches ( ps, icdt, ica, 0, rv ) ) { + int[] ica = cr.getClasses (icdt.getClassIndex (gi, ps.getClassMatchSet (gi))); + if (matches (ps, icdt, ica, 0, rv)) { int[] bca = cr.getBacktrackClasses(); - if ( matches ( ps, bcdt, bca, -1, null ) ) { + if (matches (ps, bcdt, bca, -1, null)) { int[] lca = cr.getLookaheadClasses(); - if ( matches ( ps, lcdt, lca, rv[0], null ) ) { + if (matches (ps, lcdt, lca, rv[0], null)) { return r.getLookups(); } } @@ -1651,42 +1651,42 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private boolean matches ( GlyphPositioningState ps, GlyphClassTable cdt, int[] classes, int offset, int[] rv ) { - return ContextualSubtableFormat2.matches ( ps, cdt, classes, offset, rv ); + private boolean matches (GlyphPositioningState ps, GlyphClassTable cdt, int[] classes, int offset, int[] rv) { + return ContextualSubtableFormat2.matches (ps, cdt, classes, offset, rv); } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 5 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 5 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 5) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { icdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(1) ) != null ) && ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass() ); + if (((o = entries.get(1)) != null) && ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); } else { bcdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(2) ) != null ) && ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass() ); + if (((o = entries.get(2)) != null) && ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); } else { lcdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { ngc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(4) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fifth entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(4)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; - if ( rsa.length != ngc ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes" ); + if (rsa.length != ngc) { + throw new AdvancedTypographicTableFormatException ("illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes"); } } } @@ -1695,43 +1695,43 @@ public class GlyphPositioningTable extends GlyphTable { private static class ChainedContextualSubtableFormat3 extends ChainedContextualSubtable { private RuleSet[] rsa; // rule set array, containing a single rule set - ChainedContextualSubtableFormat3 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat3 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphPositioningState ps, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphPositioningState ps, int[] rv) { assert ps != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedCoverageSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; GlyphCoverageTable[] igca = cr.getCoverages(); - if ( matches ( ps, igca, 0, rv ) ) { + if (matches (ps, igca, 0, rv)) { GlyphCoverageTable[] bgca = cr.getBacktrackCoverages(); - if ( matches ( ps, bgca, -1, null ) ) { + if (matches (ps, bgca, -1, null)) { GlyphCoverageTable[] lgca = cr.getLookaheadCoverages(); - if ( matches ( ps, lgca, rv[0], null ) ) { + if (matches (ps, lgca, rv[0], null)) { return r.getLookups(); } } @@ -1742,18 +1742,18 @@ public class GlyphPositioningTable extends GlyphTable { } return null; } - private boolean matches ( GlyphPositioningState ps, GlyphCoverageTable[] gca, int offset, int[] rv ) { - return ContextualSubtableFormat3.matches ( ps, gca, offset, rv ); + private boolean matches (GlyphPositioningState ps, GlyphCoverageTable[] gca, int offset, int[] rv) { + return ContextualSubtableFormat3.matches (ps, gca, offset, rv); } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1777,11 +1777,11 @@ public class GlyphPositioningTable extends GlyphTable { * @param endSize the ending (scaled) size * @param deltas adjustments for each scaled size */ - public DeviceTable ( int startSize, int endSize, int[] deltas ) { + public DeviceTable (int startSize, int endSize, int[] deltas) { assert startSize >= 0; assert startSize <= endSize; assert deltas != null; - assert deltas.length == ( endSize - startSize ) + 1; + assert deltas.length == (endSize - startSize) + 1; this.startSize = startSize; this.endSize = endSize; this.deltas = deltas; @@ -1807,12 +1807,12 @@ public class GlyphPositioningTable extends GlyphTable { * @param fontSize the font size to search for * @return an adjustment if font size matches an entry */ - public int findAdjustment ( int fontSize ) { + public int findAdjustment (int fontSize) { // [TODO] at present, assumes that 1 device unit equals one point int fs = fontSize / 1000; - if ( fs < startSize ) { + if (fs < startSize) { return 0; - } else if ( fs <= endSize ) { + } else if (fs <= endSize) { return deltas [ fs - startSize ] * 1000; } else { return 0; @@ -1821,7 +1821,7 @@ public class GlyphPositioningTable extends GlyphTable { /** {@inheritDoc} */ public String toString() { - return "{ start = " + startSize + ", end = " + endSize + ", deltas = " + Arrays.toString ( deltas ) + "}"; + return "{ start = " + startSize + ", end = " + endSize + ", deltas = " + Arrays.toString (deltas) + "}"; } } @@ -1879,7 +1879,7 @@ public class GlyphPositioningTable extends GlyphTable { * @param xAdvDevice the x advance device table or null * @param yAdvDevice the y advance device table or null */ - public Value ( int xPlacement, int yPlacement, int xAdvance, int yAdvance, DeviceTable xPlaDevice, DeviceTable yPlaDevice, DeviceTable xAdvDevice, DeviceTable yAdvDevice ) { + public Value (int xPlacement, int yPlacement, int xAdvance, int yAdvance, DeviceTable xPlaDevice, DeviceTable yPlaDevice, DeviceTable xAdvDevice, DeviceTable yAdvDevice) { this.xPlacement = xPlacement; this.yPlacement = yPlacement; this.xAdvance = xAdvance; @@ -1937,7 +1937,7 @@ public class GlyphPositioningTable extends GlyphTable { * @param xAdvance the x advance or zero * @param yAdvance the y advance or zero */ - public void adjust ( int xPlacement, int yPlacement, int xAdvance, int yAdvance ) { + public void adjust (int xPlacement, int yPlacement, int xAdvance, int yAdvance) { this.xPlacement += xPlacement; this.yPlacement += yPlacement; this.xAdvance += xAdvance; @@ -1950,47 +1950,47 @@ public class GlyphPositioningTable extends GlyphTable { * @param fontSize font size for device table adjustments * @return true if some adjustment was made */ - public boolean adjust ( int[] adjustments, int fontSize ) { + public boolean adjust (int[] adjustments, int fontSize) { boolean adjust = false; int dv; - if ( ( dv = xPlacement ) != 0 ) { + if ((dv = xPlacement) != 0) { adjustments [ IDX_X_PLACEMENT ] += dv; adjust = true; } - if ( ( dv = yPlacement ) != 0 ) { + if ((dv = yPlacement) != 0) { adjustments [ IDX_Y_PLACEMENT ] += dv; adjust = true; } - if ( ( dv = xAdvance ) != 0 ) { + if ((dv = xAdvance) != 0) { adjustments [ IDX_X_ADVANCE ] += dv; adjust = true; } - if ( ( dv = yAdvance ) != 0 ) { + if ((dv = yAdvance) != 0) { adjustments [ IDX_Y_ADVANCE ] += dv; adjust = true; } - if ( fontSize != 0 ) { + if (fontSize != 0) { DeviceTable dt; - if ( ( dt = xPlaDevice ) != null ) { - if ( ( dv = dt.findAdjustment ( fontSize ) ) != 0 ) { + if ((dt = xPlaDevice) != null) { + if ((dv = dt.findAdjustment (fontSize)) != 0) { adjustments [ IDX_X_PLACEMENT ] += dv; adjust = true; } } - if ( ( dt = yPlaDevice ) != null ) { - if ( ( dv = dt.findAdjustment ( fontSize ) ) != 0 ) { + if ((dt = yPlaDevice) != null) { + if ((dv = dt.findAdjustment (fontSize)) != 0) { adjustments [ IDX_Y_PLACEMENT ] += dv; adjust = true; } } - if ( ( dt = xAdvDevice ) != null ) { - if ( ( dv = dt.findAdjustment ( fontSize ) ) != 0 ) { + if ((dt = xAdvDevice) != null) { + if ((dv = dt.findAdjustment (fontSize)) != 0) { adjustments [ IDX_X_ADVANCE ] += dv; adjust = true; } } - if ( ( dt = yAdvDevice ) != null ) { - if ( ( dv = dt.findAdjustment ( fontSize ) ) != 0 ) { + if ((dt = yAdvDevice) != null) { + if ((dv = dt.findAdjustment (fontSize)) != 0) { adjustments [ IDX_Y_ADVANCE ] += dv; adjust = true; } @@ -2003,70 +2003,70 @@ public class GlyphPositioningTable extends GlyphTable { public String toString() { StringBuffer sb = new StringBuffer(); boolean first = true; - sb.append ( "{ " ); - if ( xPlacement != 0 ) { - if ( ! first ) { - sb.append ( ", " ); + sb.append ("{ "); + if (xPlacement != 0) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xPlacement = " + xPlacement ); + sb.append ("xPlacement = " + xPlacement); } - if ( yPlacement != 0 ) { - if ( ! first ) { - sb.append ( ", " ); + if (yPlacement != 0) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "yPlacement = " + yPlacement ); + sb.append ("yPlacement = " + yPlacement); } - if ( xAdvance != 0 ) { - if ( ! first ) { - sb.append ( ", " ); + if (xAdvance != 0) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xAdvance = " + xAdvance ); + sb.append ("xAdvance = " + xAdvance); } - if ( yAdvance != 0 ) { - if ( ! first ) { - sb.append ( ", " ); + if (yAdvance != 0) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "yAdvance = " + yAdvance ); + sb.append ("yAdvance = " + yAdvance); } - if ( xPlaDevice != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (xPlaDevice != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xPlaDevice = " + xPlaDevice ); + sb.append ("xPlaDevice = " + xPlaDevice); } - if ( yPlaDevice != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (yPlaDevice != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xPlaDevice = " + yPlaDevice ); + sb.append ("xPlaDevice = " + yPlaDevice); } - if ( xAdvDevice != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (xAdvDevice != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xAdvDevice = " + xAdvDevice ); + sb.append ("xAdvDevice = " + xAdvDevice); } - if ( yAdvDevice != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (yAdvDevice != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "xAdvDevice = " + yAdvDevice ); + sb.append ("xAdvDevice = " + yAdvDevice); } sb.append(" }"); return sb.toString(); @@ -2090,7 +2090,7 @@ public class GlyphPositioningTable extends GlyphTable { * @param value1 the value of the first glyph in pair (or null) * @param value2 the value of the second glyph in pair (or null) */ - public PairValues ( int glyph, Value value1, Value value2 ) { + public PairValues (int glyph, Value value1, Value value2) { assert glyph >= 0; this.glyph = glyph; this.value1 = value1; @@ -2116,30 +2116,30 @@ public class GlyphPositioningTable extends GlyphTable { public String toString() { StringBuffer sb = new StringBuffer(); boolean first = true; - sb.append ( "{ " ); - if ( glyph != 0 ) { - if ( ! first ) { - sb.append ( ", " ); + sb.append ("{ "); + if (glyph != 0) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "glyph = " + glyph ); + sb.append ("glyph = " + glyph); } - if ( value1 != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (value1 != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "value1 = " + value1 ); + sb.append ("value1 = " + value1); } - if ( value2 != null ) { - if ( ! first ) { - sb.append ( ", " ); + if (value2 != null) { + if (! first) { + sb.append (", "); } else { first = false; } - sb.append ( "value2 = " + value2 ); + sb.append ("value2 = " + value2); } sb.append(" }"); return sb.toString(); @@ -2164,8 +2164,8 @@ public class GlyphPositioningTable extends GlyphTable { * @param x the x coordinate * @param y the y coordinate */ - public Anchor ( int x, int y ) { - this ( x, y, -1, null, null ); + public Anchor (int x, int y) { + this (x, y, -1, null, null); } /** @@ -2174,8 +2174,8 @@ public class GlyphPositioningTable extends GlyphTable { * @param y the y coordinate * @param anchorPoint anchor index (or -1) */ - public Anchor ( int x, int y, int anchorPoint ) { - this ( x, y, anchorPoint, null, null ); + public Anchor (int x, int y, int anchorPoint) { + this (x, y, anchorPoint, null, null); } /** @@ -2185,20 +2185,20 @@ public class GlyphPositioningTable extends GlyphTable { * @param xDevice the x device table (or null if not present) * @param yDevice the y device table (or null if not present) */ - public Anchor ( int x, int y, DeviceTable xDevice, DeviceTable yDevice ) { - this ( x, y, -1, xDevice, yDevice ); + public Anchor (int x, int y, DeviceTable xDevice, DeviceTable yDevice) { + this (x, y, -1, xDevice, yDevice); } /** * Instantiate an Anchor based on an existing anchor. * @param a the existing anchor */ - protected Anchor ( Anchor a ) { - this ( a.x, a.y, a.anchorPoint, a.xDevice, a.yDevice ); + protected Anchor (Anchor a) { + this (a.x, a.y, a.anchorPoint, a.xDevice, a.yDevice); } - private Anchor ( int x, int y, int anchorPoint, DeviceTable xDevice, DeviceTable yDevice ) { - assert ( anchorPoint >= 0 ) || ( anchorPoint == -1 ); + private Anchor (int x, int y, int anchorPoint, DeviceTable xDevice, DeviceTable yDevice) { + assert (anchorPoint >= 0) || (anchorPoint == -1); this.x = x; this.y = y; this.anchorPoint = anchorPoint; @@ -2237,25 +2237,25 @@ public class GlyphPositioningTable extends GlyphTable { * @param a the anchor to align * @return the adjustment value needed to effect alignment */ - public Value getAlignmentAdjustment ( Anchor a ) { + public Value getAlignmentAdjustment (Anchor a) { assert a != null; // TODO - handle anchor point // TODO - handle device tables - return new Value ( x - a.x, y - a.y, 0, 0, null, null, null, null ); + return new Value (x - a.x, y - a.y, 0, 0, null, null, null, null); } /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ [" + x + "," + y + "]" ); - if ( anchorPoint != -1 ) { - sb.append ( ", anchorPoint = " + anchorPoint ); + sb.append ("{ [" + x + "," + y + "]"); + if (anchorPoint != -1) { + sb.append (", anchorPoint = " + anchorPoint); } - if ( xDevice != null ) { - sb.append ( ", xDevice = " + xDevice ); + if (xDevice != null) { + sb.append (", xDevice = " + xDevice); } - if ( yDevice != null ) { - sb.append ( ", yDevice = " + yDevice ); + if (yDevice != null) { + sb.append (", yDevice = " + yDevice); } sb.append(" }"); return sb.toString(); @@ -2276,8 +2276,8 @@ public class GlyphPositioningTable extends GlyphTable { * @param markClass the mark class * @param a the underlying anchor (whose fields are copied) */ - public MarkAnchor ( int markClass, Anchor a ) { - super ( a ); + public MarkAnchor (int markClass, Anchor a) { + super (a); this.markClass = markClass; } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java index 6916e2742..9c6f5731c 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java @@ -89,14 +89,14 @@ public class GlyphProcessingState { * @param feature feature identifier * @param sct script context tester (or null) */ - protected GlyphProcessingState ( GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct ) { + protected GlyphProcessingState (GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) { this.script = script; this.language = language; this.feature = feature; this.igs = gs; this.indexLast = gs.getGlyphCount(); this.sct = sct; - this.gct = ( sct != null ) ? sct.getTester ( feature ) : null; + this.gct = (sct != null) ? sct.getTester (feature) : null; this.ignoreBase = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredBase(gi, flags); } }; this.ignoreLigature = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredLigature(gi, flags); } }; this.ignoreMark = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredMark(gi, flags); } }; @@ -107,9 +107,9 @@ public class GlyphProcessingState { * except as follows: input glyph sequence is copied deep except for its characters array. * @param s existing processing state to copy from */ - protected GlyphProcessingState ( GlyphProcessingState s ) { - this ( new GlyphSequence ( s.igs ), s.script, s.language, s.feature, s.sct ); - setPosition ( s.index ); + protected GlyphProcessingState (GlyphProcessingState s) { + this (new GlyphSequence (s.igs), s.script, s.language, s.feature, s.sct); + setPosition (s.index); } /** @@ -120,7 +120,7 @@ public class GlyphProcessingState { * @param feature feature identifier * @param sct script context tester (or null) */ - protected GlyphProcessingState reset ( GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct ) { + protected GlyphProcessingState reset (GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) { this.gdef = null; this.script = script; this.language = language; @@ -132,7 +132,7 @@ public class GlyphProcessingState { this.lookupFlags = 0; this.classMatchSet = 0; this.sct = sct; - this.gct = ( sct != null ) ? sct.getTester ( feature ) : null; + this.gct = (sct != null) ? sct.getTester (feature) : null; this.ignoreBase = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredBase(gi, flags); } }; this.ignoreLigature = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredLigature(gi, flags); } }; this.ignoreMark = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredMark(gi, flags); } }; @@ -145,10 +145,10 @@ public class GlyphProcessingState { * Set governing glyph definition table. * @param gdef glyph definition table (or null, to unset) */ - public void setGDEF ( GlyphDefinitionTable gdef ) { - if ( this.gdef == null ) { + public void setGDEF (GlyphDefinitionTable gdef) { + if (this.gdef == null) { this.gdef = gdef; - } else if ( gdef == null ) { + } else if (gdef == null) { this.gdef = null; } } @@ -165,10 +165,10 @@ public class GlyphProcessingState { * Set governing lookup flags * @param flags lookup flags (or zero, to unset) */ - public void setLookupFlags ( int flags ) { - if ( this.lookupFlags == 0 ) { + public void setLookupFlags (int flags) { + if (this.lookupFlags == 0) { this.lookupFlags = flags; - } else if ( flags == 0 ) { + } else if (flags == 0) { this.lookupFlags = 0; } } @@ -186,7 +186,7 @@ public class GlyphProcessingState { * @param gi glyph index that may be used to determine which match set applies * @return class match set (zero may indicate unset or no set) */ - public int getClassMatchSet ( int gi ) { + public int getClassMatchSet (int gi) { return 0; } @@ -194,10 +194,10 @@ public class GlyphProcessingState { * Set default ignore tester. * @param ignoreDefault glyph tester (or null, to unset) */ - public void setIgnoreDefault ( GlyphTester ignoreDefault ) { - if ( this.ignoreDefault == null ) { + public void setIgnoreDefault (GlyphTester ignoreDefault) { + if (this.ignoreDefault == null) { this.ignoreDefault = ignoreDefault; - } else if ( ignoreDefault == null ) { + } else if (ignoreDefault == null) { this.ignoreDefault = null; } } @@ -217,11 +217,11 @@ public class GlyphProcessingState { * this state is to be reset. * @param st glyph subtable to use for update */ - public void updateSubtableState ( GlyphSubtable st ) { - if ( this.subtable != st ) { - setGDEF ( st.getGDEF() ); - setLookupFlags ( st.getFlags() ); - setIgnoreDefault ( getIgnoreTester ( getLookupFlags() ) ); + public void updateSubtableState (GlyphSubtable st) { + if (this.subtable != st) { + setGDEF (st.getGDEF()); + setLookupFlags (st.getFlags()); + setIgnoreDefault (getIgnoreTester (getLookupFlags())); this.subtable = st; } } @@ -240,8 +240,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if index is less than zero * or exceeds last valid position */ - public void setPosition ( int index ) throws IndexOutOfBoundsException { - if ( ( index >= 0 ) && ( index <= indexLast ) ) { + public void setPosition (int index) throws IndexOutOfBoundsException { + if ((index >= 0) && (index <= indexLast)) { this.index = index; } else { throw new IndexOutOfBoundsException(); @@ -262,7 +262,7 @@ public class GlyphProcessingState { * @return true if one or more glyph remains */ public boolean hasNext() { - return hasNext ( 1 ); + return hasNext (1); } /** @@ -271,8 +271,8 @@ public class GlyphProcessingState { * @param count of glyphs to test * @return true if at least count glyphs are available */ - public boolean hasNext ( int count ) { - return ( index + count ) <= indexLast; + public boolean hasNext (int count) { + return (index + count) <= indexLast; } /** @@ -283,14 +283,14 @@ public class GlyphProcessingState { * @return the new (updated) position index */ public int next() { - if ( index < indexLast ) { + if (index < indexLast) { // force consumption of at least one input glyph - if ( consumed == 0 ) { + if (consumed == 0) { consumed = 1; } index += consumed; consumed = 0; - if ( index > indexLast ) { + if (index > indexLast) { index = indexLast; } } @@ -303,7 +303,7 @@ public class GlyphProcessingState { * @return true if one or more glyph remains */ public boolean hasPrev() { - return hasPrev ( 1 ); + return hasPrev (1); } /** @@ -312,8 +312,8 @@ public class GlyphProcessingState { * @param count of glyphs to test * @return true if at least count glyphs are available */ - public boolean hasPrev ( int count ) { - return ( index - count ) >= 0; + public boolean hasPrev (int count) { + return (index - count) >= 0; } /** @@ -325,14 +325,14 @@ public class GlyphProcessingState { * @return the new (updated) position index */ public int prev() { - if ( index > 0 ) { + if (index > 0) { // force consumption of at least one input glyph - if ( consumed == 0 ) { + if (consumed == 0) { consumed = 1; } index -= consumed; consumed = 0; - if ( index < 0 ) { + if (index < 0) { index = 0; } } @@ -348,8 +348,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if count would cause consumption * to exceed count of glyphs in input glyph sequence */ - public int consume ( int count ) throws IndexOutOfBoundsException { - if ( ( consumed + count ) <= indexLast ) { + public int consume (int count) throws IndexOutOfBoundsException { + if ((consumed + count) <= indexLast) { consumed += count; return consumed; } else { @@ -379,12 +379,12 @@ public class GlyphProcessingState { * @return glyph at specified offset from current position * @throws IndexOutOfBoundsException if no glyph available at offset */ - public int getGlyph ( int offset ) throws IndexOutOfBoundsException { + public int getGlyph (int offset) throws IndexOutOfBoundsException { int i = index + offset; - if ( ( i >= 0 ) && ( i < indexLast ) ) { - return igs.getGlyph ( i ); + if ((i >= 0) && (i < indexLast)) { + return igs.getGlyph (i); } else { - throw new IndexOutOfBoundsException ( "attempting index at " + i ); + throw new IndexOutOfBoundsException ("attempting index at " + i); } } @@ -394,7 +394,7 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if no glyph available */ public int getGlyph() throws IndexOutOfBoundsException { - return getGlyph ( 0 ); + return getGlyph (0); } /** @@ -403,12 +403,12 @@ public class GlyphProcessingState { * @param glyph to set at specified offset from current position * @throws IndexOutOfBoundsException if specified offset is not valid position */ - public void setGlyph ( int offset, int glyph ) throws IndexOutOfBoundsException { + public void setGlyph (int offset, int glyph) throws IndexOutOfBoundsException { int i = index + offset; - if ( ( i >= 0 ) && ( i < indexLast ) ) { - igs.setGlyph ( i, glyph ); + if ((i >= 0) && (i < indexLast)) { + igs.setGlyph (i, glyph); } else { - throw new IndexOutOfBoundsException ( "attempting index at " + i ); + throw new IndexOutOfBoundsException ("attempting index at " + i); } } @@ -418,12 +418,12 @@ public class GlyphProcessingState { * @return character association of glyph at current position * @throws IndexOutOfBoundsException if offset results in an invalid index into input glyph sequence */ - public GlyphSequence.CharAssociation getAssociation ( int offset ) throws IndexOutOfBoundsException { + public GlyphSequence.CharAssociation getAssociation (int offset) throws IndexOutOfBoundsException { int i = index + offset; - if ( ( i >= 0 ) && ( i < indexLast ) ) { - return igs.getAssociation ( i ); + if ((i >= 0) && (i < indexLast)) { + return igs.getAssociation (i); } else { - throw new IndexOutOfBoundsException ( "attempting index at " + i ); + throw new IndexOutOfBoundsException ("attempting index at " + i); } } @@ -433,7 +433,7 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if no glyph available */ public GlyphSequence.CharAssociation getAssociation() throws IndexOutOfBoundsException { - return getAssociation ( 0 ); + return getAssociation (0); } /** @@ -452,68 +452,68 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getGlyphs ( int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException { - if ( count < 0 ) { - count = getGlyphsAvailable ( offset, reverseOrder, ignoreTester ) [ 0 ]; + public int[] getGlyphs (int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws IndexOutOfBoundsException { + if (count < 0) { + count = getGlyphsAvailable (offset, reverseOrder, ignoreTester) [ 0 ]; } int start = index + offset; - if ( start < 0 ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + start ); - } else if ( ! reverseOrder && ( ( start + count ) > indexLast ) ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + ( start + count ) ); - } else if ( reverseOrder && ( ( start + 1 ) < count ) ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + ( start - count ) ); + if (start < 0) { + throw new IndexOutOfBoundsException ("will attempt index at " + start); + } else if (! reverseOrder && ((start + count) > indexLast)) { + throw new IndexOutOfBoundsException ("will attempt index at " + (start + count)); + } else if (reverseOrder && ((start + 1) < count)) { + throw new IndexOutOfBoundsException ("will attempt index at " + (start - count)); } - if ( glyphs == null ) { + if (glyphs == null) { glyphs = new int [ count ]; - } else if ( glyphs.length != count ) { - throw new IllegalArgumentException ( "glyphs array is non-null, but its length (" + glyphs.length + "), is not equal to count (" + count + ")" ); + } else if (glyphs.length != count) { + throw new IllegalArgumentException ("glyphs array is non-null, but its length (" + glyphs.length + "), is not equal to count (" + count + ")"); } - if ( ! reverseOrder ) { - return getGlyphsForward ( start, count, ignoreTester, glyphs, counts ); + if (! reverseOrder) { + return getGlyphsForward (start, count, ignoreTester, glyphs, counts); } else { - return getGlyphsReverse ( start, count, ignoreTester, glyphs, counts ); + return getGlyphsReverse (start, count, ignoreTester, glyphs, counts); } } - private int[] getGlyphsForward ( int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException { + private int[] getGlyphsForward (int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - for ( int i = start, n = indexLast; ( i < n ) && ( counted < count ); i++ ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start, n = indexLast; (i < n) && (counted < count); i++) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) { + if ((ignoreTester == null) || ! ignoreTester.test (gi, getLookupFlags())) { glyphs [ counted++ ] = gi; } else { ignored++; } } } - if ( ( counts != null ) && ( counts.length > 1 ) ) { + if ((counts != null) && (counts.length > 1)) { counts[0] = counted; counts[1] = ignored; } return glyphs; } - private int[] getGlyphsReverse ( int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException { + private int[] getGlyphsReverse (int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - for ( int i = start; ( i >= 0 ) && ( counted < count ); i-- ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start; (i >= 0) && (counted < count); i--) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) { + if ((ignoreTester == null) || ! ignoreTester.test (gi, getLookupFlags())) { glyphs [ counted++ ] = gi; } else { ignored++; } } } - if ( ( counts != null ) && ( counts.length > 1 ) ) { + if ((counts != null) && (counts.length > 1)) { counts[0] = counted; counts[1] = ignored; } @@ -534,8 +534,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getGlyphs ( int offset, int count, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException { - return getGlyphs ( offset, count, offset < 0, ignoreDefault, glyphs, counts ); + public int[] getGlyphs (int offset, int count, int[] glyphs, int[] counts) throws IndexOutOfBoundsException { + return getGlyphs (offset, count, offset < 0, ignoreDefault, glyphs, counts); } /** @@ -544,7 +544,7 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if no glyph available */ public int[] getGlyphs() throws IndexOutOfBoundsException { - return getGlyphs ( 0, indexLast - index, false, null, null, null ); + return getGlyphs (0, indexLast - index, false, null, null, null); } /** @@ -563,8 +563,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getIgnoredGlyphs ( int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException { - return getGlyphs ( offset, count, reverseOrder, new NotGlyphTester ( ignoreTester ), glyphs, counts ); + public int[] getIgnoredGlyphs (int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws IndexOutOfBoundsException { + return getGlyphs (offset, count, reverseOrder, new NotGlyphTester (ignoreTester), glyphs, counts); } /** @@ -576,8 +576,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getIgnoredGlyphs ( int offset, int count ) throws IndexOutOfBoundsException { - return getIgnoredGlyphs ( offset, count, offset < 0, ignoreDefault, null, null ); + public int[] getIgnoredGlyphs (int offset, int count) throws IndexOutOfBoundsException { + return getIgnoredGlyphs (offset, count, offset < 0, ignoreDefault, null, null); } /** @@ -589,8 +589,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset results in an * invalid index into input glyph sequence */ - public boolean isIgnoredGlyph ( int offset, GlyphTester ignoreTester ) throws IndexOutOfBoundsException { - return ( ignoreTester != null ) && ignoreTester.test ( getGlyph ( offset ), getLookupFlags() ); + public boolean isIgnoredGlyph (int offset, GlyphTester ignoreTester) throws IndexOutOfBoundsException { + return (ignoreTester != null) && ignoreTester.test (getGlyph (offset), getLookupFlags()); } /** @@ -601,8 +601,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset results in an * invalid index into input glyph sequence */ - public boolean isIgnoredGlyph ( int offset ) throws IndexOutOfBoundsException { - return isIgnoredGlyph ( offset, ignoreDefault ); + public boolean isIgnoredGlyph (int offset) throws IndexOutOfBoundsException { + return isIgnoredGlyph (offset, ignoreDefault); } /** @@ -612,7 +612,7 @@ public class GlyphProcessingState { * invalid index into input glyph sequence */ public boolean isIgnoredGlyph() throws IndexOutOfBoundsException { - return isIgnoredGlyph ( getPosition() ); + return isIgnoredGlyph (getPosition()); } /** @@ -625,29 +625,29 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getGlyphsAvailable ( int offset, boolean reverseOrder, GlyphTester ignoreTester ) throws IndexOutOfBoundsException { + public int[] getGlyphsAvailable (int offset, boolean reverseOrder, GlyphTester ignoreTester) throws IndexOutOfBoundsException { int start = index + offset; - if ( ( start < 0 ) || ( start > indexLast ) ) { + if ((start < 0) || (start > indexLast)) { return new int[] { 0, 0 }; - } else if ( ! reverseOrder ) { - return getGlyphsAvailableForward ( start, ignoreTester ); + } else if (! reverseOrder) { + return getGlyphsAvailableForward (start, ignoreTester); } else { - return getGlyphsAvailableReverse ( start, ignoreTester ); + return getGlyphsAvailableReverse (start, ignoreTester); } } - private int[] getGlyphsAvailableForward ( int start, GlyphTester ignoreTester ) throws IndexOutOfBoundsException { + private int[] getGlyphsAvailableForward (int start, GlyphTester ignoreTester) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - if ( ignoreTester == null ) { + if (ignoreTester == null) { counted = indexLast - start; } else { - for ( int i = start, n = indexLast; i < n; i++ ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start, n = indexLast; i < n; i++) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ignoreTester.test ( gi, getLookupFlags() ) ) { + if (ignoreTester.test (gi, getLookupFlags())) { ignored++; } else { counted++; @@ -658,18 +658,18 @@ public class GlyphProcessingState { return new int[] { counted, ignored }; } - private int[] getGlyphsAvailableReverse ( int start, GlyphTester ignoreTester ) throws IndexOutOfBoundsException { + private int[] getGlyphsAvailableReverse (int start, GlyphTester ignoreTester) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - if ( ignoreTester == null ) { + if (ignoreTester == null) { counted = start + 1; } else { - for ( int i = start; i >= 0; i-- ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start; i >= 0; i--) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ignoreTester.test ( gi, getLookupFlags() ) ) { + if (ignoreTester.test (gi, getLookupFlags())) { ignored++; } else { counted++; @@ -690,8 +690,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getGlyphsAvailable ( int offset, boolean reverseOrder ) throws IndexOutOfBoundsException { - return getGlyphsAvailable ( offset, reverseOrder, ignoreDefault ); + public int[] getGlyphsAvailable (int offset, boolean reverseOrder) throws IndexOutOfBoundsException { + return getGlyphsAvailable (offset, reverseOrder, ignoreDefault); } /** @@ -703,8 +703,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int[] getGlyphsAvailable ( int offset ) throws IndexOutOfBoundsException { - return getGlyphsAvailable ( offset, offset < 0 ); + public int[] getGlyphsAvailable (int offset) throws IndexOutOfBoundsException { + return getGlyphsAvailable (offset, offset < 0); } /** @@ -723,43 +723,43 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public GlyphSequence.CharAssociation[] getAssociations ( int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts ) + public GlyphSequence.CharAssociation[] getAssociations (int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts) throws IndexOutOfBoundsException { - if ( count < 0 ) { - count = getGlyphsAvailable ( offset, reverseOrder, ignoreTester ) [ 0 ]; + if (count < 0) { + count = getGlyphsAvailable (offset, reverseOrder, ignoreTester) [ 0 ]; } int start = index + offset; - if ( start < 0 ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + start ); - } else if ( ! reverseOrder && ( ( start + count ) > indexLast ) ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + ( start + count ) ); - } else if ( reverseOrder && ( ( start + 1 ) < count ) ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + ( start - count ) ); + if (start < 0) { + throw new IndexOutOfBoundsException ("will attempt index at " + start); + } else if (! reverseOrder && ((start + count) > indexLast)) { + throw new IndexOutOfBoundsException ("will attempt index at " + (start + count)); + } else if (reverseOrder && ((start + 1) < count)) { + throw new IndexOutOfBoundsException ("will attempt index at " + (start - count)); } - if ( associations == null ) { + if (associations == null) { associations = new GlyphSequence.CharAssociation [ count ]; - } else if ( associations.length != count ) { - throw new IllegalArgumentException ( "associations array is non-null, but its length (" + associations.length + "), is not equal to count (" + count + ")" ); + } else if (associations.length != count) { + throw new IllegalArgumentException ("associations array is non-null, but its length (" + associations.length + "), is not equal to count (" + count + ")"); } - if ( ! reverseOrder ) { - return getAssociationsForward ( start, count, ignoreTester, associations, counts ); + if (! reverseOrder) { + return getAssociationsForward (start, count, ignoreTester, associations, counts); } else { - return getAssociationsReverse ( start, count, ignoreTester, associations, counts ); + return getAssociationsReverse (start, count, ignoreTester, associations, counts); } } - private GlyphSequence.CharAssociation[] getAssociationsForward ( int start, int count, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts ) + private GlyphSequence.CharAssociation[] getAssociationsForward (int start, int count, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - for ( int i = start, n = indexLast, k = 0; i < n; i++ ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start, n = indexLast, k = 0; i < n; i++) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) { - if ( k < count ) { - associations [ k++ ] = getAssociation ( i - index ); + if ((ignoreTester == null) || ! ignoreTester.test (gi, getLookupFlags())) { + if (k < count) { + associations [ k++ ] = getAssociation (i - index); counted++; } else { break; @@ -769,25 +769,25 @@ public class GlyphProcessingState { } } } - if ( ( counts != null ) && ( counts.length > 1 ) ) { + if ((counts != null) && (counts.length > 1)) { counts[0] = counted; counts[1] = ignored; } return associations; } - private GlyphSequence.CharAssociation[] getAssociationsReverse ( int start, int count, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts ) + private GlyphSequence.CharAssociation[] getAssociationsReverse (int start, int count, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts) throws IndexOutOfBoundsException { int counted = 0; int ignored = 0; - for ( int i = start, k = 0; i >= 0; i-- ) { - int gi = getGlyph ( i - index ); - if ( gi == 65535 ) { + for (int i = start, k = 0; i >= 0; i--) { + int gi = getGlyph (i - index); + if (gi == 65535) { ignored++; } else { - if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) { - if ( k < count ) { - associations [ k++ ] = getAssociation ( i - index ); + if ((ignoreTester == null) || ! ignoreTester.test (gi, getLookupFlags())) { + if (k < count) { + associations [ k++ ] = getAssociation (i - index); counted++; } else { break; @@ -797,7 +797,7 @@ public class GlyphProcessingState { } } } - if ( ( counts != null ) && ( counts.length > 1 ) ) { + if ((counts != null) && (counts.length > 1)) { counts[0] = counted; counts[1] = ignored; } @@ -814,8 +814,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public GlyphSequence.CharAssociation[] getAssociations ( int offset, int count ) throws IndexOutOfBoundsException { - return getAssociations ( offset, count, offset < 0, ignoreDefault, null, null ); + public GlyphSequence.CharAssociation[] getAssociations (int offset, int count) throws IndexOutOfBoundsException { + return getAssociations (offset, count, offset < 0, ignoreDefault, null, null); } /** @@ -834,9 +834,9 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public GlyphSequence.CharAssociation[] getIgnoredAssociations ( int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts ) + public GlyphSequence.CharAssociation[] getIgnoredAssociations (int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, GlyphSequence.CharAssociation[] associations, int[] counts) throws IndexOutOfBoundsException { - return getAssociations ( offset, count, reverseOrder, new NotGlyphTester ( ignoreTester ), associations, counts ); + return getAssociations (offset, count, reverseOrder, new NotGlyphTester (ignoreTester), associations, counts); } /** @@ -849,8 +849,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public GlyphSequence.CharAssociation[] getIgnoredAssociations ( int offset, int count ) throws IndexOutOfBoundsException { - return getIgnoredAssociations ( offset, count, offset < 0, ignoreDefault, null, null ); + public GlyphSequence.CharAssociation[] getIgnoredAssociations (int offset, int count) throws IndexOutOfBoundsException { + return getIgnoredAssociations (offset, count, offset < 0, ignoreDefault, null, null); } /** @@ -866,44 +866,44 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public boolean replaceInput ( int offset, int count, GlyphSequence gs, int gsOffset, int gsCount ) throws IndexOutOfBoundsException { - int nig = ( igs != null ) ? igs.getGlyphCount() : 0; + public boolean replaceInput (int offset, int count, GlyphSequence gs, int gsOffset, int gsCount) throws IndexOutOfBoundsException { + int nig = (igs != null) ? igs.getGlyphCount() : 0; int position = getPosition() + offset; - if ( position < 0 ) { + if (position < 0) { position = 0; - } else if ( position > nig ) { + } else if (position > nig) { position = nig; } - if ( ( count < 0 ) || ( ( position + count ) > nig ) ) { + if ((count < 0) || ((position + count) > nig)) { count = nig - position; } - int nrg = ( gs != null ) ? gs.getGlyphCount() : 0; - if ( gsOffset < 0 ) { + int nrg = (gs != null) ? gs.getGlyphCount() : 0; + if (gsOffset < 0) { gsOffset = 0; - } else if ( gsOffset > nrg ) { + } else if (gsOffset > nrg) { gsOffset = nrg; } - if ( ( gsCount < 0 ) || ( ( gsOffset + gsCount ) > nrg ) ) { + if ((gsCount < 0) || ((gsOffset + gsCount) > nrg)) { gsCount = nrg - gsOffset; } int ng = nig + gsCount - count; - IntBuffer gb = IntBuffer.allocate ( ng ); - List al = new ArrayList ( ng ); - for ( int i = 0, n = position; i < n; i++ ) { - gb.put ( igs.getGlyph ( i ) ); - al.add ( igs.getAssociation ( i ) ); + IntBuffer gb = IntBuffer.allocate (ng); + List al = new ArrayList (ng); + for (int i = 0, n = position; i < n; i++) { + gb.put (igs.getGlyph (i)); + al.add (igs.getAssociation (i)); } - for ( int i = gsOffset, n = gsOffset + gsCount; i < n; i++ ) { - gb.put ( gs.getGlyph ( i ) ); - al.add ( gs.getAssociation ( i ) ); + for (int i = gsOffset, n = gsOffset + gsCount; i < n; i++) { + gb.put (gs.getGlyph (i)); + al.add (gs.getAssociation (i)); } - for ( int i = position + count, n = nig; i < n; i++ ) { - gb.put ( igs.getGlyph ( i ) ); - al.add ( igs.getAssociation ( i ) ); + for (int i = position + count, n = nig; i < n; i++) { + gb.put (igs.getGlyph (i)); + al.add (igs.getAssociation (i)); } gb.flip(); - if ( igs.compareGlyphs ( gb ) != 0 ) { - this.igs = new GlyphSequence ( igs.getCharacters(), gb, al ); + if (igs.compareGlyphs (gb) != 0) { + this.igs = new GlyphSequence (igs.getCharacters(), gb, al); this.indexLast = gb.limit(); return true; } else { @@ -921,8 +921,8 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public boolean replaceInput ( int offset, int count, GlyphSequence gs ) throws IndexOutOfBoundsException { - return replaceInput ( offset, count, gs, 0, gs.getGlyphCount() ); + public boolean replaceInput (int offset, int count, GlyphSequence gs) throws IndexOutOfBoundsException { + return replaceInput (offset, count, gs, 0, gs.getGlyphCount()); } /** @@ -935,16 +935,16 @@ public class GlyphProcessingState { * @throws IndexOutOfBoundsException if offset or count results in an * invalid index into input glyph sequence */ - public int erase ( int offset, int[] glyphs ) throws IndexOutOfBoundsException { + public int erase (int offset, int[] glyphs) throws IndexOutOfBoundsException { int start = index + offset; - if ( ( start < 0 ) || ( start > indexLast ) ) { - throw new IndexOutOfBoundsException ( "will attempt index at " + start ); + if ((start < 0) || (start > indexLast)) { + throw new IndexOutOfBoundsException ("will attempt index at " + start); } else { int erased = 0; - for ( int i = start - index, n = indexLast - start; i < n; i++ ) { - int gi = getGlyph ( i ); - if ( gi == glyphs [ erased ] ) { - setGlyph ( i, 65535 ); + for (int i = start - index, n = indexLast - start; i < n; i++) { + int gi = getGlyph (i); + if (gi == glyphs [ erased ]) { + setGlyph (i, 65535); erased++; } } @@ -959,10 +959,10 @@ public class GlyphProcessingState { * true for the current input sequence context */ public boolean maybeApplicable() { - if ( gct == null ) { + if (gct == null) { return true; } else { - return gct.test ( script, language, feature, igs, index, getLookupFlags() ); + return gct.test (script, language, feature, igs, index, getLookupFlags()); } } @@ -979,9 +979,9 @@ public class GlyphProcessingState { * @param gi glyph index to test * @return true if glyph definition table records glyph as a base glyph; otherwise, false */ - public boolean isBase ( int gi ) { - if ( gdef != null ) { - return gdef.isGlyphClass ( gi, GlyphDefinitionTable.GLYPH_CLASS_BASE ); + public boolean isBase (int gi) { + if (gdef != null) { + return gdef.isGlyphClass (gi, GlyphDefinitionTable.GLYPH_CLASS_BASE); } else { return false; } @@ -994,8 +994,8 @@ public class GlyphProcessingState { * @param flags that apply to lookup in scope * @return true if glyph definition table records glyph as a base glyph; otherwise, false */ - public boolean isIgnoredBase ( int gi, int flags ) { - return ( ( flags & GlyphSubtable.LF_IGNORE_BASE ) != 0 ) && isBase ( gi ); + public boolean isIgnoredBase (int gi, int flags) { + return ((flags & GlyphSubtable.LF_IGNORE_BASE) != 0) && isBase (gi); } /** @@ -1004,9 +1004,9 @@ public class GlyphProcessingState { * @param gi glyph index to test * @return true if glyph definition table records glyph as a ligature glyph; otherwise, false */ - public boolean isLigature ( int gi ) { - if ( gdef != null ) { - return gdef.isGlyphClass ( gi, GlyphDefinitionTable.GLYPH_CLASS_LIGATURE ); + public boolean isLigature (int gi) { + if (gdef != null) { + return gdef.isGlyphClass (gi, GlyphDefinitionTable.GLYPH_CLASS_LIGATURE); } else { return false; } @@ -1019,8 +1019,8 @@ public class GlyphProcessingState { * @param flags that apply to lookup in scope * @return true if glyph definition table records glyph as a ligature glyph; otherwise, false */ - public boolean isIgnoredLigature ( int gi, int flags ) { - return ( ( flags & GlyphSubtable.LF_IGNORE_LIGATURE ) != 0 ) && isLigature ( gi ); + public boolean isIgnoredLigature (int gi, int flags) { + return ((flags & GlyphSubtable.LF_IGNORE_LIGATURE) != 0) && isLigature (gi); } /** @@ -1029,9 +1029,9 @@ public class GlyphProcessingState { * @param gi glyph index to test * @return true if glyph definition table records glyph as a mark glyph; otherwise, false */ - public boolean isMark ( int gi ) { - if ( gdef != null ) { - return gdef.isGlyphClass ( gi, GlyphDefinitionTable.GLYPH_CLASS_MARK ); + public boolean isMark (int gi) { + if (gdef != null) { + return gdef.isGlyphClass (gi, GlyphDefinitionTable.GLYPH_CLASS_MARK); } else { return false; } @@ -1044,13 +1044,13 @@ public class GlyphProcessingState { * @param flags that apply to lookup in scope * @return true if glyph definition table records glyph as a ligature glyph; otherwise, false */ - public boolean isIgnoredMark ( int gi, int flags ) { - if ( ( flags & GlyphSubtable.LF_IGNORE_MARK ) != 0 ) { - return isMark ( gi ); - } else if ( ( flags & GlyphSubtable.LF_MARK_ATTACHMENT_TYPE ) != 0 ) { - int lac = ( flags & GlyphSubtable.LF_MARK_ATTACHMENT_TYPE ) >> 8; - int gac = gdef.getMarkAttachClass ( gi ); - return ( gac != lac ); + public boolean isIgnoredMark (int gi, int flags) { + if ((flags & GlyphSubtable.LF_IGNORE_MARK) != 0) { + return isMark (gi); + } else if ((flags & GlyphSubtable.LF_MARK_ATTACHMENT_TYPE) != 0) { + int lac = (flags & GlyphSubtable.LF_MARK_ATTACHMENT_TYPE) >> 8; + int gac = gdef.getMarkAttachClass (gi); + return (gac != lac); } else { return false; } @@ -1061,26 +1061,26 @@ public class GlyphProcessingState { * @param flags lookup flags * @return a glyph tester */ - public GlyphTester getIgnoreTester ( int flags ) { - if ( ( flags & GlyphSubtable.LF_IGNORE_BASE ) != 0 ) { - if ( ( flags & (GlyphSubtable.LF_IGNORE_LIGATURE | GlyphSubtable.LF_IGNORE_MARK) ) == 0 ) { + public GlyphTester getIgnoreTester (int flags) { + if ((flags & GlyphSubtable.LF_IGNORE_BASE) != 0) { + if ((flags & (GlyphSubtable.LF_IGNORE_LIGATURE | GlyphSubtable.LF_IGNORE_MARK)) == 0) { return ignoreBase; } else { - return getCombinedIgnoreTester ( flags ); + return getCombinedIgnoreTester (flags); } } - if ( ( flags & GlyphSubtable.LF_IGNORE_LIGATURE ) != 0 ) { - if ( ( flags & (GlyphSubtable.LF_IGNORE_BASE | GlyphSubtable.LF_IGNORE_MARK) ) == 0 ) { + if ((flags & GlyphSubtable.LF_IGNORE_LIGATURE) != 0) { + if ((flags & (GlyphSubtable.LF_IGNORE_BASE | GlyphSubtable.LF_IGNORE_MARK)) == 0) { return ignoreLigature; } else { - return getCombinedIgnoreTester ( flags ); + return getCombinedIgnoreTester (flags); } } - if ( ( flags & GlyphSubtable.LF_IGNORE_MARK ) != 0 ) { - if ( ( flags & (GlyphSubtable.LF_IGNORE_BASE | GlyphSubtable.LF_IGNORE_LIGATURE) ) == 0 ) { + if ((flags & GlyphSubtable.LF_IGNORE_MARK) != 0) { + if ((flags & (GlyphSubtable.LF_IGNORE_BASE | GlyphSubtable.LF_IGNORE_LIGATURE)) == 0) { return ignoreMark; } else { - return getCombinedIgnoreTester ( flags ); + return getCombinedIgnoreTester (flags); } } return null; @@ -1091,19 +1091,19 @@ public class GlyphProcessingState { * @param flags lookup flags * @return a glyph tester */ - public GlyphTester getCombinedIgnoreTester ( int flags ) { + public GlyphTester getCombinedIgnoreTester (int flags) { GlyphTester[] gta = new GlyphTester [ 3 ]; int ngt = 0; - if ( ( flags & GlyphSubtable.LF_IGNORE_BASE ) != 0 ) { + if ((flags & GlyphSubtable.LF_IGNORE_BASE) != 0) { gta [ ngt++ ] = ignoreBase; } - if ( ( flags & GlyphSubtable.LF_IGNORE_LIGATURE ) != 0 ) { + if ((flags & GlyphSubtable.LF_IGNORE_LIGATURE) != 0) { gta [ ngt++ ] = ignoreLigature; } - if ( ( flags & GlyphSubtable.LF_IGNORE_MARK ) != 0 ) { + if ((flags & GlyphSubtable.LF_IGNORE_MARK) != 0) { gta [ ngt++ ] = ignoreMark; } - return getCombinedOrTester ( gta, ngt ); + return getCombinedOrTester (gta, ngt); } /** @@ -1112,9 +1112,9 @@ public class GlyphProcessingState { * @param ngt number of glyph testers present in specified array * @return a combined OR glyph tester */ - public GlyphTester getCombinedOrTester ( GlyphTester[] gta, int ngt ) { - if ( ngt > 0 ) { - return new CombinedOrGlyphTester ( gta, ngt ); + public GlyphTester getCombinedOrTester (GlyphTester[] gta, int ngt) { + if (ngt > 0) { + return new CombinedOrGlyphTester (gta, ngt); } else { return null; } @@ -1126,9 +1126,9 @@ public class GlyphProcessingState { * @param ngt number of glyph testers present in specified array * @return a combined AND glyph tester */ - public GlyphTester getCombinedAndTester ( GlyphTester[] gta, int ngt ) { - if ( ngt > 0 ) { - return new CombinedAndGlyphTester ( gta, ngt ); + public GlyphTester getCombinedAndTester (GlyphTester[] gta, int ngt) { + if (ngt > 0) { + return new CombinedAndGlyphTester (gta, ngt); } else { return null; } @@ -1138,16 +1138,16 @@ public class GlyphProcessingState { private static class CombinedOrGlyphTester implements GlyphTester { private GlyphTester[] gta; private int ngt; - CombinedOrGlyphTester ( GlyphTester[] gta, int ngt ) { + CombinedOrGlyphTester (GlyphTester[] gta, int ngt) { this.gta = gta; this.ngt = ngt; } /** {@inheritDoc} */ - public boolean test ( int gi, int flags ) { - for ( int i = 0, n = ngt; i < n; i++ ) { + public boolean test (int gi, int flags) { + for (int i = 0, n = ngt; i < n; i++) { GlyphTester gt = gta [ i ]; - if ( gt != null ) { - if ( gt.test ( gi, flags ) ) { + if (gt != null) { + if (gt.test (gi, flags)) { return true; } } @@ -1160,16 +1160,16 @@ public class GlyphProcessingState { private static class CombinedAndGlyphTester implements GlyphTester { private GlyphTester[] gta; private int ngt; - CombinedAndGlyphTester ( GlyphTester[] gta, int ngt ) { + CombinedAndGlyphTester (GlyphTester[] gta, int ngt) { this.gta = gta; this.ngt = ngt; } /** {@inheritDoc} */ - public boolean test ( int gi, int flags ) { - for ( int i = 0, n = ngt; i < n; i++ ) { + public boolean test (int gi, int flags) { + for (int i = 0, n = ngt; i < n; i++) { GlyphTester gt = gta [ i ]; - if ( gt != null ) { - if ( ! gt.test ( gi, flags ) ) { + if (gt != null) { + if (! gt.test (gi, flags)) { return false; } } @@ -1181,13 +1181,13 @@ public class GlyphProcessingState { /** NOT glyph tester */ private static class NotGlyphTester implements GlyphTester { private GlyphTester gt; - NotGlyphTester ( GlyphTester gt ) { + NotGlyphTester (GlyphTester gt) { this.gt = gt; } /** {@inheritDoc} */ - public boolean test ( int gi, int flags ) { - if ( gt != null ) { - if ( gt.test ( gi, flags ) ) { + public boolean test (int gi, int flags) { + if (gt != null) { + if (gt.test (gi, flags)) { return false; } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitution.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitution.java index 600d4de49..0cbb4cc4f 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitution.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitution.java @@ -37,6 +37,6 @@ public interface GlyphSubstitution { * @return true if the glyph subtable was applied, meaning that the current context matches the * associated input context glyph coverage table */ - boolean substitute ( GlyphSubstitutionState ss ); + boolean substitute (GlyphSubstitutionState ss); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java index 5ff3394a2..fba534361 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java @@ -61,10 +61,10 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @param feature feature identifier * @param sct script context tester (or null) */ - public GlyphSubstitutionState ( GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct ) { - super ( gs, script, language, feature, sct ); - this.ogb = IntBuffer.allocate ( gs.getGlyphCount() ); - this.oal = new ArrayList ( gs.getGlyphCount() ); + public GlyphSubstitutionState (GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) { + super (gs, script, language, feature, sct); + this.ogb = IntBuffer.allocate (gs.getGlyphCount()); + this.oal = new ArrayList (gs.getGlyphCount()); this.predications = gs.getPredications(); } @@ -73,10 +73,10 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * except as follows: input glyph sequence is copied deep except for its characters array. * @param ss existing positioning state to copy from */ - public GlyphSubstitutionState ( GlyphSubstitutionState ss ) { - super ( ss ); - this.ogb = IntBuffer.allocate ( indexLast ); - this.oal = new ArrayList ( indexLast ); + public GlyphSubstitutionState (GlyphSubstitutionState ss) { + super (ss); + this.ogb = IntBuffer.allocate (indexLast); + this.oal = new ArrayList (indexLast); } /** @@ -87,11 +87,11 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @param feature feature identifier * @param sct script context tester (or null) */ - public GlyphSubstitutionState reset ( GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct ) { - super.reset ( gs, script, language, feature, sct ); + public GlyphSubstitutionState reset (GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) { + super.reset (gs, script, language, feature, sct); this.alternatesIndex = null; - this.ogb = IntBuffer.allocate ( gs.getGlyphCount() ); - this.oal = new ArrayList ( gs.getGlyphCount() ); + this.ogb = IntBuffer.allocate (gs.getGlyphCount()); + this.oal = new ArrayList (gs.getGlyphCount()); this.predications = gs.getPredications(); return this; } @@ -100,7 +100,7 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * Set alternates indices. * @param alternates array of alternates indices ordered by coverage index */ - public void setAlternates ( int[] alternates ) { + public void setAlternates (int[] alternates) { this.alternatesIndex = alternates; } @@ -113,10 +113,10 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @param ci coverage index * @return an alternates index */ - public int getAlternatesIndex ( int ci ) { - if ( alternatesIndex == null ) { + public int getAlternatesIndex (int ci) { + if (alternatesIndex == null) { return 0; - } else if ( ( ci < 0 ) || ( ci > alternatesIndex.length ) ) { + } else if ((ci < 0) || (ci > alternatesIndex.length)) { return 0; } else { return alternatesIndex [ ci ]; @@ -129,15 +129,15 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @param a character association that applies to glyph * @param predication a predication value to add to association A if predications enabled */ - public void putGlyph ( int glyph, GlyphSequence.CharAssociation a, Object predication ) { - if ( ! ogb.hasRemaining() ) { - ogb = growBuffer ( ogb ); + public void putGlyph (int glyph, GlyphSequence.CharAssociation a, Object predication) { + if (! ogb.hasRemaining()) { + ogb = growBuffer (ogb); } - ogb.put ( glyph ); - if ( predications && ( predication != null ) ) { - a.setPredication ( feature, predication ); + ogb.put (glyph); + if (predications && (predication != null)) { + a.setPredication (feature, predication); } - oal.add ( a ); + oal.add (a); } /** @@ -146,12 +146,12 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @param associations array of character associations that apply to glyphs * @param predication optional predicaion object to be associated with glyphs' associations */ - public void putGlyphs ( int[] glyphs, GlyphSequence.CharAssociation[] associations, Object predication ) { + public void putGlyphs (int[] glyphs, GlyphSequence.CharAssociation[] associations, Object predication) { assert glyphs != null; assert associations != null; assert associations.length >= glyphs.length; - for ( int i = 0, n = glyphs.length; i < n; i++ ) { - putGlyph ( glyphs [ i ], associations [ i ], predication ); + for (int i = 0, n = glyphs.length; i < n; i++) { + putGlyph (glyphs [ i ], associations [ i ], predication); } } @@ -162,10 +162,10 @@ public class GlyphSubstitutionState extends GlyphProcessingState { */ public GlyphSequence getOutput() { int position = ogb.position(); - if ( position > 0 ) { - ogb.limit ( position ); + if (position > 0) { + ogb.limit (position); ogb.rewind(); - return new GlyphSequence ( igs.getCharacters(), ogb, oal ); + return new GlyphSequence (igs.getCharacters(), ogb, oal); } else { return igs; } @@ -181,10 +181,10 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * @return true if subtable applied, or false if it did not (e.g., its * input coverage table did not match current input context) */ - public boolean apply ( GlyphSubstitutionSubtable st ) { + public boolean apply (GlyphSubstitutionSubtable st) { assert st != null; - updateSubtableState ( st ); - boolean applied = st.substitute ( this ); + updateSubtableState (st); + boolean applied = st.substitute (this); return applied; } @@ -198,32 +198,32 @@ public class GlyphSubstitutionState extends GlyphProcessingState { * the lookups are to apply, and to be consumed once the application has finished * @return true if lookups are non-null and non-empty; otherwise, false */ - public boolean apply ( GlyphTable.RuleLookup[] lookups, int nig ) { + public boolean apply (GlyphTable.RuleLookup[] lookups, int nig) { // int nbg = index; - int nlg = indexLast - ( index + nig ); + int nlg = indexLast - (index + nig); int nog = 0; - if ( ( lookups != null ) && ( lookups.length > 0 ) ) { + if ((lookups != null) && (lookups.length > 0)) { // apply each rule lookup to extracted input glyph array - for ( int i = 0, n = lookups.length; i < n; i++ ) { + for (int i = 0, n = lookups.length; i < n; i++) { GlyphTable.RuleLookup l = lookups [ i ]; - if ( l != null ) { + if (l != null) { GlyphTable.LookupTable lt = l.getLookup(); - if ( lt != null ) { + if (lt != null) { // perform substitution on a copy of previous state - GlyphSubstitutionState ss = new GlyphSubstitutionState ( this ); + GlyphSubstitutionState ss = new GlyphSubstitutionState (this); // apply lookup table substitutions - GlyphSequence gs = lt.substitute ( ss, l.getSequenceIndex() ); + GlyphSequence gs = lt.substitute (ss, l.getSequenceIndex()); // replace current input sequence starting at current position with result - if ( replaceInput ( 0, -1, gs ) ) { + if (replaceInput (0, -1, gs)) { nog = gs.getGlyphCount() - nlg; } } } } // output glyphs and associations - putGlyphs ( getGlyphs ( 0, nog, false, null, null, null ), getAssociations ( 0, nog, false, null, null, null ), null ); + putGlyphs (getGlyphs (0, nog, false, null, null, null), getAssociations (0, nog, false, null, null, null), null); // consume replaced input glyphs - consume ( nog ); + consume (nog); return true; } else { return false; @@ -237,17 +237,17 @@ public class GlyphSubstitutionState extends GlyphProcessingState { public void applyDefault() { super.applyDefault(); int gi = getGlyph(); - if ( gi != 65535 ) { - putGlyph ( gi, getAssociation(), null ); + if (gi != 65535) { + putGlyph (gi, getAssociation(), null); } } - private static IntBuffer growBuffer ( IntBuffer ib ) { + private static IntBuffer growBuffer (IntBuffer ib) { int capacity = ib.capacity(); int capacityNew = capacity * 2; - IntBuffer ibNew = IntBuffer.allocate ( capacityNew ); + IntBuffer ibNew = IntBuffer.allocate (capacityNew); ib.rewind(); - return ibNew.put ( ib ); + return ibNew.put (ib); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionSubtable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionSubtable.java index 2ea247785..6545cc601 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionSubtable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionSubtable.java @@ -43,8 +43,8 @@ public abstract class GlyphSubstitutionSubtable extends GlyphSubtable implements * @param format subtable format * @param coverage subtable coverage table */ - protected GlyphSubstitutionSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage ) { - super ( id, sequence, flags, format, coverage ); + protected GlyphSubstitutionSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ @@ -54,11 +54,11 @@ public abstract class GlyphSubstitutionSubtable extends GlyphSubtable implements /** {@inheritDoc} */ public String getTypeName() { - return GlyphSubstitutionTable.getLookupTypeName ( getType() ); + return GlyphSubstitutionTable.getLookupTypeName (getType()); } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof GlyphSubstitutionSubtable; } @@ -68,7 +68,7 @@ public abstract class GlyphSubstitutionSubtable extends GlyphSubtable implements } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { return false; } @@ -85,24 +85,24 @@ public abstract class GlyphSubstitutionSubtable extends GlyphSubtable implements * @param sequenceIndex if non negative, then apply subtables only at specified sequence index * @return output glyph sequence */ - public static final GlyphSequence substitute ( GlyphSubstitutionState ss, GlyphSubstitutionSubtable[] sta, int sequenceIndex ) { + public static final GlyphSequence substitute (GlyphSubstitutionState ss, GlyphSubstitutionSubtable[] sta, int sequenceIndex) { int sequenceStart = ss.getPosition(); boolean appliedOneShot = false; - while ( ss.hasNext() ) { + while (ss.hasNext()) { boolean applied = false; - if ( ! appliedOneShot && ss.maybeApplicable() ) { - for ( int i = 0, n = sta.length; ! applied && ( i < n ); i++ ) { - if ( sequenceIndex < 0 ) { - applied = ss.apply ( sta [ i ] ); - } else if ( ss.getPosition() == ( sequenceStart + sequenceIndex ) ) { - applied = ss.apply ( sta [ i ] ); - if ( applied ) { + if (! appliedOneShot && ss.maybeApplicable()) { + for (int i = 0, n = sta.length; ! applied && (i < n); i++) { + if (sequenceIndex < 0) { + applied = ss.apply (sta [ i ]); + } else if (ss.getPosition() == (sequenceStart + sequenceIndex)) { + applied = ss.apply (sta [ i ]); + if (applied) { appliedOneShot = true; } } } } - if ( ! applied || ! ss.didConsume() ) { + if (! applied || ! ss.didConsume()) { ss.applyDefault(); } ss.next(); @@ -120,9 +120,9 @@ public abstract class GlyphSubstitutionSubtable extends GlyphSubtable implements * @param sct script context tester * @return output glyph sequence */ - public static final GlyphSequence substitute ( GlyphSequence gs, String script, String language, String feature, GlyphSubstitutionSubtable[] sta, ScriptContextTester sct ) { - synchronized ( state ) { - return substitute ( state.reset ( gs, script, language, feature, sct ), sta, -1 ); + public static final GlyphSequence substitute (GlyphSequence gs, String script, String language, String feature, GlyphSubstitutionSubtable[] sta, ScriptContextTester sct) { + synchronized (state) { + return substitute (state.reset (gs, script, language, feature, sct), sta, -1); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java index 06ed69c4a..39a8cb184 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java @@ -70,17 +70,17 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param lookups a map of lookup specifications to subtable identifier strings * @param subtables a list of identified subtables */ - public GlyphSubstitutionTable ( GlyphDefinitionTable gdef, Map lookups, List subtables ) { - super ( gdef, lookups ); - if ( ( subtables == null ) || ( subtables.size() == 0 ) ) { - throw new AdvancedTypographicTableFormatException ( "subtables must be non-empty" ); + public GlyphSubstitutionTable (GlyphDefinitionTable gdef, Map lookups, List subtables) { + super (gdef, lookups); + if ((subtables == null) || (subtables.size() == 0)) { + throw new AdvancedTypographicTableFormatException ("subtables must be non-empty"); } else { - for ( Iterator it = subtables.iterator(); it.hasNext();) { + for (Iterator it = subtables.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof GlyphSubstitutionSubtable ) { - addSubtable ( (GlyphSubtable) o ); + if (o instanceof GlyphSubstitutionSubtable) { + addSubtable ((GlyphSubtable) o); } else { - throw new AdvancedTypographicTableFormatException ( "subtable must be a glyph substitution subtable" ); + throw new AdvancedTypographicTableFormatException ("subtable must be a glyph substitution subtable"); } } freezeSubtables(); @@ -94,12 +94,12 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param language a language identifier * @return the substituted (output) glyph sequence */ - public GlyphSequence substitute ( GlyphSequence gs, String script, String language ) { + public GlyphSequence substitute (GlyphSequence gs, String script, String language) { GlyphSequence ogs; - Map/*>*/ lookups = matchLookups ( script, language, "*" ); - if ( ( lookups != null ) && ( lookups.size() > 0 ) ) { - ScriptProcessor sp = ScriptProcessor.getInstance ( script ); - ogs = sp.substitute ( this, gs, script, language, lookups ); + Map/*>*/ lookups = matchLookups (script, language, "*"); + if ((lookups != null) && (lookups.size() > 0)) { + ScriptProcessor sp = ScriptProcessor.getInstance (script); + ogs = sp.substitute (this, gs, script, language, lookups); } else { ogs = gs; } @@ -111,24 +111,24 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param name lookup type name * @return lookup type */ - public static int getLookupTypeFromName ( String name ) { + public static int getLookupTypeFromName (String name) { int t; String s = name.toLowerCase(); - if ( "single".equals ( s ) ) { + if ("single".equals (s)) { t = GSUB_LOOKUP_TYPE_SINGLE; - } else if ( "multiple".equals ( s ) ) { + } else if ("multiple".equals (s)) { t = GSUB_LOOKUP_TYPE_MULTIPLE; - } else if ( "alternate".equals ( s ) ) { + } else if ("alternate".equals (s)) { t = GSUB_LOOKUP_TYPE_ALTERNATE; - } else if ( "ligature".equals ( s ) ) { + } else if ("ligature".equals (s)) { t = GSUB_LOOKUP_TYPE_LIGATURE; - } else if ( "contextual".equals ( s ) ) { + } else if ("contextual".equals (s)) { t = GSUB_LOOKUP_TYPE_CONTEXTUAL; - } else if ( "chainedcontextual".equals ( s ) ) { + } else if ("chainedcontextual".equals (s)) { t = GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL; - } else if ( "extensionsubstitution".equals ( s ) ) { + } else if ("extensionsubstitution".equals (s)) { t = GSUB_LOOKUP_TYPE_EXTENSION_SUBSTITUTION; - } else if ( "reversechainiingcontextualsingle".equals ( s ) ) { + } else if ("reversechainiingcontextualsingle".equals (s)) { t = GSUB_LOOKUP_TYPE_REVERSE_CHAINED_SINGLE; } else { t = -1; @@ -141,9 +141,9 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param type lookup type * @return lookup type name */ - public static String getLookupTypeName ( int type ) { + public static String getLookupTypeName (int type) { String tn = null; - switch ( type ) { + switch (type) { case GSUB_LOOKUP_TYPE_SINGLE: tn = "single"; break; @@ -186,29 +186,29 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param entries subtable entries * @return a glyph subtable instance */ - public static GlyphSubtable createSubtable ( int type, String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { + public static GlyphSubtable createSubtable (int type, String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { GlyphSubtable st = null; - switch ( type ) { + switch (type) { case GSUB_LOOKUP_TYPE_SINGLE: - st = SingleSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = SingleSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_MULTIPLE: - st = MultipleSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = MultipleSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_ALTERNATE: - st = AlternateSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = AlternateSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_LIGATURE: - st = LigatureSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = LigatureSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_CONTEXTUAL: - st = ContextualSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = ContextualSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL: - st = ChainedContextualSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = ChainedContextualSubtable.create (id, sequence, flags, format, coverage, entries); break; case GSUB_LOOKUP_TYPE_REVERSE_CHAINED_SINGLE: - st = ReverseChainedSingleSubtable.create ( id, sequence, flags, format, coverage, entries ); + st = ReverseChainedSingleSubtable.create (id, sequence, flags, format, coverage, entries); break; default: break; @@ -227,34 +227,34 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param entries subtable entries * @return a glyph subtable instance */ - public static GlyphSubtable createSubtable ( int type, String id, int sequence, int flags, int format, List coverage, List entries ) { - return createSubtable ( type, id, sequence, flags, format, GlyphCoverageTable.createCoverageTable ( coverage ), entries ); + public static GlyphSubtable createSubtable (int type, String id, int sequence, int flags, int format, List coverage, List entries) { + return createSubtable (type, id, sequence, flags, format, GlyphCoverageTable.createCoverageTable (coverage), entries); } private abstract static class SingleSubtable extends GlyphSubstitutionSubtable { - SingleSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + SingleSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_SINGLE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof SingleSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { - int go = getGlyphForCoverageIndex ( ci, gi ); - if ( ( go < 0 ) || ( go > 65535 ) ) { + int go = getGlyphForCoverageIndex (ci, gi); + if ((go < 0) || (go > 65535)) { go = 65535; } - ss.putGlyph ( go, ss.getAssociation(), Boolean.TRUE ); + ss.putGlyph (go, ss.getAssociation(), Boolean.TRUE); ss.consume(1); return true; } @@ -266,12 +266,12 @@ public class GlyphSubstitutionTable extends GlyphTable { * @return substituted glyph value * @throws IllegalArgumentException if coverage index is not valid */ - public abstract int getGlyphForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException; - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new SingleSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new SingleSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); + public abstract int getGlyphForCoverageIndex (int ci, int gi) throws IllegalArgumentException; + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new SingleSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new SingleSubtableFormat2 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -281,34 +281,34 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class SingleSubtableFormat1 extends SingleSubtable { private int delta; private int ciMax; - SingleSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + SingleSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - List entries = new ArrayList ( 1 ); - entries.add ( Integer.valueOf ( delta ) ); + List entries = new ArrayList (1); + entries.add (Integer.valueOf (delta)); return entries; } /** {@inheritDoc} */ - public int getGlyphForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException { - if ( ci <= ciMax ) { + public int getGlyphForCoverageIndex (int ci, int gi) throws IllegalArgumentException { + if (ci <= ciMax) { return gi + delta; } else { - throw new IllegalArgumentException ( "coverage index " + ci + " out of range, maximum coverage index is " + ciMax ); + throw new IllegalArgumentException ("coverage index " + ci + " out of range, maximum coverage index is " + ciMax); } } - private void populate ( List entries ) { - if ( ( entries == null ) || ( entries.size() != 1 ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null and contain exactly one entry" ); + private void populate (List entries) { + if ((entries == null) || (entries.size() != 1)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null and contain exactly one entry"); } else { Object o = entries.get(0); int delta = 0; - if ( o instanceof Integer ) { - delta = ( (Integer) o ) . intValue(); + if (o instanceof Integer) { + delta = ((Integer) o) . intValue(); } else { - throw new AdvancedTypographicTableFormatException ( "illegal entries entry, must be Integer, but is: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal entries entry, must be Integer, but is: " + o); } this.delta = delta; this.ciMax = getCoverageSize() - 1; @@ -318,43 +318,43 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class SingleSubtableFormat2 extends SingleSubtable { private int[] glyphs; - SingleSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + SingleSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - List entries = new ArrayList ( glyphs.length ); - for ( int i = 0, n = glyphs.length; i < n; i++ ) { - entries.add ( Integer.valueOf ( glyphs[i] ) ); + List entries = new ArrayList (glyphs.length); + for (int i = 0, n = glyphs.length; i < n; i++) { + entries.add (Integer.valueOf (glyphs[i])); } return entries; } /** {@inheritDoc} */ - public int getGlyphForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException { - if ( glyphs == null ) { + public int getGlyphForCoverageIndex (int ci, int gi) throws IllegalArgumentException { + if (glyphs == null) { return -1; - } else if ( ci >= glyphs.length ) { - throw new IllegalArgumentException ( "coverage index " + ci + " out of range, maximum coverage index is " + glyphs.length ); + } else if (ci >= glyphs.length) { + throw new IllegalArgumentException ("coverage index " + ci + " out of range, maximum coverage index is " + glyphs.length); } else { return glyphs [ ci ]; } } - private void populate ( List entries ) { + private void populate (List entries) { int i = 0; int n = entries.size(); int[] glyphs = new int [ n ]; - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof Integer ) { - int gid = ( (Integer) o ) .intValue(); - if ( ( gid >= 0 ) && ( gid < 65536 ) ) { + if (o instanceof Integer) { + int gid = ((Integer) o) .intValue(); + if ((gid >= 0) && (gid < 65536)) { glyphs [ i++ ] = gid; } else { - throw new AdvancedTypographicTableFormatException ( "illegal glyph index: " + gid ); + throw new AdvancedTypographicTableFormatException ("illegal glyph index: " + gid); } } else { - throw new AdvancedTypographicTableFormatException ( "illegal entries entry, must be Integer: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal entries entry, must be Integer: " + o); } } assert i == n; @@ -364,27 +364,27 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class MultipleSubtable extends GlyphSubstitutionSubtable { - public MultipleSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public MultipleSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_MULTIPLE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof MultipleSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { - int[] ga = getGlyphsForCoverageIndex ( ci, gi ); - if ( ga != null ) { - ss.putGlyphs ( ga, GlyphSequence.CharAssociation.replicate ( ss.getAssociation(), ga.length ), Boolean.TRUE ); + int[] ga = getGlyphsForCoverageIndex (ci, gi); + if (ga != null) { + ss.putGlyphs (ga, GlyphSequence.CharAssociation.replicate (ss.getAssociation(), ga.length), Boolean.TRUE); ss.consume(1); } return true; @@ -397,10 +397,10 @@ public class GlyphSubstitutionTable extends GlyphTable { * @return sequence of glyphs to substitute for input glyph * @throws IllegalArgumentException if coverage index is not valid */ - public abstract int[] getGlyphsForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException; - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new MultipleSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract int[] getGlyphsForCoverageIndex (int ci, int gi) throws IllegalArgumentException; + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new MultipleSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -409,39 +409,39 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class MultipleSubtableFormat1 extends MultipleSubtable { private int[][] gsa; // glyph sequence array, ordered by coverage index - MultipleSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + MultipleSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( gsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( gsa ); + if (gsa != null) { + List entries = new ArrayList (1); + entries.add (gsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public int[] getGlyphsForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException { - if ( gsa == null ) { + public int[] getGlyphsForCoverageIndex (int ci, int gi) throws IllegalArgumentException { + if (gsa == null) { return null; - } else if ( ci >= gsa.length ) { - throw new IllegalArgumentException ( "coverage index " + ci + " out of range, maximum coverage index is " + gsa.length ); + } else if (ci >= gsa.length) { + throw new IllegalArgumentException ("coverage index " + ci + " out of range, maximum coverage index is " + gsa.length); } else { return gsa [ ci ]; } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof int[][] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an int[][], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof int[][])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an int[][], but is: " + ((o != null) ? o.getClass() : null)); } else { gsa = (int[][]) o; } @@ -450,36 +450,36 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class AlternateSubtable extends GlyphSubstitutionSubtable { - public AlternateSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public AlternateSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_ALTERNATE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof AlternateSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { - int[] ga = getAlternatesForCoverageIndex ( ci, gi ); - int ai = ss.getAlternatesIndex ( ci ); + int[] ga = getAlternatesForCoverageIndex (ci, gi); + int ai = ss.getAlternatesIndex (ci); int go; - if ( ( ai < 0 ) || ( ai >= ga.length ) ) { + if ((ai < 0) || (ai >= ga.length)) { go = gi; } else { go = ga [ ai ]; } - if ( ( go < 0 ) || ( go > 65535 ) ) { + if ((go < 0) || (go > 65535)) { go = 65535; } - ss.putGlyph ( go, ss.getAssociation(), Boolean.TRUE ); + ss.putGlyph (go, ss.getAssociation(), Boolean.TRUE); ss.consume(1); return true; } @@ -491,10 +491,10 @@ public class GlyphSubstitutionTable extends GlyphTable { * @return sequence of glyphs to substitute for input glyph * @throws IllegalArgumentException if coverage index is not valid */ - public abstract int[] getAlternatesForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException; - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new AlternateSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract int[] getAlternatesForCoverageIndex (int ci, int gi) throws IllegalArgumentException; + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new AlternateSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -503,38 +503,38 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class AlternateSubtableFormat1 extends AlternateSubtable { private int[][] gaa; // glyph alternates array, ordered by coverage index - AlternateSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + AlternateSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - List entries = new ArrayList ( gaa.length ); - for ( int i = 0, n = gaa.length; i < n; i++ ) { - entries.add ( gaa[i] ); + List entries = new ArrayList (gaa.length); + for (int i = 0, n = gaa.length; i < n; i++) { + entries.add (gaa[i]); } return entries; } /** {@inheritDoc} */ - public int[] getAlternatesForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException { - if ( gaa == null ) { + public int[] getAlternatesForCoverageIndex (int ci, int gi) throws IllegalArgumentException { + if (gaa == null) { return null; - } else if ( ci >= gaa.length ) { - throw new IllegalArgumentException ( "coverage index " + ci + " out of range, maximum coverage index is " + gaa.length ); + } else if (ci >= gaa.length) { + throw new IllegalArgumentException ("coverage index " + ci + " out of range, maximum coverage index is " + gaa.length); } else { return gaa [ ci ]; } } - private void populate ( List entries ) { + private void populate (List entries) { int i = 0; int n = entries.size(); int[][] gaa = new int [ n ][]; - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof int[] ) { + if (o instanceof int[]) { gaa [ i++ ] = (int[]) o; } else { - throw new AdvancedTypographicTableFormatException ( "illegal entries entry, must be int[]: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal entries entry, must be int[]: " + o); } } assert i == n; @@ -544,74 +544,74 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class LigatureSubtable extends GlyphSubstitutionSubtable { - public LigatureSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public LigatureSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_LIGATURE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof LigatureSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { - LigatureSet ls = getLigatureSetForCoverageIndex ( ci, gi ); - if ( ls != null ) { + LigatureSet ls = getLigatureSetForCoverageIndex (ci, gi); + if (ls != null) { boolean reverse = false; GlyphTester ignores = ss.getIgnoreDefault(); - int[] counts = ss.getGlyphsAvailable ( 0, reverse, ignores ); + int[] counts = ss.getGlyphsAvailable (0, reverse, ignores); int nga = counts[0]; int ngi; - if ( nga > 1 ) { - int[] iga = ss.getGlyphs ( 0, nga, reverse, ignores, null, counts ); - Ligature l = findLigature ( ls, iga ); - if ( l != null ) { + if (nga > 1) { + int[] iga = ss.getGlyphs (0, nga, reverse, ignores, null, counts); + Ligature l = findLigature (ls, iga); + if (l != null) { int go = l.getLigature(); - if ( ( go < 0 ) || ( go > 65535 ) ) { + if ((go < 0) || (go > 65535)) { go = 65535; } int nmg = 1 + l.getNumComponents(); // fetch matched number of component glyphs to determine matched and ignored count - ss.getGlyphs ( 0, nmg, reverse, ignores, null, counts ); + ss.getGlyphs (0, nmg, reverse, ignores, null, counts); nga = counts[0]; ngi = counts[1]; // fetch associations of matched component glyphs - GlyphSequence.CharAssociation[] laa = ss.getAssociations ( 0, nga ); + GlyphSequence.CharAssociation[] laa = ss.getAssociations (0, nga); // output ligature glyph and its association - ss.putGlyph ( go, GlyphSequence.CharAssociation.join ( laa ), Boolean.TRUE ); + ss.putGlyph (go, GlyphSequence.CharAssociation.join (laa), Boolean.TRUE); // fetch and output ignored glyphs (if necessary) - if ( ngi > 0 ) { - ss.putGlyphs ( ss.getIgnoredGlyphs ( 0, ngi ), ss.getIgnoredAssociations ( 0, ngi ), null ); + if (ngi > 0) { + ss.putGlyphs (ss.getIgnoredGlyphs (0, ngi), ss.getIgnoredAssociations (0, ngi), null); } - ss.consume ( nga + ngi ); + ss.consume (nga + ngi); } } } return true; } } - private Ligature findLigature ( LigatureSet ls, int[] glyphs ) { + private Ligature findLigature (LigatureSet ls, int[] glyphs) { Ligature[] la = ls.getLigatures(); int k = -1; int maxComponents = -1; - for ( int i = 0, n = la.length; i < n; i++ ) { + for (int i = 0, n = la.length; i < n; i++) { Ligature l = la [ i ]; - if ( l.matchesComponents ( glyphs ) ) { + if (l.matchesComponents (glyphs)) { int nc = l.getNumComponents(); - if ( nc > maxComponents ) { + if (nc > maxComponents) { maxComponents = nc; k = i; } } } - if ( k >= 0 ) { + if (k >= 0) { return la [ k ]; } else { return null; @@ -624,10 +624,10 @@ public class GlyphSubstitutionTable extends GlyphTable { * @return ligature set (or null if none defined) * @throws IllegalArgumentException if coverage index is not valid */ - public abstract LigatureSet getLigatureSetForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException; - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new LigatureSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + public abstract LigatureSet getLigatureSetForCoverageIndex (int ci, int gi) throws IllegalArgumentException; + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new LigatureSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -636,38 +636,38 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class LigatureSubtableFormat1 extends LigatureSubtable { private LigatureSet[] ligatureSets; - public LigatureSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + public LigatureSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - List entries = new ArrayList ( ligatureSets.length ); - for ( int i = 0, n = ligatureSets.length; i < n; i++ ) { - entries.add ( ligatureSets[i] ); + List entries = new ArrayList (ligatureSets.length); + for (int i = 0, n = ligatureSets.length; i < n; i++) { + entries.add (ligatureSets[i]); } return entries; } /** {@inheritDoc} */ - public LigatureSet getLigatureSetForCoverageIndex ( int ci, int gi ) throws IllegalArgumentException { - if ( ligatureSets == null ) { + public LigatureSet getLigatureSetForCoverageIndex (int ci, int gi) throws IllegalArgumentException { + if (ligatureSets == null) { return null; - } else if ( ci >= ligatureSets.length ) { - throw new IllegalArgumentException ( "coverage index " + ci + " out of range, maximum coverage index is " + ligatureSets.length ); + } else if (ci >= ligatureSets.length) { + throw new IllegalArgumentException ("coverage index " + ci + " out of range, maximum coverage index is " + ligatureSets.length); } else { return ligatureSets [ ci ]; } } - private void populate ( List entries ) { + private void populate (List entries) { int i = 0; int n = entries.size(); LigatureSet[] ligatureSets = new LigatureSet [ n ]; - for ( Iterator it = entries.iterator(); it.hasNext();) { + for (Iterator it = entries.iterator(); it.hasNext();) { Object o = it.next(); - if ( o instanceof LigatureSet ) { + if (o instanceof LigatureSet) { ligatureSets [ i++ ] = (LigatureSet) o; } else { - throw new AdvancedTypographicTableFormatException ( "illegal ligatures entry, must be LigatureSet: " + o ); + throw new AdvancedTypographicTableFormatException ("illegal ligatures entry, must be LigatureSet: " + o); } } assert i == n; @@ -677,28 +677,28 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class ContextualSubtable extends GlyphSubstitutionSubtable { - public ContextualSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public ContextualSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_CONTEXTUAL; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof ContextualSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { int[] rv = new int[1]; - RuleLookup[] la = getLookups ( ci, gi, ss, rv ); - if ( la != null ) { - ss.apply ( la, rv[0] ); + RuleLookup[] la = getLookups (ci, gi, ss, rv); + if (la != null) { + ss.apply (la, rv[0]); } return true; } @@ -712,14 +712,14 @@ public class GlyphSubstitutionTable extends GlyphTable { * where the first entry is used to return the input sequence length of the matched rule * @return array of rule lookups or null if none applies */ - public abstract RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ); - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new ContextualSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new ContextualSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 3 ) { - return new ContextualSubtableFormat3 ( id, sequence, flags, format, coverage, entries ); + public abstract RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv); + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new ContextualSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new ContextualSubtableFormat2 (id, sequence, flags, format, coverage, entries); + } else if (format == 3) { + return new ContextualSubtableFormat3 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -728,39 +728,39 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class ContextualSubtableFormat1 extends ContextualSubtable { private RuleSet[] rsa; // rule set array, ordered by glyph coverage index - ContextualSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedGlyphSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; - int[] iga = cr.getGlyphs ( gi ); - if ( matches ( ss, iga, 0, rv ) ) { + int[] iga = cr.getGlyphs (gi); + if (matches (ss, iga, 0, rv)) { return r.getLookups(); } } @@ -769,40 +769,40 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - static boolean matches ( GlyphSubstitutionState ss, int[] glyphs, int offset, int[] rv ) { - if ( ( glyphs == null ) || ( glyphs.length == 0 ) ) { + static boolean matches (GlyphSubstitutionState ss, int[] glyphs, int offset, int[] rv) { + if ((glyphs == null) || (glyphs.length == 0)) { return true; // match null or empty glyph sequence } else { boolean reverse = offset < 0; GlyphTester ignores = ss.getIgnoreDefault(); - int[] counts = ss.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ss.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = glyphs.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ss.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { - if ( ga [ k ] != glyphs [ k ] ) { + int[] ga = ss.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { + if (ga [ k ] != glyphs [ k ]) { return false; // match fails at ga [ k ] } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -814,41 +814,41 @@ public class GlyphSubstitutionTable extends GlyphTable { private GlyphClassTable cdt; // class def table private int ngc; // class set count private RuleSet[] rsa; // rule set array, ordered by class number [0...ngc - 1] - ContextualSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 3 ); - entries.add ( cdt ); - entries.add ( Integer.valueOf ( ngc ) ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (3); + entries.add (cdt); + entries.add (Integer.valueOf (ngc)); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedClassSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedClassSequenceRule)) { ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; - int[] ca = cr.getClasses ( cdt.getClassIndex ( gi, ss.getClassMatchSet ( gi ) ) ); - if ( matches ( ss, cdt, ca, 0, rv ) ) { + int[] ca = cr.getClasses (cdt.getClassIndex (gi, ss.getClassMatchSet (gi))); + if (matches (ss, cdt, ca, 0, rv)) { return r.getLookups(); } } @@ -857,59 +857,59 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - static boolean matches ( GlyphSubstitutionState ss, GlyphClassTable cdt, int[] classes, int offset, int[] rv ) { - if ( ( cdt == null ) || ( classes == null ) || ( classes.length == 0 ) ) { + static boolean matches (GlyphSubstitutionState ss, GlyphClassTable cdt, int[] classes, int offset, int[] rv) { + if ((cdt == null) || (classes == null) || (classes.length == 0)) { return true; // match null class definitions, null or empty class sequence } else { boolean reverse = offset < 0; GlyphTester ignores = ss.getIgnoreDefault(); - int[] counts = ss.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ss.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = classes.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ss.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { + int[] ga = ss.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { int gi = ga [ k ]; - int ms = ss.getClassMatchSet ( gi ); - int gc = cdt.getClassIndex ( gi, ms ); - if ( ( gc < 0 ) || ( gc >= cdt.getClassSize ( ms ) ) ) { + int ms = ss.getClassMatchSet (gi); + int gc = cdt.getClassIndex (gi, ms); + if ((gc < 0) || (gc >= cdt.getClassSize (ms))) { return false; // none or invalid class fails mat ch - } else if ( gc != classes [ k ] ) { + } else if (gc != classes [ k ]) { return false; // match fails at ga [ k ] } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 3 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 3 entries" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 3) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { cdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(1) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { ngc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(2) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(2)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; - if ( rsa.length != ngc ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes" ); + if (rsa.length != ngc) { + throw new AdvancedTypographicTableFormatException ("illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes"); } } } @@ -918,39 +918,39 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class ContextualSubtableFormat3 extends ContextualSubtable { private RuleSet[] rsa; // rule set array, containing a single rule set - ContextualSubtableFormat3 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ContextualSubtableFormat3 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedCoverageSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; GlyphCoverageTable[] gca = cr.getCoverages(); - if ( matches ( ss, gca, 0, rv ) ) { + if (matches (ss, gca, 0, rv)) { return r.getLookups(); } } @@ -959,43 +959,43 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - static boolean matches ( GlyphSubstitutionState ss, GlyphCoverageTable[] gca, int offset, int[] rv ) { - if ( ( gca == null ) || ( gca.length == 0 ) ) { + static boolean matches (GlyphSubstitutionState ss, GlyphCoverageTable[] gca, int offset, int[] rv) { + if ((gca == null) || (gca.length == 0)) { return true; // match null or empty coverage array } else { boolean reverse = offset < 0; GlyphTester ignores = ss.getIgnoreDefault(); - int[] counts = ss.getGlyphsAvailable ( offset, reverse, ignores ); + int[] counts = ss.getGlyphsAvailable (offset, reverse, ignores); int nga = counts[0]; int ngm = gca.length; - if ( nga < ngm ) { + if (nga < ngm) { return false; // insufficient glyphs available to match } else { - int[] ga = ss.getGlyphs ( offset, ngm, reverse, ignores, null, counts ); - for ( int k = 0; k < ngm; k++ ) { + int[] ga = ss.getGlyphs (offset, ngm, reverse, ignores, null, counts); + for (int k = 0; k < ngm; k++) { GlyphCoverageTable ct = gca [ k ]; - if ( ct != null ) { - if ( ct.getCoverageIndex ( ga [ k ] ) < 0 ) { + if (ct != null) { + if (ct.getCoverageIndex (ga [ k ]) < 0) { return false; // match fails at ga [ k ] } } } - if ( rv != null ) { + if (rv != null) { rv[0] = counts[0] + counts[1]; } return true; // all glyphs match } } } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1004,28 +1004,28 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class ChainedContextualSubtable extends GlyphSubstitutionSubtable { - public ChainedContextualSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public ChainedContextualSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof ChainedContextualSubtable; } /** {@inheritDoc} */ - public boolean substitute ( GlyphSubstitutionState ss ) { + public boolean substitute (GlyphSubstitutionState ss) { int gi = ss.getGlyph(); int ci; - if ( ( ci = getCoverageIndex ( gi ) ) < 0 ) { + if ((ci = getCoverageIndex (gi)) < 0) { return false; } else { int[] rv = new int[1]; - RuleLookup[] la = getLookups ( ci, gi, ss, rv ); - if ( la != null ) { - ss.apply ( la, rv[0] ); + RuleLookup[] la = getLookups (ci, gi, ss, rv); + if (la != null) { + ss.apply (la, rv[0]); return true; } else { return false; @@ -1040,14 +1040,14 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param rv array of ints used to receive multiple return values, must be of length 1 or greater * @return array of rule lookups or null if none applies */ - public abstract RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ); - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new ChainedContextualSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 2 ) { - return new ChainedContextualSubtableFormat2 ( id, sequence, flags, format, coverage, entries ); - } else if ( format == 3 ) { - return new ChainedContextualSubtableFormat3 ( id, sequence, flags, format, coverage, entries ); + public abstract RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv); + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new ChainedContextualSubtableFormat1 (id, sequence, flags, format, coverage, entries); + } else if (format == 2) { + return new ChainedContextualSubtableFormat2 (id, sequence, flags, format, coverage, entries); + } else if (format == 3) { + return new ChainedContextualSubtableFormat3 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -1056,43 +1056,43 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class ChainedContextualSubtableFormat1 extends ChainedContextualSubtable { private RuleSet[] rsa; // rule set array, ordered by glyph coverage index - ChainedContextualSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedGlyphSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; - int[] iga = cr.getGlyphs ( gi ); - if ( matches ( ss, iga, 0, rv ) ) { + int[] iga = cr.getGlyphs (gi); + if (matches (ss, iga, 0, rv)) { int[] bga = cr.getBacktrackGlyphs(); - if ( matches ( ss, bga, -1, null ) ) { + if (matches (ss, bga, -1, null)) { int[] lga = cr.getLookaheadGlyphs(); - if ( matches ( ss, lga, rv[0], null ) ) { + if (matches (ss, lga, rv[0], null)) { return r.getLookups(); } } @@ -1103,18 +1103,18 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - private boolean matches ( GlyphSubstitutionState ss, int[] glyphs, int offset, int[] rv ) { - return ContextualSubtableFormat1.matches ( ss, glyphs, offset, rv ); + private boolean matches (GlyphSubstitutionState ss, int[] glyphs, int offset, int[] rv) { + return ContextualSubtableFormat1.matches (ss, glyphs, offset, rv); } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1128,43 +1128,43 @@ public class GlyphSubstitutionTable extends GlyphTable { private GlyphClassTable lcdt; // lookahead class def table private int ngc; // class set count private RuleSet[] rsa; // rule set array, ordered by class number [0...ngc - 1] - ChainedContextualSubtableFormat2 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat2 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 5 ); - entries.add ( icdt ); - entries.add ( bcdt ); - entries.add ( lcdt ); - entries.add ( Integer.valueOf ( ngc ) ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (5); + entries.add (icdt); + entries.add (bcdt); + entries.add (lcdt); + entries.add (Integer.valueOf (ngc)); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedClassSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedClassSequenceRule)) { ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; - int[] ica = cr.getClasses ( icdt.getClassIndex ( gi, ss.getClassMatchSet ( gi ) ) ); - if ( matches ( ss, icdt, ica, 0, rv ) ) { + int[] ica = cr.getClasses (icdt.getClassIndex (gi, ss.getClassMatchSet (gi))); + if (matches (ss, icdt, ica, 0, rv)) { int[] bca = cr.getBacktrackClasses(); - if ( matches ( ss, bcdt, bca, -1, null ) ) { + if (matches (ss, bcdt, bca, -1, null)) { int[] lca = cr.getLookaheadClasses(); - if ( matches ( ss, lcdt, lca, rv[0], null ) ) { + if (matches (ss, lcdt, lca, rv[0], null)) { return r.getLookups(); } } @@ -1175,46 +1175,46 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - private boolean matches ( GlyphSubstitutionState ss, GlyphClassTable cdt, int[] classes, int offset, int[] rv ) { - return ContextualSubtableFormat2.matches ( ss, cdt, classes, offset, rv ); + private boolean matches (GlyphSubstitutionState ss, GlyphClassTable cdt, int[] classes, int offset, int[] rv) { + return ContextualSubtableFormat2.matches (ss, cdt, classes, offset, rv); } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); - } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 5 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 5 entries" ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); + } + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 5) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an GlyphClassTable, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); } else { icdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(1) ) != null ) && ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass() ); + if (((o = entries.get(1)) != null) && ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); } else { bcdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(2) ) != null ) && ! ( o instanceof GlyphClassTable ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass() ); + if (((o = entries.get(2)) != null) && ! (o instanceof GlyphClassTable)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); } else { lcdt = (GlyphClassTable) o; } - if ( ( ( o = entries.get(3) ) == null ) || ! ( o instanceof Integer ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fourth entry must be an Integer, but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); } else { ngc = ((Integer)(o)).intValue(); } - if ( ( ( o = entries.get(4) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, fifth entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(4)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; - if ( rsa.length != ngc ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes" ); + if (rsa.length != ngc) { + throw new AdvancedTypographicTableFormatException ("illegal entries, RuleSet[] length is " + rsa.length + ", but expected " + ngc + " glyph classes"); } } } @@ -1223,43 +1223,43 @@ public class GlyphSubstitutionTable extends GlyphTable { private static class ChainedContextualSubtableFormat3 extends ChainedContextualSubtable { private RuleSet[] rsa; // rule set array, containing a single rule set - ChainedContextualSubtableFormat3 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ChainedContextualSubtableFormat3 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { - if ( rsa != null ) { - List entries = new ArrayList ( 1 ); - entries.add ( rsa ); + if (rsa != null) { + List entries = new ArrayList (1); + entries.add (rsa); return entries; } else { return null; } } /** {@inheritDoc} */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - GlyphTable.resolveLookupReferences ( rsa, lookupTables ); + public void resolveLookupReferences (Map/**/ lookupTables) { + GlyphTable.resolveLookupReferences (rsa, lookupTables); } /** {@inheritDoc} */ - public RuleLookup[] getLookups ( int ci, int gi, GlyphSubstitutionState ss, int[] rv ) { + public RuleLookup[] getLookups (int ci, int gi, GlyphSubstitutionState ss, int[] rv) { assert ss != null; - assert ( rv != null ) && ( rv.length > 0 ); + assert (rv != null) && (rv.length > 0); assert rsa != null; - if ( rsa.length > 0 ) { + if (rsa.length > 0) { RuleSet rs = rsa [ 0 ]; - if ( rs != null ) { + if (rs != null) { Rule[] ra = rs.getRules(); - for ( int i = 0, n = ra.length; i < n; i++ ) { + for (int i = 0, n = ra.length; i < n; i++) { Rule r = ra [ i ]; - if ( ( r != null ) && ( r instanceof ChainedCoverageSequenceRule ) ) { + if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; GlyphCoverageTable[] igca = cr.getCoverages(); - if ( matches ( ss, igca, 0, rv ) ) { + if (matches (ss, igca, 0, rv)) { GlyphCoverageTable[] bgca = cr.getBacktrackCoverages(); - if ( matches ( ss, bgca, -1, null ) ) { + if (matches (ss, bgca, -1, null)) { GlyphCoverageTable[] lgca = cr.getLookaheadCoverages(); - if ( matches ( ss, lgca, rv[0], null ) ) { + if (matches (ss, lgca, rv[0], null)) { return r.getLookups(); } } @@ -1270,18 +1270,18 @@ public class GlyphSubstitutionTable extends GlyphTable { } return null; } - private boolean matches ( GlyphSubstitutionState ss, GlyphCoverageTable[] gca, int offset, int[] rv ) { - return ContextualSubtableFormat3.matches ( ss, gca, offset, rv ); + private boolean matches (GlyphSubstitutionState ss, GlyphCoverageTable[] gca, int offset, int[] rv) { + return ContextualSubtableFormat3.matches (ss, gca, offset, rv); } - private void populate ( List entries ) { - if ( entries == null ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, must be non-null" ); - } else if ( entries.size() != 1 ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, " + entries.size() + " entries present, but requires 1 entry" ); + private void populate (List entries) { + if (entries == null) { + throw new AdvancedTypographicTableFormatException ("illegal entries, must be non-null"); + } else if (entries.size() != 1) { + throw new AdvancedTypographicTableFormatException ("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); } else { Object o; - if ( ( ( o = entries.get(0) ) == null ) || ! ( o instanceof RuleSet[] ) ) { - throw new AdvancedTypographicTableFormatException ( "illegal entries, first entry must be an RuleSet[], but is: " + ( ( o != null ) ? o.getClass() : null ) ); + if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { + throw new AdvancedTypographicTableFormatException ("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); } else { rsa = (RuleSet[]) o; } @@ -1290,24 +1290,24 @@ public class GlyphSubstitutionTable extends GlyphTable { } private abstract static class ReverseChainedSingleSubtable extends GlyphSubstitutionSubtable { - public ReverseChainedSingleSubtable ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage ); + public ReverseChainedSingleSubtable (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage); } /** {@inheritDoc} */ public int getType() { return GSUB_LOOKUP_TYPE_REVERSE_CHAINED_SINGLE; } /** {@inheritDoc} */ - public boolean isCompatible ( GlyphSubtable subtable ) { + public boolean isCompatible (GlyphSubtable subtable) { return subtable instanceof ReverseChainedSingleSubtable; } /** {@inheritDoc} */ public boolean usesReverseScan() { return true; } - static GlyphSubstitutionSubtable create ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - if ( format == 1 ) { - return new ReverseChainedSingleSubtableFormat1 ( id, sequence, flags, format, coverage, entries ); + static GlyphSubstitutionSubtable create (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + if (format == 1) { + return new ReverseChainedSingleSubtableFormat1 (id, sequence, flags, format, coverage, entries); } else { throw new UnsupportedOperationException(); } @@ -1315,15 +1315,15 @@ public class GlyphSubstitutionTable extends GlyphTable { } private static class ReverseChainedSingleSubtableFormat1 extends ReverseChainedSingleSubtable { - ReverseChainedSingleSubtableFormat1 ( String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries ) { - super ( id, sequence, flags, format, coverage, entries ); - populate ( entries ); + ReverseChainedSingleSubtableFormat1 (String id, int sequence, int flags, int format, GlyphCoverageTable coverage, List entries) { + super (id, sequence, flags, format, coverage, entries); + populate (entries); } /** {@inheritDoc} */ public List getEntries() { return null; } - private void populate ( List entries ) { + private void populate (List entries) { } } @@ -1343,16 +1343,16 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param ligature glyph id * @param components sequence of N+1... component glyph (or character) identifiers */ - public Ligature ( int ligature, int[] components ) { - if ( ( ligature < 0 ) || ( ligature > 65535 ) ) { - throw new AdvancedTypographicTableFormatException ( "invalid ligature glyph index: " + ligature ); - } else if ( components == null ) { - throw new AdvancedTypographicTableFormatException ( "invalid ligature components, must be non-null array" ); + public Ligature (int ligature, int[] components) { + if ((ligature < 0) || (ligature > 65535)) { + throw new AdvancedTypographicTableFormatException ("invalid ligature glyph index: " + ligature); + } else if (components == null) { + throw new AdvancedTypographicTableFormatException ("invalid ligature components, must be non-null array"); } else { - for ( int i = 0, n = components.length; i < n; i++ ) { + for (int i = 0, n = components.length; i < n; i++) { int gc = components [ i ]; - if ( ( gc < 0 ) || ( gc > 65535 ) ) { - throw new AdvancedTypographicTableFormatException ( "invalid component glyph index: " + gc ); + if ((gc < 0) || (gc > 65535)) { + throw new AdvancedTypographicTableFormatException ("invalid component glyph index: " + gc); } } this.ligature = ligature; @@ -1380,12 +1380,12 @@ public class GlyphSubstitutionTable extends GlyphTable { * @param glyphs array of glyph components to match (including first, implied glyph) * @return true if matches */ - public boolean matchesComponents ( int[] glyphs ) { - if ( glyphs.length < ( components.length + 1 ) ) { + public boolean matchesComponents (int[] glyphs) { + if (glyphs.length < (components.length + 1)) { return false; } else { - for ( int i = 0, n = components.length; i < n; i++ ) { - if ( glyphs [ i + 1 ] != components [ i ] ) { + for (int i = 0, n = components.length; i < n; i++) { + if (glyphs [ i + 1 ] != components [ i ]) { return false; } } @@ -1397,8 +1397,8 @@ public class GlyphSubstitutionTable extends GlyphTable { public String toString() { StringBuffer sb = new StringBuffer(); sb.append("{components={"); - for ( int i = 0, n = components.length; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = components.length; i < n; i++) { + if (i > 0) { sb.append(','); } sb.append(Integer.toString(components[i])); @@ -1423,24 +1423,24 @@ public class GlyphSubstitutionTable extends GlyphTable { * Instantiate a set of ligatures. * @param ligatures collection of ligatures */ - public LigatureSet ( List ligatures ) { - this ( (Ligature[]) ligatures.toArray ( new Ligature [ ligatures.size() ] ) ); + public LigatureSet (List ligatures) { + this ((Ligature[]) ligatures.toArray (new Ligature [ ligatures.size() ])); } /** * Instantiate a set of ligatures. * @param ligatures array of ligatures */ - public LigatureSet ( Ligature[] ligatures ) { - if ( ligatures == null ) { - throw new AdvancedTypographicTableFormatException ( "invalid ligatures, must be non-null array" ); + public LigatureSet (Ligature[] ligatures) { + if (ligatures == null) { + throw new AdvancedTypographicTableFormatException ("invalid ligatures, must be non-null array"); } else { this.ligatures = ligatures; int ncMax = -1; - for ( int i = 0, n = ligatures.length; i < n; i++ ) { + for (int i = 0, n = ligatures.length; i < n; i++) { Ligature l = ligatures [ i ]; int nc = l.getNumComponents() + 1; - if ( nc > ncMax ) { + if (nc > ncMax) { ncMax = nc; } } @@ -1467,8 +1467,8 @@ public class GlyphSubstitutionTable extends GlyphTable { public String toString() { StringBuffer sb = new StringBuffer(); sb.append("{ligs={"); - for ( int i = 0, n = ligatures.length; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = ligatures.length; i < n; i++) { + if (i > 0) { sb.append(','); } sb.append(ligatures[i]); diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java index 776fcb029..5302c4e42 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java @@ -73,12 +73,12 @@ public abstract class GlyphSubtable implements Comparable { * @param format subtable format * @param mapping subtable mapping table */ - protected GlyphSubtable ( String lookupId, int sequence, int flags, int format, GlyphMappingTable mapping ) + protected GlyphSubtable (String lookupId, int sequence, int flags, int format, GlyphMappingTable mapping) { - if ( ( lookupId == null ) || ( lookupId.length() == 0 ) ) { - throw new AdvancedTypographicTableFormatException ( "invalid lookup identifier, must be non-empty string" ); - } else if ( mapping == null ) { - throw new AdvancedTypographicTableFormatException ( "invalid mapping table, must not be null" ); + if ((lookupId == null) || (lookupId.length() == 0)) { + throw new AdvancedTypographicTableFormatException ("invalid lookup identifier, must be non-empty string"); + } else if (mapping == null) { + throw new AdvancedTypographicTableFormatException ("invalid mapping table, must not be null"); } else { this.lookupId = lookupId; this.sequence = sequence; @@ -109,7 +109,7 @@ public abstract class GlyphSubtable implements Comparable { * @return true if specified subtable is compatible with this glyph subtable, where by compatible * is meant that they share the same lookup type */ - public abstract boolean isCompatible ( GlyphSubtable subtable ); + public abstract boolean isCompatible (GlyphSubtable subtable); /** @return true if subtable uses reverse scanning of glyph sequence, meaning from the last glyph * in a glyph sequence to the first glyph @@ -134,7 +134,7 @@ public abstract class GlyphSubtable implements Comparable { /** @return this subtable's governing glyph definition table or null if none available */ public GlyphDefinitionTable getGDEF() { GlyphTable gt = getTable(); - if ( gt != null ) { + if (gt != null) { return gt.getGlyphDefinitions(); } else { return null; @@ -143,7 +143,7 @@ public abstract class GlyphSubtable implements Comparable { /** @return this subtable's coverage mapping or null if mapping is not a coverage mapping */ public GlyphCoverageMapping getCoverage() { - if ( mapping instanceof GlyphCoverageMapping ) { + if (mapping instanceof GlyphCoverageMapping) { return (GlyphCoverageMapping) mapping; } else { return null; @@ -152,7 +152,7 @@ public abstract class GlyphSubtable implements Comparable { /** @return this subtable's class mapping or null if mapping is not a class mapping */ public GlyphClassMapping getClasses() { - if ( mapping instanceof GlyphClassMapping ) { + if (mapping instanceof GlyphClassMapping) { return (GlyphClassMapping) mapping; } else { return null; @@ -165,7 +165,7 @@ public abstract class GlyphSubtable implements Comparable { /** @return this subtable's parent table (or null if undefined) */ public synchronized GlyphTable getTable() { WeakReference r = this.table; - return ( r != null ) ? (GlyphTable) r.get() : null; + return (r != null) ? (GlyphTable) r.get() : null; } /** @@ -175,17 +175,17 @@ public abstract class GlyphSubtable implements Comparable { * @param table the table or null * @throws IllegalStateException if table is already set to non-null */ - public synchronized void setTable ( GlyphTable table ) throws IllegalStateException { + public synchronized void setTable (GlyphTable table) throws IllegalStateException { WeakReference r = this.table; - if ( table == null ) { + if (table == null) { this.table = null; - if ( r != null ) { + if (r != null) { r.clear(); } - } else if ( r == null ) { - this.table = new WeakReference ( table ); + } else if (r == null) { + this.table = new WeakReference (table); } else { - throw new IllegalStateException ( "table already set" ); + throw new IllegalStateException ("table already set"); } } @@ -193,7 +193,7 @@ public abstract class GlyphSubtable implements Comparable { * Resolve references to lookup tables, e.g., in RuleLookup, to the lookup tables themselves. * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { + public void resolveLookupReferences (Map/**/ lookupTables) { } /** @@ -201,9 +201,9 @@ public abstract class GlyphSubtable implements Comparable { * @param gid glyph id * @return the corresponding coverage index of the specified glyph id */ - public int getCoverageIndex ( int gid ) { - if ( mapping instanceof GlyphCoverageMapping ) { - return ( (GlyphCoverageMapping) mapping ) .getCoverageIndex ( gid ); + public int getCoverageIndex (int gid) { + if (mapping instanceof GlyphCoverageMapping) { + return ((GlyphCoverageMapping) mapping) .getCoverageIndex (gid); } else { return -1; } @@ -214,8 +214,8 @@ public abstract class GlyphSubtable implements Comparable { * @return the corresponding coverage index of the specified glyph id */ public int getCoverageSize() { - if ( mapping instanceof GlyphCoverageMapping ) { - return ( (GlyphCoverageMapping) mapping ) .getCoverageSize(); + if (mapping instanceof GlyphCoverageMapping) { + return ((GlyphCoverageMapping) mapping) .getCoverageSize(); } else { return 0; } @@ -224,7 +224,7 @@ public abstract class GlyphSubtable implements Comparable { /** {@inheritDoc} */ public int hashCode() { int hc = sequence; - hc = ( hc * 3 ) + ( lookupId.hashCode() ^ hc ); + hc = (hc * 3) + (lookupId.hashCode() ^ hc); return hc; } @@ -233,10 +233,10 @@ public abstract class GlyphSubtable implements Comparable { * @return true if the lookup identifier and the sequence number of the specified subtable is the same * as the lookup identifier and sequence number of this subtable */ - public boolean equals ( Object o ) { - if ( o instanceof GlyphSubtable ) { + public boolean equals (Object o) { + if (o instanceof GlyphSubtable) { GlyphSubtable st = (GlyphSubtable) o; - return lookupId.equals ( st.lookupId ) && ( sequence == st.sequence ); + return lookupId.equals (st.lookupId) && (sequence == st.sequence); } else { return false; } @@ -247,14 +247,14 @@ public abstract class GlyphSubtable implements Comparable { * @return the result of comparing the lookup identifier and the sequence number of the specified subtable with * the lookup identifier and sequence number of this subtable */ - public int compareTo ( Object o ) { + public int compareTo (Object o) { int d; - if ( o instanceof GlyphSubtable ) { + if (o instanceof GlyphSubtable) { GlyphSubtable st = (GlyphSubtable) o; - if ( ( d = lookupId.compareTo ( st.lookupId ) ) == 0 ) { - if ( sequence < st.sequence ) { + if ((d = lookupId.compareTo (st.lookupId)) == 0) { + if (sequence < st.sequence) { d = -1; - } else if ( sequence > st.sequence ) { + } else if (sequence > st.sequence) { d = 1; } } @@ -269,12 +269,12 @@ public abstract class GlyphSubtable implements Comparable { * @param subtables array of glyph subtables * @return true if any of the specified subtables uses reverse scanning. */ - public static boolean usesReverseScan ( GlyphSubtable[] subtables ) { - if ( ( subtables == null ) || ( subtables.length == 0 ) ) { + public static boolean usesReverseScan (GlyphSubtable[] subtables) { + if ((subtables == null) || (subtables.length == 0)) { return false; } else { - for ( int i = 0, n = subtables.length; i < n; i++ ) { - if ( subtables[i].usesReverseScan() ) { + for (int i = 0, n = subtables.length; i < n; i++) { + if (subtables[i].usesReverseScan()) { return true; } } @@ -288,27 +288,27 @@ public abstract class GlyphSubtable implements Comparable { * @return consistent flags * @throws IllegalStateException if inconsistent flags */ - public static int getFlags ( GlyphSubtable[] subtables ) throws IllegalStateException { - if ( ( subtables == null ) || ( subtables.length == 0 ) ) { + public static int getFlags (GlyphSubtable[] subtables) throws IllegalStateException { + if ((subtables == null) || (subtables.length == 0)) { return 0; } else { int flags = 0; // obtain first non-zero value of flags in array of subtables - for ( int i = 0, n = subtables.length; i < n; i++ ) { + for (int i = 0, n = subtables.length; i < n; i++) { int f = subtables[i].getFlags(); - if ( flags == 0 ) { + if (flags == 0) { flags = f; break; } } // enforce flag consistency - for ( int i = 0, n = subtables.length; i < n; i++ ) { + for (int i = 0, n = subtables.length; i < n; i++) { int f = subtables[i].getFlags(); - if ( f != flags ) { - throw new IllegalStateException ( "inconsistent lookup flags " + f + ", expected " + flags ); + if (f != flags) { + throw new IllegalStateException ("inconsistent lookup flags " + f + ", expected " + flags); } } - return flags | ( usesReverseScan ( subtables ) ? LF_INTERNAL_USE_REVERSE_SCAN : 0 ); + return flags | (usesReverseScan (subtables) ? LF_INTERNAL_USE_REVERSE_SCAN : 0); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphTable.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphTable.java index 1dd9d8b77..d0baab90a 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphTable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphTable.java @@ -85,11 +85,11 @@ public class GlyphTable { * @param gdef glyph definition table that applies * @param lookups map from lookup specs to lookup tables */ - public GlyphTable ( GlyphTable gdef, Map/*>*/ lookups ) { - if ( ( gdef != null ) && ! ( gdef instanceof GlyphDefinitionTable ) ) { - throw new AdvancedTypographicTableFormatException ( "bad glyph definition table" ); - } else if ( lookups == null ) { - throw new AdvancedTypographicTableFormatException ( "lookups must be non-null map" ); + public GlyphTable (GlyphTable gdef, Map/*>*/ lookups) { + if ((gdef != null) && ! (gdef instanceof GlyphDefinitionTable)) { + throw new AdvancedTypographicTableFormatException ("bad glyph definition table"); + } else if (lookups == null) { + throw new AdvancedTypographicTableFormatException ("lookups must be non-null map"); } else { this.gdef = gdef; this.lookups = lookups; @@ -111,7 +111,7 @@ public class GlyphTable { * @return (possibly empty) list of all lookup specifications */ public List/**/ getLookups() { - return matchLookupSpecs ( "*", "*", "*" ); + return matchLookupSpecs ("*", "*", "*"); } /** @@ -120,11 +120,11 @@ public class GlyphTable { * @return (possibly empty) ordered list of all lookup tables */ public List/**/ getLookupTables() { - TreeSet/**/ lids = new TreeSet/**/ ( lookupTables.keySet() ); - List/**/ ltl = new ArrayList/**/ ( lids.size() ); - for ( Iterator it = lids.iterator(); it.hasNext(); ) { + TreeSet/**/ lids = new TreeSet/**/ (lookupTables.keySet()); + List/**/ ltl = new ArrayList/**/ (lids.size()); + for (Iterator it = lids.iterator(); it.hasNext(); ) { String lid = (String) it.next(); - ltl.add ( lookupTables.get ( lid ) ); + ltl.add (lookupTables.get (lid)); } return ltl; } @@ -135,29 +135,29 @@ public class GlyphTable { * @param lid lookup id * @return table associated with lookup id or null if none */ - public LookupTable getLookupTable ( String lid ) { - return (LookupTable) lookupTables.get ( lid ); + public LookupTable getLookupTable (String lid) { + return (LookupTable) lookupTables.get (lid); } /** * Add a subtable. * @param subtable a (non-null) glyph subtable */ - protected void addSubtable ( GlyphSubtable subtable ) { + protected void addSubtable (GlyphSubtable subtable) { // ensure table is not frozen - if ( frozen ) { - throw new IllegalStateException ( "glyph table is frozen, subtable addition prohibited" ); + if (frozen) { + throw new IllegalStateException ("glyph table is frozen, subtable addition prohibited"); } // set subtable's table reference to this table - subtable.setTable ( this ); + subtable.setTable (this); // add subtable to this table's subtable collection String lid = subtable.getLookupId(); - if ( lookupTables.containsKey ( lid ) ) { - LookupTable lt = (LookupTable) lookupTables.get ( lid ); - lt.addSubtable ( subtable ); + if (lookupTables.containsKey (lid)) { + LookupTable lt = (LookupTable) lookupTables.get (lid); + lt.addSubtable (subtable); } else { - LookupTable lt = new LookupTable ( lid, subtable ); - lookupTables.put ( lid, lt ); + LookupTable lt = new LookupTable (lid, subtable); + lookupTables.put (lid, lt); } } @@ -166,10 +166,10 @@ public class GlyphTable { * create resulting cached state. */ protected void freezeSubtables() { - if ( ! frozen ) { - for ( Iterator it = lookupTables.values().iterator(); it.hasNext(); ) { + if (! frozen) { + for (Iterator it = lookupTables.values().iterator(); it.hasNext(); ) { LookupTable lt = (LookupTable) it.next(); - lt.freezeSubtables ( lookupTables ); + lt.freezeSubtables (lookupTables); } frozen = true; } @@ -183,27 +183,27 @@ public class GlyphTable { * @param feature a feature identifier * @return a (possibly empty) array of matching lookup specifications */ - public List/**/ matchLookupSpecs ( String script, String language, String feature ) { + public List/**/ matchLookupSpecs (String script, String language, String feature) { Set/**/ keys = lookups.keySet(); List/**/ matches = new ArrayList/**/(); - for ( Iterator it = keys.iterator(); it.hasNext();) { + for (Iterator it = keys.iterator(); it.hasNext();) { LookupSpec ls = (LookupSpec) it.next(); - if ( ! "*".equals(script) ) { - if ( ! ls.getScript().equals ( script ) ) { + if (! "*".equals(script)) { + if (! ls.getScript().equals (script)) { continue; } } - if ( ! "*".equals(language) ) { - if ( ! ls.getLanguage().equals ( language ) ) { + if (! "*".equals(language)) { + if (! ls.getLanguage().equals (language)) { continue; } } - if ( ! "*".equals(feature) ) { - if ( ! ls.getFeature().equals ( feature ) ) { + if (! "*".equals(feature)) { + if (! ls.getFeature().equals (feature)) { continue; } } - matches.add ( ls ); + matches.add (ls); } return matches; } @@ -216,17 +216,17 @@ public class GlyphTable { * @param feature a feature identifier * @return a (possibly empty) map from matching lookup specifications to lists of corresponding lookup tables */ - public Map/*>*/ matchLookups ( String script, String language, String feature ) { - LookupSpec lsm = new LookupSpec ( script, language, feature, true, true ); - Map/*>*/ lm = (Map/*>*/) matchedLookups.get ( lsm ); - if ( lm == null ) { + public Map/*>*/ matchLookups (String script, String language, String feature) { + LookupSpec lsm = new LookupSpec (script, language, feature, true, true); + Map/*>*/ lm = (Map/*>*/) matchedLookups.get (lsm); + if (lm == null) { lm = new LinkedHashMap(); - List/**/ lsl = matchLookupSpecs ( script, language, feature ); - for ( Iterator it = lsl.iterator(); it.hasNext(); ) { + List/**/ lsl = matchLookupSpecs (script, language, feature); + for (Iterator it = lsl.iterator(); it.hasNext(); ) { LookupSpec ls = (LookupSpec) it.next(); - lm.put ( ls, findLookupTables ( ls ) ); + lm.put (ls, findLookupTables (ls)); } - matchedLookups.put ( lsm, lm ); + matchedLookups.put (lsm, lm); } return lm; } @@ -236,19 +236,19 @@ public class GlyphTable { * @param ls a (non-null) lookup specification * @return a (possibly empty) ordered list of lookup tables whose corresponding lookup specifications match the specified lookup spec */ - public List/**/ findLookupTables ( LookupSpec ls ) { + public List/**/ findLookupTables (LookupSpec ls) { TreeSet/**/ lts = new TreeSet/**/(); List/**/ ids; - if ( ( ids = (List/**/) lookups.get ( ls ) ) != null ) { - for ( Iterator it = ids.iterator(); it.hasNext();) { + if ((ids = (List/**/) lookups.get (ls)) != null) { + for (Iterator it = ids.iterator(); it.hasNext();) { String lid = (String) it.next(); LookupTable lt; - if ( ( lt = (LookupTable) lookupTables.get ( lid ) ) != null ) { - lts.add ( lt ); + if ((lt = (LookupTable) lookupTables.get (lid)) != null) { + lts.add (lt); } } } - return new ArrayList/**/ ( lts ); + return new ArrayList/**/ (lts); } /** @@ -258,25 +258,25 @@ public class GlyphTable { * @param lookups a mapping from lookup specifications to lists of look tables from which to select lookup tables according to the specified features * @return ordered array of assembled lookup table use specifications */ - public UseSpec[] assembleLookups ( String[] features, Map/*>*/ lookups ) { + public UseSpec[] assembleLookups (String[] features, Map/*>*/ lookups) { TreeSet/**/ uss = new TreeSet/**/(); - for ( int i = 0, n = features.length; i < n; i++ ) { + for (int i = 0, n = features.length; i < n; i++) { String feature = features[i]; - for ( Iterator it = lookups.entrySet().iterator(); it.hasNext(); ) { + for (Iterator it = lookups.entrySet().iterator(); it.hasNext(); ) { Map.Entry/*>*/ e = (Map.Entry/*>*/) it.next(); LookupSpec ls = (LookupSpec) e.getKey(); - if ( ls.getFeature().equals ( feature ) ) { + if (ls.getFeature().equals (feature)) { List/**/ ltl = (List/**/) e.getValue(); - if ( ltl != null ) { - for ( Iterator ltit = ltl.iterator(); ltit.hasNext(); ) { + if (ltl != null) { + for (Iterator ltit = ltl.iterator(); ltit.hasNext(); ) { LookupTable lt = (LookupTable) ltit.next(); - uss.add ( new UseSpec ( lt, feature ) ); + uss.add (new UseSpec (lt, feature)); } } } } } - return (UseSpec[]) uss.toArray ( new UseSpec [ uss.size() ] ); + return (UseSpec[]) uss.toArray (new UseSpec [ uss.size() ]); } /** {@inheritDoc} */ @@ -296,18 +296,18 @@ public class GlyphTable { * @param name of table type to map to type value * @return glyph table type (as an integer constant) */ - public static int getTableTypeFromName ( String name ) { + public static int getTableTypeFromName (String name) { int t; String s = name.toLowerCase(); - if ( "gsub".equals ( s ) ) { + if ("gsub".equals (s)) { t = GLYPH_TABLE_TYPE_SUBSTITUTION; - } else if ( "gpos".equals ( s ) ) { + } else if ("gpos".equals (s)) { t = GLYPH_TABLE_TYPE_POSITIONING; - } else if ( "jstf".equals ( s ) ) { + } else if ("jstf".equals (s)) { t = GLYPH_TABLE_TYPE_JUSTIFICATION; - } else if ( "base".equals ( s ) ) { + } else if ("base".equals (s)) { t = GLYPH_TABLE_TYPE_BASELINE; - } else if ( "gdef".equals ( s ) ) { + } else if ("gdef".equals (s)) { t = GLYPH_TABLE_TYPE_DEFINITION; } else { t = -1; @@ -320,12 +320,12 @@ public class GlyphTable { * @param rsa array of rule sets * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public static void resolveLookupReferences ( RuleSet[] rsa, Map/**/ lookupTables ) { - if ( ( rsa != null ) && ( lookupTables != null ) ) { - for ( int i = 0, n = rsa.length; i < n; i++ ) { + public static void resolveLookupReferences (RuleSet[] rsa, Map/**/ lookupTables) { + if ((rsa != null) && (lookupTables != null)) { + for (int i = 0, n = rsa.length; i < n; i++) { RuleSet rs = rsa [ i ]; - if ( rs != null ) { - rs.resolveLookupReferences ( lookupTables ); + if (rs != null) { + rs.resolveLookupReferences (lookupTables); } } } @@ -346,8 +346,8 @@ public class GlyphTable { * @param language a language identifier * @param feature a feature identifier */ - public LookupSpec ( String script, String language, String feature ) { - this ( script, language, feature, false, false ); + public LookupSpec (String script, String language, String feature) { + this (script, language, feature, false, false); } /** @@ -358,19 +358,19 @@ public class GlyphTable { * @param permitEmpty if true the permit empty script, language, or feature * @param permitWildcard if true the permit wildcard script, language, or feature */ - LookupSpec ( String script, String language, String feature, boolean permitEmpty, boolean permitWildcard ) { - if ( ( script == null ) || ( ! permitEmpty && ( script.length() == 0 ) ) ) { - throw new AdvancedTypographicTableFormatException ( "script must be non-empty string" ); - } else if ( ( language == null ) || ( ! permitEmpty && ( language.length() == 0 ) ) ) { - throw new AdvancedTypographicTableFormatException ( "language must be non-empty string" ); - } else if ( ( feature == null ) || ( ! permitEmpty && ( feature.length() == 0 ) ) ) { - throw new AdvancedTypographicTableFormatException ( "feature must be non-empty string" ); - } else if ( ! permitWildcard && script.equals("*") ) { - throw new AdvancedTypographicTableFormatException ( "script must not be wildcard" ); - } else if ( ! permitWildcard && language.equals("*") ) { - throw new AdvancedTypographicTableFormatException ( "language must not be wildcard" ); - } else if ( ! permitWildcard && feature.equals("*") ) { - throw new AdvancedTypographicTableFormatException ( "feature must not be wildcard" ); + LookupSpec (String script, String language, String feature, boolean permitEmpty, boolean permitWildcard) { + if ((script == null) || (! permitEmpty && (script.length() == 0))) { + throw new AdvancedTypographicTableFormatException ("script must be non-empty string"); + } else if ((language == null) || (! permitEmpty && (language.length() == 0))) { + throw new AdvancedTypographicTableFormatException ("language must be non-empty string"); + } else if ((feature == null) || (! permitEmpty && (feature.length() == 0))) { + throw new AdvancedTypographicTableFormatException ("feature must be non-empty string"); + } else if (! permitWildcard && script.equals("*")) { + throw new AdvancedTypographicTableFormatException ("script must not be wildcard"); + } else if (! permitWildcard && language.equals("*")) { + throw new AdvancedTypographicTableFormatException ("language must not be wildcard"); + } else if (! permitWildcard && feature.equals("*")) { + throw new AdvancedTypographicTableFormatException ("feature must not be wildcard"); } this.script = script.trim(); this.language = language.trim(); @@ -395,21 +395,21 @@ public class GlyphTable { /** {@inheritDoc} */ public int hashCode() { int hc = 0; - hc = 7 * hc + ( hc ^ script.hashCode() ); - hc = 11 * hc + ( hc ^ language.hashCode() ); - hc = 17 * hc + ( hc ^ feature.hashCode() ); + hc = 7 * hc + (hc ^ script.hashCode()); + hc = 11 * hc + (hc ^ language.hashCode()); + hc = 17 * hc + (hc ^ feature.hashCode()); return hc; } /** {@inheritDoc} */ - public boolean equals ( Object o ) { - if ( o instanceof LookupSpec ) { + public boolean equals (Object o) { + if (o instanceof LookupSpec) { LookupSpec l = (LookupSpec) o; - if ( ! l.script.equals ( script ) ) { + if (! l.script.equals (script)) { return false; - } else if ( ! l.language.equals ( language ) ) { + } else if (! l.language.equals (language)) { return false; - } else if ( ! l.feature.equals ( feature ) ) { + } else if (! l.feature.equals (feature)) { return false; } else { return true; @@ -420,13 +420,13 @@ public class GlyphTable { } /** {@inheritDoc} */ - public int compareTo ( Object o ) { + public int compareTo (Object o) { int d; - if ( o instanceof LookupSpec ) { + if (o instanceof LookupSpec) { LookupSpec ls = (LookupSpec) o; - if ( ( d = script.compareTo ( ls.script ) ) == 0 ) { - if ( ( d = language.compareTo ( ls.language ) ) == 0 ) { - if ( ( d = feature.compareTo ( ls.feature ) ) == 0 ) { + if ((d = script.compareTo (ls.script)) == 0) { + if ((d = language.compareTo (ls.language)) == 0) { + if ((d = feature.compareTo (ls.feature)) == 0) { d = 0; } } @@ -471,8 +471,8 @@ public class GlyphTable { * @param id the lookup table's identifier * @param subtable an initial subtable (or null) */ - public LookupTable ( String id, GlyphSubtable subtable ) { - this ( id, makeSingleton ( subtable ) ); + public LookupTable (String id, GlyphSubtable subtable) { + this (id, makeSingleton (subtable)); } /** @@ -480,30 +480,30 @@ public class GlyphTable { * @param id the lookup table's identifier * @param subtables a pre-poplated list of subtables or null */ - public LookupTable ( String id, List/**/ subtables ) { + public LookupTable (String id, List/**/ subtables) { assert id != null; assert id.length() != 0; - assert id.startsWith ( "lu" ); + assert id.startsWith ("lu"); this.id = id; - this.idOrdinal = Integer.parseInt ( id.substring ( 2 ) ); + this.idOrdinal = Integer.parseInt (id.substring (2)); this.subtables = new LinkedList/**/(); - if ( subtables != null ) { - for ( Iterator it = subtables.iterator(); it.hasNext(); ) { + if (subtables != null) { + for (Iterator it = subtables.iterator(); it.hasNext(); ) { GlyphSubtable st = (GlyphSubtable) it.next(); - addSubtable ( st ); + addSubtable (st); } } } /** @return the subtables as an array */ public GlyphSubtable[] getSubtables() { - if ( frozen ) { - return ( subtablesArray != null ) ? subtablesArray : subtablesArrayEmpty; + if (frozen) { + return (subtablesArray != null) ? subtablesArray : subtablesArrayEmpty; } else { - if ( doesSub ) { - return (GlyphSubtable[]) subtables.toArray ( new GlyphSubstitutionSubtable [ subtables.size() ] ); - } else if ( doesPos ) { - return (GlyphSubtable[]) subtables.toArray ( new GlyphPositioningSubtable [ subtables.size() ] ); + if (doesSub) { + return (GlyphSubtable[]) subtables.toArray (new GlyphSubstitutionSubtable [ subtables.size() ]); + } else if (doesPos) { + return (GlyphSubtable[]) subtables.toArray (new GlyphPositioningSubtable [ subtables.size() ]); } else { return null; } @@ -516,59 +516,59 @@ public class GlyphTable { * @param subtable to add * @return true if subtable was not already present, otherwise false */ - public boolean addSubtable ( GlyphSubtable subtable ) { + public boolean addSubtable (GlyphSubtable subtable) { boolean added = false; // ensure table is not frozen - if ( frozen ) { - throw new IllegalStateException ( "glyph table is frozen, subtable addition prohibited" ); + if (frozen) { + throw new IllegalStateException ("glyph table is frozen, subtable addition prohibited"); } // validate subtable to ensure consistency with current subtables - validateSubtable ( subtable ); + validateSubtable (subtable); // insert subtable into ordered list - for ( ListIterator/**/ lit = subtables.listIterator(0); lit.hasNext(); ) { + for (ListIterator/**/ lit = subtables.listIterator(0); lit.hasNext(); ) { GlyphSubtable st = (GlyphSubtable) lit.next(); int d; - if ( ( d = subtable.compareTo ( st ) ) < 0 ) { + if ((d = subtable.compareTo (st)) < 0) { // insert within list - lit.set ( subtable ); - lit.add ( st ); + lit.set (subtable); + lit.add (st); added = true; - } else if ( d == 0 ) { + } else if (d == 0) { // duplicate entry is ignored added = false; subtable = null; } } // append at end of list - if ( ! added && ( subtable != null ) ) { - subtables.add ( subtable ); + if (! added && (subtable != null)) { + subtables.add (subtable); added = true; } return added; } - private void validateSubtable ( GlyphSubtable subtable ) { - if ( subtable == null ) { - throw new AdvancedTypographicTableFormatException ( "subtable must be non-null" ); + private void validateSubtable (GlyphSubtable subtable) { + if (subtable == null) { + throw new AdvancedTypographicTableFormatException ("subtable must be non-null"); } - if ( subtable instanceof GlyphSubstitutionSubtable ) { - if ( doesPos ) { - throw new AdvancedTypographicTableFormatException ( "subtable must be positioning subtable, but is: " + subtable ); + if (subtable instanceof GlyphSubstitutionSubtable) { + if (doesPos) { + throw new AdvancedTypographicTableFormatException ("subtable must be positioning subtable, but is: " + subtable); } else { doesSub = true; } } - if ( subtable instanceof GlyphPositioningSubtable ) { - if ( doesSub ) { - throw new AdvancedTypographicTableFormatException ( "subtable must be substitution subtable, but is: " + subtable ); + if (subtable instanceof GlyphPositioningSubtable) { + if (doesSub) { + throw new AdvancedTypographicTableFormatException ("subtable must be substitution subtable, but is: " + subtable); } else { doesPos = true; } } - if ( subtables.size() > 0 ) { + if (subtables.size() > 0) { GlyphSubtable st = (GlyphSubtable) subtables.get(0); - if ( ! st.isCompatible ( subtable ) ) { - throw new AdvancedTypographicTableFormatException ( "subtable " + subtable + " is not compatible with subtable " + st ); + if (! st.isCompatible (subtable)) { + throw new AdvancedTypographicTableFormatException ("subtable " + subtable + " is not compatible with subtable " + st); } } } @@ -579,21 +579,21 @@ public class GlyphTable { * lookup tables that appear in this lookup table's subtables. * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public void freezeSubtables ( Map/**/ lookupTables ) { - if ( ! frozen ) { + public void freezeSubtables (Map/**/ lookupTables) { + if (! frozen) { GlyphSubtable[] sta = getSubtables(); - resolveLookupReferences ( sta, lookupTables ); + resolveLookupReferences (sta, lookupTables); this.subtablesArray = sta; this.frozen = true; } } - private void resolveLookupReferences ( GlyphSubtable[] subtables, Map/**/ lookupTables ) { - if ( subtables != null ) { - for ( int i = 0, n = subtables.length; i < n; i++ ) { + private void resolveLookupReferences (GlyphSubtable[] subtables, Map/**/ lookupTables) { + if (subtables != null) { + for (int i = 0, n = subtables.length; i < n; i++) { GlyphSubtable st = subtables [ i ]; - if ( st != null ) { - st.resolveLookupReferences ( lookupTables ); + if (st != null) { + st.resolveLookupReferences (lookupTables); } } } @@ -616,9 +616,9 @@ public class GlyphTable { * @param sct a script specific context tester (or null) * @return the substituted (output) glyph sequence */ - public GlyphSequence substitute ( GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct ) { - if ( performsSubstitution() ) { - return GlyphSubstitutionSubtable.substitute ( gs, script, language, feature, (GlyphSubstitutionSubtable[]) subtablesArray, sct ); + public GlyphSequence substitute (GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) { + if (performsSubstitution()) { + return GlyphSubstitutionSubtable.substitute (gs, script, language, feature, (GlyphSubstitutionSubtable[]) subtablesArray, sct); } else { return gs; } @@ -630,9 +630,9 @@ public class GlyphTable { * @param sequenceIndex if non negative, then apply subtables only at specified sequence index * @return the substituted (output) glyph sequence */ - public GlyphSequence substitute ( GlyphSubstitutionState ss, int sequenceIndex ) { - if ( performsSubstitution() ) { - return GlyphSubstitutionSubtable.substitute ( ss, (GlyphSubstitutionSubtable[]) subtablesArray, sequenceIndex ); + public GlyphSequence substitute (GlyphSubstitutionState ss, int sequenceIndex) { + if (performsSubstitution()) { + return GlyphSubstitutionSubtable.substitute (ss, (GlyphSubstitutionSubtable[]) subtablesArray, sequenceIndex); } else { return ss.getInput(); } @@ -659,9 +659,9 @@ public class GlyphTable { * @param sct a script specific context tester (or null) * @return true if some adjustment is not zero; otherwise, false */ - public boolean position ( GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - if ( performsPositioning() ) { - return GlyphPositioningSubtable.position ( gs, script, language, feature, fontSize, (GlyphPositioningSubtable[]) subtablesArray, widths, adjustments, sct ); + public boolean position (GlyphSequence gs, String script, String language, String feature, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct) { + if (performsPositioning()) { + return GlyphPositioningSubtable.position (gs, script, language, feature, fontSize, (GlyphPositioningSubtable[]) subtablesArray, widths, adjustments, sct); } else { return false; } @@ -673,9 +673,9 @@ public class GlyphTable { * @param sequenceIndex if non negative, then apply subtables only at specified sequence index * @return true if some adjustment is not zero; otherwise, false */ - public boolean position ( GlyphPositioningState ps, int sequenceIndex ) { - if ( performsPositioning() ) { - return GlyphPositioningSubtable.position ( ps, (GlyphPositioningSubtable[]) subtablesArray, sequenceIndex ); + public boolean position (GlyphPositioningState ps, int sequenceIndex) { + if (performsPositioning()) { + return GlyphPositioningSubtable.position (ps, (GlyphPositioningSubtable[]) subtablesArray, sequenceIndex); } else { return false; } @@ -691,8 +691,8 @@ public class GlyphTable { * @return true if identifier of the specified lookup table is the same * as the identifier of this lookup table */ - public boolean equals ( Object o ) { - if ( o instanceof LookupTable ) { + public boolean equals (Object o) { + if (o instanceof LookupTable) { LookupTable lt = (LookupTable) o; return idOrdinal == lt.idOrdinal; } else { @@ -707,14 +707,14 @@ public class GlyphTable { * "lu(DIGIT)+", with comparison based on numerical ordering of numbers expressed by * (DIGIT)+. */ - public int compareTo ( Object o ) { - if ( o instanceof LookupTable ) { + public int compareTo (Object o) { + if (o instanceof LookupTable) { LookupTable lt = (LookupTable) o; int i = idOrdinal; int j = lt.idOrdinal; - if ( i < j ) { + if (i < j) { return -1; - } else if ( i > j ) { + } else if (i > j) { return 1; } else { return 0; @@ -727,19 +727,19 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "id = " + id ); - sb.append ( ", subtables = " + subtables ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("id = " + id); + sb.append (", subtables = " + subtables); + sb.append (" }"); return sb.toString(); } - private static List/**/ makeSingleton ( GlyphSubtable subtable ) { - if ( subtable == null ) { + private static List/**/ makeSingleton (GlyphSubtable subtable) { + if (subtable == null) { return null; } else { - List/**/ stl = new ArrayList/**/ ( 1 ); - stl.add ( subtable ); + List/**/ stl = new ArrayList/**/ (1); + stl.add (subtable); return stl; } } @@ -762,7 +762,7 @@ public class GlyphTable { * @param lookupTable a glyph lookup table * @param feature a feature that caused lookup table selection */ - public UseSpec ( LookupTable lookupTable, String feature ) { + public UseSpec (LookupTable lookupTable, String feature) { this.lookupTable = lookupTable; this.feature = feature; } @@ -785,8 +785,8 @@ public class GlyphTable { * @param sct a script specific context tester (or null) * @return the substituted (output) glyph sequence */ - public GlyphSequence substitute ( GlyphSequence gs, String script, String language, ScriptContextTester sct ) { - return lookupTable.substitute ( gs, script, language, feature, sct ); + public GlyphSequence substitute (GlyphSequence gs, String script, String language, ScriptContextTester sct) { + return lookupTable.substitute (gs, script, language, feature, sct); } /** @@ -801,8 +801,8 @@ public class GlyphTable { * @param sct a script specific context tester (or null) * @return true if some adjustment is not zero; otherwise, false */ - public boolean position ( GlyphSequence gs, String script, String language, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - return lookupTable.position ( gs, script, language, feature, fontSize, widths, adjustments, sct ); + public boolean position (GlyphSequence gs, String script, String language, int fontSize, int[] widths, int[][] adjustments, ScriptContextTester sct) { + return lookupTable.position (gs, script, language, feature, fontSize, widths, adjustments, sct); } /** {@inheritDoc} */ @@ -811,20 +811,20 @@ public class GlyphTable { } /** {@inheritDoc} */ - public boolean equals ( Object o ) { - if ( o instanceof UseSpec ) { + public boolean equals (Object o) { + if (o instanceof UseSpec) { UseSpec u = (UseSpec) o; - return lookupTable.equals ( u.lookupTable ); + return lookupTable.equals (u.lookupTable); } else { return false; } } /** {@inheritDoc} */ - public int compareTo ( Object o ) { - if ( o instanceof UseSpec ) { + public int compareTo (Object o) { + if (o instanceof UseSpec) { UseSpec u = (UseSpec) o; - return lookupTable.compareTo ( u.lookupTable ); + return lookupTable.compareTo (u.lookupTable); } else { return -1; } @@ -847,7 +847,7 @@ public class GlyphTable { * @param sequenceIndex the index into the input sequence * @param lookupIndex the lookup table index */ - public RuleLookup ( int sequenceIndex, int lookupIndex ) { + public RuleLookup (int sequenceIndex, int lookupIndex) { this.sequenceIndex = sequenceIndex; this.lookupIndex = lookupIndex; this.lookup = null; @@ -872,14 +872,14 @@ public class GlyphTable { * Resolve references to lookup tables. * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - if ( lookupTables != null ) { - String lid = "lu" + Integer.toString ( lookupIndex ); - LookupTable lt = (LookupTable) lookupTables.get ( lid ); - if ( lt != null ) { + public void resolveLookupReferences (Map/**/ lookupTables) { + if (lookupTables != null) { + String lid = "lu" + Integer.toString (lookupIndex); + LookupTable lt = (LookupTable) lookupTables.get (lid); + if (lt != null) { this.lookup = lt; } else { - log.warn ( "unable to resolve glyph lookup table reference '" + lid + "' amongst lookup tables: " + lookupTables.values() ); + log.warn ("unable to resolve glyph lookup table reference '" + lid + "' amongst lookup tables: " + lookupTables.values()); } } } @@ -904,7 +904,7 @@ public class GlyphTable { * @param lookups the rule's lookups * @param inputSequenceLength the number of glyphs in the input sequence for this rule */ - protected Rule ( RuleLookup[] lookups, int inputSequenceLength ) { + protected Rule (RuleLookup[] lookups, int inputSequenceLength) { assert lookups != null; this.lookups = lookups; this.inputSequenceLength = inputSequenceLength; @@ -924,12 +924,12 @@ public class GlyphTable { * Resolve references to lookup tables, e.g., in RuleLookup, to the lookup tables themselves. * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - if ( lookups != null ) { - for ( int i = 0, n = lookups.length; i < n; i++ ) { + public void resolveLookupReferences (Map/**/ lookupTables) { + if (lookups != null) { + for (int i = 0, n = lookups.length; i < n; i++) { RuleLookup l = lookups [ i ]; - if ( l != null ) { - l.resolveLookupReferences ( lookupTables ); + if (l != null) { + l.resolveLookupReferences (lookupTables); } } } @@ -937,7 +937,7 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { - return "{ lookups = " + Arrays.toString ( lookups ) + ", inputSequenceLength = " + inputSequenceLength + " }"; + return "{ lookups = " + Arrays.toString (lookups) + ", inputSequenceLength = " + inputSequenceLength + " }"; } } @@ -956,8 +956,8 @@ public class GlyphTable { * @param inputSequenceLength number of glyphs constituting input sequence (to be consumed) * @param glyphs the rule's glyph sequence to match, starting with second glyph in sequence */ - public GlyphSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, int[] glyphs ) { - super ( lookups, inputSequenceLength ); + public GlyphSequenceRule (RuleLookup[] lookups, int inputSequenceLength, int[] glyphs) { + super (lookups, inputSequenceLength); assert glyphs != null; this.glyphs = glyphs; } @@ -976,20 +976,20 @@ public class GlyphTable { * @param firstGlyph to fill in first glyph entry * @return the glyphs augmented by first glyph */ - public int[] getGlyphs ( int firstGlyph ) { + public int[] getGlyphs (int firstGlyph) { int[] ga = new int [ glyphs.length + 1 ]; ga [ 0 ] = firstGlyph; - System.arraycopy ( glyphs, 0, ga, 1, glyphs.length ); + System.arraycopy (glyphs, 0, ga, 1, glyphs.length); return ga; } /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", glyphs = " + Arrays.toString ( glyphs ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", glyphs = " + Arrays.toString (glyphs)); + sb.append (" }"); return sb.toString(); } @@ -1009,8 +1009,8 @@ public class GlyphTable { * @param inputSequenceLength number of glyphs constituting input sequence (to be consumed) * @param classes the rule's glyph class sequence to match, starting with second glyph in sequence */ - public ClassSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, int[] classes ) { - super ( lookups, inputSequenceLength ); + public ClassSequenceRule (RuleLookup[] lookups, int inputSequenceLength, int[] classes) { + super (lookups, inputSequenceLength); assert classes != null; this.classes = classes; } @@ -1029,20 +1029,20 @@ public class GlyphTable { * @param firstClass to fill in first class entry * @return the classes augmented by first class */ - public int[] getClasses ( int firstClass ) { + public int[] getClasses (int firstClass) { int[] ca = new int [ classes.length + 1 ]; ca [ 0 ] = firstClass; - System.arraycopy ( classes, 0, ca, 1, classes.length ); + System.arraycopy (classes, 0, ca, 1, classes.length); return ca; } /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", classes = " + Arrays.toString( classes ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", classes = " + Arrays.toString(classes)); + sb.append (" }"); return sb.toString(); } @@ -1062,8 +1062,8 @@ public class GlyphTable { * @param inputSequenceLength number of glyphs constituting input sequence (to be consumed) * @param coverages the rule's glyph coverage sequence to match, starting with first glyph in sequence */ - public CoverageSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, GlyphCoverageTable[] coverages ) { - super ( lookups, inputSequenceLength ); + public CoverageSequenceRule (RuleLookup[] lookups, int inputSequenceLength, GlyphCoverageTable[] coverages) { + super (lookups, inputSequenceLength); assert coverages != null; this.coverages = coverages; } @@ -1076,10 +1076,10 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", coverages = " + Arrays.toString( coverages ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", coverages = " + Arrays.toString(coverages)); + sb.append (" }"); return sb.toString(); } @@ -1102,8 +1102,8 @@ public class GlyphTable { * @param backtrackGlyphs the rule's backtrack glyph sequence to match, starting with first glyph in sequence * @param lookaheadGlyphs the rule's lookahead glyph sequence to match, starting with first glyph in sequence */ - public ChainedGlyphSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, int[] glyphs, int[] backtrackGlyphs, int[] lookaheadGlyphs ) { - super ( lookups, inputSequenceLength, glyphs ); + public ChainedGlyphSequenceRule (RuleLookup[] lookups, int inputSequenceLength, int[] glyphs, int[] backtrackGlyphs, int[] lookaheadGlyphs) { + super (lookups, inputSequenceLength, glyphs); assert backtrackGlyphs != null; assert lookaheadGlyphs != null; this.backtrackGlyphs = backtrackGlyphs; @@ -1123,12 +1123,12 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", glyphs = " + Arrays.toString ( getGlyphs() ) ); - sb.append ( ", backtrackGlyphs = " + Arrays.toString ( backtrackGlyphs ) ); - sb.append ( ", lookaheadGlyphs = " + Arrays.toString ( lookaheadGlyphs ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", glyphs = " + Arrays.toString (getGlyphs())); + sb.append (", backtrackGlyphs = " + Arrays.toString (backtrackGlyphs)); + sb.append (", lookaheadGlyphs = " + Arrays.toString (lookaheadGlyphs)); + sb.append (" }"); return sb.toString(); } @@ -1151,8 +1151,8 @@ public class GlyphTable { * @param backtrackClasses the rule's backtrack glyph class sequence to match, starting with first glyph in sequence * @param lookaheadClasses the rule's lookahead glyph class sequence to match, starting with first glyph in sequence */ - public ChainedClassSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, int[] classes, int[] backtrackClasses, int[] lookaheadClasses ) { - super ( lookups, inputSequenceLength, classes ); + public ChainedClassSequenceRule (RuleLookup[] lookups, int inputSequenceLength, int[] classes, int[] backtrackClasses, int[] lookaheadClasses) { + super (lookups, inputSequenceLength, classes); assert backtrackClasses != null; assert lookaheadClasses != null; this.backtrackClasses = backtrackClasses; @@ -1172,12 +1172,12 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", classes = " + Arrays.toString ( getClasses() ) ); - sb.append ( ", backtrackClasses = " + Arrays.toString ( backtrackClasses ) ); - sb.append ( ", lookaheadClasses = " + Arrays.toString ( lookaheadClasses ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", classes = " + Arrays.toString (getClasses())); + sb.append (", backtrackClasses = " + Arrays.toString (backtrackClasses)); + sb.append (", lookaheadClasses = " + Arrays.toString (lookaheadClasses)); + sb.append (" }"); return sb.toString(); } @@ -1200,8 +1200,8 @@ public class GlyphTable { * @param backtrackCoverages the rule's backtrack glyph class sequence to match, starting with first glyph in sequence * @param lookaheadCoverages the rule's lookahead glyph class sequence to match, starting with first glyph in sequence */ - public ChainedCoverageSequenceRule ( RuleLookup[] lookups, int inputSequenceLength, GlyphCoverageTable[] coverages, GlyphCoverageTable[] backtrackCoverages, GlyphCoverageTable[] lookaheadCoverages ) { - super ( lookups, inputSequenceLength, coverages ); + public ChainedCoverageSequenceRule (RuleLookup[] lookups, int inputSequenceLength, GlyphCoverageTable[] coverages, GlyphCoverageTable[] backtrackCoverages, GlyphCoverageTable[] lookaheadCoverages) { + super (lookups, inputSequenceLength, coverages); assert backtrackCoverages != null; assert lookaheadCoverages != null; this.backtrackCoverages = backtrackCoverages; @@ -1221,12 +1221,12 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( "{ " ); - sb.append ( "lookups = " + Arrays.toString ( getLookups() ) ); - sb.append ( ", coverages = " + Arrays.toString ( getCoverages() ) ); - sb.append ( ", backtrackCoverages = " + Arrays.toString ( backtrackCoverages ) ); - sb.append ( ", lookaheadCoverages = " + Arrays.toString ( lookaheadCoverages ) ); - sb.append ( " }" ); + sb.append ("{ "); + sb.append ("lookups = " + Arrays.toString (getLookups())); + sb.append (", coverages = " + Arrays.toString (getCoverages())); + sb.append (", backtrackCoverages = " + Arrays.toString (backtrackCoverages)); + sb.append (", lookaheadCoverages = " + Arrays.toString (lookaheadCoverages)); + sb.append (" }"); return sb.toString(); } @@ -1245,10 +1245,10 @@ public class GlyphTable { * @param rules the rules * @throws AdvancedTypographicTableFormatException if rules or some element of rules is null */ - public RuleSet ( Rule[] rules ) throws AdvancedTypographicTableFormatException { + public RuleSet (Rule[] rules) throws AdvancedTypographicTableFormatException { // enforce rules array instance - if ( rules == null ) { - throw new AdvancedTypographicTableFormatException ( "rules[] is null" ); + if (rules == null) { + throw new AdvancedTypographicTableFormatException ("rules[] is null"); } this.rules = rules; } @@ -1262,12 +1262,12 @@ public class GlyphTable { * Resolve references to lookup tables, e.g., in RuleLookup, to the lookup tables themselves. * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables */ - public void resolveLookupReferences ( Map/**/ lookupTables ) { - if ( rules != null ) { - for ( int i = 0, n = rules.length; i < n; i++ ) { + public void resolveLookupReferences (Map/**/ lookupTables) { + if (rules != null) { + for (int i = 0, n = rules.length; i < n; i++) { Rule r = rules [ i ]; - if ( r != null ) { - r.resolveLookupReferences ( lookupTables ); + if (r != null) { + r.resolveLookupReferences (lookupTables); } } } @@ -1275,7 +1275,7 @@ public class GlyphTable { /** {@inheritDoc} */ public String toString() { - return "{ rules = " + Arrays.toString ( rules ) + " }"; + return "{ rules = " + Arrays.toString (rules) + " }"; } } @@ -1291,22 +1291,22 @@ public class GlyphTable { * @param rules the rules * @throws AdvancedTypographicTableFormatException if some rule[i] is not an instance of rule[0] */ - public HomogeneousRuleSet ( Rule[] rules ) throws AdvancedTypographicTableFormatException { - super ( rules ); + public HomogeneousRuleSet (Rule[] rules) throws AdvancedTypographicTableFormatException { + super (rules); // find first non-null rule Rule r0 = null; - for ( int i = 1, n = rules.length; ( r0 == null ) && ( i < n ); i++ ) { - if ( rules[i] != null ) { + for (int i = 1, n = rules.length; (r0 == null) && (i < n); i++) { + if (rules[i] != null) { r0 = rules[i]; } } // enforce rule instance homogeneity - if ( r0 != null ) { + if (r0 != null) { Class c = r0.getClass(); - for ( int i = 1, n = rules.length; i < n; i++ ) { + for (int i = 1, n = rules.length; i < n; i++) { Rule r = rules[i]; - if ( ( r != null ) && ! c.isInstance ( r ) ) { - throw new AdvancedTypographicTableFormatException ( "rules[" + i + "] is not an instance of " + c.getName() ); + if ((r != null) && ! c.isInstance (r)) { + throw new AdvancedTypographicTableFormatException ("rules[" + i + "] is not an instance of " + c.getName()); } } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java b/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java index 9afb893b5..d5d5cc8d2 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java +++ b/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java @@ -68,7 +68,7 @@ public final class OTFAdvancedTypographicTableReader { * @param ttf parent font file reader (must be non-null) * @param in font file reader (must be non-null) */ - public OTFAdvancedTypographicTableReader ( TTFFile ttf, FontFileReader in ) { + public OTFAdvancedTypographicTableReader (TTFFile ttf, FontFileReader in) { assert ttf != null; assert in != null; this.ttf = ttf; @@ -84,12 +84,12 @@ public final class OTFAdvancedTypographicTableReader { readGDEF(); readGSUB(); readGPOS(); - } catch ( AdvancedTypographicTableFormatException e ) { + } catch (AdvancedTypographicTableFormatException e) { resetATStateAll(); throw e; - } catch ( IOException e ) { + } catch (IOException e) { resetATStateAll(); - throw new AdvancedTypographicTableFormatException ( e.getMessage(), e ); + throw new AdvancedTypographicTableFormatException (e.getMessage(), e); } finally { resetATState(); } @@ -100,7 +100,7 @@ public final class OTFAdvancedTypographicTableReader { * @return true if advanced (typographic) table is present */ public boolean hasAdvancedTable() { - return ( gdef != null ) || ( gsub != null ) || ( gpos != null ); + return (gdef != null) || (gsub != null) || (gpos != null); } /** @@ -130,14 +130,14 @@ public final class OTFAdvancedTypographicTableReader { private void readLangSysTable(TTFTableName tableTag, long langSysTable, String langSysTag) throws IOException { in.seekSet(langSysTable); if (log.isDebugEnabled()) { - log.debug(tableTag + " lang sys table: " + langSysTag ); + log.debug(tableTag + " lang sys table: " + langSysTag); } // read lookup order (reorder) table offset int lo = in.readTTFUShort(); // read required feature index int rf = in.readTTFUShort(); String rfi; - if ( rf != 65535 ) { + if (rf != 65535) { rfi = "f" + rf; } else { rfi = null; @@ -146,25 +146,25 @@ public final class OTFAdvancedTypographicTableReader { int nf = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " lang sys table reorder table: " + lo ); - log.debug(tableTag + " lang sys table required feature index: " + rf ); - log.debug(tableTag + " lang sys table non-required feature count: " + nf ); + log.debug(tableTag + " lang sys table reorder table: " + lo); + log.debug(tableTag + " lang sys table required feature index: " + rf); + log.debug(tableTag + " lang sys table non-required feature count: " + nf); } // read (non-required) feature indices int[] fia = new int[nf]; List fl = new java.util.ArrayList(); - for ( int i = 0; i < nf; i++ ) { + for (int i = 0; i < nf; i++) { int fi = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " lang sys table non-required feature index: " + fi ); + log.debug(tableTag + " lang sys table non-required feature index: " + fi); } fia[i] = fi; - fl.add ( "f" + fi ); + fl.add ("f" + fi); } - if ( seLanguages == null ) { + if (seLanguages == null) { seLanguages = new java.util.LinkedHashMap(); } - seLanguages.put ( langSysTag, new Object[] { rfi, fl } ); + seLanguages.put (langSysTag, new Object[] { rfi, fl }); } private static String defaultTag = "dflt"; @@ -172,53 +172,53 @@ public final class OTFAdvancedTypographicTableReader { private void readScriptTable(TTFTableName tableTag, long scriptTable, String scriptTag) throws IOException { in.seekSet(scriptTable); if (log.isDebugEnabled()) { - log.debug(tableTag + " script table: " + scriptTag ); + log.debug(tableTag + " script table: " + scriptTag); } // read default language system table offset int dl = in.readTTFUShort(); String dt = defaultTag; - if ( dl > 0 ) { + if (dl > 0) { if (log.isDebugEnabled()) { - log.debug(tableTag + " default lang sys tag: " + dt ); - log.debug(tableTag + " default lang sys table offset: " + dl ); + log.debug(tableTag + " default lang sys tag: " + dt); + log.debug(tableTag + " default lang sys table offset: " + dl); } } // read language system record count int nl = in.readTTFUShort(); List ll = new java.util.ArrayList(); - if ( nl > 0 ) { + if (nl > 0) { String[] lta = new String[nl]; int[] loa = new int[nl]; // read language system records - for ( int i = 0, n = nl; i < n; i++ ) { + for (int i = 0, n = nl; i < n; i++) { String lt = in.readTTFString(4); int lo = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " lang sys tag: " + lt ); - log.debug(tableTag + " lang sys table offset: " + lo ); + log.debug(tableTag + " lang sys tag: " + lt); + log.debug(tableTag + " lang sys table offset: " + lo); } lta[i] = lt; loa[i] = lo; - if ( dl == lo ) { + if (dl == lo) { dl = 0; dt = lt; } - ll.add ( lt ); + ll.add (lt); } // read non-default language system tables - for ( int i = 0, n = nl; i < n; i++ ) { - readLangSysTable ( tableTag, scriptTable + loa [ i ], lta [ i ] ); + for (int i = 0, n = nl; i < n; i++) { + readLangSysTable (tableTag, scriptTable + loa [ i ], lta [ i ]); } } // read default language system table (if specified) - if ( dl > 0 ) { - readLangSysTable ( tableTag, scriptTable + dl, dt ); - } else if ( dt != null ) { + if (dl > 0) { + readLangSysTable (tableTag, scriptTable + dl, dt); + } else if (dt != null) { if (log.isDebugEnabled()) { - log.debug(tableTag + " lang sys default: " + dt ); + log.debug(tableTag + " lang sys default: " + dt); } } - seScripts.put ( scriptTag, new Object[] { dt, ll, seLanguages } ); + seScripts.put (scriptTag, new Object[] { dt, ll, seLanguages }); seLanguages = null; } @@ -227,26 +227,26 @@ public final class OTFAdvancedTypographicTableReader { // read script record count int ns = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " script list record count: " + ns ); + log.debug(tableTag + " script list record count: " + ns); } - if ( ns > 0 ) { + if (ns > 0) { String[] sta = new String[ns]; int[] soa = new int[ns]; // read script records - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { String st = in.readTTFString(4); int so = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " script tag: " + st ); - log.debug(tableTag + " script table offset: " + so ); + log.debug(tableTag + " script tag: " + st); + log.debug(tableTag + " script table offset: " + so); } sta[i] = st; soa[i] = so; } // read script tables - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { seLanguages = null; - readScriptTable ( tableTag, scriptList + soa [ i ], sta [ i ] ); + readScriptTable (tableTag, scriptList + soa [ i ], sta [ i ]); } } } @@ -254,7 +254,7 @@ public final class OTFAdvancedTypographicTableReader { private void readFeatureTable(TTFTableName tableTag, long featureTable, String featureTag, int featureIndex) throws IOException { in.seekSet(featureTable); if (log.isDebugEnabled()) { - log.debug(tableTag + " feature table: " + featureTag ); + log.debug(tableTag + " feature table: " + featureTag); } // read feature params offset int po = in.readTTFUShort(); @@ -262,21 +262,21 @@ public final class OTFAdvancedTypographicTableReader { int nl = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " feature table parameters offset: " + po ); - log.debug(tableTag + " feature table lookup list index count: " + nl ); + log.debug(tableTag + " feature table parameters offset: " + po); + log.debug(tableTag + " feature table lookup list index count: " + nl); } // read lookup table indices int[] lia = new int[nl]; List lul = new java.util.ArrayList(); - for ( int i = 0; i < nl; i++ ) { + for (int i = 0; i < nl; i++) { int li = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " feature table lookup index: " + li ); + log.debug(tableTag + " feature table lookup index: " + li); } lia[i] = li; - lul.add ( "lu" + li ); + lul.add ("lu" + li); } - seFeatures.put ( "f" + featureIndex, new Object[] { featureTag, lul } ); + seFeatures.put ("f" + featureIndex, new Object[] { featureTag, lul }); } private void readFeatureList(TTFTableName tableTag, long featureList) throws IOException { @@ -284,28 +284,28 @@ public final class OTFAdvancedTypographicTableReader { // read feature record count int nf = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " feature list record count: " + nf ); + log.debug(tableTag + " feature list record count: " + nf); } - if ( nf > 0 ) { + if (nf > 0) { String[] fta = new String[nf]; int[] foa = new int[nf]; // read feature records - for ( int i = 0, n = nf; i < n; i++ ) { + for (int i = 0, n = nf; i < n; i++) { String ft = in.readTTFString(4); int fo = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " feature tag: " + ft ); - log.debug(tableTag + " feature table offset: " + fo ); + log.debug(tableTag + " feature tag: " + ft); + log.debug(tableTag + " feature table offset: " + fo); } fta[i] = ft; foa[i] = fo; } // read feature tables - for ( int i = 0, n = nf; i < n; i++ ) { + for (int i = 0, n = nf; i < n; i++) { if (log.isDebugEnabled()) { - log.debug(tableTag + " feature index: " + i ); + log.debug(tableTag + " feature index: " + i); } - readFeatureTable ( tableTag, featureList + foa [ i ], fta [ i ], i ); + readFeatureTable (tableTag, featureList + foa [ i ], fta [ i ], i); } } } @@ -317,9 +317,9 @@ public final class OTFAdvancedTypographicTableReader { static final int MARK_ATTACHMENT = 4; private GDEFLookupType() { } - public static int getSubtableType ( int lt ) { + public static int getSubtableType (int lt) { int st; - switch ( lt ) { + switch (lt) { case GDEFLookupType.GLYPH_CLASS: st = GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS; break; @@ -340,7 +340,7 @@ public final class OTFAdvancedTypographicTableReader { } public static String toString(int type) { String s; - switch ( type ) { + switch (type) { case GLYPH_CLASS: s = "GlyphClass"; break; @@ -372,9 +372,9 @@ public final class OTFAdvancedTypographicTableReader { static final int REVERSE_CHAINED_SINGLE = 8; private GSUBLookupType() { } - public static int getSubtableType ( int lt ) { + public static int getSubtableType (int lt) { int st; - switch ( lt ) { + switch (lt) { case GSUBLookupType.SINGLE: st = GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_SINGLE; break; @@ -407,7 +407,7 @@ public final class OTFAdvancedTypographicTableReader { } public static String toString(int type) { String s; - switch ( type ) { + switch (type) { case SINGLE: s = "Single"; break; @@ -454,7 +454,7 @@ public final class OTFAdvancedTypographicTableReader { } public static String toString(int type) { String s; - switch ( type ) { + switch (type) { case SINGLE: s = "Single"; break; @@ -502,48 +502,48 @@ public final class OTFAdvancedTypographicTableReader { public static String toString(int flags) { StringBuffer sb = new StringBuffer(); boolean first = true; - if ( ( flags & RIGHT_TO_LEFT ) != 0 ) { - if ( first ) { + if ((flags & RIGHT_TO_LEFT) != 0) { + if (first) { first = false; } else { - sb.append ( '|' ); + sb.append ('|'); } - sb.append ( "RightToLeft" ); + sb.append ("RightToLeft"); } - if ( ( flags & IGNORE_BASE_GLYPHS ) != 0 ) { - if ( first ) { + if ((flags & IGNORE_BASE_GLYPHS) != 0) { + if (first) { first = false; } else { - sb.append ( '|' ); + sb.append ('|'); } - sb.append ( "IgnoreBaseGlyphs" ); + sb.append ("IgnoreBaseGlyphs"); } - if ( ( flags & IGNORE_LIGATURE ) != 0 ) { - if ( first ) { + if ((flags & IGNORE_LIGATURE) != 0) { + if (first) { first = false; } else { - sb.append ( '|' ); + sb.append ('|'); } - sb.append ( "IgnoreLigature" ); + sb.append ("IgnoreLigature"); } - if ( ( flags & IGNORE_MARKS ) != 0 ) { - if ( first ) { + if ((flags & IGNORE_MARKS) != 0) { + if (first) { first = false; } else { - sb.append ( '|' ); + sb.append ('|'); } - sb.append ( "IgnoreMarks" ); + sb.append ("IgnoreMarks"); } - if ( ( flags & USE_MARK_FILTERING_SET ) != 0 ) { - if ( first ) { + if ((flags & USE_MARK_FILTERING_SET) != 0) { + if (first) { first = false; } else { - sb.append ( '|' ); + sb.append ('|'); } - sb.append ( "UseMarkFilteringSet" ); + sb.append ("UseMarkFilteringSet"); } - if ( sb.length() == 0 ) { - sb.append ( '-' ); + if (sb.length() == 0) { + sb.append ('-'); } return sb.toString(); } @@ -553,30 +553,30 @@ public final class OTFAdvancedTypographicTableReader { List entries = new java.util.ArrayList(); in.seekSet(tableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read glyph count int ng = in.readTTFUShort(); int[] ga = new int[ng]; - for ( int i = 0, n = ng; i < n; i++ ) { + for (int i = 0, n = ng; i < n; i++) { int g = in.readTTFUShort(); ga[i] = g; - entries.add ( Integer.valueOf(g) ); + entries.add (Integer.valueOf(g)); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(label + " glyphs: " + toString(ga) ); + log.debug(label + " glyphs: " + toString(ga)); } - return GlyphCoverageTable.createCoverageTable ( entries ); + return GlyphCoverageTable.createCoverageTable (entries); } private GlyphCoverageTable readCoverageTableFormat2(String label, long tableOffset, int coverageFormat) throws IOException { List entries = new java.util.ArrayList(); in.seekSet(tableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read range record count int nr = in.readTTFUShort(); - for ( int i = 0, n = nr; i < n; i++ ) { + for (int i = 0, n = nr; i < n; i++) { // read range start int s = in.readTTFUShort(); // read range end @@ -585,11 +585,11 @@ public final class OTFAdvancedTypographicTableReader { int m = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(label + " range[" + i + "]: [" + s + "," + e + "]: " + m ); + log.debug(label + " range[" + i + "]: [" + s + "," + e + "]: " + m); } - entries.add ( new GlyphCoverageTable.MappingRange ( s, e, m ) ); + entries.add (new GlyphCoverageTable.MappingRange (s, e, m)); } - return GlyphCoverageTable.createCoverageTable ( entries ); + return GlyphCoverageTable.createCoverageTable (entries); } private GlyphCoverageTable readCoverageTable(String label, long tableOffset) throws IOException { @@ -598,14 +598,14 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(tableOffset); // read coverage table format int cf = in.readTTFUShort(); - if ( cf == 1 ) { - gct = readCoverageTableFormat1 ( label, tableOffset, cf ); - } else if ( cf == 2 ) { - gct = readCoverageTableFormat2 ( label, tableOffset, cf ); + if (cf == 1) { + gct = readCoverageTableFormat1 (label, tableOffset, cf); + } else if (cf == 2) { + gct = readCoverageTableFormat2 (label, tableOffset, cf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported coverage table format: " + cf ); + throw new AdvancedTypographicTableFormatException ("unsupported coverage table format: " + cf); } - in.seekSet ( cp ); + in.seekSet (cp); return gct; } @@ -613,34 +613,34 @@ public final class OTFAdvancedTypographicTableReader { List entries = new java.util.ArrayList(); in.seekSet(tableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read start glyph int sg = in.readTTFUShort(); - entries.add ( Integer.valueOf(sg) ); + entries.add (Integer.valueOf(sg)); // read glyph count int ng = in.readTTFUShort(); // read glyph classes int[] ca = new int[ng]; - for ( int i = 0, n = ng; i < n; i++ ) { + for (int i = 0, n = ng; i < n; i++) { int gc = in.readTTFUShort(); ca[i] = gc; - entries.add ( Integer.valueOf(gc) ); + entries.add (Integer.valueOf(gc)); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(label + " glyph classes: " + toString(ca) ); + log.debug(label + " glyph classes: " + toString(ca)); } - return GlyphClassTable.createClassTable ( entries ); + return GlyphClassTable.createClassTable (entries); } private GlyphClassTable readClassDefTableFormat2(String label, long tableOffset, int classFormat) throws IOException { List entries = new java.util.ArrayList(); in.seekSet(tableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read range record count int nr = in.readTTFUShort(); - for ( int i = 0, n = nr; i < n; i++ ) { + for (int i = 0, n = nr; i < n; i++) { // read range start int s = in.readTTFUShort(); // read range end @@ -649,11 +649,11 @@ public final class OTFAdvancedTypographicTableReader { int m = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(label + " range[" + i + "]: [" + s + "," + e + "]: " + m ); + log.debug(label + " range[" + i + "]: [" + s + "," + e + "]: " + m); } - entries.add ( new GlyphClassTable.MappingRange ( s, e, m ) ); + entries.add (new GlyphClassTable.MappingRange (s, e, m)); } - return GlyphClassTable.createClassTable ( entries ); + return GlyphClassTable.createClassTable (entries); } private GlyphClassTable readClassDefTable(String label, long tableOffset) throws IOException { @@ -662,14 +662,14 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(tableOffset); // read class table format int cf = in.readTTFUShort(); - if ( cf == 1 ) { - gct = readClassDefTableFormat1 ( label, tableOffset, cf ); - } else if ( cf == 2 ) { - gct = readClassDefTableFormat2 ( label, tableOffset, cf ); + if (cf == 1) { + gct = readClassDefTableFormat1 (label, tableOffset, cf); + } else if (cf == 2) { + gct = readClassDefTableFormat2 (label, tableOffset, cf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported class definition table format: " + cf ); + throw new AdvancedTypographicTableFormatException ("unsupported class definition table format: " + cf); } - in.seekSet ( cp ); + in.seekSet (cp); return gct; } @@ -677,48 +677,48 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read delta glyph int dg = in.readTTFShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " single substitution subtable format: " + subtableFormat + " (delta)" ); - log.debug(tableTag + " single substitution coverage table offset: " + co ); - log.debug(tableTag + " single substitution delta: " + dg ); + log.debug(tableTag + " single substitution subtable format: " + subtableFormat + " (delta)"); + log.debug(tableTag + " single substitution coverage table offset: " + co); + log.debug(tableTag + " single substitution delta: " + dg); } // read coverage table - seMapping = readCoverageTable ( tableTag + " single substitution coverage", subtableOffset + co ); - seEntries.add ( Integer.valueOf ( dg ) ); + seMapping = readCoverageTable (tableTag + " single substitution coverage", subtableOffset + co); + seEntries.add (Integer.valueOf (dg)); } private void readSingleSubTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read glyph count int ng = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " single substitution subtable format: " + subtableFormat + " (mapped)" ); - log.debug(tableTag + " single substitution coverage table offset: " + co ); - log.debug(tableTag + " single substitution glyph count: " + ng ); + log.debug(tableTag + " single substitution subtable format: " + subtableFormat + " (mapped)"); + log.debug(tableTag + " single substitution coverage table offset: " + co); + log.debug(tableTag + " single substitution glyph count: " + ng); } // read coverage table - seMapping = readCoverageTable ( tableTag + " single substitution coverage", subtableOffset + co ); + seMapping = readCoverageTable (tableTag + " single substitution coverage", subtableOffset + co); // read glyph substitutions int[] gsa = new int[ng]; - for ( int i = 0, n = ng; i < n; i++ ) { + for (int i = 0, n = ng; i < n; i++) { int gs = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " single substitution glyph[" + i + "]: " + gs ); + log.debug(tableTag + " single substitution glyph[" + i + "]: " + gs); } gsa[i] = gs; - seEntries.add ( Integer.valueOf ( gs ) ); + seEntries.add (Integer.valueOf (gs)); } } @@ -726,12 +726,12 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readSingleSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readSingleSubTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readSingleSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readSingleSubTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported single substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported single substitution subtable format: " + sf); } return sf; } @@ -740,56 +740,56 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read sequence count int ns = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " multiple substitution subtable format: " + subtableFormat + " (mapped)" ); - log.debug(tableTag + " multiple substitution coverage table offset: " + co ); - log.debug(tableTag + " multiple substitution sequence count: " + ns ); + log.debug(tableTag + " multiple substitution subtable format: " + subtableFormat + " (mapped)"); + log.debug(tableTag + " multiple substitution coverage table offset: " + co); + log.debug(tableTag + " multiple substitution sequence count: " + ns); } // read coverage table - seMapping = readCoverageTable ( tableTag + " multiple substitution coverage", subtableOffset + co ); + seMapping = readCoverageTable (tableTag + " multiple substitution coverage", subtableOffset + co); // read sequence table offsets int[] soa = new int[ns]; - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { soa[i] = in.readTTFUShort(); } // read sequence tables int[][] gsa = new int [ ns ] []; - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { int so = soa[i]; int[] ga; - if ( so > 0 ) { + if (so > 0) { in.seekSet(subtableOffset + so); // read glyph count int ng = in.readTTFUShort(); ga = new int[ng]; - for ( int j = 0; j < ng; j++ ) { + for (int j = 0; j < ng; j++) { ga[j] = in.readTTFUShort(); } } else { ga = null; } if (log.isDebugEnabled()) { - log.debug(tableTag + " multiple substitution sequence[" + i + "]: " + toString ( ga ) ); + log.debug(tableTag + " multiple substitution sequence[" + i + "]: " + toString (ga)); } gsa [ i ] = ga; } - seEntries.add ( gsa ); + seEntries.add (gsa); } private int readMultipleSubTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readMultipleSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readMultipleSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported multiple substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported multiple substitution subtable format: " + sf); } return sf; } @@ -798,39 +798,39 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read alternate set count int ns = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " alternate substitution subtable format: " + subtableFormat + " (mapped)" ); - log.debug(tableTag + " alternate substitution coverage table offset: " + co ); - log.debug(tableTag + " alternate substitution alternate set count: " + ns ); + log.debug(tableTag + " alternate substitution subtable format: " + subtableFormat + " (mapped)"); + log.debug(tableTag + " alternate substitution coverage table offset: " + co); + log.debug(tableTag + " alternate substitution alternate set count: " + ns); } // read coverage table - seMapping = readCoverageTable ( tableTag + " alternate substitution coverage", subtableOffset + co ); + seMapping = readCoverageTable (tableTag + " alternate substitution coverage", subtableOffset + co); // read alternate set table offsets int[] soa = new int[ns]; - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { soa[i] = in.readTTFUShort(); } // read alternate set tables - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { int so = soa[i]; in.seekSet(subtableOffset + so); // read glyph count int ng = in.readTTFUShort(); int[] ga = new int[ng]; - for ( int j = 0; j < ng; j++ ) { + for (int j = 0; j < ng; j++) { int gs = in.readTTFUShort(); ga[j] = gs; } if (log.isDebugEnabled()) { - log.debug(tableTag + " alternate substitution alternate set[" + i + "]: " + toString ( ga ) ); + log.debug(tableTag + " alternate substitution alternate set[" + i + "]: " + toString (ga)); } - seEntries.add ( ga ); + seEntries.add (ga); } } @@ -838,10 +838,10 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readAlternateSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readAlternateSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported alternate substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported alternate substitution subtable format: " + sf); } return sf; } @@ -850,36 +850,36 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read ligature set count int ns = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " ligature substitution subtable format: " + subtableFormat + " (mapped)" ); - log.debug(tableTag + " ligature substitution coverage table offset: " + co ); - log.debug(tableTag + " ligature substitution ligature set count: " + ns ); + log.debug(tableTag + " ligature substitution subtable format: " + subtableFormat + " (mapped)"); + log.debug(tableTag + " ligature substitution coverage table offset: " + co); + log.debug(tableTag + " ligature substitution ligature set count: " + ns); } // read coverage table - seMapping = readCoverageTable ( tableTag + " ligature substitution coverage", subtableOffset + co ); + seMapping = readCoverageTable (tableTag + " ligature substitution coverage", subtableOffset + co); // read ligature set table offsets int[] soa = new int[ns]; - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { soa[i] = in.readTTFUShort(); } // read ligature set tables - for ( int i = 0, n = ns; i < n; i++ ) { + for (int i = 0, n = ns; i < n; i++) { int so = soa[i]; in.seekSet(subtableOffset + so); // read ligature table count int nl = in.readTTFUShort(); int[] loa = new int[nl]; - for ( int j = 0; j < nl; j++ ) { + for (int j = 0; j < nl; j++) { loa[j] = in.readTTFUShort(); } List ligs = new java.util.ArrayList(); - for ( int j = 0; j < nl; j++ ) { + for (int j = 0; j < nl; j++) { int lo = loa[j]; in.seekSet(subtableOffset + so + lo); // read ligature glyph id @@ -888,15 +888,15 @@ public final class OTFAdvancedTypographicTableReader { int nc = in.readTTFUShort(); int[] ca = new int [ nc - 1 ]; // read ligature (input) component glyph ids - for ( int k = 0; k < nc - 1; k++ ) { + for (int k = 0; k < nc - 1; k++) { ca[k] = in.readTTFUShort(); } if (log.isDebugEnabled()) { - log.debug(tableTag + " ligature substitution ligature set[" + i + "]: ligature(" + lg + "), components: " + toString ( ca ) ); + log.debug(tableTag + " ligature substitution ligature set[" + i + "]: ligature(" + lg + "), components: " + toString (ca)); } - ligs.add ( new GlyphSubstitutionTable.Ligature ( lg, ca ) ); + ligs.add (new GlyphSubstitutionTable.Ligature (lg, ca)); } - seEntries.add ( new GlyphSubstitutionTable.LigatureSet ( ligs ) ); + seEntries.add (new GlyphSubstitutionTable.LigatureSet (ligs)); } } @@ -904,22 +904,22 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readLigatureSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readLigatureSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported ligature substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported ligature substitution subtable format: " + sf); } return sf; } private GlyphTable.RuleLookup[] readRuleLookups(int numLookups, String header) throws IOException { GlyphTable.RuleLookup[] la = new GlyphTable.RuleLookup [ numLookups ]; - for ( int i = 0, n = numLookups; i < n; i++ ) { + for (int i = 0, n = numLookups; i < n; i++) { int sequenceIndex = in.readTTFUShort(); int lookupIndex = in.readTTFUShort(); - la [ i ] = new GlyphTable.RuleLookup ( sequenceIndex, lookupIndex ); + la [ i ] = new GlyphTable.RuleLookup (sequenceIndex, lookupIndex); // dump info if debugging and header is non-null - if ( log.isDebugEnabled() && ( header != null ) ) { + if (log.isDebugEnabled() && (header != null)) { log.debug(header + "lookup[" + i + "]: " + la[i]); } } @@ -930,77 +930,77 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read rule set count int nrs = in.readTTFUShort(); // read rule set offsets int[] rsoa = new int [ nrs ]; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { rsoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyphs)" ); - log.debug(tableTag + " contextual substitution coverage table offset: " + co ); - log.debug(tableTag + " contextual substitution rule set count: " + nrs ); - for ( int i = 0; i < nrs; i++ ) { - log.debug(tableTag + " contextual substitution rule set offset[" + i + "]: " + rsoa[i] ); + log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyphs)"); + log.debug(tableTag + " contextual substitution coverage table offset: " + co); + log.debug(tableTag + " contextual substitution rule set count: " + nrs); + for (int i = 0; i < nrs; i++) { + log.debug(tableTag + " contextual substitution rule set offset[" + i + "]: " + rsoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " contextual substitution coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " contextual substitution coverage", subtableOffset + co); } else { ct = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ nrs ]; String header = null; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { GlyphTable.RuleSet rs; int rso = rsoa [ i ]; - if ( rso > 0 ) { + if (rso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + rso ); + in.seekSet (subtableOffset + rso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { GlyphTable.GlyphSequenceRule r; int ro = roa [ j ]; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + rso + ro ); + in.seekSet (subtableOffset + rso + ro); // read glyph count int ng = in.readTTFUShort(); // read rule lookup count int nl = in.readTTFUShort(); // read glyphs int[] glyphs = new int [ ng - 1 ]; - for ( int k = 0, nk = glyphs.length; k < nk; k++ ) { + for (int k = 0, nk = glyphs.length; k < nk; k++) { glyphs [ k ] = in.readTTFUShort(); } // read rule lookups if (log.isDebugEnabled()) { header = tableTag + " contextual substitution lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.GlyphSequenceRule ( lookups, ng, glyphs ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.GlyphSequenceRule (lookups, ng, glyphs); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -1008,14 +1008,14 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( rsa ); + seEntries.add (rsa); } private void readContextualSubTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read class def table offset @@ -1024,78 +1024,78 @@ public final class OTFAdvancedTypographicTableReader { int ngc = in.readTTFUShort(); // read class rule set offsets int[] csoa = new int [ ngc ]; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { csoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyph classes)" ); - log.debug(tableTag + " contextual substitution coverage table offset: " + co ); - log.debug(tableTag + " contextual substitution class set count: " + ngc ); - for ( int i = 0; i < ngc; i++ ) { - log.debug(tableTag + " contextual substitution class set offset[" + i + "]: " + csoa[i] ); + log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyph classes)"); + log.debug(tableTag + " contextual substitution coverage table offset: " + co); + log.debug(tableTag + " contextual substitution class set count: " + ngc); + for (int i = 0; i < ngc; i++) { + log.debug(tableTag + " contextual substitution class set offset[" + i + "]: " + csoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " contextual substitution coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " contextual substitution coverage", subtableOffset + co); } else { ct = null; } // read class definition table GlyphClassTable cdt; - if ( cdo > 0 ) { - cdt = readClassDefTable ( tableTag + " contextual substitution class definition", subtableOffset + cdo ); + if (cdo > 0) { + cdt = readClassDefTable (tableTag + " contextual substitution class definition", subtableOffset + cdo); } else { cdt = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ ngc ]; String header = null; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { int cso = csoa [ i ]; GlyphTable.RuleSet rs; - if ( cso > 0 ) { + if (cso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + cso ); + in.seekSet (subtableOffset + cso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { int ro = roa [ j ]; GlyphTable.ClassSequenceRule r; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + cso + ro ); + in.seekSet (subtableOffset + cso + ro); // read glyph count int ng = in.readTTFUShort(); // read rule lookup count int nl = in.readTTFUShort(); // read classes int[] classes = new int [ ng - 1 ]; - for ( int k = 0, nk = classes.length; k < nk; k++ ) { + for (int k = 0, nk = classes.length; k < nk; k++) { classes [ k ] = in.readTTFUShort(); } // read rule lookups if (log.isDebugEnabled()) { header = tableTag + " contextual substitution lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ClassSequenceRule ( lookups, ng, classes ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ClassSequenceRule (lookups, ng, classes); } else { assert ro > 0 : "unexpected null subclass rule offset"; r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -1103,41 +1103,41 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( cdt ); - seEntries.add ( Integer.valueOf ( ngc ) ); - seEntries.add ( rsa ); + seEntries.add (cdt); + seEntries.add (Integer.valueOf (ngc)); + seEntries.add (rsa); } private void readContextualSubTableFormat3(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read glyph (input sequence length) count int ng = in.readTTFUShort(); // read substitution lookup count int nl = in.readTTFUShort(); // read glyph coverage offsets, one per glyph input sequence length count int[] gcoa = new int [ ng ]; - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { gcoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyph sets)" ); - log.debug(tableTag + " contextual substitution glyph input sequence length count: " + ng ); - log.debug(tableTag + " contextual substitution lookup count: " + nl ); - for ( int i = 0; i < ng; i++ ) { - log.debug(tableTag + " contextual substitution coverage table offset[" + i + "]: " + gcoa[i] ); + log.debug(tableTag + " contextual substitution format: " + subtableFormat + " (glyph sets)"); + log.debug(tableTag + " contextual substitution glyph input sequence length count: " + ng); + log.debug(tableTag + " contextual substitution lookup count: " + nl); + for (int i = 0; i < ng; i++) { + log.debug(tableTag + " contextual substitution coverage table offset[" + i + "]: " + gcoa[i]); } } // read coverage tables GlyphCoverageTable[] gca = new GlyphCoverageTable [ ng ]; - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { int gco = gcoa [ i ]; GlyphCoverageTable gct; - if ( gco > 0 ) { - gct = readCoverageTable ( tableTag + " contextual substitution coverage[" + i + "]", subtableOffset + gco ); + if (gco > 0) { + gct = readCoverageTable (tableTag + " contextual substitution coverage[" + i + "]", subtableOffset + gco); } else { gct = null; } @@ -1148,29 +1148,29 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual substitution lookups: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); // construct rule, rule set, and rule set array - GlyphTable.Rule r = new GlyphTable.CoverageSequenceRule ( lookups, ng, gca ); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet ( new GlyphTable.Rule[] {r} ); + GlyphTable.Rule r = new GlyphTable.CoverageSequenceRule (lookups, ng, gca); + GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet (new GlyphTable.Rule[] {r}); GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; // store results - assert ( gca != null ) && ( gca.length > 0 ); + assert (gca != null) && (gca.length > 0); seMapping = gca[0]; - seEntries.add ( rsa ); + seEntries.add (rsa); } private int readContextualSubTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readContextualSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readContextualSubTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 3 ) { - readContextualSubTableFormat3 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readContextualSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readContextualSubTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 3) { + readContextualSubTableFormat3 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported contextual substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported contextual substitution subtable format: " + sf); } return sf; } @@ -1179,75 +1179,75 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read rule set count int nrs = in.readTTFUShort(); // read rule set offsets int[] rsoa = new int [ nrs ]; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { rsoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyphs)" ); - log.debug(tableTag + " chained contextual substitution coverage table offset: " + co ); - log.debug(tableTag + " chained contextual substitution rule set count: " + nrs ); - for ( int i = 0; i < nrs; i++ ) { - log.debug(tableTag + " chained contextual substitution rule set offset[" + i + "]: " + rsoa[i] ); + log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyphs)"); + log.debug(tableTag + " chained contextual substitution coverage table offset: " + co); + log.debug(tableTag + " chained contextual substitution rule set count: " + nrs); + for (int i = 0; i < nrs; i++) { + log.debug(tableTag + " chained contextual substitution rule set offset[" + i + "]: " + rsoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " chained contextual substitution coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " chained contextual substitution coverage", subtableOffset + co); } else { ct = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ nrs ]; String header = null; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { GlyphTable.RuleSet rs; int rso = rsoa [ i ]; - if ( rso > 0 ) { + if (rso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + rso ); + in.seekSet (subtableOffset + rso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { GlyphTable.ChainedGlyphSequenceRule r; int ro = roa [ j ]; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + rso + ro ); + in.seekSet (subtableOffset + rso + ro); // read backtrack glyph count int nbg = in.readTTFUShort(); // read backtrack glyphs int[] backtrackGlyphs = new int [ nbg ]; - for ( int k = 0, nk = backtrackGlyphs.length; k < nk; k++ ) { + for (int k = 0, nk = backtrackGlyphs.length; k < nk; k++) { backtrackGlyphs [ k ] = in.readTTFUShort(); } // read input glyph count int nig = in.readTTFUShort(); // read glyphs int[] glyphs = new int [ nig - 1 ]; - for ( int k = 0, nk = glyphs.length; k < nk; k++ ) { + for (int k = 0, nk = glyphs.length; k < nk; k++) { glyphs [ k ] = in.readTTFUShort(); } // read lookahead glyph count int nlg = in.readTTFUShort(); // read lookahead glyphs int[] lookaheadGlyphs = new int [ nlg ]; - for ( int k = 0, nk = lookaheadGlyphs.length; k < nk; k++ ) { + for (int k = 0, nk = lookaheadGlyphs.length; k < nk; k++) { lookaheadGlyphs [ k ] = in.readTTFUShort(); } // read rule lookup count @@ -1256,14 +1256,14 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual substitution lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ChainedGlyphSequenceRule ( lookups, nig, glyphs, backtrackGlyphs, lookaheadGlyphs ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ChainedGlyphSequenceRule (lookups, nig, glyphs, backtrackGlyphs, lookaheadGlyphs); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -1271,14 +1271,14 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( rsa ); + seEntries.add (rsa); } private void readChainedContextualSubTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read backtrack class def table offset @@ -1291,89 +1291,89 @@ public final class OTFAdvancedTypographicTableReader { int ngc = in.readTTFUShort(); // read class set offsets int[] csoa = new int [ ngc ]; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { csoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyph classes)" ); - log.debug(tableTag + " chained contextual substitution coverage table offset: " + co ); - log.debug(tableTag + " chained contextual substitution class set count: " + ngc ); - for ( int i = 0; i < ngc; i++ ) { - log.debug(tableTag + " chained contextual substitution class set offset[" + i + "]: " + csoa[i] ); + log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyph classes)"); + log.debug(tableTag + " chained contextual substitution coverage table offset: " + co); + log.debug(tableTag + " chained contextual substitution class set count: " + ngc); + for (int i = 0; i < ngc; i++) { + log.debug(tableTag + " chained contextual substitution class set offset[" + i + "]: " + csoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " chained contextual substitution coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " chained contextual substitution coverage", subtableOffset + co); } else { ct = null; } // read backtrack class definition table GlyphClassTable bcdt; - if ( bcdo > 0 ) { - bcdt = readClassDefTable ( tableTag + " contextual substitution backtrack class definition", subtableOffset + bcdo ); + if (bcdo > 0) { + bcdt = readClassDefTable (tableTag + " contextual substitution backtrack class definition", subtableOffset + bcdo); } else { bcdt = null; } // read input class definition table GlyphClassTable icdt; - if ( icdo > 0 ) { - icdt = readClassDefTable ( tableTag + " contextual substitution input class definition", subtableOffset + icdo ); + if (icdo > 0) { + icdt = readClassDefTable (tableTag + " contextual substitution input class definition", subtableOffset + icdo); } else { icdt = null; } // read lookahead class definition table GlyphClassTable lcdt; - if ( lcdo > 0 ) { - lcdt = readClassDefTable ( tableTag + " contextual substitution lookahead class definition", subtableOffset + lcdo ); + if (lcdo > 0) { + lcdt = readClassDefTable (tableTag + " contextual substitution lookahead class definition", subtableOffset + lcdo); } else { lcdt = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ ngc ]; String header = null; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { int cso = csoa [ i ]; GlyphTable.RuleSet rs; - if ( cso > 0 ) { + if (cso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + cso ); + in.seekSet (subtableOffset + cso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { int ro = roa [ j ]; GlyphTable.ChainedClassSequenceRule r; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + cso + ro ); + in.seekSet (subtableOffset + cso + ro); // read backtrack glyph class count int nbc = in.readTTFUShort(); // read backtrack glyph classes int[] backtrackClasses = new int [ nbc ]; - for ( int k = 0, nk = backtrackClasses.length; k < nk; k++ ) { + for (int k = 0, nk = backtrackClasses.length; k < nk; k++) { backtrackClasses [ k ] = in.readTTFUShort(); } // read input glyph class count int nic = in.readTTFUShort(); // read input glyph classes int[] classes = new int [ nic - 1 ]; - for ( int k = 0, nk = classes.length; k < nk; k++ ) { + for (int k = 0, nk = classes.length; k < nk; k++) { classes [ k ] = in.readTTFUShort(); } // read lookahead glyph class count int nlc = in.readTTFUShort(); // read lookahead glyph classes int[] lookaheadClasses = new int [ nlc ]; - for ( int k = 0, nk = lookaheadClasses.length; k < nk; k++ ) { + for (int k = 0, nk = lookaheadClasses.length; k < nk; k++) { lookaheadClasses [ k ] = in.readTTFUShort(); } // read rule lookup count @@ -1382,14 +1382,14 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual substitution lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ChainedClassSequenceRule ( lookups, nic, classes, backtrackClasses, lookaheadClasses ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ChainedClassSequenceRule (lookups, nic, classes, backtrackClasses, lookaheadClasses); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -1397,65 +1397,65 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( icdt ); - seEntries.add ( bcdt ); - seEntries.add ( lcdt ); - seEntries.add ( Integer.valueOf ( ngc ) ); - seEntries.add ( rsa ); + seEntries.add (icdt); + seEntries.add (bcdt); + seEntries.add (lcdt); + seEntries.add (Integer.valueOf (ngc)); + seEntries.add (rsa); } private void readChainedContextualSubTableFormat3(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read backtrack glyph count int nbg = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] bgcoa = new int [ nbg ]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { bgcoa [ i ] = in.readTTFUShort(); } // read input glyph count int nig = in.readTTFUShort(); // read input glyph coverage offsets int[] igcoa = new int [ nig ]; - for ( int i = 0; i < nig; i++ ) { + for (int i = 0; i < nig; i++) { igcoa [ i ] = in.readTTFUShort(); } // read lookahead glyph count int nlg = in.readTTFUShort(); // read lookahead glyph coverage offsets int[] lgcoa = new int [ nlg ]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { lgcoa [ i ] = in.readTTFUShort(); } // read substitution lookup count int nl = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyph sets)" ); - log.debug(tableTag + " chained contextual substitution backtrack glyph count: " + nbg ); - for ( int i = 0; i < nbg; i++ ) { - log.debug(tableTag + " chained contextual substitution backtrack coverage table offset[" + i + "]: " + bgcoa[i] ); + log.debug(tableTag + " chained contextual substitution format: " + subtableFormat + " (glyph sets)"); + log.debug(tableTag + " chained contextual substitution backtrack glyph count: " + nbg); + for (int i = 0; i < nbg; i++) { + log.debug(tableTag + " chained contextual substitution backtrack coverage table offset[" + i + "]: " + bgcoa[i]); } - log.debug(tableTag + " chained contextual substitution input glyph count: " + nig ); - for ( int i = 0; i < nig; i++ ) { - log.debug(tableTag + " chained contextual substitution input coverage table offset[" + i + "]: " + igcoa[i] ); + log.debug(tableTag + " chained contextual substitution input glyph count: " + nig); + for (int i = 0; i < nig; i++) { + log.debug(tableTag + " chained contextual substitution input coverage table offset[" + i + "]: " + igcoa[i]); } - log.debug(tableTag + " chained contextual substitution lookahead glyph count: " + nlg ); - for ( int i = 0; i < nlg; i++ ) { - log.debug(tableTag + " chained contextual substitution lookahead coverage table offset[" + i + "]: " + lgcoa[i] ); + log.debug(tableTag + " chained contextual substitution lookahead glyph count: " + nlg); + for (int i = 0; i < nlg; i++) { + log.debug(tableTag + " chained contextual substitution lookahead coverage table offset[" + i + "]: " + lgcoa[i]); } - log.debug(tableTag + " chained contextual substitution lookup count: " + nl ); + log.debug(tableTag + " chained contextual substitution lookup count: " + nl); } // read backtrack coverage tables GlyphCoverageTable[] bgca = new GlyphCoverageTable[nbg]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { int bgco = bgcoa [ i ]; GlyphCoverageTable bgct; - if ( bgco > 0 ) { - bgct = readCoverageTable ( tableTag + " chained contextual substitution backtrack coverage[" + i + "]", subtableOffset + bgco ); + if (bgco > 0) { + bgct = readCoverageTable (tableTag + " chained contextual substitution backtrack coverage[" + i + "]", subtableOffset + bgco); } else { bgct = null; } @@ -1463,11 +1463,11 @@ public final class OTFAdvancedTypographicTableReader { } // read input coverage tables GlyphCoverageTable[] igca = new GlyphCoverageTable[nig]; - for ( int i = 0; i < nig; i++ ) { + for (int i = 0; i < nig; i++) { int igco = igcoa [ i ]; GlyphCoverageTable igct; - if ( igco > 0 ) { - igct = readCoverageTable ( tableTag + " chained contextual substitution input coverage[" + i + "]", subtableOffset + igco ); + if (igco > 0) { + igct = readCoverageTable (tableTag + " chained contextual substitution input coverage[" + i + "]", subtableOffset + igco); } else { igct = null; } @@ -1475,11 +1475,11 @@ public final class OTFAdvancedTypographicTableReader { } // read lookahead coverage tables GlyphCoverageTable[] lgca = new GlyphCoverageTable[nlg]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { int lgco = lgcoa [ i ]; GlyphCoverageTable lgct; - if ( lgco > 0 ) { - lgct = readCoverageTable ( tableTag + " chained contextual substitution lookahead coverage[" + i + "]", subtableOffset + lgco ); + if (lgco > 0) { + lgct = readCoverageTable (tableTag + " chained contextual substitution lookahead coverage[" + i + "]", subtableOffset + lgco); } else { lgct = null; } @@ -1490,29 +1490,29 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " chained contextual substitution lookups: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); // construct rule, rule set, and rule set array - GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule ( lookups, nig, igca, bgca, lgca ); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet ( new GlyphTable.Rule[] {r} ); + GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule (lookups, nig, igca, bgca, lgca); + GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet (new GlyphTable.Rule[] {r}); GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; // store results - assert ( igca != null ) && ( igca.length > 0 ); + assert (igca != null) && (igca.length > 0); seMapping = igca[0]; - seEntries.add ( rsa ); + seEntries.add (rsa); } private int readChainedContextualSubTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readChainedContextualSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readChainedContextualSubTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 3 ) { - readChainedContextualSubTableFormat3 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readChainedContextualSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readChainedContextualSubTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 3) { + readChainedContextualSubTableFormat3 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported chained contextual substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported chained contextual substitution subtable format: " + sf); } return sf; } @@ -1521,29 +1521,29 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read extension lookup type int lt = in.readTTFUShort(); // read extension offset long eo = in.readTTFULong(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " extension substitution subtable format: " + subtableFormat ); - log.debug(tableTag + " extension substitution lookup type: " + lt ); - log.debug(tableTag + " extension substitution lookup table offset: " + eo ); + log.debug(tableTag + " extension substitution subtable format: " + subtableFormat); + log.debug(tableTag + " extension substitution lookup type: " + lt); + log.debug(tableTag + " extension substitution lookup table offset: " + eo); } // read referenced subtable from extended offset - readGSUBSubtable ( lt, lookupFlags, lookupSequence, subtableSequence, subtableOffset + eo ); + readGSUBSubtable (lt, lookupFlags, lookupSequence, subtableSequence, subtableOffset + eo); } private int readExtensionSubTable(int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readExtensionSubTableFormat1 ( lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset, sf ); + if (sf == 1) { + readExtensionSubTableFormat1 (lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported extension substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported extension substitution subtable format: " + sf); } return sf; } @@ -1552,53 +1552,53 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GSUB"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read backtrack glyph count int nbg = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] bgcoa = new int [ nbg ]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { bgcoa [ i ] = in.readTTFUShort(); } // read lookahead glyph count int nlg = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] lgcoa = new int [ nlg ]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { lgcoa [ i ] = in.readTTFUShort(); } // read substitution (output) glyph count int ng = in.readTTFUShort(); // read substitution (output) glyphs int[] glyphs = new int [ ng ]; - for ( int i = 0, n = ng; i < n; i++ ) { + for (int i = 0, n = ng; i < n; i++) { glyphs [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " reverse chained contextual substitution format: " + subtableFormat ); - log.debug(tableTag + " reverse chained contextual substitution coverage table offset: " + co ); - log.debug(tableTag + " reverse chained contextual substitution backtrack glyph count: " + nbg ); - for ( int i = 0; i < nbg; i++ ) { - log.debug(tableTag + " reverse chained contextual substitution backtrack coverage table offset[" + i + "]: " + bgcoa[i] ); + log.debug(tableTag + " reverse chained contextual substitution format: " + subtableFormat); + log.debug(tableTag + " reverse chained contextual substitution coverage table offset: " + co); + log.debug(tableTag + " reverse chained contextual substitution backtrack glyph count: " + nbg); + for (int i = 0; i < nbg; i++) { + log.debug(tableTag + " reverse chained contextual substitution backtrack coverage table offset[" + i + "]: " + bgcoa[i]); } - log.debug(tableTag + " reverse chained contextual substitution lookahead glyph count: " + nlg ); - for ( int i = 0; i < nlg; i++ ) { - log.debug(tableTag + " reverse chained contextual substitution lookahead coverage table offset[" + i + "]: " + lgcoa[i] ); + log.debug(tableTag + " reverse chained contextual substitution lookahead glyph count: " + nlg); + for (int i = 0; i < nlg; i++) { + log.debug(tableTag + " reverse chained contextual substitution lookahead coverage table offset[" + i + "]: " + lgcoa[i]); } - log.debug(tableTag + " reverse chained contextual substitution glyphs: " + toString(glyphs) ); + log.debug(tableTag + " reverse chained contextual substitution glyphs: " + toString(glyphs)); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " reverse chained contextual substitution coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " reverse chained contextual substitution coverage", subtableOffset + co); // read backtrack coverage tables GlyphCoverageTable[] bgca = new GlyphCoverageTable[nbg]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { int bgco = bgcoa[i]; GlyphCoverageTable bgct; - if ( bgco > 0 ) { - bgct = readCoverageTable ( tableTag + " reverse chained contextual substitution backtrack coverage[" + i + "]", subtableOffset + bgco ); + if (bgco > 0) { + bgct = readCoverageTable (tableTag + " reverse chained contextual substitution backtrack coverage[" + i + "]", subtableOffset + bgco); } else { bgct = null; } @@ -1606,11 +1606,11 @@ public final class OTFAdvancedTypographicTableReader { } // read lookahead coverage tables GlyphCoverageTable[] lgca = new GlyphCoverageTable[nlg]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { int lgco = lgcoa[i]; GlyphCoverageTable lgct; - if ( lgco > 0 ) { - lgct = readCoverageTable ( tableTag + " reverse chained contextual substitution lookahead coverage[" + i + "]", subtableOffset + lgco ); + if (lgco > 0) { + lgct = readCoverageTable (tableTag + " reverse chained contextual substitution lookahead coverage[" + i + "]", subtableOffset + lgco); } else { lgct = null; } @@ -1618,19 +1618,19 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( bgca ); - seEntries.add ( lgca ); - seEntries.add ( glyphs ); + seEntries.add (bgca); + seEntries.add (lgca); + seEntries.add (glyphs); } private int readReverseChainedSingleSubTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read substitution subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readReverseChainedSingleSubTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readReverseChainedSingleSubTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported reverse chained single substitution subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported reverse chained single substitution subtable format: " + sf); } return sf; } @@ -1638,35 +1638,35 @@ public final class OTFAdvancedTypographicTableReader { private void readGSUBSubtable(int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, long subtableOffset) throws IOException { initATSubState(); int subtableFormat = -1; - switch ( lookupType ) { + switch (lookupType) { case GSUBLookupType.SINGLE: - subtableFormat = readSingleSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readSingleSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.MULTIPLE: - subtableFormat = readMultipleSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readMultipleSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.ALTERNATE: - subtableFormat = readAlternateSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readAlternateSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.LIGATURE: - subtableFormat = readLigatureSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readLigatureSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.CONTEXTUAL: - subtableFormat = readContextualSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readContextualSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.CHAINED_CONTEXTUAL: - subtableFormat = readChainedContextualSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readChainedContextualSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.REVERSE_CHAINED_SINGLE: - subtableFormat = readReverseChainedSingleSubTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readReverseChainedSingleSubTable (lookupType, lookupFlags, subtableOffset); break; case GSUBLookupType.EXTENSION: - subtableFormat = readExtensionSubTable ( lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset ); + subtableFormat = readExtensionSubTable (lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset); break; default: break; } - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION, lookupType, lookupFlags, lookupSequence, subtableSequence, subtableFormat ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION, lookupType, lookupFlags, lookupSequence, subtableSequence, subtableFormat); resetATSubState(); } @@ -1684,43 +1684,43 @@ public final class OTFAdvancedTypographicTableReader { int dm; int dd; int s2; - if ( df == 1 ) { + if (df == 1) { s1 = 14; m1 = 0x3; dm = 1; dd = 4; s2 = 2; - } else if ( df == 2 ) { + } else if (df == 2) { s1 = 12; m1 = 0xF; dm = 7; dd = 16; s2 = 4; - } else if ( df == 3 ) { + } else if (df == 3) { s1 = 8; m1 = 0xFF; dm = 127; dd = 256; s2 = 8; } else { - log.debug ( "unsupported device table delta format: " + df + ", ignoring device table" ); + log.debug ("unsupported device table delta format: " + df + ", ignoring device table"); return null; } // read deltas - int n = ( es - ss ) + 1; - if ( n < 0 ) { - log.debug ( "invalid device table delta count: " + n + ", ignoring device table" ); + int n = (es - ss) + 1; + if (n < 0) { + log.debug ("invalid device table delta count: " + n + ", ignoring device table"); return null; } int[] da = new int [ n ]; - for ( int i = 0; ( i < n ) && ( s2 > 0 );) { + for (int i = 0; (i < n) && (s2 > 0);) { int p = in.readTTFUShort(); - for ( int j = 0, k = 16 / s2; j < k; j++ ) { - int d = ( p >> s1 ) & m1; - if ( d > dm ) { + for (int j = 0, k = 16 / s2; j < k; j++) { + int d = (p >> s1) & m1; + if (d > dm) { d -= dd; } - if ( i < n ) { + if (i < n) { da [ i++ ] = d; } else { break; @@ -1729,102 +1729,102 @@ public final class OTFAdvancedTypographicTableReader { } } in.seekSet(cp); - return new GlyphPositioningTable.DeviceTable ( ss, es, da ); + return new GlyphPositioningTable.DeviceTable (ss, es, da); } private GlyphPositioningTable.Value readPosValue(long subtableOffset, int valueFormat) throws IOException { // XPlacement int xp; - if ( ( valueFormat & GlyphPositioningTable.Value.X_PLACEMENT ) != 0 ) { - xp = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + if ((valueFormat & GlyphPositioningTable.Value.X_PLACEMENT) != 0) { + xp = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); } else { xp = 0; } // YPlacement int yp; - if ( ( valueFormat & GlyphPositioningTable.Value.Y_PLACEMENT ) != 0 ) { - yp = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + if ((valueFormat & GlyphPositioningTable.Value.Y_PLACEMENT) != 0) { + yp = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); } else { yp = 0; } // XAdvance int xa; - if ( ( valueFormat & GlyphPositioningTable.Value.X_ADVANCE ) != 0 ) { - xa = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + if ((valueFormat & GlyphPositioningTable.Value.X_ADVANCE) != 0) { + xa = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); } else { xa = 0; } // YAdvance int ya; - if ( ( valueFormat & GlyphPositioningTable.Value.Y_ADVANCE ) != 0 ) { - ya = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + if ((valueFormat & GlyphPositioningTable.Value.Y_ADVANCE) != 0) { + ya = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); } else { ya = 0; } // XPlaDevice GlyphPositioningTable.DeviceTable xpd; - if ( ( valueFormat & GlyphPositioningTable.Value.X_PLACEMENT_DEVICE ) != 0 ) { + if ((valueFormat & GlyphPositioningTable.Value.X_PLACEMENT_DEVICE) != 0) { int xpdo = in.readTTFUShort(); - xpd = readPosDeviceTable ( subtableOffset, xpdo ); + xpd = readPosDeviceTable (subtableOffset, xpdo); } else { xpd = null; } // YPlaDevice GlyphPositioningTable.DeviceTable ypd; - if ( ( valueFormat & GlyphPositioningTable.Value.Y_PLACEMENT_DEVICE ) != 0 ) { + if ((valueFormat & GlyphPositioningTable.Value.Y_PLACEMENT_DEVICE) != 0) { int ypdo = in.readTTFUShort(); - ypd = readPosDeviceTable ( subtableOffset, ypdo ); + ypd = readPosDeviceTable (subtableOffset, ypdo); } else { ypd = null; } // XAdvDevice GlyphPositioningTable.DeviceTable xad; - if ( ( valueFormat & GlyphPositioningTable.Value.X_ADVANCE_DEVICE ) != 0 ) { + if ((valueFormat & GlyphPositioningTable.Value.X_ADVANCE_DEVICE) != 0) { int xado = in.readTTFUShort(); - xad = readPosDeviceTable ( subtableOffset, xado ); + xad = readPosDeviceTable (subtableOffset, xado); } else { xad = null; } // YAdvDevice GlyphPositioningTable.DeviceTable yad; - if ( ( valueFormat & GlyphPositioningTable.Value.Y_ADVANCE_DEVICE ) != 0 ) { + if ((valueFormat & GlyphPositioningTable.Value.Y_ADVANCE_DEVICE) != 0) { int yado = in.readTTFUShort(); - yad = readPosDeviceTable ( subtableOffset, yado ); + yad = readPosDeviceTable (subtableOffset, yado); } else { yad = null; } - return new GlyphPositioningTable.Value ( xp, yp, xa, ya, xpd, ypd, xad, yad ); + return new GlyphPositioningTable.Value (xp, yp, xa, ya, xpd, ypd, xad, yad); } private void readSinglePosTableFormat1(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read value format int vf = in.readTTFUShort(); // read value - GlyphPositioningTable.Value v = readPosValue ( subtableOffset, vf ); + GlyphPositioningTable.Value v = readPosValue (subtableOffset, vf); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " single positioning subtable format: " + subtableFormat + " (delta)" ); - log.debug(tableTag + " single positioning coverage table offset: " + co ); - log.debug(tableTag + " single positioning value: " + v ); + log.debug(tableTag + " single positioning subtable format: " + subtableFormat + " (delta)"); + log.debug(tableTag + " single positioning coverage table offset: " + co); + log.debug(tableTag + " single positioning value: " + v); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " single positioning coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " single positioning coverage", subtableOffset + co); // store results seMapping = ct; - seEntries.add ( v ); + seEntries.add (v); } private void readSinglePosTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read value format @@ -1833,36 +1833,36 @@ public final class OTFAdvancedTypographicTableReader { int nv = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " single positioning subtable format: " + subtableFormat + " (mapped)" ); - log.debug(tableTag + " single positioning coverage table offset: " + co ); - log.debug(tableTag + " single positioning value count: " + nv ); + log.debug(tableTag + " single positioning subtable format: " + subtableFormat + " (mapped)"); + log.debug(tableTag + " single positioning coverage table offset: " + co); + log.debug(tableTag + " single positioning value count: " + nv); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " single positioning coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " single positioning coverage", subtableOffset + co); // read positioning values GlyphPositioningTable.Value[] pva = new GlyphPositioningTable.Value[nv]; - for ( int i = 0, n = nv; i < n; i++ ) { - GlyphPositioningTable.Value pv = readPosValue ( subtableOffset, vf ); + for (int i = 0, n = nv; i < n; i++) { + GlyphPositioningTable.Value pv = readPosValue (subtableOffset, vf); if (log.isDebugEnabled()) { - log.debug(tableTag + " single positioning value[" + i + "]: " + pv ); + log.debug(tableTag + " single positioning value[" + i + "]: " + pv); } pva[i] = pv; } // store results seMapping = ct; - seEntries.add ( pva ); + seEntries.add (pva); } private int readSinglePosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positionining subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readSinglePosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readSinglePosTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readSinglePosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readSinglePosTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported single positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported single positioning subtable format: " + sf); } return sf; } @@ -1870,26 +1870,26 @@ public final class OTFAdvancedTypographicTableReader { private GlyphPositioningTable.PairValues readPosPairValues(long subtableOffset, boolean hasGlyph, int vf1, int vf2) throws IOException { // read glyph (if present) int glyph; - if ( hasGlyph ) { + if (hasGlyph) { glyph = in.readTTFUShort(); } else { glyph = 0; } // read first value (if present) GlyphPositioningTable.Value v1; - if ( vf1 != 0 ) { - v1 = readPosValue ( subtableOffset, vf1 ); + if (vf1 != 0) { + v1 = readPosValue (subtableOffset, vf1); } else { v1 = null; } // read second value (if present) GlyphPositioningTable.Value v2; - if ( vf2 != 0 ) { - v2 = readPosValue ( subtableOffset, vf2 ); + if (vf2 != 0) { + v2 = readPosValue (subtableOffset, vf2); } else { v2 = null; } - return new GlyphPositioningTable.PairValues ( glyph, v1, v2 ); + return new GlyphPositioningTable.PairValues (glyph, v1, v2); } private GlyphPositioningTable.PairValues[] readPosPairSetTable(long subtableOffset, int pairSetTableOffset, int vf1, int vf2) throws IOException { @@ -1900,13 +1900,13 @@ public final class OTFAdvancedTypographicTableReader { int npv = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " pair set table offset: " + pairSetTableOffset ); - log.debug(tableTag + " pair set table values count: " + npv ); + log.debug(tableTag + " pair set table offset: " + pairSetTableOffset); + log.debug(tableTag + " pair set table values count: " + npv); } // read pair values GlyphPositioningTable.PairValues[] pva = new GlyphPositioningTable.PairValues [ npv ]; - for ( int i = 0, n = npv; i < n; i++ ) { - GlyphPositioningTable.PairValues pv = readPosPairValues ( subtableOffset, true, vf1, vf2 ); + for (int i = 0, n = npv; i < n; i++) { + GlyphPositioningTable.PairValues pv = readPosPairValues (subtableOffset, true, vf1, vf2); pva [ i ] = pv; if (log.isDebugEnabled()) { log.debug(tableTag + " pair set table value[" + i + "]: " + pv); @@ -1920,7 +1920,7 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read value format for first glyph @@ -1931,31 +1931,31 @@ public final class OTFAdvancedTypographicTableReader { int nps = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " pair positioning subtable format: " + subtableFormat + " (glyphs)" ); - log.debug(tableTag + " pair positioning coverage table offset: " + co ); - log.debug(tableTag + " pair positioning value format #1: " + vf1 ); - log.debug(tableTag + " pair positioning value format #2: " + vf2 ); + log.debug(tableTag + " pair positioning subtable format: " + subtableFormat + " (glyphs)"); + log.debug(tableTag + " pair positioning coverage table offset: " + co); + log.debug(tableTag + " pair positioning value format #1: " + vf1); + log.debug(tableTag + " pair positioning value format #2: " + vf2); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " pair positioning coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " pair positioning coverage", subtableOffset + co); // read pair value matrix GlyphPositioningTable.PairValues[][] pvm = new GlyphPositioningTable.PairValues [ nps ][]; - for ( int i = 0, n = nps; i < n; i++ ) { + for (int i = 0, n = nps; i < n; i++) { // read pair set offset int pso = in.readTTFUShort(); // read pair set table at offset - pvm [ i ] = readPosPairSetTable ( subtableOffset, pso, vf1, vf2 ); + pvm [ i ] = readPosPairSetTable (subtableOffset, pso, vf1, vf2); } // store results seMapping = ct; - seEntries.add ( pvm ); + seEntries.add (pvm); } private void readPairPosTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read value format for first glyph @@ -1972,26 +1972,26 @@ public final class OTFAdvancedTypographicTableReader { int nc2 = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " pair positioning subtable format: " + subtableFormat + " (glyph classes)" ); - log.debug(tableTag + " pair positioning coverage table offset: " + co ); - log.debug(tableTag + " pair positioning value format #1: " + vf1 ); - log.debug(tableTag + " pair positioning value format #2: " + vf2 ); - log.debug(tableTag + " pair positioning class def table #1 offset: " + cd1o ); - log.debug(tableTag + " pair positioning class def table #2 offset: " + cd2o ); - log.debug(tableTag + " pair positioning class #1 count: " + nc1 ); - log.debug(tableTag + " pair positioning class #2 count: " + nc2 ); + log.debug(tableTag + " pair positioning subtable format: " + subtableFormat + " (glyph classes)"); + log.debug(tableTag + " pair positioning coverage table offset: " + co); + log.debug(tableTag + " pair positioning value format #1: " + vf1); + log.debug(tableTag + " pair positioning value format #2: " + vf2); + log.debug(tableTag + " pair positioning class def table #1 offset: " + cd1o); + log.debug(tableTag + " pair positioning class def table #2 offset: " + cd2o); + log.debug(tableTag + " pair positioning class #1 count: " + nc1); + log.debug(tableTag + " pair positioning class #2 count: " + nc2); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " pair positioning coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " pair positioning coverage", subtableOffset + co); // read class definition table #1 - GlyphClassTable cdt1 = readClassDefTable ( tableTag + " pair positioning class definition #1", subtableOffset + cd1o ); + GlyphClassTable cdt1 = readClassDefTable (tableTag + " pair positioning class definition #1", subtableOffset + cd1o); // read class definition table #2 - GlyphClassTable cdt2 = readClassDefTable ( tableTag + " pair positioning class definition #2", subtableOffset + cd2o ); + GlyphClassTable cdt2 = readClassDefTable (tableTag + " pair positioning class definition #2", subtableOffset + cd2o); // read pair value matrix GlyphPositioningTable.PairValues[][] pvm = new GlyphPositioningTable.PairValues [ nc1 ] [ nc2 ]; - for ( int i = 0; i < nc1; i++ ) { - for ( int j = 0; j < nc2; j++ ) { - GlyphPositioningTable.PairValues pv = readPosPairValues ( subtableOffset, false, vf1, vf2 ); + for (int i = 0; i < nc1; i++) { + for (int j = 0; j < nc2; j++) { + GlyphPositioningTable.PairValues pv = readPosPairValues (subtableOffset, false, vf1, vf2); pvm [ i ] [ j ] = pv; if (log.isDebugEnabled()) { log.debug(tableTag + " pair set table value[" + i + "][" + j + "]: " + pv); @@ -2000,23 +2000,23 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( cdt1 ); - seEntries.add ( cdt2 ); - seEntries.add ( Integer.valueOf ( nc1 ) ); - seEntries.add ( Integer.valueOf ( nc2 ) ); - seEntries.add ( pvm ); + seEntries.add (cdt1); + seEntries.add (cdt2); + seEntries.add (Integer.valueOf (nc1)); + seEntries.add (Integer.valueOf (nc2)); + seEntries.add (pvm); } private int readPairPosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readPairPosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readPairPosTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readPairPosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readPairPosTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported pair positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported pair positioning subtable format: " + sf); } return sf; } @@ -2027,46 +2027,46 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(anchorTableOffset); // read anchor table format int af = in.readTTFUShort(); - if ( af == 1 ) { + if (af == 1) { // read x coordinate - int x = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + int x = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); // read y coordinate - int y = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); - a = new GlyphPositioningTable.Anchor ( x, y ); - } else if ( af == 2 ) { + int y = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); + a = new GlyphPositioningTable.Anchor (x, y); + } else if (af == 2) { // read x coordinate - int x = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + int x = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); // read y coordinate - int y = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + int y = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); // read anchor point index int ap = in.readTTFUShort(); - a = new GlyphPositioningTable.Anchor ( x, y, ap ); - } else if ( af == 3 ) { + a = new GlyphPositioningTable.Anchor (x, y, ap); + } else if (af == 3) { // read x coordinate - int x = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + int x = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); // read y coordinate - int y = ttf.convertTTFUnit2PDFUnit ( in.readTTFShort() ); + int y = ttf.convertTTFUnit2PDFUnit (in.readTTFShort()); // read x device table offset int xdo = in.readTTFUShort(); // read y device table offset int ydo = in.readTTFUShort(); // read x device table (if present) GlyphPositioningTable.DeviceTable xd; - if ( xdo != 0 ) { - xd = readPosDeviceTable ( cp, xdo ); + if (xdo != 0) { + xd = readPosDeviceTable (cp, xdo); } else { xd = null; } // read y device table (if present) GlyphPositioningTable.DeviceTable yd; - if ( ydo != 0 ) { - yd = readPosDeviceTable ( cp, ydo ); + if (ydo != 0) { + yd = readPosDeviceTable (cp, ydo); } else { yd = null; } - a = new GlyphPositioningTable.Anchor ( x, y, xd, yd ); + a = new GlyphPositioningTable.Anchor (x, y, xd, yd); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported positioning anchor format: " + af ); + throw new AdvancedTypographicTableFormatException ("unsupported positioning anchor format: " + af); } in.seekSet(cp); return a; @@ -2076,64 +2076,64 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read entry/exit count int ec = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " cursive positioning subtable format: " + subtableFormat ); - log.debug(tableTag + " cursive positioning coverage table offset: " + co ); - log.debug(tableTag + " cursive positioning entry/exit count: " + ec ); + log.debug(tableTag + " cursive positioning subtable format: " + subtableFormat); + log.debug(tableTag + " cursive positioning coverage table offset: " + co); + log.debug(tableTag + " cursive positioning entry/exit count: " + ec); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " cursive positioning coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " cursive positioning coverage", subtableOffset + co); // read entry/exit records GlyphPositioningTable.Anchor[] aa = new GlyphPositioningTable.Anchor [ ec * 2 ]; - for ( int i = 0, n = ec; i < n; i++ ) { + for (int i = 0, n = ec; i < n; i++) { // read entry anchor offset int eno = in.readTTFUShort(); // read exit anchor offset int exo = in.readTTFUShort(); // read entry anchor GlyphPositioningTable.Anchor ena; - if ( eno > 0 ) { - ena = readPosAnchor ( subtableOffset + eno ); + if (eno > 0) { + ena = readPosAnchor (subtableOffset + eno); } else { ena = null; } // read exit anchor GlyphPositioningTable.Anchor exa; - if ( exo > 0 ) { - exa = readPosAnchor ( subtableOffset + exo ); + if (exo > 0) { + exa = readPosAnchor (subtableOffset + exo); } else { exa = null; } - aa [ ( i * 2 ) + 0 ] = ena; - aa [ ( i * 2 ) + 1 ] = exa; + aa [ (i * 2) + 0 ] = ena; + aa [ (i * 2) + 1 ] = exa; if (log.isDebugEnabled()) { - if ( ena != null ) { - log.debug(tableTag + " cursive entry anchor [" + i + "]: " + ena ); + if (ena != null) { + log.debug(tableTag + " cursive entry anchor [" + i + "]: " + ena); } - if ( exa != null ) { - log.debug(tableTag + " cursive exit anchor [" + i + "]: " + exa ); + if (exa != null) { + log.debug(tableTag + " cursive exit anchor [" + i + "]: " + exa); } } } // store results seMapping = ct; - seEntries.add ( aa ); + seEntries.add (aa); } private int readCursivePosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readCursivePosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readCursivePosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported cursive positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported cursive positioning subtable format: " + sf); } return sf; } @@ -2142,7 +2142,7 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read mark coverage offset int mco = in.readTTFUShort(); // read base coverage offset @@ -2155,41 +2155,41 @@ public final class OTFAdvancedTypographicTableReader { int bao = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-base positioning subtable format: " + subtableFormat ); - log.debug(tableTag + " mark-to-base positioning mark coverage table offset: " + mco ); - log.debug(tableTag + " mark-to-base positioning base coverage table offset: " + bco ); - log.debug(tableTag + " mark-to-base positioning mark class count: " + nmc ); - log.debug(tableTag + " mark-to-base positioning mark array offset: " + mao ); - log.debug(tableTag + " mark-to-base positioning base array offset: " + bao ); + log.debug(tableTag + " mark-to-base positioning subtable format: " + subtableFormat); + log.debug(tableTag + " mark-to-base positioning mark coverage table offset: " + mco); + log.debug(tableTag + " mark-to-base positioning base coverage table offset: " + bco); + log.debug(tableTag + " mark-to-base positioning mark class count: " + nmc); + log.debug(tableTag + " mark-to-base positioning mark array offset: " + mao); + log.debug(tableTag + " mark-to-base positioning base array offset: " + bao); } // read mark coverage table - GlyphCoverageTable mct = readCoverageTable ( tableTag + " mark-to-base positioning mark coverage", subtableOffset + mco ); + GlyphCoverageTable mct = readCoverageTable (tableTag + " mark-to-base positioning mark coverage", subtableOffset + mco); // read base coverage table - GlyphCoverageTable bct = readCoverageTable ( tableTag + " mark-to-base positioning base coverage", subtableOffset + bco ); + GlyphCoverageTable bct = readCoverageTable (tableTag + " mark-to-base positioning base coverage", subtableOffset + bco); // read mark anchor array // seek to mark array in.seekSet(subtableOffset + mao); // read mark count int nm = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-base positioning mark count: " + nm ); + log.debug(tableTag + " mark-to-base positioning mark count: " + nm); } // read mark anchor array, where i:{0...markCount} GlyphPositioningTable.MarkAnchor[] maa = new GlyphPositioningTable.MarkAnchor [ nm ]; - for ( int i = 0; i < nm; i++ ) { + for (int i = 0; i < nm; i++) { // read mark class int mc = in.readTTFUShort(); // read mark anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + mao + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + mao + ao); } else { a = null; } GlyphPositioningTable.MarkAnchor ma; - if ( a != null ) { - ma = new GlyphPositioningTable.MarkAnchor ( mc, a ); + if (a != null) { + ma = new GlyphPositioningTable.MarkAnchor (mc, a); } else { ma = null; } @@ -2205,17 +2205,17 @@ public final class OTFAdvancedTypographicTableReader { // read base count int nb = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-base positioning base count: " + nb ); + log.debug(tableTag + " mark-to-base positioning base count: " + nb); } // read anchor matrix, where i:{0...baseCount - 1}, j:{0...markClassCount - 1} GlyphPositioningTable.Anchor[][] bam = new GlyphPositioningTable.Anchor [ nb ] [ nmc ]; - for ( int i = 0; i < nb; i++ ) { - for ( int j = 0; j < nmc; j++ ) { + for (int i = 0; i < nb; i++) { + for (int j = 0; j < nmc; j++) { // read base anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + bao + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + bao + ao); } else { a = null; } @@ -2227,20 +2227,20 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = mct; - seEntries.add ( bct ); - seEntries.add ( Integer.valueOf ( nmc ) ); - seEntries.add ( maa ); - seEntries.add ( bam ); + seEntries.add (bct); + seEntries.add (Integer.valueOf (nmc)); + seEntries.add (maa); + seEntries.add (bam); } private int readMarkToBasePosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readMarkToBasePosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readMarkToBasePosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported mark-to-base positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported mark-to-base positioning subtable format: " + sf); } return sf; } @@ -2249,7 +2249,7 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read mark coverage offset int mco = in.readTTFUShort(); // read ligature coverage offset @@ -2262,41 +2262,41 @@ public final class OTFAdvancedTypographicTableReader { int lao = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-ligature positioning subtable format: " + subtableFormat ); - log.debug(tableTag + " mark-to-ligature positioning mark coverage table offset: " + mco ); - log.debug(tableTag + " mark-to-ligature positioning ligature coverage table offset: " + lco ); - log.debug(tableTag + " mark-to-ligature positioning mark class count: " + nmc ); - log.debug(tableTag + " mark-to-ligature positioning mark array offset: " + mao ); - log.debug(tableTag + " mark-to-ligature positioning ligature array offset: " + lao ); + log.debug(tableTag + " mark-to-ligature positioning subtable format: " + subtableFormat); + log.debug(tableTag + " mark-to-ligature positioning mark coverage table offset: " + mco); + log.debug(tableTag + " mark-to-ligature positioning ligature coverage table offset: " + lco); + log.debug(tableTag + " mark-to-ligature positioning mark class count: " + nmc); + log.debug(tableTag + " mark-to-ligature positioning mark array offset: " + mao); + log.debug(tableTag + " mark-to-ligature positioning ligature array offset: " + lao); } // read mark coverage table - GlyphCoverageTable mct = readCoverageTable ( tableTag + " mark-to-ligature positioning mark coverage", subtableOffset + mco ); + GlyphCoverageTable mct = readCoverageTable (tableTag + " mark-to-ligature positioning mark coverage", subtableOffset + mco); // read ligature coverage table - GlyphCoverageTable lct = readCoverageTable ( tableTag + " mark-to-ligature positioning ligature coverage", subtableOffset + lco ); + GlyphCoverageTable lct = readCoverageTable (tableTag + " mark-to-ligature positioning ligature coverage", subtableOffset + lco); // read mark anchor array // seek to mark array in.seekSet(subtableOffset + mao); // read mark count int nm = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-ligature positioning mark count: " + nm ); + log.debug(tableTag + " mark-to-ligature positioning mark count: " + nm); } // read mark anchor array, where i:{0...markCount} GlyphPositioningTable.MarkAnchor[] maa = new GlyphPositioningTable.MarkAnchor [ nm ]; - for ( int i = 0; i < nm; i++ ) { + for (int i = 0; i < nm; i++) { // read mark class int mc = in.readTTFUShort(); // read mark anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + mao + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + mao + ao); } else { a = null; } GlyphPositioningTable.MarkAnchor ma; - if ( a != null ) { - ma = new GlyphPositioningTable.MarkAnchor ( mc, a ); + if (a != null) { + ma = new GlyphPositioningTable.MarkAnchor (mc, a); } else { ma = null; } @@ -2311,43 +2311,43 @@ public final class OTFAdvancedTypographicTableReader { // read ligature count int nl = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-ligature positioning ligature count: " + nl ); + log.debug(tableTag + " mark-to-ligature positioning ligature count: " + nl); } // read ligature attach table offsets int[] laoa = new int [ nl ]; - for ( int i = 0; i < nl; i++ ) { + for (int i = 0; i < nl; i++) { laoa [ i ] = in.readTTFUShort(); } // iterate over ligature attach tables, recording maximum component count int mxc = 0; - for ( int i = 0; i < nl; i++ ) { + for (int i = 0; i < nl; i++) { int lato = laoa [ i ]; - in.seekSet ( subtableOffset + lao + lato ); + in.seekSet (subtableOffset + lao + lato); // read component count int cc = in.readTTFUShort(); - if ( cc > mxc ) { + if (cc > mxc) { mxc = cc; } } if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-ligature positioning maximum component count: " + mxc ); + log.debug(tableTag + " mark-to-ligature positioning maximum component count: " + mxc); } // read anchor matrix, where i:{0...ligatureCount - 1}, j:{0...maxComponentCount - 1}, k:{0...markClassCount - 1} GlyphPositioningTable.Anchor[][][] lam = new GlyphPositioningTable.Anchor [ nl ][][]; - for ( int i = 0; i < nl; i++ ) { + for (int i = 0; i < nl; i++) { int lato = laoa [ i ]; // seek to ligature attach table for ligature[i] - in.seekSet ( subtableOffset + lao + lato ); + in.seekSet (subtableOffset + lao + lato); // read component count int cc = in.readTTFUShort(); GlyphPositioningTable.Anchor[][] lcm = new GlyphPositioningTable.Anchor [ cc ] [ nmc ]; - for ( int j = 0; j < cc; j++ ) { - for ( int k = 0; k < nmc; k++ ) { + for (int j = 0; j < cc; j++) { + for (int k = 0; k < nmc; k++) { // read ligature anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + lao + lato + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + lao + lato + ao); } else { a = null; } @@ -2361,21 +2361,21 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = mct; - seEntries.add ( lct ); - seEntries.add ( Integer.valueOf ( nmc ) ); - seEntries.add ( Integer.valueOf ( mxc ) ); - seEntries.add ( maa ); - seEntries.add ( lam ); + seEntries.add (lct); + seEntries.add (Integer.valueOf (nmc)); + seEntries.add (Integer.valueOf (mxc)); + seEntries.add (maa); + seEntries.add (lam); } private int readMarkToLigaturePosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readMarkToLigaturePosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readMarkToLigaturePosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported mark-to-ligature positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported mark-to-ligature positioning subtable format: " + sf); } return sf; } @@ -2384,7 +2384,7 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read mark #1 coverage offset int m1co = in.readTTFUShort(); // read mark #2 coverage offset @@ -2397,41 +2397,41 @@ public final class OTFAdvancedTypographicTableReader { int m2ao = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-mark positioning subtable format: " + subtableFormat ); - log.debug(tableTag + " mark-to-mark positioning mark #1 coverage table offset: " + m1co ); - log.debug(tableTag + " mark-to-mark positioning mark #2 coverage table offset: " + m2co ); - log.debug(tableTag + " mark-to-mark positioning mark class count: " + nmc ); - log.debug(tableTag + " mark-to-mark positioning mark #1 array offset: " + m1ao ); - log.debug(tableTag + " mark-to-mark positioning mark #2 array offset: " + m2ao ); + log.debug(tableTag + " mark-to-mark positioning subtable format: " + subtableFormat); + log.debug(tableTag + " mark-to-mark positioning mark #1 coverage table offset: " + m1co); + log.debug(tableTag + " mark-to-mark positioning mark #2 coverage table offset: " + m2co); + log.debug(tableTag + " mark-to-mark positioning mark class count: " + nmc); + log.debug(tableTag + " mark-to-mark positioning mark #1 array offset: " + m1ao); + log.debug(tableTag + " mark-to-mark positioning mark #2 array offset: " + m2ao); } // read mark #1 coverage table - GlyphCoverageTable mct1 = readCoverageTable ( tableTag + " mark-to-mark positioning mark #1 coverage", subtableOffset + m1co ); + GlyphCoverageTable mct1 = readCoverageTable (tableTag + " mark-to-mark positioning mark #1 coverage", subtableOffset + m1co); // read mark #2 coverage table - GlyphCoverageTable mct2 = readCoverageTable ( tableTag + " mark-to-mark positioning mark #2 coverage", subtableOffset + m2co ); + GlyphCoverageTable mct2 = readCoverageTable (tableTag + " mark-to-mark positioning mark #2 coverage", subtableOffset + m2co); // read mark #1 anchor array // seek to mark array in.seekSet(subtableOffset + m1ao); // read mark count int nm1 = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-mark positioning mark #1 count: " + nm1 ); + log.debug(tableTag + " mark-to-mark positioning mark #1 count: " + nm1); } // read mark anchor array, where i:{0...mark1Count} GlyphPositioningTable.MarkAnchor[] maa = new GlyphPositioningTable.MarkAnchor [ nm1 ]; - for ( int i = 0; i < nm1; i++ ) { + for (int i = 0; i < nm1; i++) { // read mark class int mc = in.readTTFUShort(); // read mark anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + m1ao + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + m1ao + ao); } else { a = null; } GlyphPositioningTable.MarkAnchor ma; - if ( a != null ) { - ma = new GlyphPositioningTable.MarkAnchor ( mc, a ); + if (a != null) { + ma = new GlyphPositioningTable.MarkAnchor (mc, a); } else { ma = null; } @@ -2446,17 +2446,17 @@ public final class OTFAdvancedTypographicTableReader { // read mark #2 count int nm2 = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " mark-to-mark positioning mark #2 count: " + nm2 ); + log.debug(tableTag + " mark-to-mark positioning mark #2 count: " + nm2); } // read anchor matrix, where i:{0...mark2Count - 1}, j:{0...markClassCount - 1} GlyphPositioningTable.Anchor[][] mam = new GlyphPositioningTable.Anchor [ nm2 ] [ nmc ]; - for ( int i = 0; i < nm2; i++ ) { - for ( int j = 0; j < nmc; j++ ) { + for (int i = 0; i < nm2; i++) { + for (int j = 0; j < nmc; j++) { // read mark anchor offset int ao = in.readTTFUShort(); GlyphPositioningTable.Anchor a; - if ( ao > 0 ) { - a = readPosAnchor ( subtableOffset + m2ao + ao ); + if (ao > 0) { + a = readPosAnchor (subtableOffset + m2ao + ao); } else { a = null; } @@ -2468,20 +2468,20 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = mct1; - seEntries.add ( mct2 ); - seEntries.add ( Integer.valueOf ( nmc ) ); - seEntries.add ( maa ); - seEntries.add ( mam ); + seEntries.add (mct2); + seEntries.add (Integer.valueOf (nmc)); + seEntries.add (maa); + seEntries.add (mam); } private int readMarkToMarkPosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readMarkToMarkPosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readMarkToMarkPosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported mark-to-mark positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported mark-to-mark positioning subtable format: " + sf); } return sf; } @@ -2490,77 +2490,77 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read rule set count int nrs = in.readTTFUShort(); // read rule set offsets int[] rsoa = new int [ nrs ]; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { rsoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyphs)" ); - log.debug(tableTag + " contextual positioning coverage table offset: " + co ); - log.debug(tableTag + " contextual positioning rule set count: " + nrs ); - for ( int i = 0; i < nrs; i++ ) { - log.debug(tableTag + " contextual positioning rule set offset[" + i + "]: " + rsoa[i] ); + log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyphs)"); + log.debug(tableTag + " contextual positioning coverage table offset: " + co); + log.debug(tableTag + " contextual positioning rule set count: " + nrs); + for (int i = 0; i < nrs; i++) { + log.debug(tableTag + " contextual positioning rule set offset[" + i + "]: " + rsoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " contextual positioning coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " contextual positioning coverage", subtableOffset + co); } else { ct = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ nrs ]; String header = null; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { GlyphTable.RuleSet rs; int rso = rsoa [ i ]; - if ( rso > 0 ) { + if (rso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + rso ); + in.seekSet (subtableOffset + rso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { GlyphTable.GlyphSequenceRule r; int ro = roa [ j ]; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + rso + ro ); + in.seekSet (subtableOffset + rso + ro); // read glyph count int ng = in.readTTFUShort(); // read rule lookup count int nl = in.readTTFUShort(); // read glyphs int[] glyphs = new int [ ng - 1 ]; - for ( int k = 0, nk = glyphs.length; k < nk; k++ ) { + for (int k = 0, nk = glyphs.length; k < nk; k++) { glyphs [ k ] = in.readTTFUShort(); } // read rule lookups if (log.isDebugEnabled()) { header = tableTag + " contextual positioning lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.GlyphSequenceRule ( lookups, ng, glyphs ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.GlyphSequenceRule (lookups, ng, glyphs); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -2568,14 +2568,14 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( rsa ); + seEntries.add (rsa); } private void readContextualPosTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read class def table offset @@ -2584,77 +2584,77 @@ public final class OTFAdvancedTypographicTableReader { int ngc = in.readTTFUShort(); // read class rule set offsets int[] csoa = new int [ ngc ]; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { csoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyph classes)" ); - log.debug(tableTag + " contextual positioning coverage table offset: " + co ); - log.debug(tableTag + " contextual positioning class set count: " + ngc ); - for ( int i = 0; i < ngc; i++ ) { - log.debug(tableTag + " contextual positioning class set offset[" + i + "]: " + csoa[i] ); + log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyph classes)"); + log.debug(tableTag + " contextual positioning coverage table offset: " + co); + log.debug(tableTag + " contextual positioning class set count: " + ngc); + for (int i = 0; i < ngc; i++) { + log.debug(tableTag + " contextual positioning class set offset[" + i + "]: " + csoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " contextual positioning coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " contextual positioning coverage", subtableOffset + co); } else { ct = null; } // read class definition table GlyphClassTable cdt; - if ( cdo > 0 ) { - cdt = readClassDefTable ( tableTag + " contextual positioning class definition", subtableOffset + cdo ); + if (cdo > 0) { + cdt = readClassDefTable (tableTag + " contextual positioning class definition", subtableOffset + cdo); } else { cdt = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ ngc ]; String header = null; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { int cso = csoa [ i ]; GlyphTable.RuleSet rs; - if ( cso > 0 ) { + if (cso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + cso ); + in.seekSet (subtableOffset + cso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { int ro = roa [ j ]; GlyphTable.ClassSequenceRule r; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + cso + ro ); + in.seekSet (subtableOffset + cso + ro); // read glyph count int ng = in.readTTFUShort(); // read rule lookup count int nl = in.readTTFUShort(); // read classes int[] classes = new int [ ng - 1 ]; - for ( int k = 0, nk = classes.length; k < nk; k++ ) { + for (int k = 0, nk = classes.length; k < nk; k++) { classes [ k ] = in.readTTFUShort(); } // read rule lookups if (log.isDebugEnabled()) { header = tableTag + " contextual positioning lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ClassSequenceRule ( lookups, ng, classes ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ClassSequenceRule (lookups, ng, classes); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -2662,41 +2662,41 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( cdt ); - seEntries.add ( Integer.valueOf ( ngc ) ); - seEntries.add ( rsa ); + seEntries.add (cdt); + seEntries.add (Integer.valueOf (ngc)); + seEntries.add (rsa); } private void readContextualPosTableFormat3(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read glyph (input sequence length) count int ng = in.readTTFUShort(); // read positioning lookup count int nl = in.readTTFUShort(); // read glyph coverage offsets, one per glyph input sequence length count int[] gcoa = new int [ ng ]; - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { gcoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyph sets)" ); - log.debug(tableTag + " contextual positioning glyph input sequence length count: " + ng ); - log.debug(tableTag + " contextual positioning lookup count: " + nl ); - for ( int i = 0; i < ng; i++ ) { - log.debug(tableTag + " contextual positioning coverage table offset[" + i + "]: " + gcoa[i] ); + log.debug(tableTag + " contextual positioning subtable format: " + subtableFormat + " (glyph sets)"); + log.debug(tableTag + " contextual positioning glyph input sequence length count: " + ng); + log.debug(tableTag + " contextual positioning lookup count: " + nl); + for (int i = 0; i < ng; i++) { + log.debug(tableTag + " contextual positioning coverage table offset[" + i + "]: " + gcoa[i]); } } // read coverage tables GlyphCoverageTable[] gca = new GlyphCoverageTable [ ng ]; - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { int gco = gcoa [ i ]; GlyphCoverageTable gct; - if ( gco > 0 ) { - gct = readCoverageTable ( tableTag + " contextual positioning coverage[" + i + "]", subtableOffset + gcoa[i] ); + if (gco > 0) { + gct = readCoverageTable (tableTag + " contextual positioning coverage[" + i + "]", subtableOffset + gcoa[i]); } else { gct = null; } @@ -2707,29 +2707,29 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual positioning lookups: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); // construct rule, rule set, and rule set array - GlyphTable.Rule r = new GlyphTable.CoverageSequenceRule ( lookups, ng, gca ); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet ( new GlyphTable.Rule[] {r} ); + GlyphTable.Rule r = new GlyphTable.CoverageSequenceRule (lookups, ng, gca); + GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet (new GlyphTable.Rule[] {r}); GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; // store results - assert ( gca != null ) && ( gca.length > 0 ); + assert (gca != null) && (gca.length > 0); seMapping = gca[0]; - seEntries.add ( rsa ); + seEntries.add (rsa); } private int readContextualPosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readContextualPosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readContextualPosTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 3 ) { - readContextualPosTableFormat3 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readContextualPosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readContextualPosTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 3) { + readContextualPosTableFormat3 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported contextual positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported contextual positioning subtable format: " + sf); } return sf; } @@ -2738,75 +2738,75 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read rule set count int nrs = in.readTTFUShort(); // read rule set offsets int[] rsoa = new int [ nrs ]; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { rsoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyphs)" ); - log.debug(tableTag + " chained contextual positioning coverage table offset: " + co ); - log.debug(tableTag + " chained contextual positioning rule set count: " + nrs ); - for ( int i = 0; i < nrs; i++ ) { - log.debug(tableTag + " chained contextual positioning rule set offset[" + i + "]: " + rsoa[i] ); + log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyphs)"); + log.debug(tableTag + " chained contextual positioning coverage table offset: " + co); + log.debug(tableTag + " chained contextual positioning rule set count: " + nrs); + for (int i = 0; i < nrs; i++) { + log.debug(tableTag + " chained contextual positioning rule set offset[" + i + "]: " + rsoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " chained contextual positioning coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " chained contextual positioning coverage", subtableOffset + co); } else { ct = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ nrs ]; String header = null; - for ( int i = 0; i < nrs; i++ ) { + for (int i = 0; i < nrs; i++) { GlyphTable.RuleSet rs; int rso = rsoa [ i ]; - if ( rso > 0 ) { + if (rso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + rso ); + in.seekSet (subtableOffset + rso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { GlyphTable.ChainedGlyphSequenceRule r; int ro = roa [ j ]; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + rso + ro ); + in.seekSet (subtableOffset + rso + ro); // read backtrack glyph count int nbg = in.readTTFUShort(); // read backtrack glyphs int[] backtrackGlyphs = new int [ nbg ]; - for ( int k = 0, nk = backtrackGlyphs.length; k < nk; k++ ) { + for (int k = 0, nk = backtrackGlyphs.length; k < nk; k++) { backtrackGlyphs [ k ] = in.readTTFUShort(); } // read input glyph count int nig = in.readTTFUShort(); // read glyphs int[] glyphs = new int [ nig - 1 ]; - for ( int k = 0, nk = glyphs.length; k < nk; k++ ) { + for (int k = 0, nk = glyphs.length; k < nk; k++) { glyphs [ k ] = in.readTTFUShort(); } // read lookahead glyph count int nlg = in.readTTFUShort(); // read lookahead glyphs int[] lookaheadGlyphs = new int [ nlg ]; - for ( int k = 0, nk = lookaheadGlyphs.length; k < nk; k++ ) { + for (int k = 0, nk = lookaheadGlyphs.length; k < nk; k++) { lookaheadGlyphs [ k ] = in.readTTFUShort(); } // read rule lookup count @@ -2815,14 +2815,14 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual positioning lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ChainedGlyphSequenceRule ( lookups, nig, glyphs, backtrackGlyphs, lookaheadGlyphs ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ChainedGlyphSequenceRule (lookups, nig, glyphs, backtrackGlyphs, lookaheadGlyphs); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -2830,14 +2830,14 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( rsa ); + seEntries.add (rsa); } private void readChainedContextualPosTableFormat2(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read coverage offset int co = in.readTTFUShort(); // read backtrack class def table offset @@ -2850,89 +2850,89 @@ public final class OTFAdvancedTypographicTableReader { int ngc = in.readTTFUShort(); // read class set offsets int[] csoa = new int [ ngc ]; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { csoa [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyph classes)" ); - log.debug(tableTag + " chained contextual positioning coverage table offset: " + co ); - log.debug(tableTag + " chained contextual positioning class set count: " + ngc ); - for ( int i = 0; i < ngc; i++ ) { - log.debug(tableTag + " chained contextual positioning class set offset[" + i + "]: " + csoa[i] ); + log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyph classes)"); + log.debug(tableTag + " chained contextual positioning coverage table offset: " + co); + log.debug(tableTag + " chained contextual positioning class set count: " + ngc); + for (int i = 0; i < ngc; i++) { + log.debug(tableTag + " chained contextual positioning class set offset[" + i + "]: " + csoa[i]); } } // read coverage table GlyphCoverageTable ct; - if ( co > 0 ) { - ct = readCoverageTable ( tableTag + " chained contextual positioning coverage", subtableOffset + co ); + if (co > 0) { + ct = readCoverageTable (tableTag + " chained contextual positioning coverage", subtableOffset + co); } else { ct = null; } // read backtrack class definition table GlyphClassTable bcdt; - if ( bcdo > 0 ) { - bcdt = readClassDefTable ( tableTag + " contextual positioning backtrack class definition", subtableOffset + bcdo ); + if (bcdo > 0) { + bcdt = readClassDefTable (tableTag + " contextual positioning backtrack class definition", subtableOffset + bcdo); } else { bcdt = null; } // read input class definition table GlyphClassTable icdt; - if ( icdo > 0 ) { - icdt = readClassDefTable ( tableTag + " contextual positioning input class definition", subtableOffset + icdo ); + if (icdo > 0) { + icdt = readClassDefTable (tableTag + " contextual positioning input class definition", subtableOffset + icdo); } else { icdt = null; } // read lookahead class definition table GlyphClassTable lcdt; - if ( lcdo > 0 ) { - lcdt = readClassDefTable ( tableTag + " contextual positioning lookahead class definition", subtableOffset + lcdo ); + if (lcdo > 0) { + lcdt = readClassDefTable (tableTag + " contextual positioning lookahead class definition", subtableOffset + lcdo); } else { lcdt = null; } // read rule sets GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet [ ngc ]; String header = null; - for ( int i = 0; i < ngc; i++ ) { + for (int i = 0; i < ngc; i++) { int cso = csoa [ i ]; GlyphTable.RuleSet rs; - if ( cso > 0 ) { + if (cso > 0) { // seek to rule set [ i ] - in.seekSet ( subtableOffset + cso ); + in.seekSet (subtableOffset + cso); // read rule count int nr = in.readTTFUShort(); // read rule offsets int[] roa = new int [ nr ]; GlyphTable.Rule[] ra = new GlyphTable.Rule [ nr ]; - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { roa [ j ] = in.readTTFUShort(); } // read glyph sequence rules - for ( int j = 0; j < nr; j++ ) { + for (int j = 0; j < nr; j++) { GlyphTable.ChainedClassSequenceRule r; int ro = roa [ j ]; - if ( ro > 0 ) { + if (ro > 0) { // seek to rule [ j ] - in.seekSet ( subtableOffset + cso + ro ); + in.seekSet (subtableOffset + cso + ro); // read backtrack glyph class count int nbc = in.readTTFUShort(); // read backtrack glyph classes int[] backtrackClasses = new int [ nbc ]; - for ( int k = 0, nk = backtrackClasses.length; k < nk; k++ ) { + for (int k = 0, nk = backtrackClasses.length; k < nk; k++) { backtrackClasses [ k ] = in.readTTFUShort(); } // read input glyph class count int nic = in.readTTFUShort(); // read input glyph classes int[] classes = new int [ nic - 1 ]; - for ( int k = 0, nk = classes.length; k < nk; k++ ) { + for (int k = 0, nk = classes.length; k < nk; k++) { classes [ k ] = in.readTTFUShort(); } // read lookahead glyph class count int nlc = in.readTTFUShort(); // read lookahead glyph classes int[] lookaheadClasses = new int [ nlc ]; - for ( int k = 0, nk = lookaheadClasses.length; k < nk; k++ ) { + for (int k = 0, nk = lookaheadClasses.length; k < nk; k++) { lookaheadClasses [ k ] = in.readTTFUShort(); } // read rule lookup count @@ -2941,14 +2941,14 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " contextual positioning lookups @rule[" + i + "][" + j + "]: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); - r = new GlyphTable.ChainedClassSequenceRule ( lookups, nic, classes, backtrackClasses, lookaheadClasses ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); + r = new GlyphTable.ChainedClassSequenceRule (lookups, nic, classes, backtrackClasses, lookaheadClasses); } else { r = null; } ra [ j ] = r; } - rs = new GlyphTable.HomogeneousRuleSet ( ra ); + rs = new GlyphTable.HomogeneousRuleSet (ra); } else { rs = null; } @@ -2956,65 +2956,65 @@ public final class OTFAdvancedTypographicTableReader { } // store results seMapping = ct; - seEntries.add ( icdt ); - seEntries.add ( bcdt ); - seEntries.add ( lcdt ); - seEntries.add ( Integer.valueOf ( ngc ) ); - seEntries.add ( rsa ); + seEntries.add (icdt); + seEntries.add (bcdt); + seEntries.add (lcdt); + seEntries.add (Integer.valueOf (ngc)); + seEntries.add (rsa); } private void readChainedContextualPosTableFormat3(int lookupType, int lookupFlags, long subtableOffset, int subtableFormat) throws IOException { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read backtrack glyph count int nbg = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] bgcoa = new int [ nbg ]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { bgcoa [ i ] = in.readTTFUShort(); } // read input glyph count int nig = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] igcoa = new int [ nig ]; - for ( int i = 0; i < nig; i++ ) { + for (int i = 0; i < nig; i++) { igcoa [ i ] = in.readTTFUShort(); } // read lookahead glyph count int nlg = in.readTTFUShort(); // read backtrack glyph coverage offsets int[] lgcoa = new int [ nlg ]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { lgcoa [ i ] = in.readTTFUShort(); } // read positioning lookup count int nl = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyph sets)" ); - log.debug(tableTag + " chained contextual positioning backtrack glyph count: " + nbg ); - for ( int i = 0; i < nbg; i++ ) { - log.debug(tableTag + " chained contextual positioning backtrack coverage table offset[" + i + "]: " + bgcoa[i] ); + log.debug(tableTag + " chained contextual positioning subtable format: " + subtableFormat + " (glyph sets)"); + log.debug(tableTag + " chained contextual positioning backtrack glyph count: " + nbg); + for (int i = 0; i < nbg; i++) { + log.debug(tableTag + " chained contextual positioning backtrack coverage table offset[" + i + "]: " + bgcoa[i]); } - log.debug(tableTag + " chained contextual positioning input glyph count: " + nig ); - for ( int i = 0; i < nig; i++ ) { - log.debug(tableTag + " chained contextual positioning input coverage table offset[" + i + "]: " + igcoa[i] ); + log.debug(tableTag + " chained contextual positioning input glyph count: " + nig); + for (int i = 0; i < nig; i++) { + log.debug(tableTag + " chained contextual positioning input coverage table offset[" + i + "]: " + igcoa[i]); } - log.debug(tableTag + " chained contextual positioning lookahead glyph count: " + nlg ); - for ( int i = 0; i < nlg; i++ ) { - log.debug(tableTag + " chained contextual positioning lookahead coverage table offset[" + i + "]: " + lgcoa[i] ); + log.debug(tableTag + " chained contextual positioning lookahead glyph count: " + nlg); + for (int i = 0; i < nlg; i++) { + log.debug(tableTag + " chained contextual positioning lookahead coverage table offset[" + i + "]: " + lgcoa[i]); } - log.debug(tableTag + " chained contextual positioning lookup count: " + nl ); + log.debug(tableTag + " chained contextual positioning lookup count: " + nl); } // read backtrack coverage tables GlyphCoverageTable[] bgca = new GlyphCoverageTable[nbg]; - for ( int i = 0; i < nbg; i++ ) { + for (int i = 0; i < nbg; i++) { int bgco = bgcoa [ i ]; GlyphCoverageTable bgct; - if ( bgco > 0 ) { - bgct = readCoverageTable ( tableTag + " chained contextual positioning backtrack coverage[" + i + "]", subtableOffset + bgco ); + if (bgco > 0) { + bgct = readCoverageTable (tableTag + " chained contextual positioning backtrack coverage[" + i + "]", subtableOffset + bgco); } else { bgct = null; } @@ -3022,11 +3022,11 @@ public final class OTFAdvancedTypographicTableReader { } // read input coverage tables GlyphCoverageTable[] igca = new GlyphCoverageTable[nig]; - for ( int i = 0; i < nig; i++ ) { + for (int i = 0; i < nig; i++) { int igco = igcoa [ i ]; GlyphCoverageTable igct; - if ( igco > 0 ) { - igct = readCoverageTable ( tableTag + " chained contextual positioning input coverage[" + i + "]", subtableOffset + igco ); + if (igco > 0) { + igct = readCoverageTable (tableTag + " chained contextual positioning input coverage[" + i + "]", subtableOffset + igco); } else { igct = null; } @@ -3034,11 +3034,11 @@ public final class OTFAdvancedTypographicTableReader { } // read lookahead coverage tables GlyphCoverageTable[] lgca = new GlyphCoverageTable[nlg]; - for ( int i = 0; i < nlg; i++ ) { + for (int i = 0; i < nlg; i++) { int lgco = lgcoa [ i ]; GlyphCoverageTable lgct; - if ( lgco > 0 ) { - lgct = readCoverageTable ( tableTag + " chained contextual positioning lookahead coverage[" + i + "]", subtableOffset + lgco ); + if (lgco > 0) { + lgct = readCoverageTable (tableTag + " chained contextual positioning lookahead coverage[" + i + "]", subtableOffset + lgco); } else { lgct = null; } @@ -3049,29 +3049,29 @@ public final class OTFAdvancedTypographicTableReader { if (log.isDebugEnabled()) { header = tableTag + " chained contextual positioning lookups: "; } - GlyphTable.RuleLookup[] lookups = readRuleLookups ( nl, header ); + GlyphTable.RuleLookup[] lookups = readRuleLookups (nl, header); // construct rule, rule set, and rule set array - GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule ( lookups, nig, igca, bgca, lgca ); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet ( new GlyphTable.Rule[] {r} ); + GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule (lookups, nig, igca, bgca, lgca); + GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet (new GlyphTable.Rule[] {r}); GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; // store results - assert ( igca != null ) && ( igca.length > 0 ); + assert (igca != null) && (igca.length > 0); seMapping = igca[0]; - seEntries.add ( rsa ); + seEntries.add (rsa); } private int readChainedContextualPosTable(int lookupType, int lookupFlags, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readChainedContextualPosTableFormat1 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 2 ) { - readChainedContextualPosTableFormat2 ( lookupType, lookupFlags, subtableOffset, sf ); - } else if ( sf == 3 ) { - readChainedContextualPosTableFormat3 ( lookupType, lookupFlags, subtableOffset, sf ); + if (sf == 1) { + readChainedContextualPosTableFormat1 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 2) { + readChainedContextualPosTableFormat2 (lookupType, lookupFlags, subtableOffset, sf); + } else if (sf == 3) { + readChainedContextualPosTableFormat3 (lookupType, lookupFlags, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported chained contextual positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported chained contextual positioning subtable format: " + sf); } return sf; } @@ -3080,29 +3080,29 @@ public final class OTFAdvancedTypographicTableReader { String tableTag = "GPOS"; in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read extension lookup type int lt = in.readTTFUShort(); // read extension offset long eo = in.readTTFULong(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " extension positioning subtable format: " + subtableFormat ); - log.debug(tableTag + " extension positioning lookup type: " + lt ); - log.debug(tableTag + " extension positioning lookup table offset: " + eo ); + log.debug(tableTag + " extension positioning subtable format: " + subtableFormat); + log.debug(tableTag + " extension positioning lookup type: " + lt); + log.debug(tableTag + " extension positioning lookup table offset: " + eo); } // read referenced subtable from extended offset - readGPOSSubtable ( lt, lookupFlags, lookupSequence, subtableSequence, subtableOffset + eo ); + readGPOSSubtable (lt, lookupFlags, lookupSequence, subtableSequence, subtableOffset + eo); } private int readExtensionPosTable(int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, long subtableOffset) throws IOException { in.seekSet(subtableOffset); // read positioning subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readExtensionPosTableFormat1 ( lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset, sf ); + if (sf == 1) { + readExtensionPosTableFormat1 (lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported extension positioning subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported extension positioning subtable format: " + sf); } return sf; } @@ -3110,44 +3110,44 @@ public final class OTFAdvancedTypographicTableReader { private void readGPOSSubtable(int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, long subtableOffset) throws IOException { initATSubState(); int subtableFormat = -1; - switch ( lookupType ) { + switch (lookupType) { case GPOSLookupType.SINGLE: - subtableFormat = readSinglePosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readSinglePosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.PAIR: - subtableFormat = readPairPosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readPairPosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.CURSIVE: - subtableFormat = readCursivePosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readCursivePosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.MARK_TO_BASE: - subtableFormat = readMarkToBasePosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readMarkToBasePosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.MARK_TO_LIGATURE: - subtableFormat = readMarkToLigaturePosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readMarkToLigaturePosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.MARK_TO_MARK: - subtableFormat = readMarkToMarkPosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readMarkToMarkPosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.CONTEXTUAL: - subtableFormat = readContextualPosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readContextualPosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.CHAINED_CONTEXTUAL: - subtableFormat = readChainedContextualPosTable ( lookupType, lookupFlags, subtableOffset ); + subtableFormat = readChainedContextualPosTable (lookupType, lookupFlags, subtableOffset); break; case GPOSLookupType.EXTENSION: - subtableFormat = readExtensionPosTable ( lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset ); + subtableFormat = readExtensionPosTable (lookupType, lookupFlags, lookupSequence, subtableSequence, subtableOffset); break; default: break; } - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_POSITIONING, lookupType, lookupFlags, lookupSequence, subtableSequence, subtableFormat ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_POSITIONING, lookupType, lookupFlags, lookupSequence, subtableSequence, subtableFormat); resetATSubState(); } private void readLookupTable(TTFTableName tableTag, int lookupSequence, long lookupTable) throws IOException { - boolean isGSUB = tableTag.equals ( TTFTableName.GSUB ); - boolean isGPOS = tableTag.equals ( TTFTableName.GPOS ); + boolean isGSUB = tableTag.equals (TTFTableName.GSUB); + boolean isGPOS = tableTag.equals (TTFTableName.GPOS); in.seekSet(lookupTable); // read lookup type int lt = in.readTTFUShort(); @@ -3158,42 +3158,42 @@ public final class OTFAdvancedTypographicTableReader { // dump info if debugging if (log.isDebugEnabled()) { String lts; - if ( isGSUB ) { - lts = GSUBLookupType.toString ( lt ); - } else if ( isGPOS ) { - lts = GPOSLookupType.toString ( lt ); + if (isGSUB) { + lts = GSUBLookupType.toString (lt); + } else if (isGPOS) { + lts = GPOSLookupType.toString (lt); } else { lts = "?"; } - log.debug(tableTag + " lookup table type: " + lt + " (" + lts + ")" ); - log.debug(tableTag + " lookup table flags: " + lf + " (" + LookupFlag.toString ( lf ) + ")" ); - log.debug(tableTag + " lookup table subtable count: " + ns ); + log.debug(tableTag + " lookup table type: " + lt + " (" + lts + ")"); + log.debug(tableTag + " lookup table flags: " + lf + " (" + LookupFlag.toString (lf) + ")"); + log.debug(tableTag + " lookup table subtable count: " + ns); } // read subtable offsets int[] soa = new int[ns]; - for ( int i = 0; i < ns; i++ ) { + for (int i = 0; i < ns; i++) { int so = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " lookup table subtable offset: " + so ); + log.debug(tableTag + " lookup table subtable offset: " + so); } soa[i] = so; } // read mark filtering set - if ( ( lf & LookupFlag.USE_MARK_FILTERING_SET ) != 0 ) { + if ((lf & LookupFlag.USE_MARK_FILTERING_SET) != 0) { // read mark filtering set int fs = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " lookup table mark filter set: " + fs ); + log.debug(tableTag + " lookup table mark filter set: " + fs); } } // read subtables - for ( int i = 0; i < ns; i++ ) { + for (int i = 0; i < ns; i++) { int so = soa[i]; - if ( isGSUB ) { - readGSUBSubtable ( lt, lf, lookupSequence, i, lookupTable + so ); - } else if ( isGPOS ) { - readGPOSSubtable ( lt, lf, lookupSequence, i, lookupTable + so ); + if (isGSUB) { + readGSUBSubtable (lt, lf, lookupSequence, i, lookupTable + so); + } else if (isGPOS) { + readGPOSSubtable (lt, lf, lookupSequence, i, lookupTable + so); } } } @@ -3203,24 +3203,24 @@ public final class OTFAdvancedTypographicTableReader { // read lookup record count int nl = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " lookup list record count: " + nl ); + log.debug(tableTag + " lookup list record count: " + nl); } - if ( nl > 0 ) { + if (nl > 0) { int[] loa = new int[nl]; // read lookup records - for ( int i = 0, n = nl; i < n; i++ ) { + for (int i = 0, n = nl; i < n; i++) { int lo = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " lookup table offset: " + lo ); + log.debug(tableTag + " lookup table offset: " + lo); } loa[i] = lo; } // read lookup tables - for ( int i = 0, n = nl; i < n; i++ ) { + for (int i = 0, n = nl; i < n; i++) { if (log.isDebugEnabled()) { - log.debug(tableTag + " lookup index: " + i ); + log.debug(tableTag + " lookup index: " + i); } - readLookupTable ( tableTag, i, lookupList + loa [ i ] ); + readLookupTable (tableTag, i, lookupList + loa [ i ]); } } } @@ -3234,14 +3234,14 @@ public final class OTFAdvancedTypographicTableReader { * @throws IOException In case of a I/O problem */ private void readCommonLayoutTables(TTFTableName tableTag, long scriptList, long featureList, long lookupList) throws IOException { - if ( scriptList > 0 ) { - readScriptList ( tableTag, scriptList ); + if (scriptList > 0) { + readScriptList (tableTag, scriptList); } - if ( featureList > 0 ) { - readFeatureList ( tableTag, featureList ); + if (featureList > 0) { + readFeatureList (tableTag, featureList); } - if ( lookupList > 0 ) { - readLookupList ( tableTag, lookupList ); + if (lookupList > 0) { + readLookupList (tableTag, lookupList); } } @@ -3249,11 +3249,11 @@ public final class OTFAdvancedTypographicTableReader { initATSubState(); in.seekSet(subtableOffset); // subtable is a bare class definition table - GlyphClassTable ct = readClassDefTable ( tableTag + " glyph class definition table", subtableOffset ); + GlyphClassTable ct = readClassDefTable (tableTag + " glyph class definition table", subtableOffset); // store results seMapping = ct; // extract subtable - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.GLYPH_CLASS, 0, lookupSequence, 0, 1 ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.GLYPH_CLASS, 0, lookupSequence, 0, 1); resetATSubState(); } @@ -3264,14 +3264,14 @@ public final class OTFAdvancedTypographicTableReader { int co = in.readTTFUShort(); // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " attachment point coverage table offset: " + co ); + log.debug(tableTag + " attachment point coverage table offset: " + co); } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " attachment point coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " attachment point coverage", subtableOffset + co); // store results seMapping = ct; // extract subtable - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.ATTACHMENT_POINT, 0, lookupSequence, 0, 1 ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.ATTACHMENT_POINT, 0, lookupSequence, 0, 1); resetATSubState(); } @@ -3284,24 +3284,24 @@ public final class OTFAdvancedTypographicTableReader { int nl = in.readTTFUShort(); // read ligature glyph table offsets int[] lgto = new int [ nl ]; - for ( int i = 0; i < nl; i++ ) { + for (int i = 0; i < nl; i++) { lgto [ i ] = in.readTTFUShort(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " ligature caret coverage table offset: " + co ); - log.debug(tableTag + " ligature caret ligature glyph count: " + nl ); - for ( int i = 0; i < nl; i++ ) { - log.debug(tableTag + " ligature glyph table offset[" + i + "]: " + lgto[i] ); + log.debug(tableTag + " ligature caret coverage table offset: " + co); + log.debug(tableTag + " ligature caret ligature glyph count: " + nl); + for (int i = 0; i < nl; i++) { + log.debug(tableTag + " ligature glyph table offset[" + i + "]: " + lgto[i]); } } // read coverage table - GlyphCoverageTable ct = readCoverageTable ( tableTag + " ligature caret coverage", subtableOffset + co ); + GlyphCoverageTable ct = readCoverageTable (tableTag + " ligature caret coverage", subtableOffset + co); // store results seMapping = ct; // extract subtable - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.LIGATURE_CARET, 0, lookupSequence, 0, 1 ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.LIGATURE_CARET, 0, lookupSequence, 0, 1); resetATSubState(); } @@ -3309,11 +3309,11 @@ public final class OTFAdvancedTypographicTableReader { initATSubState(); in.seekSet(subtableOffset); // subtable is a bare class definition table - GlyphClassTable ct = readClassDefTable ( tableTag + " glyph class definition table", subtableOffset ); + GlyphClassTable ct = readClassDefTable (tableTag + " glyph class definition table", subtableOffset); // store results seMapping = ct; // extract subtable - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.MARK_ATTACHMENT, 0, lookupSequence, 0, 1 ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.MARK_ATTACHMENT, 0, lookupSequence, 0, 1); resetATSubState(); } @@ -3321,33 +3321,33 @@ public final class OTFAdvancedTypographicTableReader { initATSubState(); in.seekSet(subtableOffset); // skip over format (already known) - in.skip ( 2 ); + in.skip (2); // read mark set class count int nmc = in.readTTFUShort(); long[] mso = new long [ nmc ]; // read mark set coverage offsets - for ( int i = 0; i < nmc; i++ ) { + for (int i = 0; i < nmc; i++) { mso [ i ] = in.readTTFULong(); } // dump info if debugging if (log.isDebugEnabled()) { - log.debug(tableTag + " mark set subtable format: " + subtableFormat + " (glyph sets)" ); - log.debug(tableTag + " mark set class count: " + nmc ); - for ( int i = 0; i < nmc; i++ ) { - log.debug(tableTag + " mark set coverage table offset[" + i + "]: " + mso[i] ); + log.debug(tableTag + " mark set subtable format: " + subtableFormat + " (glyph sets)"); + log.debug(tableTag + " mark set class count: " + nmc); + for (int i = 0; i < nmc; i++) { + log.debug(tableTag + " mark set coverage table offset[" + i + "]: " + mso[i]); } } // read mark set coverage tables, one per class GlyphCoverageTable[] msca = new GlyphCoverageTable[nmc]; - for ( int i = 0; i < nmc; i++ ) { - msca[i] = readCoverageTable ( tableTag + " mark set coverage[" + i + "]", subtableOffset + mso[i] ); + for (int i = 0; i < nmc; i++) { + msca[i] = readCoverageTable (tableTag + " mark set coverage[" + i + "]", subtableOffset + mso[i]); } // create combined class table from per-class coverage tables - GlyphClassTable ct = GlyphClassTable.createClassTable ( Arrays.asList ( msca ) ); + GlyphClassTable ct = GlyphClassTable.createClassTable (Arrays.asList (msca)); // store results seMapping = ct; // extract subtable - extractSESubState ( GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.MARK_ATTACHMENT, 0, lookupSequence, 0, 1 ); + extractSESubState (GlyphTable.GLYPH_TABLE_TYPE_DEFINITION, GDEFLookupType.MARK_ATTACHMENT, 0, lookupSequence, 0, 1); resetATSubState(); } @@ -3355,10 +3355,10 @@ public final class OTFAdvancedTypographicTableReader { in.seekSet(subtableOffset); // read mark set subtable format int sf = in.readTTFUShort(); - if ( sf == 1 ) { - readGDEFMarkGlyphsTableFormat1 ( tableTag, lookupSequence, subtableOffset, sf ); + if (sf == 1) { + readGDEFMarkGlyphsTableFormat1 (tableTag, lookupSequence, subtableOffset, sf); } else { - throw new AdvancedTypographicTableFormatException ( "unsupported mark glyph sets subtable format: " + sf ); + throw new AdvancedTypographicTableFormatException ("unsupported mark glyph sets subtable format: " + sf); } } @@ -3371,8 +3371,8 @@ public final class OTFAdvancedTypographicTableReader { // Initialize temporary state initATState(); // Read glyph definition (GDEF) table - TTFDirTabEntry dirTab = ttf.getDirectoryEntry( tableTag ); - if ( gdef != null ) { + TTFDirTabEntry dirTab = ttf.getDirectoryEntry(tableTag); + if (gdef != null) { if (log.isDebugEnabled()) { log.debug(tableTag + ": ignoring duplicate table"); } @@ -3380,7 +3380,7 @@ public final class OTFAdvancedTypographicTableReader { ttf.seekTab(in, tableTag, 0); long version = in.readTTFULong(); if (log.isDebugEnabled()) { - log.debug(tableTag + " version: " + ( version / 65536 ) + "." + ( version % 65536 )); + log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536)); } // glyph class definition table offset (may be null) int cdo = in.readTTFUShort(); @@ -3392,44 +3392,44 @@ public final class OTFAdvancedTypographicTableReader { int mao = in.readTTFUShort(); // mark glyph sets definition table offset (may be null) int mgo; - if ( version >= 0x00010002 ) { + if (version >= 0x00010002) { mgo = in.readTTFUShort(); } else { mgo = 0; } if (log.isDebugEnabled()) { - log.debug(tableTag + " glyph class definition table offset: " + cdo ); - log.debug(tableTag + " attachment point list offset: " + apo ); - log.debug(tableTag + " ligature caret list offset: " + lco ); - log.debug(tableTag + " mark attachment class definition table offset: " + mao ); - log.debug(tableTag + " mark glyph set definitions table offset: " + mgo ); + log.debug(tableTag + " glyph class definition table offset: " + cdo); + log.debug(tableTag + " attachment point list offset: " + apo); + log.debug(tableTag + " ligature caret list offset: " + lco); + log.debug(tableTag + " mark attachment class definition table offset: " + mao); + log.debug(tableTag + " mark glyph set definitions table offset: " + mgo); } // initialize subtable sequence number int seqno = 0; // obtain offset to start of gdef table long to = dirTab.getOffset(); // (optionally) read glyph class definition subtable - if ( cdo != 0 ) { - readGDEFClassDefTable ( tableTag, seqno++, to + cdo ); + if (cdo != 0) { + readGDEFClassDefTable (tableTag, seqno++, to + cdo); } // (optionally) read glyph attachment point subtable - if ( apo != 0 ) { - readGDEFAttachmentTable ( tableTag, seqno++, to + apo ); + if (apo != 0) { + readGDEFAttachmentTable (tableTag, seqno++, to + apo); } // (optionally) read ligature caret subtable - if ( lco != 0 ) { - readGDEFLigatureCaretTable ( tableTag, seqno++, to + lco ); + if (lco != 0) { + readGDEFLigatureCaretTable (tableTag, seqno++, to + lco); } // (optionally) read mark attachment class subtable - if ( mao != 0 ) { - readGDEFMarkAttachmentTable ( tableTag, seqno++, to + mao ); + if (mao != 0) { + readGDEFMarkAttachmentTable (tableTag, seqno++, to + mao); } // (optionally) read mark glyph sets subtable - if ( mgo != 0 ) { - readGDEFMarkGlyphsTable ( tableTag, seqno++, to + mgo ); + if (mgo != 0) { + readGDEFMarkGlyphsTable (tableTag, seqno++, to + mgo); } GlyphDefinitionTable gdef; - if ( ( gdef = constructGDEF() ) != null ) { + if ((gdef = constructGDEF()) != null) { this.gdef = gdef; } } @@ -3444,8 +3444,8 @@ public final class OTFAdvancedTypographicTableReader { // Initialize temporary state initATState(); // Read glyph substitution (GSUB) table - TTFDirTabEntry dirTab = ttf.getDirectoryEntry ( tableTag ); - if ( gpos != null ) { + TTFDirTabEntry dirTab = ttf.getDirectoryEntry (tableTag); + if (gpos != null) { if (log.isDebugEnabled()) { log.debug(tableTag + ": ignoring duplicate table"); } @@ -3453,20 +3453,20 @@ public final class OTFAdvancedTypographicTableReader { ttf.seekTab(in, tableTag, 0); int version = in.readTTFLong(); if (log.isDebugEnabled()) { - log.debug(tableTag + " version: " + ( version / 65536 ) + "." + ( version % 65536 )); + log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536)); } int slo = in.readTTFUShort(); int flo = in.readTTFUShort(); int llo = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " script list offset: " + slo ); - log.debug(tableTag + " feature list offset: " + flo ); - log.debug(tableTag + " lookup list offset: " + llo ); + log.debug(tableTag + " script list offset: " + slo); + log.debug(tableTag + " feature list offset: " + flo); + log.debug(tableTag + " lookup list offset: " + llo); } long to = dirTab.getOffset(); - readCommonLayoutTables ( tableTag, to + slo, to + flo, to + llo ); + readCommonLayoutTables (tableTag, to + slo, to + flo, to + llo); GlyphSubstitutionTable gsub; - if ( ( gsub = constructGSUB() ) != null ) { + if ((gsub = constructGSUB()) != null) { this.gsub = gsub; } } @@ -3481,8 +3481,8 @@ public final class OTFAdvancedTypographicTableReader { // Initialize temporary state initATState(); // Read glyph positioning (GPOS) table - TTFDirTabEntry dirTab = ttf.getDirectoryEntry ( tableTag ); - if ( gpos != null ) { + TTFDirTabEntry dirTab = ttf.getDirectoryEntry (tableTag); + if (gpos != null) { if (log.isDebugEnabled()) { log.debug(tableTag + ": ignoring duplicate table"); } @@ -3490,20 +3490,20 @@ public final class OTFAdvancedTypographicTableReader { ttf.seekTab(in, tableTag, 0); int version = in.readTTFLong(); if (log.isDebugEnabled()) { - log.debug(tableTag + " version: " + ( version / 65536 ) + "." + ( version % 65536 )); + log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536)); } int slo = in.readTTFUShort(); int flo = in.readTTFUShort(); int llo = in.readTTFUShort(); if (log.isDebugEnabled()) { - log.debug(tableTag + " script list offset: " + slo ); - log.debug(tableTag + " feature list offset: " + flo ); - log.debug(tableTag + " lookup list offset: " + llo ); + log.debug(tableTag + " script list offset: " + slo); + log.debug(tableTag + " feature list offset: " + flo); + log.debug(tableTag + " lookup list offset: " + llo); } long to = dirTab.getOffset(); - readCommonLayoutTables ( tableTag, to + slo, to + flo, to + llo ); + readCommonLayoutTables (tableTag, to + slo, to + flo, to + llo); GlyphPositioningTable gpos; - if ( ( gpos = constructGPOS() ) != null ) { + if ((gpos = constructGPOS()) != null) { this.gpos = gpos; } } @@ -3517,9 +3517,9 @@ public final class OTFAdvancedTypographicTableReader { private GlyphDefinitionTable constructGDEF() { GlyphDefinitionTable gdef = null; List subtables; - if ( ( subtables = constructGDEFSubtables() ) != null ) { - if ( subtables.size() > 0 ) { - gdef = new GlyphDefinitionTable ( subtables ); + if ((subtables = constructGDEFSubtables()) != null) { + if (subtables.size() > 0) { + gdef = new GlyphDefinitionTable (subtables); } } resetATState(); @@ -3534,11 +3534,11 @@ public final class OTFAdvancedTypographicTableReader { private GlyphSubstitutionTable constructGSUB() { GlyphSubstitutionTable gsub = null; Map lookups; - if ( ( lookups = constructLookups() ) != null ) { + if ((lookups = constructLookups()) != null) { List subtables; - if ( ( subtables = constructGSUBSubtables() ) != null ) { - if ( ( lookups.size() > 0 ) && ( subtables.size() > 0 ) ) { - gsub = new GlyphSubstitutionTable ( gdef, lookups, subtables ); + if ((subtables = constructGSUBSubtables()) != null) { + if ((lookups.size() > 0) && (subtables.size() > 0)) { + gsub = new GlyphSubstitutionTable (gdef, lookups, subtables); } } } @@ -3554,11 +3554,11 @@ public final class OTFAdvancedTypographicTableReader { private GlyphPositioningTable constructGPOS() { GlyphPositioningTable gpos = null; Map lookups; - if ( ( lookups = constructLookups() ) != null ) { + if ((lookups = constructLookups()) != null) { List subtables; - if ( ( subtables = constructGPOSSubtables() ) != null ) { - if ( ( lookups.size() > 0 ) && ( subtables.size() > 0 ) ) { - gpos = new GlyphPositioningTable ( gdef, lookups, subtables ); + if ((subtables = constructGPOSSubtables()) != null) { + if ((lookups.size() > 0) && (subtables.size() > 0)) { + gpos = new GlyphPositioningTable (gdef, lookups, subtables); } } } @@ -3566,59 +3566,59 @@ public final class OTFAdvancedTypographicTableReader { return gpos; } - private void constructLookupsFeature ( Map lookups, String st, String lt, String fid ) { - Object[] fp = (Object[]) seFeatures.get ( fid ); - if ( fp != null ) { + private void constructLookupsFeature (Map lookups, String st, String lt, String fid) { + Object[] fp = (Object[]) seFeatures.get (fid); + if (fp != null) { assert fp.length == 2; String ft = (String) fp[0]; // feature tag List/**/ lul = (List) fp[1]; // list of lookup table ids - if ( ( ft != null ) && ( lul != null ) && ( lul.size() > 0 ) ) { - GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec ( st, lt, ft ); - lookups.put ( ls, lul ); + if ((ft != null) && (lul != null) && (lul.size() > 0)) { + GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec (st, lt, ft); + lookups.put (ls, lul); } } } - private void constructLookupsFeatures ( Map lookups, String st, String lt, List/**/ fids ) { - for ( Iterator fit = fids.iterator(); fit.hasNext();) { + private void constructLookupsFeatures (Map lookups, String st, String lt, List/**/ fids) { + for (Iterator fit = fids.iterator(); fit.hasNext();) { String fid = (String) fit.next(); - constructLookupsFeature ( lookups, st, lt, fid ); + constructLookupsFeature (lookups, st, lt, fid); } } - private void constructLookupsLanguage ( Map lookups, String st, String lt, Map/**/ languages ) { - Object[] lp = (Object[]) languages.get ( lt ); - if ( lp != null ) { + private void constructLookupsLanguage (Map lookups, String st, String lt, Map/**/ languages) { + Object[] lp = (Object[]) languages.get (lt); + if (lp != null) { assert lp.length == 2; - if ( lp[0] != null ) { // required feature id - constructLookupsFeature ( lookups, st, lt, (String) lp[0] ); + if (lp[0] != null) { // required feature id + constructLookupsFeature (lookups, st, lt, (String) lp[0]); } - if ( lp[1] != null ) { // non-required features ids - constructLookupsFeatures ( lookups, st, lt, (List) lp[1] ); + if (lp[1] != null) { // non-required features ids + constructLookupsFeatures (lookups, st, lt, (List) lp[1]); } } } - private void constructLookupsLanguages ( Map lookups, String st, List/**/ ll, Map/**/ languages ) { - for ( Iterator lit = ll.iterator(); lit.hasNext();) { + private void constructLookupsLanguages (Map lookups, String st, List/**/ ll, Map/**/ languages) { + for (Iterator lit = ll.iterator(); lit.hasNext();) { String lt = (String) lit.next(); - constructLookupsLanguage ( lookups, st, lt, languages ); + constructLookupsLanguage (lookups, st, lt, languages); } } private Map constructLookups() { Map/*>*/ lookups = new java.util.LinkedHashMap(); - for ( Iterator sit = seScripts.keySet().iterator(); sit.hasNext();) { + for (Iterator sit = seScripts.keySet().iterator(); sit.hasNext();) { String st = (String) sit.next(); - Object[] sp = (Object[]) seScripts.get ( st ); - if ( sp != null ) { + Object[] sp = (Object[]) seScripts.get (st); + if (sp != null) { assert sp.length == 3; Map/**/ languages = (Map) sp[2]; - if ( sp[0] != null ) { // default language - constructLookupsLanguage ( lookups, st, (String) sp[0], languages ); + if (sp[0] != null) { // default language + constructLookupsLanguage (lookups, st, (String) sp[0], languages); } - if ( sp[1] != null ) { // non-default languages - constructLookupsLanguages ( lookups, st, (List) sp[1], languages ); + if (sp[1] != null) { // non-default languages + constructLookupsLanguages (lookups, st, (List) sp[1], languages); } } } @@ -3627,21 +3627,21 @@ public final class OTFAdvancedTypographicTableReader { private List constructGDEFSubtables() { List/**/ subtables = new java.util.ArrayList(); - if ( seSubtables != null ) { - for ( Iterator it = seSubtables.iterator(); it.hasNext();) { + if (seSubtables != null) { + for (Iterator it = seSubtables.iterator(); it.hasNext();) { Object[] stp = (Object[]) it.next(); GlyphSubtable st; - if ( ( st = constructGDEFSubtable ( stp ) ) != null ) { - subtables.add ( st ); + if ((st = constructGDEFSubtable (stp)) != null) { + subtables.add (st); } } } return subtables; } - private GlyphSubtable constructGDEFSubtable ( Object[] stp ) { + private GlyphSubtable constructGDEFSubtable (Object[] stp) { GlyphSubtable st = null; - assert ( stp != null ) && ( stp.length == 8 ); + assert (stp != null) && (stp.length == 8); Integer tt = (Integer) stp[0]; // table type Integer lt = (Integer) stp[1]; // lookup type Integer ln = (Integer) stp[2]; // lookup sequence number @@ -3650,34 +3650,34 @@ public final class OTFAdvancedTypographicTableReader { Integer sf = (Integer) stp[5]; // subtable format GlyphMappingTable mapping = (GlyphMappingTable) stp[6]; List entries = (List) stp[7]; - if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION ) { - int type = GDEFLookupType.getSubtableType ( lt.intValue() ); + if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION) { + int type = GDEFLookupType.getSubtableType (lt.intValue()); String lid = "lu" + ln.intValue(); int sequence = sn.intValue(); int flags = lf.intValue(); int format = sf.intValue(); - st = GlyphDefinitionTable.createSubtable ( type, lid, sequence, flags, format, mapping, entries ); + st = GlyphDefinitionTable.createSubtable (type, lid, sequence, flags, format, mapping, entries); } return st; } private List constructGSUBSubtables() { List/**/ subtables = new java.util.ArrayList(); - if ( seSubtables != null ) { - for ( Iterator it = seSubtables.iterator(); it.hasNext();) { + if (seSubtables != null) { + for (Iterator it = seSubtables.iterator(); it.hasNext();) { Object[] stp = (Object[]) it.next(); GlyphSubtable st; - if ( ( st = constructGSUBSubtable ( stp ) ) != null ) { - subtables.add ( st ); + if ((st = constructGSUBSubtable (stp)) != null) { + subtables.add (st); } } } return subtables; } - private GlyphSubtable constructGSUBSubtable ( Object[] stp ) { + private GlyphSubtable constructGSUBSubtable (Object[] stp) { GlyphSubtable st = null; - assert ( stp != null ) && ( stp.length == 8 ); + assert (stp != null) && (stp.length == 8); Integer tt = (Integer) stp[0]; // table type Integer lt = (Integer) stp[1]; // lookup type Integer ln = (Integer) stp[2]; // lookup sequence number @@ -3686,34 +3686,34 @@ public final class OTFAdvancedTypographicTableReader { Integer sf = (Integer) stp[5]; // subtable format GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; List entries = (List) stp[7]; - if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION ) { - int type = GSUBLookupType.getSubtableType ( lt.intValue() ); + if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION) { + int type = GSUBLookupType.getSubtableType (lt.intValue()); String lid = "lu" + ln.intValue(); int sequence = sn.intValue(); int flags = lf.intValue(); int format = sf.intValue(); - st = GlyphSubstitutionTable.createSubtable ( type, lid, sequence, flags, format, coverage, entries ); + st = GlyphSubstitutionTable.createSubtable (type, lid, sequence, flags, format, coverage, entries); } return st; } private List constructGPOSSubtables() { List/**/ subtables = new java.util.ArrayList(); - if ( seSubtables != null ) { - for ( Iterator it = seSubtables.iterator(); it.hasNext();) { + if (seSubtables != null) { + for (Iterator it = seSubtables.iterator(); it.hasNext();) { Object[] stp = (Object[]) it.next(); GlyphSubtable st; - if ( ( st = constructGPOSSubtable ( stp ) ) != null ) { - subtables.add ( st ); + if ((st = constructGPOSSubtable (stp)) != null) { + subtables.add (st); } } } return subtables; } - private GlyphSubtable constructGPOSSubtable ( Object[] stp ) { + private GlyphSubtable constructGPOSSubtable (Object[] stp) { GlyphSubtable st = null; - assert ( stp != null ) && ( stp.length == 8 ); + assert (stp != null) && (stp.length == 8); Integer tt = (Integer) stp[0]; // table type Integer lt = (Integer) stp[1]; // lookup type Integer ln = (Integer) stp[2]; // lookup sequence number @@ -3722,13 +3722,13 @@ public final class OTFAdvancedTypographicTableReader { Integer sf = (Integer) stp[5]; // subtable format GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; List entries = (List) stp[7]; - if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING ) { - int type = GSUBLookupType.getSubtableType ( lt.intValue() ); + if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING) { + int type = GSUBLookupType.getSubtableType (lt.intValue()); String lid = "lu" + ln.intValue(); int sequence = sn.intValue(); int flags = lf.intValue(); int format = sf.intValue(); - st = GlyphPositioningTable.createSubtable ( type, lid, sequence, flags, format, coverage, entries ); + st = GlyphPositioningTable.createSubtable (type, lid, sequence, flags, format, coverage, entries); } return st; } @@ -3754,17 +3754,17 @@ public final class OTFAdvancedTypographicTableReader { seEntries = new java.util.ArrayList(); } - private void extractSESubState ( int tableType, int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, int subtableFormat ) { - if ( seEntries != null ) { - if ( ( tableType == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION ) || ( seEntries.size() > 0 ) ) { - if ( seSubtables != null ) { - Integer tt = Integer.valueOf ( tableType ); - Integer lt = Integer.valueOf ( lookupType ); - Integer ln = Integer.valueOf ( lookupSequence ); - Integer lf = Integer.valueOf ( lookupFlags ); - Integer sn = Integer.valueOf ( subtableSequence ); - Integer sf = Integer.valueOf ( subtableFormat ); - seSubtables.add ( new Object[] { tt, lt, ln, lf, sn, sf, seMapping, seEntries } ); + private void extractSESubState (int tableType, int lookupType, int lookupFlags, int lookupSequence, int subtableSequence, int subtableFormat) { + if (seEntries != null) { + if ((tableType == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION) || (seEntries.size() > 0)) { + if (seSubtables != null) { + Integer tt = Integer.valueOf (tableType); + Integer lt = Integer.valueOf (lookupType); + Integer ln = Integer.valueOf (lookupSequence); + Integer lf = Integer.valueOf (lookupFlags); + Integer sn = Integer.valueOf (subtableSequence); + Integer sf = Integer.valueOf (subtableFormat); + seSubtables.add (new Object[] { tt, lt, ln, lf, sn, sf, seMapping, seEntries }); } } } @@ -3783,19 +3783,19 @@ public final class OTFAdvancedTypographicTableReader { } /** helper method for formatting an integer array for output */ - private String toString ( int[] ia ) { + private String toString (int[] ia) { StringBuffer sb = new StringBuffer(); - if ( ( ia == null ) || ( ia.length == 0 ) ) { - sb.append ( '-' ); + if ((ia == null) || (ia.length == 0)) { + sb.append ('-'); } else { boolean first = true; - for ( int i = 0; i < ia.length; i++ ) { - if ( ! first ) { - sb.append ( ' ' ); + for (int i = 0; i < ia.length; i++) { + if (! first) { + sb.append (' '); } else { first = false; } - sb.append ( ia[i] ); + sb.append (ia[i]); } } return sb.toString(); diff --git a/src/java/org/apache/fop/complexscripts/fonts/Positionable.java b/src/java/org/apache/fop/complexscripts/fonts/Positionable.java index b566631dc..927d6c854 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/Positionable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/Positionable.java @@ -44,7 +44,7 @@ public interface Positionable { * @return array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, * with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies */ - int[][] performPositioning ( CharSequence cs, String script, String language, int fontSize ); + int[][] performPositioning (CharSequence cs, String script, String language, int fontSize); /** * Perform glyph positioning using an implied font size. @@ -54,6 +54,6 @@ public interface Positionable { * @return array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, * with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies */ - int[][] performPositioning ( CharSequence cs, String script, String language ); + int[][] performPositioning (CharSequence cs, String script, String language); } diff --git a/src/java/org/apache/fop/complexscripts/fonts/Substitutable.java b/src/java/org/apache/fop/complexscripts/fonts/Substitutable.java index 426ea1627..31824ad8e 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/Substitutable.java +++ b/src/java/org/apache/fop/complexscripts/fonts/Substitutable.java @@ -46,7 +46,7 @@ public interface Substitutable { * @return output sequence (represented as a character sequence, where each character in the returned sequence * denotes "font characters", i.e., character codes that map directly (1-1) to their associated glyphs */ - CharSequence performSubstitution ( CharSequence cs, String script, String language ); + CharSequence performSubstitution (CharSequence cs, String script, String language); /** * Reorder combining marks in character sequence so that they precede (within the sequence) the base @@ -59,6 +59,6 @@ public interface Substitutable { * @param language a language identifier * @return output sequence containing reordered "font characters" */ - CharSequence reorderCombiningMarks ( CharSequence cs, int[][] gpa, String script, String language ); + CharSequence reorderCombiningMarks (CharSequence cs, int[][] gpa, String script, String language); } diff --git a/src/java/org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java index ef3c9f43a..740d81335 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java @@ -75,49 +75,49 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { private static class SubstitutionScriptContextTester implements ScriptContextTester { private static Map/**/ testerMap = new HashMap/**/(); static { - testerMap.put ( "fina", new GlyphContextTester() { - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - return inFinalContext ( script, language, feature, gs, index, flags ); + testerMap.put ("fina", new GlyphContextTester() { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + return inFinalContext (script, language, feature, gs, index, flags); } - } ); - testerMap.put ( "init", new GlyphContextTester() { - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - return inInitialContext ( script, language, feature, gs, index, flags ); + }); + testerMap.put ("init", new GlyphContextTester() { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + return inInitialContext (script, language, feature, gs, index, flags); } - } ); - testerMap.put ( "isol", new GlyphContextTester() { - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - return inIsolateContext ( script, language, feature, gs, index, flags ); + }); + testerMap.put ("isol", new GlyphContextTester() { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + return inIsolateContext (script, language, feature, gs, index, flags); } - } ); - testerMap.put ( "liga", new GlyphContextTester() { - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - return inLigatureContext ( script, language, feature, gs, index, flags ); + }); + testerMap.put ("liga", new GlyphContextTester() { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + return inLigatureContext (script, language, feature, gs, index, flags); } - } ); - testerMap.put ( "medi", new GlyphContextTester() { - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - return inMedialContext ( script, language, feature, gs, index, flags ); + }); + testerMap.put ("medi", new GlyphContextTester() { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + return inMedialContext (script, language, feature, gs, index, flags); } - } ); + }); } - public GlyphContextTester getTester ( String feature ) { - return (GlyphContextTester) testerMap.get ( feature ); + public GlyphContextTester getTester (String feature) { + return (GlyphContextTester) testerMap.get (feature); } } private static class PositioningScriptContextTester implements ScriptContextTester { private static Map/**/ testerMap = new HashMap/**/(); - public GlyphContextTester getTester ( String feature ) { - return (GlyphContextTester) testerMap.get ( feature ); + public GlyphContextTester getTester (String feature) { + return (GlyphContextTester) testerMap.get (feature); } } private final ScriptContextTester subContextTester; private final ScriptContextTester posContextTester; - ArabicScriptProcessor ( String script ) { - super ( script ); + ArabicScriptProcessor (String script) { + super (script); this.subContextTester = new SubstitutionScriptContextTester(); this.posContextTester = new PositioningScriptContextTester(); } @@ -144,26 +144,26 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { /** {@inheritDoc} */ @Override - public GlyphSequence reorderCombiningMarks ( GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language ) { + public GlyphSequence reorderCombiningMarks (GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language) { // a side effect of BIDI reordering is to order combining marks before their base, so we need to override the default here to // prevent double reordering return gs; } - private static boolean inFinalContext ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( index ); - int[] ca = gs.getCharacterArray ( false ); + private static boolean inFinalContext (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + GlyphSequence.CharAssociation a = gs.getAssociation (index); + int[] ca = gs.getCharacterArray (false); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return false; } else { int s = a.getStart(); int e = a.getEnd(); - if ( ! hasFinalPrecedingContext ( ca, nc, s, e ) ) { + if (! hasFinalPrecedingContext (ca, nc, s, e)) { return false; - } else if ( forcesFinalThisContext ( ca, nc, s, e ) ) { + } else if (forcesFinalThisContext (ca, nc, s, e)) { return true; - } else if ( ! hasFinalFollowingContext ( ca, nc, s, e ) ) { + } else if (! hasFinalFollowingContext (ca, nc, s, e)) { return false; } else { return true; @@ -171,18 +171,18 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { } } - private static boolean inInitialContext ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( index ); - int[] ca = gs.getCharacterArray ( false ); + private static boolean inInitialContext (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + GlyphSequence.CharAssociation a = gs.getAssociation (index); + int[] ca = gs.getCharacterArray (false); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return false; } else { int s = a.getStart(); int e = a.getEnd(); - if ( ! hasInitialPrecedingContext ( ca, nc, s, e ) ) { + if (! hasInitialPrecedingContext (ca, nc, s, e)) { return false; - } else if ( ! hasInitialFollowingContext ( ca, nc, s, e ) ) { + } else if (! hasInitialFollowingContext (ca, nc, s, e)) { return false; } else { return true; @@ -190,30 +190,30 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { } } - private static boolean inIsolateContext ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( index ); + private static boolean inIsolateContext (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + GlyphSequence.CharAssociation a = gs.getAssociation (index); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return false; - } else if ( ( a.getStart() == 0 ) && ( a.getEnd() == nc ) ) { + } else if ((a.getStart() == 0) && (a.getEnd() == nc)) { return true; } else { return false; } } - private static boolean inLigatureContext ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( index ); - int[] ca = gs.getCharacterArray ( false ); + private static boolean inLigatureContext (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + GlyphSequence.CharAssociation a = gs.getAssociation (index); + int[] ca = gs.getCharacterArray (false); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return false; } else { int s = a.getStart(); int e = a.getEnd(); - if ( ! hasLigaturePrecedingContext ( ca, nc, s, e ) ) { + if (! hasLigaturePrecedingContext (ca, nc, s, e)) { return false; - } else if ( ! hasLigatureFollowingContext ( ca, nc, s, e ) ) { + } else if (! hasLigatureFollowingContext (ca, nc, s, e)) { return false; } else { return true; @@ -221,20 +221,20 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { } } - private static boolean inMedialContext ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( index ); - int[] ca = gs.getCharacterArray ( false ); + private static boolean inMedialContext (String script, String language, String feature, GlyphSequence gs, int index, int flags) { + GlyphSequence.CharAssociation a = gs.getAssociation (index); + int[] ca = gs.getCharacterArray (false); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return false; } else { int s = a.getStart(); int e = a.getEnd(); - if ( ! hasMedialPrecedingContext ( ca, nc, s, e ) ) { + if (! hasMedialPrecedingContext (ca, nc, s, e)) { return false; - } else if ( ! hasMedialThisContext ( ca, nc, s, e ) ) { + } else if (! hasMedialThisContext (ca, nc, s, e)) { return false; - } else if ( ! hasMedialFollowingContext ( ca, nc, s, e ) ) { + } else if (! hasMedialFollowingContext (ca, nc, s, e)) { return false; } else { return true; @@ -242,209 +242,209 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { } } - private static boolean hasFinalPrecedingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasFinalPrecedingContext (int[] ca, int nc, int s, int e) { int chp = 0; int clp = 0; - for ( int i = s; i > 0; i-- ) { + for (int i = s; i > 0; i--) { int k = i - 1; - if ( ( k >= 0 ) && ( k < nc ) ) { + if ((k >= 0) && (k < nc)) { chp = ca [ k ]; - clp = BidiClass.getBidiClass ( chp ); - if ( clp != BidiConstants.NSM ) { + clp = BidiClass.getBidiClass (chp); + if (clp != BidiConstants.NSM) { break; } } } - if ( clp != BidiConstants.AL ) { + if (clp != BidiConstants.AL) { return false; - } else if ( hasIsolateInitial ( chp ) ) { + } else if (hasIsolateInitial (chp)) { return false; } else { return true; } } - private static boolean forcesFinalThisContext ( int[] ca, int nc, int s, int e ) { + private static boolean forcesFinalThisContext (int[] ca, int nc, int s, int e) { int chl = 0; int cll = 0; - for ( int i = 0, n = e - s; i < n; i++ ) { + for (int i = 0, n = e - s; i < n; i++) { int k = n - i - 1; int j = s + k; - if ( ( j >= 0 ) && ( j < nc ) ) { + if ((j >= 0) && (j < nc)) { chl = ca [ j ]; - cll = BidiClass.getBidiClass ( chl ); - if ( cll != BidiConstants.NSM ) { + cll = BidiClass.getBidiClass (chl); + if (cll != BidiConstants.NSM) { break; } } } - if ( cll != BidiConstants.AL ) { + if (cll != BidiConstants.AL) { return false; } - if ( hasIsolateInitial ( chl ) ) { + if (hasIsolateInitial (chl)) { return true; } else { return false; } } - private static boolean hasFinalFollowingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasFinalFollowingContext (int[] ca, int nc, int s, int e) { int chf = 0; int clf = 0; - for ( int i = e, n = nc; i < n; i++ ) { + for (int i = e, n = nc; i < n; i++) { chf = ca [ i ]; - clf = BidiClass.getBidiClass ( chf ); - if ( clf != BidiConstants.NSM ) { + clf = BidiClass.getBidiClass (chf); + if (clf != BidiConstants.NSM) { break; } } - if ( clf != BidiConstants.AL ) { + if (clf != BidiConstants.AL) { return true; - } else if ( hasIsolateFinal ( chf ) ) { + } else if (hasIsolateFinal (chf)) { return true; } else { return false; } } - private static boolean hasInitialPrecedingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasInitialPrecedingContext (int[] ca, int nc, int s, int e) { int chp = 0; int clp = 0; - for ( int i = s; i > 0; i-- ) { + for (int i = s; i > 0; i--) { int k = i - 1; - if ( ( k >= 0 ) && ( k < nc ) ) { + if ((k >= 0) && (k < nc)) { chp = ca [ k ]; - clp = BidiClass.getBidiClass ( chp ); - if ( clp != BidiConstants.NSM ) { + clp = BidiClass.getBidiClass (chp); + if (clp != BidiConstants.NSM) { break; } } } - if ( clp != BidiConstants.AL ) { + if (clp != BidiConstants.AL) { return true; - } else if ( hasIsolateInitial ( chp ) ) { + } else if (hasIsolateInitial (chp)) { return true; } else { return false; } } - private static boolean hasInitialFollowingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasInitialFollowingContext (int[] ca, int nc, int s, int e) { int chf = 0; int clf = 0; - for ( int i = e, n = nc; i < n; i++ ) { + for (int i = e, n = nc; i < n; i++) { chf = ca [ i ]; - clf = BidiClass.getBidiClass ( chf ); - if ( clf != BidiConstants.NSM ) { + clf = BidiClass.getBidiClass (chf); + if (clf != BidiConstants.NSM) { break; } } - if ( clf != BidiConstants.AL ) { + if (clf != BidiConstants.AL) { return false; - } else if ( hasIsolateFinal ( chf ) ) { + } else if (hasIsolateFinal (chf)) { return false; } else { return true; } } - private static boolean hasMedialPrecedingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasMedialPrecedingContext (int[] ca, int nc, int s, int e) { int chp = 0; int clp = 0; - for ( int i = s; i > 0; i-- ) { + for (int i = s; i > 0; i--) { int k = i - 1; - if ( ( k >= 0 ) && ( k < nc ) ) { + if ((k >= 0) && (k < nc)) { chp = ca [ k ]; - clp = BidiClass.getBidiClass ( chp ); - if ( clp != BidiConstants.NSM ) { + clp = BidiClass.getBidiClass (chp); + if (clp != BidiConstants.NSM) { break; } } } - if ( clp != BidiConstants.AL ) { + if (clp != BidiConstants.AL) { return false; - } else if ( hasIsolateInitial ( chp ) ) { + } else if (hasIsolateInitial (chp)) { return false; } else { return true; } } - private static boolean hasMedialThisContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasMedialThisContext (int[] ca, int nc, int s, int e) { int chf = 0; // first non-NSM char in [s,e) int clf = 0; - for ( int i = 0, n = e - s; i < n; i++ ) { + for (int i = 0, n = e - s; i < n; i++) { int k = s + i; - if ( ( k >= 0 ) && ( k < nc ) ) { + if ((k >= 0) && (k < nc)) { chf = ca [ s + i ]; - clf = BidiClass.getBidiClass ( chf ); - if ( clf != BidiConstants.NSM ) { + clf = BidiClass.getBidiClass (chf); + if (clf != BidiConstants.NSM) { break; } } } - if ( clf != BidiConstants.AL ) { + if (clf != BidiConstants.AL) { return false; } int chl = 0; // last non-NSM char in [s,e) int cll = 0; - for ( int i = 0, n = e - s; i < n; i++ ) { + for (int i = 0, n = e - s; i < n; i++) { int k = n - i - 1; int j = s + k; - if ( ( j >= 0 ) && ( j < nc ) ) { + if ((j >= 0) && (j < nc)) { chl = ca [ j ]; - cll = BidiClass.getBidiClass ( chl ); - if ( cll != BidiConstants.NSM ) { + cll = BidiClass.getBidiClass (chl); + if (cll != BidiConstants.NSM) { break; } } } - if ( cll != BidiConstants.AL ) { + if (cll != BidiConstants.AL) { return false; } - if ( hasIsolateFinal ( chf ) ) { + if (hasIsolateFinal (chf)) { return false; - } else if ( hasIsolateInitial ( chl ) ) { + } else if (hasIsolateInitial (chl)) { return false; } else { return true; } } - private static boolean hasMedialFollowingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasMedialFollowingContext (int[] ca, int nc, int s, int e) { int chf = 0; int clf = 0; - for ( int i = e, n = nc; i < n; i++ ) { + for (int i = e, n = nc; i < n; i++) { chf = ca [ i ]; - clf = BidiClass.getBidiClass ( chf ); - if ( clf != BidiConstants.NSM ) { + clf = BidiClass.getBidiClass (chf); + if (clf != BidiConstants.NSM) { break; } } - if ( clf != BidiConstants.AL ) { + if (clf != BidiConstants.AL) { return false; - } else if ( hasIsolateFinal ( chf ) ) { + } else if (hasIsolateFinal (chf)) { return false; } else { return true; } } - private static boolean hasLigaturePrecedingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasLigaturePrecedingContext (int[] ca, int nc, int s, int e) { return true; } - private static boolean hasLigatureFollowingContext ( int[] ca, int nc, int s, int e ) { + private static boolean hasLigatureFollowingContext (int[] ca, int nc, int s, int e) { int chf = 0; int clf = 0; - for ( int i = e, n = nc; i < n; i++ ) { + for (int i = e, n = nc; i < n; i++) { chf = ca [ i ]; - clf = BidiClass.getBidiClass ( chf ); - if ( clf != BidiConstants.NSM ) { + clf = BidiClass.getBidiClass (chf); + if (clf != BidiConstants.NSM) { break; } } - if ( clf == BidiConstants.AL ) { + if (clf == BidiConstants.AL) { return true; } else { return false; @@ -504,8 +504,8 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { 0x06EF // REH WITH INVERTED V }; - private static boolean hasIsolateInitial ( int ch ) { - return Arrays.binarySearch ( isolatedInitials, ch ) >= 0; + private static boolean hasIsolateInitial (int ch) { + return Arrays.binarySearch (isolatedInitials, ch) >= 0; } /** @@ -516,8 +516,8 @@ public class ArabicScriptProcessor extends DefaultScriptProcessor { 0x0621 // HAMZA }; - private static boolean hasIsolateFinal ( int ch ) { - return Arrays.binarySearch ( isolatedFinals, ch ) >= 0; + private static boolean hasIsolateFinal (int ch) { + return Arrays.binarySearch (isolatedFinals, ch) >= 0; } } diff --git a/src/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java index 09a71db6a..5f49990ac 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java @@ -49,8 +49,8 @@ public class DefaultScriptProcessor extends ScriptProcessor { "mkmk" // mark to mark positioning }; - DefaultScriptProcessor ( String script ) { - super ( script ); + DefaultScriptProcessor (String script) { + super (script); } @Override @@ -79,43 +79,43 @@ public class DefaultScriptProcessor extends ScriptProcessor { @Override /** {@inheritDoc} */ - public GlyphSequence reorderCombiningMarks ( GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language ) { + public GlyphSequence reorderCombiningMarks (GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language) { int ng = gs.getGlyphCount(); - int[] ga = gs.getGlyphArray ( false ); + int[] ga = gs.getGlyphArray (false); int nm = 0; // count combining marks - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { int gid = ga [ i ]; - if ( gdef.isGlyphClass ( gid, GlyphDefinitionTable.GLYPH_CLASS_MARK ) ) { + if (gdef.isGlyphClass (gid, GlyphDefinitionTable.GLYPH_CLASS_MARK)) { nm++; } } // only reorder if there is at least one mark and at least one non-mark glyph - if ( ( nm > 0 ) && ( ( ng - nm ) > 0 ) ) { - GlyphSequence.CharAssociation[] aa = gs.getAssociations ( 0, -1 ); + if ((nm > 0) && ((ng - nm) > 0)) { + GlyphSequence.CharAssociation[] aa = gs.getAssociations (0, -1); int[] nga = new int [ ng ]; - int[][] npa = ( gpa != null ) ? new int [ ng ][] : null; + int[][] npa = (gpa != null) ? new int [ ng ][] : null; GlyphSequence.CharAssociation[] naa = new GlyphSequence.CharAssociation [ ng ]; int k = 0; GlyphSequence.CharAssociation ba = null; int bg = -1; int[] bpa = null; - for ( int i = 0; i < ng; i++ ) { + for (int i = 0; i < ng; i++) { int gid = ga [ i ]; - int[] pa = ( gpa != null ) ? gpa [ i ] : null; + int[] pa = (gpa != null) ? gpa [ i ] : null; GlyphSequence.CharAssociation ca = aa [ i ]; - if ( gdef.isGlyphClass ( gid, GlyphDefinitionTable.GLYPH_CLASS_MARK ) ) { + if (gdef.isGlyphClass (gid, GlyphDefinitionTable.GLYPH_CLASS_MARK)) { nga [ k ] = gid; naa [ k ] = ca; - if ( npa != null ) { + if (npa != null) { npa [ k ] = pa; } k++; } else { - if ( bg != -1 ) { + if (bg != -1) { nga [ k ] = bg; naa [ k ] = ba; - if ( npa != null ) { + if (npa != null) { npa [ k ] = bpa; } k++; @@ -123,26 +123,26 @@ public class DefaultScriptProcessor extends ScriptProcessor { ba = null; bpa = null; } - if ( bg == -1 ) { + if (bg == -1) { bg = gid; ba = ca; bpa = pa; } } } - if ( bg != -1 ) { + if (bg != -1) { nga [ k ] = bg; naa [ k ] = ba; - if ( npa != null ) { + if (npa != null) { npa [ k ] = bpa; } k++; } assert k == ng; - if ( npa != null ) { - System.arraycopy ( npa, 0, gpa, 0, ng ); + if (npa != null) { + System.arraycopy (npa, 0, gpa, 0, ng); } - return new GlyphSequence ( gs, null, nga, null, null, naa, null ); + return new GlyphSequence (gs, null, nga, null, null, naa, null); } else { return gs; } diff --git a/src/java/org/apache/fop/complexscripts/scripts/DevanagariScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/DevanagariScriptProcessor.java index be8488baf..171f52d8b 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/DevanagariScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/DevanagariScriptProcessor.java @@ -42,8 +42,8 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { /** logging instance */ private static final Log log = LogFactory.getLog(DevanagariScriptProcessor.class); // CSOK: ConstantNameCheck - DevanagariScriptProcessor ( String script ) { - super ( script ); + DevanagariScriptProcessor (String script) { + super (script); } @Override @@ -53,12 +53,12 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { @Override // find rightmost pre-base matra - protected int findPreBaseMatra ( GlyphSequence gs ) { + protected int findPreBaseMatra (GlyphSequence gs) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ng; i > 0; i-- ) { + for (int i = ng; i > 0; i--) { int k = i - 1; - if ( containsPreBaseMatra ( gs, k ) ) { + if (containsPreBaseMatra (gs, k)) { lk = k; break; } @@ -68,15 +68,15 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { @Override // find leftmost pre-base matra target, starting from source - protected int findPreBaseMatraTarget ( GlyphSequence gs, int source ) { + protected int findPreBaseMatraTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ( source < ng ) ? source : ng; i > 0; i-- ) { + for (int i = (source < ng) ? source : ng; i > 0; i--) { int k = i - 1; - if ( containsConsonant ( gs, k ) ) { - if ( containsHalfConsonant ( gs, k ) ) { + if (containsConsonant (gs, k)) { + if (containsHalfConsonant (gs, k)) { lk = k; - } else if ( lk == -1 ) { + } else if (lk == -1) { lk = k; } else { break; @@ -86,39 +86,39 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { return lk; } - private static boolean containsPreBaseMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isPreM ( ca [ i ] ) ) { + private static boolean containsPreBaseMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isPreM (ca [ i ])) { return true; } } return false; } - private static boolean containsConsonant ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isC ( ca [ i ] ) ) { + private static boolean containsConsonant (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isC (ca [ i ])) { return true; } } return false; } - private static boolean containsHalfConsonant ( GlyphSequence gs, int k ) { - Boolean half = (Boolean) gs.getAssociation ( k ) . getPredication ( "half" ); - return ( half != null ) ? half.booleanValue() : false; + private static boolean containsHalfConsonant (GlyphSequence gs, int k) { + Boolean half = (Boolean) gs.getAssociation (k) . getPredication ("half"); + return (half != null) ? half.booleanValue() : false; } @Override - protected int findReph ( GlyphSequence gs ) { + protected int findReph (GlyphSequence gs) { int ng = gs.getGlyphCount(); int li = -1; - for ( int i = 0; i < ng; i++ ) { - if ( containsReph ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if (containsReph (gs, i)) { li = i; break; } @@ -127,58 +127,58 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { } @Override - protected int findRephTarget ( GlyphSequence gs, int source ) { + protected int findRephTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int c1 = -1; int c2 = -1; // first candidate target is after first non-half consonant - for ( int i = 0; i < ng; i++ ) { - if ( ( i != source ) && containsConsonant ( gs, i ) ) { - if ( ! containsHalfConsonant ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if ((i != source) && containsConsonant (gs, i)) { + if (! containsHalfConsonant (gs, i)) { c1 = i + 1; break; } } } // second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark - for ( int i = ( c1 >= 0 ) ? c1 : 0; i < ng; i++ ) { - if ( containsMatra ( gs, i ) && ! containsPreBaseMatra ( gs, i ) ) { + for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { + if (containsMatra (gs, i) && ! containsPreBaseMatra (gs, i)) { c2 = i + 1; - } else if ( containsOtherMark ( gs, i ) ) { + } else if (containsOtherMark (gs, i)) { c2 = i; break; } } - if ( c2 >= 0 ) { + if (c2 >= 0) { return c2; - } else if ( c1 >= 0 ) { + } else if (c1 >= 0) { return c1; } else { return source; } } - private static boolean containsReph ( GlyphSequence gs, int k ) { - Boolean rphf = (Boolean) gs.getAssociation ( k ) . getPredication ( "rphf" ); - return ( rphf != null ) ? rphf.booleanValue() : false; + private static boolean containsReph (GlyphSequence gs, int k) { + Boolean rphf = (Boolean) gs.getAssociation (k) . getPredication ("rphf"); + return (rphf != null) ? rphf.booleanValue() : false; } - private static boolean containsMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isM ( ca [ i ] ) ) { + private static boolean containsMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isM (ca [ i ])) { return true; } } return false; } - private static boolean containsOtherMark ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - switch ( typeOf ( ca [ i ] ) ) { + private static boolean containsOtherMark (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + switch (typeOf (ca [ i ])) { case C_T: // tone (e.g., udatta, anudatta) case C_A: // accent (e.g., acute, grave) case C_O: // other (e.g., candrabindu, anusvara, visarga, etc) @@ -191,18 +191,18 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { } private static class DevanagariSyllabizer extends DefaultSyllabizer { - DevanagariSyllabizer ( String script, String language ) { - super ( script, language ); + DevanagariSyllabizer (String script, String language) { + super (script, language); } @Override // | C ... - protected int findStartOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findStartOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { - while ( s < e ) { + while (s < e) { int c = ca [ s ]; - if ( isC ( c ) ) { + if (isC (c)) { break; } else { s++; @@ -213,29 +213,29 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { } @Override // D* L? | ... - protected int findEndOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findEndOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { int nd = 0; int nl = 0; int i; // consume dead consonants - while ( ( i = isDeadConsonant ( ca, s, e ) ) > s ) { + while ((i = isDeadConsonant (ca, s, e)) > s) { s = i; nd++; } // consume zero or one live consonant - if ( ( i = isLiveConsonant ( ca, s, e ) ) > s ) { + if ((i = isLiveConsonant (ca, s, e)) > s) { s = i; nl++; } - return ( ( nd > 0 ) || ( nl > 0 ) ) ? s : -1; + return ((nd > 0) || (nl > 0)) ? s : -1; } } // D := ( C N? H )? - private int isDeadConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isDeadConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -244,9 +244,9 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { int nh = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; } else { @@ -254,29 +254,29 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + 1 ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // H - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { + if (isH (c)) { i++; nh++; } else { break; } } - } while ( false ); - return ( nc > 0 ) && ( nh > 0 ) ? s + i : -1; + } while (false); + return (nc > 0) && (nh > 0) ? s + i : -1; } } // L := ( (C|V) N? X* )?; where X = ( MATRA | ACCENT MARK | TONE MARK | OTHER MARK ) - private int isLiveConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isLiveConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -286,12 +286,12 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { int nx = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; - } else if ( isV ( c ) ) { + } else if (isV (c)) { i++; nv++; } else { @@ -299,37 +299,37 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // X* - while ( ( s + i ) < e ) { + while ((s + i) < e) { c = ca [ s + i ]; - if ( isX ( c ) ) { + if (isX (c)) { i++; nx++; } else { break; } } - } while ( false ); + } while (false); // if no X but has H, then ignore C|I - if ( nx == 0 ) { - if ( ( s + i ) < e ) { + if (nx == 0) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { - if ( nc > 0 ) { + if (isH (c)) { + if (nc > 0) { nc--; - } else if ( nv > 0 ) { + } else if (nv > 0) { nv--; } } } } - return ( ( nc > 0 ) || ( nv > 0 ) ) ? s + i : -1; + return ((nc > 0) || (nv > 0)) ? s + i : -1; } } } @@ -486,18 +486,18 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { C_C // 0x097F // BBA (SINDHI) }; static int typeOf(int c) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { + if ((c >= ccaStart) && (c < ccaEnd)) { return cca [ c - ccaStart ] & C_M_TYPE; } else { return C_U; } } static boolean isType(int c, int t) { - return typeOf ( c ) == t; + return typeOf (c) == t; } static boolean hasFlag(int c, int f) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { - return ( cca [ c - ccaStart ] & f ) == f; + if ((c >= ccaStart) && (c < ccaEnd)) { + return (cca [ c - ccaStart ] & f) == f; } else { return false; } @@ -524,7 +524,7 @@ public class DevanagariScriptProcessor extends IndicScriptProcessor { return isType(c,C_M) && hasFlag(c,C_PRE); } static boolean isX(int c) { - switch ( typeOf ( c ) ) { + switch (typeOf (c)) { case C_M: // matra (combining vowel) case C_A: // accent mark case C_T: // tone mark diff --git a/src/java/org/apache/fop/complexscripts/scripts/GujaratiScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/GujaratiScriptProcessor.java index 480f45f87..937cc2288 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/GujaratiScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/GujaratiScriptProcessor.java @@ -42,8 +42,8 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { /** logging instance */ private static final Log log = LogFactory.getLog(GujaratiScriptProcessor.class); // CSOK: ConstantNameCheck - GujaratiScriptProcessor ( String script ) { - super ( script ); + GujaratiScriptProcessor (String script) { + super (script); } @Override @@ -53,12 +53,12 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { @Override // find rightmost pre-base matra - protected int findPreBaseMatra ( GlyphSequence gs ) { + protected int findPreBaseMatra (GlyphSequence gs) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ng; i > 0; i-- ) { + for (int i = ng; i > 0; i--) { int k = i - 1; - if ( containsPreBaseMatra ( gs, k ) ) { + if (containsPreBaseMatra (gs, k)) { lk = k; break; } @@ -68,15 +68,15 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { @Override // find leftmost pre-base matra target, starting from source - protected int findPreBaseMatraTarget ( GlyphSequence gs, int source ) { + protected int findPreBaseMatraTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ( source < ng ) ? source : ng; i > 0; i-- ) { + for (int i = (source < ng) ? source : ng; i > 0; i--) { int k = i - 1; - if ( containsConsonant ( gs, k ) ) { - if ( containsHalfConsonant ( gs, k ) ) { + if (containsConsonant (gs, k)) { + if (containsHalfConsonant (gs, k)) { lk = k; - } else if ( lk == -1 ) { + } else if (lk == -1) { lk = k; } else { break; @@ -86,39 +86,39 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { return lk; } - private static boolean containsPreBaseMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isPreM ( ca [ i ] ) ) { + private static boolean containsPreBaseMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isPreM (ca [ i ])) { return true; } } return false; } - private static boolean containsConsonant ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isC ( ca [ i ] ) ) { + private static boolean containsConsonant (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isC (ca [ i ])) { return true; } } return false; } - private static boolean containsHalfConsonant ( GlyphSequence gs, int k ) { - Boolean half = (Boolean) gs.getAssociation ( k ) . getPredication ( "half" ); - return ( half != null ) ? half.booleanValue() : false; + private static boolean containsHalfConsonant (GlyphSequence gs, int k) { + Boolean half = (Boolean) gs.getAssociation (k) . getPredication ("half"); + return (half != null) ? half.booleanValue() : false; } @Override - protected int findReph ( GlyphSequence gs ) { + protected int findReph (GlyphSequence gs) { int ng = gs.getGlyphCount(); int li = -1; - for ( int i = 0; i < ng; i++ ) { - if ( containsReph ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if (containsReph (gs, i)) { li = i; break; } @@ -127,58 +127,58 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { } @Override - protected int findRephTarget ( GlyphSequence gs, int source ) { + protected int findRephTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int c1 = -1; int c2 = -1; // first candidate target is after first non-half consonant - for ( int i = 0; i < ng; i++ ) { - if ( ( i != source ) && containsConsonant ( gs, i ) ) { - if ( ! containsHalfConsonant ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if ((i != source) && containsConsonant (gs, i)) { + if (! containsHalfConsonant (gs, i)) { c1 = i + 1; break; } } } // second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark - for ( int i = ( c1 >= 0 ) ? c1 : 0; i < ng; i++ ) { - if ( containsMatra ( gs, i ) && ! containsPreBaseMatra ( gs, i ) ) { + for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { + if (containsMatra (gs, i) && ! containsPreBaseMatra (gs, i)) { c2 = i + 1; - } else if ( containsOtherMark ( gs, i ) ) { + } else if (containsOtherMark (gs, i)) { c2 = i; break; } } - if ( c2 >= 0 ) { + if (c2 >= 0) { return c2; - } else if ( c1 >= 0 ) { + } else if (c1 >= 0) { return c1; } else { return source; } } - private static boolean containsReph ( GlyphSequence gs, int k ) { - Boolean rphf = (Boolean) gs.getAssociation ( k ) . getPredication ( "rphf" ); - return ( rphf != null ) ? rphf.booleanValue() : false; + private static boolean containsReph (GlyphSequence gs, int k) { + Boolean rphf = (Boolean) gs.getAssociation (k) . getPredication ("rphf"); + return (rphf != null) ? rphf.booleanValue() : false; } - private static boolean containsMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isM ( ca [ i ] ) ) { + private static boolean containsMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isM (ca [ i ])) { return true; } } return false; } - private static boolean containsOtherMark ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - switch ( typeOf ( ca [ i ] ) ) { + private static boolean containsOtherMark (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + switch (typeOf (ca [ i ])) { case C_T: // tone (e.g., udatta, anudatta) case C_A: // accent (e.g., acute, grave) case C_O: // other (e.g., candrabindu, anusvara, visarga, etc) @@ -191,18 +191,18 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { } private static class GujaratiSyllabizer extends DefaultSyllabizer { - GujaratiSyllabizer ( String script, String language ) { - super ( script, language ); + GujaratiSyllabizer (String script, String language) { + super (script, language); } @Override // | C ... - protected int findStartOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findStartOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { - while ( s < e ) { + while (s < e) { int c = ca [ s ]; - if ( isC ( c ) ) { + if (isC (c)) { break; } else { s++; @@ -213,29 +213,29 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { } @Override // D* L? | ... - protected int findEndOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findEndOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { int nd = 0; int nl = 0; int i; // consume dead consonants - while ( ( i = isDeadConsonant ( ca, s, e ) ) > s ) { + while ((i = isDeadConsonant (ca, s, e)) > s) { s = i; nd++; } // consume zero or one live consonant - if ( ( i = isLiveConsonant ( ca, s, e ) ) > s ) { + if ((i = isLiveConsonant (ca, s, e)) > s) { s = i; nl++; } - return ( ( nd > 0 ) || ( nl > 0 ) ) ? s : -1; + return ((nd > 0) || (nl > 0)) ? s : -1; } } // D := ( C N? H )? - private int isDeadConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isDeadConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -244,9 +244,9 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { int nh = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; } else { @@ -254,29 +254,29 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + 1 ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // H - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { + if (isH (c)) { i++; nh++; } else { break; } } - } while ( false ); - return ( nc > 0 ) && ( nh > 0 ) ? s + i : -1; + } while (false); + return (nc > 0) && (nh > 0) ? s + i : -1; } } // L := ( (C|V) N? X* )?; where X = ( MATRA | ACCENT MARK | TONE MARK | OTHER MARK ) - private int isLiveConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isLiveConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -286,12 +286,12 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { int nx = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; - } else if ( isV ( c ) ) { + } else if (isV (c)) { i++; nv++; } else { @@ -299,37 +299,37 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // X* - while ( ( s + i ) < e ) { + while ((s + i) < e) { c = ca [ s + i ]; - if ( isX ( c ) ) { + if (isX (c)) { i++; nx++; } else { break; } } - } while ( false ); + } while (false); // if no X but has H, then ignore C|I - if ( nx == 0 ) { - if ( ( s + i ) < e ) { + if (nx == 0) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { - if ( nc > 0 ) { + if (isH (c)) { + if (nc > 0) { nc--; - } else if ( nv > 0 ) { + } else if (nv > 0) { nv--; } } } } - return ( ( nc > 0 ) || ( nv > 0 ) ) ? s + i : -1; + return ((nc > 0) || (nv > 0)) ? s + i : -1; } } } @@ -486,18 +486,18 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { C_U // 0x0AFF // UNASSIGNED }; static int typeOf(int c) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { + if ((c >= ccaStart) && (c < ccaEnd)) { return cca [ c - ccaStart ] & C_M_TYPE; } else { return C_U; } } static boolean isType(int c, int t) { - return typeOf ( c ) == t; + return typeOf (c) == t; } static boolean hasFlag(int c, int f) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { - return ( cca [ c - ccaStart ] & f ) == f; + if ((c >= ccaStart) && (c < ccaEnd)) { + return (cca [ c - ccaStart ] & f) == f; } else { return false; } @@ -524,7 +524,7 @@ public class GujaratiScriptProcessor extends IndicScriptProcessor { return isType(c,C_M) && hasFlag(c,C_PRE); } static boolean isX(int c) { - switch ( typeOf ( c ) ) { + switch (typeOf (c)) { case C_M: // matra (combining vowel) case C_A: // accent mark case C_T: // tone mark diff --git a/src/java/org/apache/fop/complexscripts/scripts/GurmukhiScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/GurmukhiScriptProcessor.java index 5fd84bfce..2da632574 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/GurmukhiScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/GurmukhiScriptProcessor.java @@ -43,8 +43,8 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { /** logging instance */ private static final Log log = LogFactory.getLog(GurmukhiScriptProcessor.class); // CSOK: ConstantNameCheck - GurmukhiScriptProcessor ( String script ) { - super ( script ); + GurmukhiScriptProcessor (String script) { + super (script); } @Override @@ -54,12 +54,12 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { @Override // find rightmost pre-base matra - protected int findPreBaseMatra ( GlyphSequence gs ) { + protected int findPreBaseMatra (GlyphSequence gs) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ng; i > 0; i-- ) { + for (int i = ng; i > 0; i--) { int k = i - 1; - if ( containsPreBaseMatra ( gs, k ) ) { + if (containsPreBaseMatra (gs, k)) { lk = k; break; } @@ -69,15 +69,15 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { @Override // find leftmost pre-base matra target, starting from source - protected int findPreBaseMatraTarget ( GlyphSequence gs, int source ) { + protected int findPreBaseMatraTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int lk = -1; - for ( int i = ( source < ng ) ? source : ng; i > 0; i-- ) { + for (int i = (source < ng) ? source : ng; i > 0; i--) { int k = i - 1; - if ( containsConsonant ( gs, k ) ) { - if ( containsHalfConsonant ( gs, k ) ) { + if (containsConsonant (gs, k)) { + if (containsHalfConsonant (gs, k)) { lk = k; - } else if ( lk == -1 ) { + } else if (lk == -1) { lk = k; } else { break; @@ -87,39 +87,39 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { return lk; } - private static boolean containsPreBaseMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isPreM ( ca [ i ] ) ) { + private static boolean containsPreBaseMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isPreM (ca [ i ])) { return true; } } return false; } - private static boolean containsConsonant ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isC ( ca [ i ] ) ) { + private static boolean containsConsonant (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isC (ca [ i ])) { return true; } } return false; } - private static boolean containsHalfConsonant ( GlyphSequence gs, int k ) { - Boolean half = (Boolean) gs.getAssociation ( k ) . getPredication ( "half" ); - return ( half != null ) ? half.booleanValue() : false; + private static boolean containsHalfConsonant (GlyphSequence gs, int k) { + Boolean half = (Boolean) gs.getAssociation (k) . getPredication ("half"); + return (half != null) ? half.booleanValue() : false; } @Override - protected int findReph ( GlyphSequence gs ) { + protected int findReph (GlyphSequence gs) { int ng = gs.getGlyphCount(); int li = -1; - for ( int i = 0; i < ng; i++ ) { - if ( containsReph ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if (containsReph (gs, i)) { li = i; break; } @@ -128,58 +128,58 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } @Override - protected int findRephTarget ( GlyphSequence gs, int source ) { + protected int findRephTarget (GlyphSequence gs, int source) { int ng = gs.getGlyphCount(); int c1 = -1; int c2 = -1; // first candidate target is after first non-half consonant - for ( int i = 0; i < ng; i++ ) { - if ( ( i != source ) && containsConsonant ( gs, i ) ) { - if ( ! containsHalfConsonant ( gs, i ) ) { + for (int i = 0; i < ng; i++) { + if ((i != source) && containsConsonant (gs, i)) { + if (! containsHalfConsonant (gs, i)) { c1 = i + 1; break; } } } // second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark - for ( int i = ( c1 >= 0 ) ? c1 : 0; i < ng; i++ ) { - if ( containsMatra ( gs, i ) && ! containsPreBaseMatra ( gs, i ) ) { + for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { + if (containsMatra (gs, i) && ! containsPreBaseMatra (gs, i)) { c2 = i + 1; - } else if ( containsOtherMark ( gs, i ) ) { + } else if (containsOtherMark (gs, i)) { c2 = i; break; } } - if ( c2 >= 0 ) { + if (c2 >= 0) { return c2; - } else if ( c1 >= 0 ) { + } else if (c1 >= 0) { return c1; } else { return source; } } - private static boolean containsReph ( GlyphSequence gs, int k ) { - Boolean rphf = (Boolean) gs.getAssociation ( k ) . getPredication ( "rphf" ); - return ( rphf != null ) ? rphf.booleanValue() : false; + private static boolean containsReph (GlyphSequence gs, int k) { + Boolean rphf = (Boolean) gs.getAssociation (k) . getPredication ("rphf"); + return (rphf != null) ? rphf.booleanValue() : false; } - private static boolean containsMatra ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - if ( isM ( ca [ i ] ) ) { + private static boolean containsMatra (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + if (isM (ca [ i ])) { return true; } } return false; } - private static boolean containsOtherMark ( GlyphSequence gs, int k ) { - GlyphSequence.CharAssociation a = gs.getAssociation ( k ); - int[] ca = gs.getCharacterArray ( false ); - for ( int i = a.getStart(), e = a.getEnd(); i < e; i++ ) { - switch ( typeOf ( ca [ i ] ) ) { + private static boolean containsOtherMark (GlyphSequence gs, int k) { + GlyphSequence.CharAssociation a = gs.getAssociation (k); + int[] ca = gs.getCharacterArray (false); + for (int i = a.getStart(), e = a.getEnd(); i < e; i++) { + switch (typeOf (ca [ i ])) { case C_T: // tone (e.g., udatta, anudatta) case C_A: // accent (e.g., acute, grave) case C_O: // other (e.g., candrabindu, anusvara, visarga, etc) @@ -192,18 +192,18 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } private static class GurmukhiSyllabizer extends DefaultSyllabizer { - GurmukhiSyllabizer ( String script, String language ) { - super ( script, language ); + GurmukhiSyllabizer (String script, String language) { + super (script, language); } @Override // | C ... - protected int findStartOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findStartOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { - while ( s < e ) { + while (s < e) { int c = ca [ s ]; - if ( isC ( c ) ) { + if (isC (c)) { break; } else { s++; @@ -214,29 +214,29 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } @Override // D* L? | ... - protected int findEndOfSyllable ( int[] ca, int s, int e ) { - if ( ( s < 0 ) || ( s >= e ) ) { + protected int findEndOfSyllable (int[] ca, int s, int e) { + if ((s < 0) || (s >= e)) { return -1; } else { int nd = 0; int nl = 0; int i; // consume dead consonants - while ( ( i = isDeadConsonant ( ca, s, e ) ) > s ) { + while ((i = isDeadConsonant (ca, s, e)) > s) { s = i; nd++; } // consume zero or one live consonant - if ( ( i = isLiveConsonant ( ca, s, e ) ) > s ) { + if ((i = isLiveConsonant (ca, s, e)) > s) { s = i; nl++; } - return ( ( nd > 0 ) || ( nl > 0 ) ) ? s : -1; + return ((nd > 0) || (nl > 0)) ? s : -1; } } // D := ( C N? H )? - private int isDeadConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isDeadConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -245,9 +245,9 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { int nh = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; } else { @@ -255,29 +255,29 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + 1 ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // H - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { + if (isH (c)) { i++; nh++; } else { break; } } - } while ( false ); - return ( nc > 0 ) && ( nh > 0 ) ? s + i : -1; + } while (false); + return (nc > 0) && (nh > 0) ? s + i : -1; } } // L := ( (C|V) N? X* )?; where X = ( MATRA | ACCENT MARK | TONE MARK | OTHER MARK ) - private int isLiveConsonant ( int[] ca, int s, int e ) { - if ( s < 0 ) { + private int isLiveConsonant (int[] ca, int s, int e) { + if (s < 0) { return -1; } else { int c; @@ -287,12 +287,12 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { int nx = 0; do { // C - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isC ( c ) ) { + if (isC (c)) { i++; nc++; - } else if ( isV ( c ) ) { + } else if (isV (c)) { i++; nv++; } else { @@ -300,37 +300,37 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } } // N? - if ( ( s + i ) < e ) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isN ( c ) ) { + if (isN (c)) { i++; } } // X* - while ( ( s + i ) < e ) { + while ((s + i) < e) { c = ca [ s + i ]; - if ( isX ( c ) ) { + if (isX (c)) { i++; nx++; } else { break; } } - } while ( false ); + } while (false); // if no X but has H, then ignore C|I - if ( nx == 0 ) { - if ( ( s + i ) < e ) { + if (nx == 0) { + if ((s + i) < e) { c = ca [ s + i ]; - if ( isH ( c ) ) { - if ( nc > 0 ) { + if (isH (c)) { + if (nc > 0) { nc--; - } else if ( nv > 0 ) { + } else if (nv > 0) { nv--; } } } } - return ( ( nc > 0 ) || ( nv > 0 ) ) ? s + i : -1; + return ((nc > 0) || (nv > 0)) ? s + i : -1; } } } @@ -487,18 +487,18 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { C_U // 0x0A7F // UNASSIGNED }; static int typeOf(int c) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { + if ((c >= ccaStart) && (c < ccaEnd)) { return cca [ c - ccaStart ] & C_M_TYPE; } else { return C_U; } } static boolean isType(int c, int t) { - return typeOf ( c ) == t; + return typeOf (c) == t; } static boolean hasFlag(int c, int f) { - if ( ( c >= ccaStart ) && ( c < ccaEnd ) ) { - return ( cca [ c - ccaStart ] & f ) == f; + if ((c >= ccaStart) && (c < ccaEnd)) { + return (cca [ c - ccaStart ] & f) == f; } else { return false; } @@ -525,7 +525,7 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { return isType(c,C_M) && hasFlag(c,C_PRE); } static boolean isX(int c) { - switch ( typeOf ( c ) ) { + switch (typeOf (c)) { case C_M: // matra (combining vowel) case C_A: // accent mark case C_T: // tone mark @@ -543,8 +543,8 @@ public class GurmukhiScriptProcessor extends IndicScriptProcessor { } @Override - public GlyphSequence reorderCombiningMarks ( GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language ) { - return super.reorderCombiningMarks ( gdef, gs, gpa, script, language ); + public GlyphSequence reorderCombiningMarks (GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language) { + return super.reorderCombiningMarks (gdef, gs, gpa, script, language); } } diff --git a/src/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java index 26249bc22..3175884cb 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java @@ -105,15 +105,15 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { private static class SubstitutionScriptContextTester implements ScriptContextTester { private static Map/**/ testerMap = new HashMap/**/(); - public GlyphContextTester getTester ( String feature ) { - return (GlyphContextTester) testerMap.get ( feature ); + public GlyphContextTester getTester (String feature) { + return (GlyphContextTester) testerMap.get (feature); } } private static class PositioningScriptContextTester implements ScriptContextTester { private static Map/**/ testerMap = new HashMap/**/(); - public GlyphContextTester getTester ( String feature ) { - return (GlyphContextTester) testerMap.get ( feature ); + public GlyphContextTester getTester (String feature) { + return (GlyphContextTester) testerMap.get (feature); } } @@ -122,28 +122,28 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param script tag * @return script processor instance */ - public static ScriptProcessor makeProcessor ( String script ) { - switch ( CharScript.scriptCodeFromTag ( script ) ) { + public static ScriptProcessor makeProcessor (String script) { + switch (CharScript.scriptCodeFromTag (script)) { case CharScript.SCRIPT_DEVANAGARI: case CharScript.SCRIPT_DEVANAGARI_2: - return new DevanagariScriptProcessor ( script ); + return new DevanagariScriptProcessor (script); case CharScript.SCRIPT_GUJARATI: case CharScript.SCRIPT_GUJARATI_2: - return new GujaratiScriptProcessor ( script ); + return new GujaratiScriptProcessor (script); case CharScript.SCRIPT_GURMUKHI: case CharScript.SCRIPT_GURMUKHI_2: - return new GurmukhiScriptProcessor ( script ); + return new GurmukhiScriptProcessor (script); // [TBD] implement other script processors default: - return new IndicScriptProcessor ( script ); + return new IndicScriptProcessor (script); } } private final ScriptContextTester subContextTester; private final ScriptContextTester posContextTester; - IndicScriptProcessor ( String script ) { - super ( script ); + IndicScriptProcessor (String script) { + super (script); this.subContextTester = new SubstitutionScriptContextTester(); this.posContextTester = new PositioningScriptContextTester(); } @@ -180,38 +180,38 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { /** {@inheritDoc} */ @Override - public GlyphSequence substitute ( GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct ) { + public GlyphSequence substitute (GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct) { assert usa != null; // 1. syllabize - GlyphSequence[] sa = syllabize ( gs, script, language ); + GlyphSequence[] sa = syllabize (gs, script, language); // 2. process each syllable - for ( int i = 0, n = sa.length; i < n; i++ ) { + for (int i = 0, n = sa.length; i < n; i++) { GlyphSequence s = sa [ i ]; // apply basic shaping subs - for ( int j = 0, m = usa.length; j < m; j++ ) { + for (int j = 0, m = usa.length; j < m; j++) { GlyphTable.UseSpec us = usa [ j ]; - if ( isBasicShapingUse ( us ) ) { - s.setPredications ( true ); - s = us.substitute ( s, script, language, sct ); + if (isBasicShapingUse (us)) { + s.setPredications (true); + s = us.substitute (s, script, language, sct); } } // reorder pre-base matra - s = reorderPreBaseMatra ( s ); + s = reorderPreBaseMatra (s); // reorder reph - s = reorderReph ( s ); + s = reorderReph (s); // apply presentation subs - for ( int j = 0, m = usa.length; j < m; j++ ) { + for (int j = 0, m = usa.length; j < m; j++) { GlyphTable.UseSpec us = usa [ j ]; - if ( isPresentationUse ( us ) ) { - s.setPredications ( true ); - s = us.substitute ( s, script, language, sct ); + if (isPresentationUse (us)) { + s.setPredications (true); + s = us.substitute (s, script, language, sct); } } // record result sa [ i ] = s; } // 3. return reassembled substituted syllables - return unsyllabize ( gs, sa ); + return unsyllabize (gs, sa); } /** @@ -222,12 +222,12 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { return null; } - private GlyphSequence[] syllabize ( GlyphSequence gs, String script, String language ) { - return Syllabizer.getSyllabizer ( script, language, getSyllabizerClass() ) . syllabize ( gs ); + private GlyphSequence[] syllabize (GlyphSequence gs, String script, String language) { + return Syllabizer.getSyllabizer (script, language, getSyllabizerClass()) . syllabize (gs); } - private GlyphSequence unsyllabize ( GlyphSequence gs, GlyphSequence[] sa ) { - return GlyphSequence.join ( gs, sa ); + private GlyphSequence unsyllabize (GlyphSequence gs, GlyphSequence[] sa) { + return GlyphSequence.join (gs, sa); } private static Set basicShapingFeatures; @@ -247,14 +247,14 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { }; static { basicShapingFeatures = new HashSet(); - for ( String s : basicShapingFeatureStrings ) { - basicShapingFeatures.add ( s ); + for (String s : basicShapingFeatureStrings) { + basicShapingFeatures.add (s); } } - private boolean isBasicShapingUse ( GlyphTable.UseSpec us ) { + private boolean isBasicShapingUse (GlyphTable.UseSpec us) { assert us != null; - if ( basicShapingFeatures != null ) { - return basicShapingFeatures.contains ( us.getFeature() ); + if (basicShapingFeatures != null) { + return basicShapingFeatures.contains (us.getFeature()); } else { return false; } @@ -271,26 +271,26 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { }; static { presentationFeatures = new HashSet(); - for ( String s : presentationFeatureStrings ) { - presentationFeatures.add ( s ); + for (String s : presentationFeatureStrings) { + presentationFeatures.add (s); } } - private boolean isPresentationUse ( GlyphTable.UseSpec us ) { + private boolean isPresentationUse (GlyphTable.UseSpec us) { assert us != null; - if ( presentationFeatures != null ) { - return presentationFeatures.contains ( us.getFeature() ); + if (presentationFeatures != null) { + return presentationFeatures.contains (us.getFeature()); } else { return false; } } - private GlyphSequence reorderPreBaseMatra ( GlyphSequence gs ) { + private GlyphSequence reorderPreBaseMatra (GlyphSequence gs) { int source; - if ( ( source = findPreBaseMatra ( gs ) ) >= 0 ) { + if ((source = findPreBaseMatra (gs)) >= 0) { int target; - if ( ( target = findPreBaseMatraTarget ( gs, source ) ) >= 0 ) { - if ( target != source ) { - gs = reorder ( gs, source, target ); + if ((target = findPreBaseMatraTarget (gs, source)) >= 0) { + if (target != source) { + gs = reorder (gs, source, target); } } } @@ -302,7 +302,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param gs input sequence * @return index of pre-base matra or -1 if not found */ - protected int findPreBaseMatra ( GlyphSequence gs ) { + protected int findPreBaseMatra (GlyphSequence gs) { return -1; } @@ -312,17 +312,17 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param source index of pre-base matra * @return index of pre-base matra target or -1 */ - protected int findPreBaseMatraTarget ( GlyphSequence gs, int source ) { + protected int findPreBaseMatraTarget (GlyphSequence gs, int source) { return -1; } - private GlyphSequence reorderReph ( GlyphSequence gs ) { + private GlyphSequence reorderReph (GlyphSequence gs) { int source; - if ( ( source = findReph ( gs ) ) >= 0 ) { + if ((source = findReph (gs)) >= 0) { int target; - if ( ( target = findRephTarget ( gs, source ) ) >= 0 ) { - if ( target != source ) { - gs = reorder ( gs, source, target ); + if ((target = findRephTarget (gs, source)) >= 0) { + if (target != source) { + gs = reorder (gs, source, target); } } } @@ -334,7 +334,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param gs input sequence * @return index of reph or -1 if not found */ - protected int findReph ( GlyphSequence gs ) { + protected int findReph (GlyphSequence gs) { return -1; } @@ -344,18 +344,18 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param source index of reph * @return index of reph target or -1 */ - protected int findRephTarget ( GlyphSequence gs, int source ) { + protected int findRephTarget (GlyphSequence gs, int source) { return -1; } - private GlyphSequence reorder ( GlyphSequence gs, int source, int target ) { - return GlyphSequence.reorder ( gs, source, 1, target ); + private GlyphSequence reorder (GlyphSequence gs, int source, int target) { + return GlyphSequence.reorder (gs, source, 1, target); } /** {@inheritDoc} */ @Override - public boolean position ( GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct ) { - boolean adjusted = super.position ( gs, script, language, fontSize, usa, widths, adjustments, sct ); + public boolean position (GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct) { + boolean adjusted = super.position (gs, script, language, fontSize, usa, widths, adjustments, sct); return adjusted; } @@ -363,7 +363,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { protected abstract static class Syllabizer implements Comparable { private String script; private String language; - Syllabizer ( String script, String language ) { + Syllabizer (String script, String language) { this.script = script; this.language = language; } @@ -373,21 +373,21 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param gs input glyph sequence * @return segmented syllabic glyph sequences */ - abstract GlyphSequence[] syllabize ( GlyphSequence gs ); + abstract GlyphSequence[] syllabize (GlyphSequence gs); /** {@inheritDoc} */ public int hashCode() { int hc = 0; - hc = 7 * hc + ( hc ^ script.hashCode() ); - hc = 11 * hc + ( hc ^ language.hashCode() ); + hc = 7 * hc + (hc ^ script.hashCode()); + hc = 11 * hc + (hc ^ language.hashCode()); return hc; } /** {@inheritDoc} */ - public boolean equals ( Object o ) { - if ( o instanceof Syllabizer ) { + public boolean equals (Object o) { + if (o instanceof Syllabizer) { Syllabizer s = (Syllabizer) o; - if ( ! s.script.equals ( script ) ) { + if (! s.script.equals (script)) { return false; - } else if ( ! s.language.equals ( language ) ) { + } else if (! s.language.equals (language)) { return false; } else { return true; @@ -397,12 +397,12 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { } } /** {@inheritDoc} */ - public int compareTo ( Object o ) { + public int compareTo (Object o) { int d; - if ( o instanceof Syllabizer ) { + if (o instanceof Syllabizer) { Syllabizer s = (Syllabizer) o; - if ( ( d = script.compareTo ( s.script ) ) == 0 ) { - d = language.compareTo ( s.language ); + if ((d = script.compareTo (s.script)) == 0) { + d = language.compareTo (s.language); } } else { d = -1; @@ -410,32 +410,32 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { return d; } private static Map syllabizers = new HashMap(); - static Syllabizer getSyllabizer ( String script, String language, Class syllabizerClass ) { - String sid = makeSyllabizerId ( script, language ); - Syllabizer s = syllabizers.get ( sid ); - if ( s == null ) { - if ( ( s = makeSyllabizer ( script, language, syllabizerClass ) ) == null ) { - s = new DefaultSyllabizer ( script, language ); + static Syllabizer getSyllabizer (String script, String language, Class syllabizerClass) { + String sid = makeSyllabizerId (script, language); + Syllabizer s = syllabizers.get (sid); + if (s == null) { + if ((s = makeSyllabizer (script, language, syllabizerClass)) == null) { + s = new DefaultSyllabizer (script, language); } - syllabizers.put ( sid, s ); + syllabizers.put (sid, s); } return s; } - static String makeSyllabizerId ( String script, String language ) { + static String makeSyllabizerId (String script, String language) { return script + ":" + language; } - static Syllabizer makeSyllabizer ( String script, String language, Class syllabizerClass ) { + static Syllabizer makeSyllabizer (String script, String language, Class syllabizerClass) { Syllabizer s; try { - Constructor cf = syllabizerClass.getDeclaredConstructor ( new Class[] { String.class, String.class } ); - s = (Syllabizer) cf.newInstance ( script, language ); - } catch ( NoSuchMethodException e ) { + Constructor cf = syllabizerClass.getDeclaredConstructor (new Class[] { String.class, String.class }); + s = (Syllabizer) cf.newInstance (script, language); + } catch (NoSuchMethodException e) { s = null; - } catch ( InstantiationException e ) { + } catch (InstantiationException e) { s = null; - } catch ( IllegalAccessException e ) { + } catch (IllegalAccessException e) { s = null; - } catch ( InvocationTargetException e ) { + } catch (InvocationTargetException e) { s = null; } return s; @@ -444,18 +444,18 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { /** Default syllabizer. */ protected static class DefaultSyllabizer extends Syllabizer { - DefaultSyllabizer ( String script, String language ) { - super ( script, language ); + DefaultSyllabizer (String script, String language) { + super (script, language); } /** {@inheritDoc} */ @Override - GlyphSequence[] syllabize ( GlyphSequence gs ) { - int[] ca = gs.getCharacterArray ( false ); + GlyphSequence[] syllabize (GlyphSequence gs) { + int[] ca = gs.getCharacterArray (false); int nc = gs.getCharacterCount(); - if ( nc == 0 ) { + if (nc == 0) { return new GlyphSequence[] { gs }; } else { - return segmentize ( gs, segmentize ( ca, nc ) ); + return segmentize (gs, segmentize (ca, nc)); } } /** @@ -464,30 +464,30 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param nc number of characters in sequence * @return array of syllable segments */ - protected Segment[] segmentize ( int[] ca, int nc ) { - Vector sv = new Vector ( nc ); - for ( int s = 0, e = nc; s < e; ) { + protected Segment[] segmentize (int[] ca, int nc) { + Vector sv = new Vector (nc); + for (int s = 0, e = nc; s < e; ) { int i; - if ( ( i = findStartOfSyllable ( ca, s, e ) ) > s ) { + if ((i = findStartOfSyllable (ca, s, e)) > s) { // from s to i is non-syllable segment - sv.add ( new Segment ( s, i, Segment.OTHER ) ); + sv.add (new Segment (s, i, Segment.OTHER)); s = i; // move s to start of syllable - } else if ( i > s ) { + } else if (i > s) { // from s to e is non-syllable segment - sv.add ( new Segment ( s, e, Segment.OTHER ) ); + sv.add (new Segment (s, e, Segment.OTHER)); s = e; // move s to end of input sequence } - if ( ( i = findEndOfSyllable ( ca, s, e ) ) > s ) { + if ((i = findEndOfSyllable (ca, s, e)) > s) { // from s to i is syllable segment - sv.add ( new Segment ( s, i, Segment.SYLLABLE ) ); + sv.add (new Segment (s, i, Segment.SYLLABLE)); s = i; // move s to end of syllable } else { // from s to e is non-syllable segment - sv.add ( new Segment ( s, e, Segment.OTHER ) ); + sv.add (new Segment (s, e, Segment.OTHER)); s = e; // move s to end of input sequence } } - return sv.toArray ( new Segment [ sv.size() ] ); + return sv.toArray (new Segment [ sv.size() ]); } /** * Construct array of glyph sequences from original glyph sequence and segment array. @@ -495,28 +495,28 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param sa segment array * @return array of glyph sequences each belonging to an (ordered) segment in SA */ - protected GlyphSequence[] segmentize ( GlyphSequence gs, Segment[] sa ) { + protected GlyphSequence[] segmentize (GlyphSequence gs, Segment[] sa) { int ng = gs.getGlyphCount(); - int[] ga = gs.getGlyphArray ( false ); - GlyphSequence.CharAssociation[] aa = gs.getAssociations ( 0, -1 ); + int[] ga = gs.getGlyphArray (false); + GlyphSequence.CharAssociation[] aa = gs.getAssociations (0, -1); Vector nsv = new Vector(); - for ( int i = 0, ns = sa.length; i < ns; i++ ) { + for (int i = 0, ns = sa.length; i < ns; i++) { Segment s = sa [ i ]; - Vector ngv = new Vector ( ng ); - Vector nav = new Vector ( ng ); - for ( int j = 0; j < ng; j++ ) { + Vector ngv = new Vector (ng); + Vector nav = new Vector (ng); + for (int j = 0; j < ng; j++) { GlyphSequence.CharAssociation ca = aa [ j ]; - if ( ca.contained ( s.getOffset(), s.getCount() ) ) { - ngv.add ( ga [ j ] ); - nav.add ( ca ); + if (ca.contained (s.getOffset(), s.getCount())) { + ngv.add (ga [ j ]); + nav.add (ca); } } - if ( ngv.size() > 0 ) { - nsv.add ( new GlyphSequence ( gs, null, toIntArray ( ngv ), null, null, nav.toArray ( new GlyphSequence.CharAssociation [ nav.size() ] ), null ) ); + if (ngv.size() > 0) { + nsv.add (new GlyphSequence (gs, null, toIntArray (ngv), null, null, nav.toArray (new GlyphSequence.CharAssociation [ nav.size() ]), null)); } } - if ( nsv.size() > 0 ) { - return nsv.toArray ( new GlyphSequence [ nsv.size() ] ); + if (nsv.size() > 0) { + return nsv.toArray (new GlyphSequence [ nsv.size() ]); } else { return new GlyphSequence[] { gs }; } @@ -528,7 +528,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param e end index * @return index of start or E if no start found */ - protected int findStartOfSyllable ( int[] ca, int s, int e ) { + protected int findStartOfSyllable (int[] ca, int s, int e) { return e; } /** @@ -538,14 +538,14 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { * @param e end index * @return index of start or S if no end found */ - protected int findEndOfSyllable ( int[] ca, int s, int e ) { + protected int findEndOfSyllable (int[] ca, int s, int e) { return s; } - private static int[] toIntArray ( Vector iv ) { + private static int[] toIntArray (Vector iv) { int ni = iv.size(); int[] ia = new int [ iv.size() ]; - for ( int i = 0, n = ni; i < n; i++ ) { - ia [ i ] = (int) iv.get ( i ); + for (int i = 0, n = ni; i < n; i++) { + ia [ i ] = (int) iv.get (i); } return ia; } @@ -561,7 +561,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor { private int end; private int type; - Segment ( int start, int end, int type ) { + Segment (int start, int end, int type) { this.start = start; this.end = end; this.type = type; diff --git a/src/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java b/src/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java index d8223bf47..e6529eb2c 100644 --- a/src/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java +++ b/src/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java @@ -55,9 +55,9 @@ public abstract class ScriptProcessor { * Instantiate a script processor. * @param script a script identifier */ - protected ScriptProcessor ( String script ) { - if ( ( script == null ) || ( script.length() == 0 ) ) { - throw new IllegalArgumentException ( "script must be non-empty string" ); + protected ScriptProcessor (String script) { + if ((script == null) || (script.length() == 0)) { + throw new IllegalArgumentException ("script must be non-empty string"); } else { this.script = script; this.assembledLookups = new HashMap/**/(); @@ -98,8 +98,8 @@ public abstract class ScriptProcessor { * @param lookups a mapping from lookup specifications to glyph subtables to use for substitution processing * @return the substituted (output) glyph sequence */ - public final GlyphSequence substitute ( GlyphSubstitutionTable gsub, GlyphSequence gs, String script, String language, Map/*>>*/ lookups ) { - return substitute ( gs, script, language, assembleLookups ( gsub, getSubstitutionFeatures(), lookups ), getSubstitutionContextTester() ); + public final GlyphSequence substitute (GlyphSubstitutionTable gsub, GlyphSequence gs, String script, String language, Map/*>>*/ lookups) { + return substitute (gs, script, language, assembleLookups (gsub, getSubstitutionFeatures(), lookups), getSubstitutionContextTester()); } /** @@ -111,11 +111,11 @@ public abstract class ScriptProcessor { * @param sct a script specific context tester (or null) * @return the substituted (output) glyph sequence */ - public GlyphSequence substitute ( GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct ) { + public GlyphSequence substitute (GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct) { assert usa != null; - for ( int i = 0, n = usa.length; i < n; i++ ) { + for (int i = 0, n = usa.length; i < n; i++) { GlyphTable.UseSpec us = usa [ i ]; - gs = us.substitute ( gs, script, language, sct ); + gs = us.substitute (gs, script, language, sct); } return gs; } @@ -132,7 +132,7 @@ public abstract class ScriptProcessor { * @param language a language identifier * @return the reordered (output) glyph sequence */ - public GlyphSequence reorderCombiningMarks ( GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language ) { + public GlyphSequence reorderCombiningMarks (GlyphDefinitionTable gdef, GlyphSequence gs, int[][] gpa, String script, String language) { return gs; } @@ -169,8 +169,8 @@ public abstract class ScriptProcessor { * with one 4-tuple for each element of glyph sequence * @return true if some adjustment is not zero; otherwise, false */ - public final boolean position ( GlyphPositioningTable gpos, GlyphSequence gs, String script, String language, int fontSize, Map/*>*/ lookups, int[] widths, int[][] adjustments ) { - return position ( gs, script, language, fontSize, assembleLookups ( gpos, getPositioningFeatures(), lookups ), widths, adjustments, getPositioningContextTester() ); + public final boolean position (GlyphPositioningTable gpos, GlyphSequence gs, String script, String language, int fontSize, Map/*>*/ lookups, int[] widths, int[][] adjustments) { + return position (gs, script, language, fontSize, assembleLookups (gpos, getPositioningFeatures(), lookups), widths, adjustments, getPositioningContextTester()); } /** @@ -186,12 +186,12 @@ public abstract class ScriptProcessor { * @param sct a script specific context tester (or null) * @return true if some adjustment is not zero; otherwise, false */ - public boolean position ( GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct ) { + public boolean position (GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct) { assert usa != null; boolean adjusted = false; - for ( int i = 0, n = usa.length; i < n; i++ ) { + for (int i = 0, n = usa.length; i < n; i++) { GlyphTable.UseSpec us = usa [ i ]; - if ( us.position ( gs, script, language, fontSize, widths, adjustments, sct ) ) { + if (us.position (gs, script, language, fontSize, widths, adjustments, sct)) { adjusted = true; } } @@ -206,22 +206,22 @@ public abstract class ScriptProcessor { * @param lookups a mapping from lookup specifications to lists of look tables from which to select lookup tables according to the specified features * @return ordered array of assembled lookup table use specifications */ - public final GlyphTable.UseSpec[] assembleLookups ( GlyphTable table, String[] features, Map/*>*/ lookups ) { - AssembledLookupsKey key = new AssembledLookupsKey ( table, features, lookups ); + public final GlyphTable.UseSpec[] assembleLookups (GlyphTable table, String[] features, Map/*>*/ lookups) { + AssembledLookupsKey key = new AssembledLookupsKey (table, features, lookups); GlyphTable.UseSpec[] usa; - if ( ( usa = assembledLookupsGet ( key ) ) != null ) { + if ((usa = assembledLookupsGet (key)) != null) { return usa; } else { - return assembledLookupsPut ( key, table.assembleLookups ( features, lookups ) ); + return assembledLookupsPut (key, table.assembleLookups (features, lookups)); } } - private GlyphTable.UseSpec[] assembledLookupsGet ( AssembledLookupsKey key ) { - return (GlyphTable.UseSpec[]) assembledLookups.get ( key ); + private GlyphTable.UseSpec[] assembledLookupsGet (AssembledLookupsKey key) { + return (GlyphTable.UseSpec[]) assembledLookups.get (key); } - private GlyphTable.UseSpec[] assembledLookupsPut ( AssembledLookupsKey key, GlyphTable.UseSpec[] usa ) { - assembledLookups.put ( key, usa ); + private GlyphTable.UseSpec[] assembledLookupsPut (AssembledLookupsKey key, GlyphTable.UseSpec[] usa) { + assembledLookups.put (key, usa); return usa; } @@ -230,25 +230,25 @@ public abstract class ScriptProcessor { * @param script a script identifier * @return a script processor instance or null if none found */ - public static synchronized ScriptProcessor getInstance ( String script ) { + public static synchronized ScriptProcessor getInstance (String script) { ScriptProcessor sp = null; assert processors != null; - if ( ( sp = processors.get ( script ) ) == null ) { - processors.put ( script, sp = createProcessor ( script ) ); + if ((sp = processors.get (script)) == null) { + processors.put (script, sp = createProcessor (script)); } return sp; } // [TBD] - rework to provide more configurable binding between script name and script processor constructor - private static ScriptProcessor createProcessor ( String script ) { + private static ScriptProcessor createProcessor (String script) { ScriptProcessor sp = null; - int sc = CharScript.scriptCodeFromTag ( script ); - if ( sc == CharScript.SCRIPT_ARABIC ) { - sp = new ArabicScriptProcessor ( script ); - } else if ( CharScript.isIndicScript ( sc ) ) { - sp = IndicScriptProcessor.makeProcessor ( script ); + int sc = CharScript.scriptCodeFromTag (script); + if (sc == CharScript.SCRIPT_ARABIC) { + sp = new ArabicScriptProcessor (script); + } else if (CharScript.isIndicScript (sc)) { + sp = IndicScriptProcessor.makeProcessor (script); } else { - sp = new DefaultScriptProcessor ( script ); + sp = new DefaultScriptProcessor (script); } return sp; } @@ -259,7 +259,7 @@ public abstract class ScriptProcessor { private final String[] features; private final Map/*>*/ lookups; - AssembledLookupsKey ( GlyphTable table, String[] features, Map/*>*/ lookups ) { + AssembledLookupsKey (GlyphTable table, String[] features, Map/*>*/ lookups) { this.table = table; this.features = features; this.lookups = lookups; @@ -268,21 +268,21 @@ public abstract class ScriptProcessor { /** {@inheritDoc} */ public int hashCode() { int hc = 0; - hc = 7 * hc + ( hc ^ table.hashCode() ); - hc = 11 * hc + ( hc ^ Arrays.hashCode ( features ) ); - hc = 17 * hc + ( hc ^ lookups.hashCode() ); + hc = 7 * hc + (hc ^ table.hashCode()); + hc = 11 * hc + (hc ^ Arrays.hashCode (features)); + hc = 17 * hc + (hc ^ lookups.hashCode()); return hc; } /** {@inheritDoc} */ - public boolean equals ( Object o ) { - if ( o instanceof AssembledLookupsKey ) { + public boolean equals (Object o) { + if (o instanceof AssembledLookupsKey) { AssembledLookupsKey k = (AssembledLookupsKey) o; - if ( ! table.equals ( k.table ) ) { + if (! table.equals (k.table)) { return false; - } else if ( ! Arrays.equals ( features, k.features ) ) { + } else if (! Arrays.equals (features, k.features)) { return false; - } else if ( ! lookups.equals ( k.lookups ) ) { + } else if (! lookups.equals (k.lookups)) { return false; } else { return true; diff --git a/src/java/org/apache/fop/complexscripts/util/CharMirror.java b/src/java/org/apache/fop/complexscripts/util/CharMirror.java index 2490b750c..c0e2cbc4d 100644 --- a/src/java/org/apache/fop/complexscripts/util/CharMirror.java +++ b/src/java/org/apache/fop/complexscripts/util/CharMirror.java @@ -36,10 +36,10 @@ public final class CharMirror { * @param s a string whose characters are to be mirrored * @return the resulting string */ - public static String mirror ( String s ) { - StringBuffer sb = new StringBuffer ( s ); - for ( int i = 0, n = sb.length(); i < n; i++ ) { - sb.setCharAt ( i, (char) mirror ( sb.charAt ( i ) ) ); + public static String mirror (String s) { + StringBuffer sb = new StringBuffer (s); + for (int i = 0, n = sb.length(); i < n; i++) { + sb.setCharAt (i, (char) mirror (sb.charAt (i))); } return sb.toString(); } @@ -704,9 +704,9 @@ public final class CharMirror { 0xFF62 }; - private static int mirror ( int c ) { - int i = Arrays.binarySearch ( mirroredCharacters, c ); - if ( i < 0 ) { + private static int mirror (int c) { + int i = Arrays.binarySearch (mirroredCharacters, c); + if (i < 0) { return c; } else { return mirroredCharactersMapping [ i ]; diff --git a/src/java/org/apache/fop/complexscripts/util/CharScript.java b/src/java/org/apache/fop/complexscripts/util/CharScript.java index d85985b17..bd8f45373 100644 --- a/src/java/org/apache/fop/complexscripts/util/CharScript.java +++ b/src/java/org/apache/fop/complexscripts/util/CharScript.java @@ -143,24 +143,24 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character is punctuation */ - public static boolean isPunctuation ( int c ) { - if ( ( c >= 0x0021 ) && ( c <= 0x002F ) ) { // basic latin punctuation + public static boolean isPunctuation (int c) { + if ((c >= 0x0021) && (c <= 0x002F)) { // basic latin punctuation return true; - } else if ( ( c >= 0x003A ) && ( c <= 0x0040 ) ) { // basic latin punctuation + } else if ((c >= 0x003A) && (c <= 0x0040)) { // basic latin punctuation return true; - } else if ( ( c >= 0x005F ) && ( c <= 0x0060 ) ) { // basic latin punctuation + } else if ((c >= 0x005F) && (c <= 0x0060)) { // basic latin punctuation return true; - } else if ( ( c >= 0x007E ) && ( c <= 0x007E ) ) { // basic latin punctuation + } else if ((c >= 0x007E) && (c <= 0x007E)) { // basic latin punctuation return true; - } else if ( ( c >= 0x007E ) && ( c <= 0x007E ) ) { // basic latin punctuation + } else if ((c >= 0x007E) && (c <= 0x007E)) { // basic latin punctuation return true; - } else if ( ( c >= 0x00A1 ) && ( c <= 0x00BF ) ) { // latin supplement punctuation + } else if ((c >= 0x00A1) && (c <= 0x00BF)) { // latin supplement punctuation return true; - } else if ( ( c >= 0x00D7 ) && ( c <= 0x00D7 ) ) { // latin supplement punctuation + } else if ((c >= 0x00D7) && (c <= 0x00D7)) { // latin supplement punctuation return true; - } else if ( ( c >= 0x00F7 ) && ( c <= 0x00F7 ) ) { // latin supplement punctuation + } else if ((c >= 0x00F7) && (c <= 0x00F7)) { // latin supplement punctuation return true; - } else if ( ( c >= 0x2000 ) && ( c <= 0x206F ) ) { // general punctuation + } else if ((c >= 0x2000) && (c <= 0x206F)) { // general punctuation return true; } else { // [TBD] - not complete return false; @@ -172,8 +172,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character is a digit */ - public static boolean isDigit ( int c ) { - if ( ( c >= 0x0030 ) && ( c <= 0x0039 ) ) { // basic latin digits + public static boolean isDigit (int c) { + if ((c >= 0x0030) && (c <= 0x0039)) { // basic latin digits return true; } else { // [TBD] - not complete return false; @@ -185,10 +185,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to hebrew script */ - public static boolean isHebrew ( int c ) { - if ( ( c >= 0x0590 ) && ( c <= 0x05FF ) ) { // hebrew block + public static boolean isHebrew (int c) { + if ((c >= 0x0590) && (c <= 0x05FF)) { // hebrew block return true; - } else if ( ( c >= 0xFB00 ) && ( c <= 0xFB4F ) ) { // hebrew presentation forms block + } else if ((c >= 0xFB00) && (c <= 0xFB4F)) { // hebrew presentation forms block return true; } else { return false; @@ -200,8 +200,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to mongolian script */ - public static boolean isMongolian ( int c ) { - if ( ( c >= 0x1800 ) && ( c <= 0x18AF ) ) { // mongolian block + public static boolean isMongolian (int c) { + if ((c >= 0x1800) && (c <= 0x18AF)) { // mongolian block return true; } else { return false; @@ -213,14 +213,14 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to arabic script */ - public static boolean isArabic ( int c ) { - if ( ( c >= 0x0600 ) && ( c <= 0x06FF ) ) { // arabic block + public static boolean isArabic (int c) { + if ((c >= 0x0600) && (c <= 0x06FF)) { // arabic block return true; - } else if ( ( c >= 0x0750 ) && ( c <= 0x077F ) ) { // arabic supplement block + } else if ((c >= 0x0750) && (c <= 0x077F)) { // arabic supplement block return true; - } else if ( ( c >= 0xFB50 ) && ( c <= 0xFDFF ) ) { // arabic presentation forms a block + } else if ((c >= 0xFB50) && (c <= 0xFDFF)) { // arabic presentation forms a block return true; - } else if ( ( c >= 0xFE70 ) && ( c <= 0xFEFF ) ) { // arabic presentation forms b block + } else if ((c >= 0xFE70) && (c <= 0xFEFF)) { // arabic presentation forms b block return true; } else { return false; @@ -232,10 +232,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to greek script */ - public static boolean isGreek ( int c ) { - if ( ( c >= 0x0370 ) && ( c <= 0x03FF ) ) { // greek (and coptic) block + public static boolean isGreek (int c) { + if ((c >= 0x0370) && (c <= 0x03FF)) { // greek (and coptic) block return true; - } else if ( ( c >= 0x1F00 ) && ( c <= 0x1FFF ) ) { // greek extended block + } else if ((c >= 0x1F00) && (c <= 0x1FFF)) { // greek extended block return true; } else { return false; @@ -247,30 +247,30 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to latin script */ - public static boolean isLatin ( int c ) { - if ( ( c >= 0x0041 ) && ( c <= 0x005A ) ) { // basic latin upper case + public static boolean isLatin (int c) { + if ((c >= 0x0041) && (c <= 0x005A)) { // basic latin upper case return true; - } else if ( ( c >= 0x0061 ) && ( c <= 0x007A ) ) { // basic latin lower case + } else if ((c >= 0x0061) && (c <= 0x007A)) { // basic latin lower case return true; - } else if ( ( c >= 0x00C0 ) && ( c <= 0x00D6 ) ) { // latin supplement upper case + } else if ((c >= 0x00C0) && (c <= 0x00D6)) { // latin supplement upper case return true; - } else if ( ( c >= 0x00D8 ) && ( c <= 0x00DF ) ) { // latin supplement upper case + } else if ((c >= 0x00D8) && (c <= 0x00DF)) { // latin supplement upper case return true; - } else if ( ( c >= 0x00E0 ) && ( c <= 0x00F6 ) ) { // latin supplement lower case + } else if ((c >= 0x00E0) && (c <= 0x00F6)) { // latin supplement lower case return true; - } else if ( ( c >= 0x00F8 ) && ( c <= 0x00FF ) ) { // latin supplement lower case + } else if ((c >= 0x00F8) && (c <= 0x00FF)) { // latin supplement lower case return true; - } else if ( ( c >= 0x0100 ) && ( c <= 0x017F ) ) { // latin extended a + } else if ((c >= 0x0100) && (c <= 0x017F)) { // latin extended a return true; - } else if ( ( c >= 0x0180 ) && ( c <= 0x024F ) ) { // latin extended b + } else if ((c >= 0x0180) && (c <= 0x024F)) { // latin extended b return true; - } else if ( ( c >= 0x1E00 ) && ( c <= 0x1EFF ) ) { // latin extended additional + } else if ((c >= 0x1E00) && (c <= 0x1EFF)) { // latin extended additional return true; - } else if ( ( c >= 0x2C60 ) && ( c <= 0x2C7F ) ) { // latin extended c + } else if ((c >= 0x2C60) && (c <= 0x2C7F)) { // latin extended c return true; - } else if ( ( c >= 0xA720 ) && ( c <= 0xA7FF ) ) { // latin extended d + } else if ((c >= 0xA720) && (c <= 0xA7FF)) { // latin extended d return true; - } else if ( ( c >= 0xFB00 ) && ( c <= 0xFB0F ) ) { // latin ligatures + } else if ((c >= 0xFB00) && (c <= 0xFB0F)) { // latin ligatures return true; } else { return false; @@ -282,14 +282,14 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to cyrillic script */ - public static boolean isCyrillic ( int c ) { - if ( ( c >= 0x0400 ) && ( c <= 0x04FF ) ) { // cyrillic block + public static boolean isCyrillic (int c) { + if ((c >= 0x0400) && (c <= 0x04FF)) { // cyrillic block return true; - } else if ( ( c >= 0x0500 ) && ( c <= 0x052F ) ) { // cyrillic supplement block + } else if ((c >= 0x0500) && (c <= 0x052F)) { // cyrillic supplement block return true; - } else if ( ( c >= 0x2DE0 ) && ( c <= 0x2DFF ) ) { // cyrillic extended-a block + } else if ((c >= 0x2DE0) && (c <= 0x2DFF)) { // cyrillic extended-a block return true; - } else if ( ( c >= 0xA640 ) && ( c <= 0xA69F ) ) { // cyrillic extended-b block + } else if ((c >= 0xA640) && (c <= 0xA69F)) { // cyrillic extended-b block return true; } else { return false; @@ -301,10 +301,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to georgian script */ - public static boolean isGeorgian ( int c ) { - if ( ( c >= 0x10A0 ) && ( c <= 0x10FF ) ) { // georgian block + public static boolean isGeorgian (int c) { + if ((c >= 0x10A0) && (c <= 0x10FF)) { // georgian block return true; - } else if ( ( c >= 0x2D00 ) && ( c <= 0x2D2F ) ) { // georgian supplement block + } else if ((c >= 0x2D00) && (c <= 0x2D2F)) { // georgian supplement block return true; } else { return false; @@ -316,16 +316,16 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to hangul script */ - public static boolean isHangul ( int c ) { - if ( ( c >= 0x1100 ) && ( c <= 0x11FF ) ) { // hangul jamo + public static boolean isHangul (int c) { + if ((c >= 0x1100) && (c <= 0x11FF)) { // hangul jamo return true; - } else if ( ( c >= 0x3130 ) && ( c <= 0x318F ) ) { // hangul compatibility jamo + } else if ((c >= 0x3130) && (c <= 0x318F)) { // hangul compatibility jamo return true; - } else if ( ( c >= 0xA960 ) && ( c <= 0xA97F ) ) { // hangul jamo extended a + } else if ((c >= 0xA960) && (c <= 0xA97F)) { // hangul jamo extended a return true; - } else if ( ( c >= 0xAC00 ) && ( c <= 0xD7A3 ) ) { // hangul syllables + } else if ((c >= 0xAC00) && (c <= 0xD7A3)) { // hangul syllables return true; - } else if ( ( c >= 0xD7B0 ) && ( c <= 0xD7FF ) ) { // hangul jamo extended a + } else if ((c >= 0xD7B0) && (c <= 0xD7FF)) { // hangul jamo extended a return true; } else { return false; @@ -337,8 +337,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to gurmukhi script */ - public static boolean isGurmukhi ( int c ) { - if ( ( c >= 0x0A00 ) && ( c <= 0x0A7F ) ) { // gurmukhi block + public static boolean isGurmukhi (int c) { + if ((c >= 0x0A00) && (c <= 0x0A7F)) { // gurmukhi block return true; } else { return false; @@ -350,10 +350,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to devanagari script */ - public static boolean isDevanagari ( int c ) { - if ( ( c >= 0x0900 ) && ( c <= 0x097F ) ) { // devangari block + public static boolean isDevanagari (int c) { + if ((c >= 0x0900) && (c <= 0x097F)) { // devangari block return true; - } else if ( ( c >= 0xA8E0 ) && ( c <= 0xA8FF ) ) { // devangari extended block + } else if ((c >= 0xA8E0) && (c <= 0xA8FF)) { // devangari extended block return true; } else { return false; @@ -365,8 +365,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to gujarati script */ - public static boolean isGujarati ( int c ) { - if ( ( c >= 0x0A80 ) && ( c <= 0x0AFF ) ) { // gujarati block + public static boolean isGujarati (int c) { + if ((c >= 0x0A80) && (c <= 0x0AFF)) { // gujarati block return true; } else { return false; @@ -378,8 +378,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to bengali script */ - public static boolean isBengali ( int c ) { - if ( ( c >= 0x0980 ) && ( c <= 0x09FF ) ) { // bengali block + public static boolean isBengali (int c) { + if ((c >= 0x0980) && (c <= 0x09FF)) { // bengali block return true; } else { return false; @@ -391,8 +391,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to oriya script */ - public static boolean isOriya ( int c ) { - if ( ( c >= 0x0B00 ) && ( c <= 0x0B7F ) ) { // oriya block + public static boolean isOriya (int c) { + if ((c >= 0x0B00) && (c <= 0x0B7F)) { // oriya block return true; } else { return false; @@ -404,8 +404,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to tibetan script */ - public static boolean isTibetan ( int c ) { - if ( ( c >= 0x0F00 ) && ( c <= 0x0FFF ) ) { // tibetan block + public static boolean isTibetan (int c) { + if ((c >= 0x0F00) && (c <= 0x0FFF)) { // tibetan block return true; } else { return false; @@ -417,8 +417,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to telugu script */ - public static boolean isTelugu ( int c ) { - if ( ( c >= 0x0C00 ) && ( c <= 0x0C7F ) ) { // telugu block + public static boolean isTelugu (int c) { + if ((c >= 0x0C00) && (c <= 0x0C7F)) { // telugu block return true; } else { return false; @@ -430,8 +430,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to kannada script */ - public static boolean isKannada ( int c ) { - if ( ( c >= 0x0C00 ) && ( c <= 0x0C7F ) ) { // kannada block + public static boolean isKannada (int c) { + if ((c >= 0x0C00) && (c <= 0x0C7F)) { // kannada block return true; } else { return false; @@ -443,8 +443,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to tamil script */ - public static boolean isTamil ( int c ) { - if ( ( c >= 0x0B80 ) && ( c <= 0x0BFF ) ) { // tamil block + public static boolean isTamil (int c) { + if ((c >= 0x0B80) && (c <= 0x0BFF)) { // tamil block return true; } else { return false; @@ -456,8 +456,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to malayalam script */ - public static boolean isMalayalam ( int c ) { - if ( ( c >= 0x0D00 ) && ( c <= 0x0D7F ) ) { // malayalam block + public static boolean isMalayalam (int c) { + if ((c >= 0x0D00) && (c <= 0x0D7F)) { // malayalam block return true; } else { return false; @@ -469,8 +469,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to sinhalese script */ - public static boolean isSinhalese ( int c ) { - if ( ( c >= 0x0D80 ) && ( c <= 0x0DFF ) ) { // sinhala block + public static boolean isSinhalese (int c) { + if ((c >= 0x0D80) && (c <= 0x0DFF)) { // sinhala block return true; } else { return false; @@ -482,10 +482,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to burmese script */ - public static boolean isBurmese ( int c ) { - if ( ( c >= 0x1000 ) && ( c <= 0x109F ) ) { // burmese (myanmar) block + public static boolean isBurmese (int c) { + if ((c >= 0x1000) && (c <= 0x109F)) { // burmese (myanmar) block return true; - } else if ( ( c >= 0xAA60 ) && ( c <= 0xAA7F ) ) { // burmese (myanmar) extended block + } else if ((c >= 0xAA60) && (c <= 0xAA7F)) { // burmese (myanmar) extended block return true; } else { return false; @@ -497,8 +497,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to thai script */ - public static boolean isThai ( int c ) { - if ( ( c >= 0x0E00 ) && ( c <= 0x0E7F ) ) { // thai block + public static boolean isThai (int c) { + if ((c >= 0x0E00) && (c <= 0x0E7F)) { // thai block return true; } else { return false; @@ -510,10 +510,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to khmer script */ - public static boolean isKhmer ( int c ) { - if ( ( c >= 0x1780 ) && ( c <= 0x17FF ) ) { // khmer block + public static boolean isKhmer (int c) { + if ((c >= 0x1780) && (c <= 0x17FF)) { // khmer block return true; - } else if ( ( c >= 0x19E0 ) && ( c <= 0x19FF ) ) { // khmer symbols block + } else if ((c >= 0x19E0) && (c <= 0x19FF)) { // khmer symbols block return true; } else { return false; @@ -525,8 +525,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to lao script */ - public static boolean isLao ( int c ) { - if ( ( c >= 0x0E80 ) && ( c <= 0x0EFF ) ) { // lao block + public static boolean isLao (int c) { + if ((c >= 0x0E80) && (c <= 0x0EFF)) { // lao block return true; } else { return false; @@ -538,14 +538,14 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to ethiopic (amharic) script */ - public static boolean isEthiopic ( int c ) { - if ( ( c >= 0x1200 ) && ( c <= 0x137F ) ) { // ethiopic block + public static boolean isEthiopic (int c) { + if ((c >= 0x1200) && (c <= 0x137F)) { // ethiopic block return true; - } else if ( ( c >= 0x1380 ) && ( c <= 0x139F ) ) { // ethoipic supplement block + } else if ((c >= 0x1380) && (c <= 0x139F)) { // ethoipic supplement block return true; - } else if ( ( c >= 0x2D80 ) && ( c <= 0x2DDF ) ) { // ethoipic extended block + } else if ((c >= 0x2D80) && (c <= 0x2DDF)) { // ethoipic extended block return true; - } else if ( ( c >= 0xAB00 ) && ( c <= 0xAB2F ) ) { // ethoipic extended-a block + } else if ((c >= 0xAB00) && (c <= 0xAB2F)) { // ethoipic extended-a block return true; } else { return false; @@ -557,18 +557,18 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to han (unified cjk) script */ - public static boolean isHan ( int c ) { - if ( ( c >= 0x3400 ) && ( c <= 0x4DBF ) ) { + public static boolean isHan (int c) { + if ((c >= 0x3400) && (c <= 0x4DBF)) { return true; // cjk unified ideographs extension a - } else if ( ( c >= 0x4E00 ) && ( c <= 0x9FFF ) ) { + } else if ((c >= 0x4E00) && (c <= 0x9FFF)) { return true; // cjk unified ideographs - } else if ( ( c >= 0xF900 ) && ( c <= 0xFAFF ) ) { + } else if ((c >= 0xF900) && (c <= 0xFAFF)) { return true; // cjk compatibility ideographs - } else if ( ( c >= 0x20000 ) && ( c <= 0x2A6DF ) ) { + } else if ((c >= 0x20000) && (c <= 0x2A6DF)) { return true; // cjk unified ideographs extension b - } else if ( ( c >= 0x2A700 ) && ( c <= 0x2B73F ) ) { + } else if ((c >= 0x2A700) && (c <= 0x2B73F)) { return true; // cjk unified ideographs extension c - } else if ( ( c >= 0x2F800 ) && ( c <= 0x2FA1F ) ) { + } else if ((c >= 0x2F800) && (c <= 0x2FA1F)) { return true; // cjk compatibility ideographs supplement } else { return false; @@ -580,8 +580,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to bopomofo script */ - public static boolean isBopomofo ( int c ) { - if ( ( c >= 0x3100 ) && ( c <= 0x312F ) ) { + public static boolean isBopomofo (int c) { + if ((c >= 0x3100) && (c <= 0x312F)) { return true; } else { return false; @@ -593,8 +593,8 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to hiragana script */ - public static boolean isHiragana ( int c ) { - if ( ( c >= 0x3040 ) && ( c <= 0x309F ) ) { + public static boolean isHiragana (int c) { + if ((c >= 0x3040) && (c <= 0x309F)) { return true; } else { return false; @@ -606,10 +606,10 @@ public final class CharScript { * @param c a character represented as a unicode scalar value * @return true if character belongs to katakana script */ - public static boolean isKatakana ( int c ) { - if ( ( c >= 0x30A0 ) && ( c <= 0x30FF ) ) { + public static boolean isKatakana (int c) { + if ((c >= 0x30A0) && (c <= 0x30FF)) { return true; - } else if ( ( c >= 0x31F0 ) && ( c <= 0x31FF ) ) { + } else if ((c >= 0x31F0) && (c <= 0x31FF)) { return true; } else { return false; @@ -622,68 +622,68 @@ public final class CharScript { * @param c the character to obtain script * @return an ISO15924 script code */ - public static int scriptOf ( int c ) { // [TBD] - needs optimization!!! - if ( CharUtilities.isAnySpace ( c ) ) { + public static int scriptOf (int c) { // [TBD] - needs optimization!!! + if (CharUtilities.isAnySpace (c)) { return SCRIPT_UNDETERMINED; - } else if ( isPunctuation ( c ) ) { + } else if (isPunctuation (c)) { return SCRIPT_UNDETERMINED; - } else if ( isDigit ( c ) ) { + } else if (isDigit (c)) { return SCRIPT_UNDETERMINED; - } else if ( isLatin ( c ) ) { + } else if (isLatin (c)) { return SCRIPT_LATIN; - } else if ( isCyrillic ( c ) ) { + } else if (isCyrillic (c)) { return SCRIPT_CYRILLIC; - } else if ( isGreek ( c ) ) { + } else if (isGreek (c)) { return SCRIPT_GREEK; - } else if ( isHan ( c ) ) { + } else if (isHan (c)) { return SCRIPT_HAN; - } else if ( isBopomofo ( c ) ) { + } else if (isBopomofo (c)) { return SCRIPT_BOPOMOFO; - } else if ( isKatakana ( c ) ) { + } else if (isKatakana (c)) { return SCRIPT_KATAKANA; - } else if ( isHiragana ( c ) ) { + } else if (isHiragana (c)) { return SCRIPT_HIRAGANA; - } else if ( isHangul ( c ) ) { + } else if (isHangul (c)) { return SCRIPT_HANGUL; - } else if ( isArabic ( c ) ) { + } else if (isArabic (c)) { return SCRIPT_ARABIC; - } else if ( isHebrew ( c ) ) { + } else if (isHebrew (c)) { return SCRIPT_HEBREW; - } else if ( isMongolian ( c ) ) { + } else if (isMongolian (c)) { return SCRIPT_MONGOLIAN; - } else if ( isGeorgian ( c ) ) { + } else if (isGeorgian (c)) { return SCRIPT_GEORGIAN; - } else if ( isGurmukhi ( c ) ) { - return useV2IndicRules ( SCRIPT_GURMUKHI ); - } else if ( isDevanagari ( c ) ) { - return useV2IndicRules ( SCRIPT_DEVANAGARI ); - } else if ( isGujarati ( c ) ) { - return useV2IndicRules ( SCRIPT_GUJARATI ); - } else if ( isBengali ( c ) ) { - return useV2IndicRules ( SCRIPT_BENGALI ); - } else if ( isOriya ( c ) ) { - return useV2IndicRules ( SCRIPT_ORIYA ); - } else if ( isTibetan ( c ) ) { + } else if (isGurmukhi (c)) { + return useV2IndicRules (SCRIPT_GURMUKHI); + } else if (isDevanagari (c)) { + return useV2IndicRules (SCRIPT_DEVANAGARI); + } else if (isGujarati (c)) { + return useV2IndicRules (SCRIPT_GUJARATI); + } else if (isBengali (c)) { + return useV2IndicRules (SCRIPT_BENGALI); + } else if (isOriya (c)) { + return useV2IndicRules (SCRIPT_ORIYA); + } else if (isTibetan (c)) { return SCRIPT_TIBETAN; - } else if ( isTelugu ( c ) ) { - return useV2IndicRules ( SCRIPT_TELUGU ); - } else if ( isKannada ( c ) ) { - return useV2IndicRules ( SCRIPT_KANNADA ); - } else if ( isTamil ( c ) ) { - return useV2IndicRules ( SCRIPT_TAMIL ); - } else if ( isMalayalam ( c ) ) { - return useV2IndicRules ( SCRIPT_MALAYALAM ); - } else if ( isSinhalese ( c ) ) { + } else if (isTelugu (c)) { + return useV2IndicRules (SCRIPT_TELUGU); + } else if (isKannada (c)) { + return useV2IndicRules (SCRIPT_KANNADA); + } else if (isTamil (c)) { + return useV2IndicRules (SCRIPT_TAMIL); + } else if (isMalayalam (c)) { + return useV2IndicRules (SCRIPT_MALAYALAM); + } else if (isSinhalese (c)) { return SCRIPT_SINHALESE; - } else if ( isBurmese ( c ) ) { + } else if (isBurmese (c)) { return SCRIPT_BURMESE; - } else if ( isThai ( c ) ) { + } else if (isThai (c)) { return SCRIPT_THAI; - } else if ( isKhmer ( c ) ) { + } else if (isKhmer (c)) { return SCRIPT_KHMER; - } else if ( isLao ( c ) ) { + } else if (isLao (c)) { return SCRIPT_LAO; - } else if ( isEthiopic ( c ) ) { + } else if (isEthiopic (c)) { return SCRIPT_ETHIOPIC; } else { return SCRIPT_UNDETERMINED; @@ -696,9 +696,9 @@ public final class CharScript { * @param sc a V1 indic script code * @return either SC or the V2 flavor of SC if V2 indic rules apply */ - public static int useV2IndicRules ( int sc ) { - if ( useV2Indic ) { - return ( sc < 1000 ) ? ( sc + 1000 ) : sc; + public static int useV2IndicRules (int sc) { + if (useV2Indic) { + return (sc < 1000) ? (sc + 1000) : sc; } else { return sc; } @@ -711,17 +711,17 @@ public final class CharScript { * @param cs the character sequence * @return a (possibly empty) array of script codes */ - public static int[] scriptsOf ( CharSequence cs ) { + public static int[] scriptsOf (CharSequence cs) { Set s = new HashSet(); - for ( int i = 0, n = cs.length(); i < n; i++ ) { - s.add ( Integer.valueOf ( scriptOf ( cs.charAt ( i ) ) ) ); + for (int i = 0, n = cs.length(); i < n; i++) { + s.add (Integer.valueOf (scriptOf (cs.charAt (i)))); } int[] sa = new int [ s.size() ]; int ns = 0; - for ( Iterator it = s.iterator(); it.hasNext();) { - sa [ ns++ ] = ( (Integer) it.next() ) .intValue(); + for (Iterator it = s.iterator(); it.hasNext();) { + sa [ ns++ ] = ((Integer) it.next()) .intValue(); } - Arrays.sort ( sa ); + Arrays.sort (sa); return sa; } @@ -730,26 +730,26 @@ public final class CharScript { * @param cs the character sequence * @return the dominant script or SCRIPT_UNDETERMINED */ - public static int dominantScript ( CharSequence cs ) { + public static int dominantScript (CharSequence cs) { Map m = new HashMap(); - for ( int i = 0, n = cs.length(); i < n; i++ ) { - int c = cs.charAt ( i ); - int s = scriptOf ( c ); - Integer k = Integer.valueOf ( s ); - Integer v = (Integer) m.get ( k ); - if ( v != null ) { - m.put ( k, Integer.valueOf ( v.intValue() + 1 ) ); + for (int i = 0, n = cs.length(); i < n; i++) { + int c = cs.charAt (i); + int s = scriptOf (c); + Integer k = Integer.valueOf (s); + Integer v = (Integer) m.get (k); + if (v != null) { + m.put (k, Integer.valueOf (v.intValue() + 1)); } else { - m.put ( k, Integer.valueOf ( 0 ) ); + m.put (k, Integer.valueOf (0)); } } int sMax = -1; int cMax = -1; - for ( Iterator it = m.entrySet().iterator(); it.hasNext();) { + for (Iterator it = m.entrySet().iterator(); it.hasNext();) { Map.Entry e = (Map.Entry) it.next(); Integer k = (Integer) e.getKey(); int s = k.intValue(); - switch ( s ) { + switch (s) { case SCRIPT_UNDETERMINED: case SCRIPT_UNCODED: break; @@ -758,7 +758,7 @@ public final class CharScript { Integer v = (Integer) e.getValue(); assert v != null; int c = v.intValue(); - if ( c > cMax ) { + if (c > cMax) { cMax = c; sMax = s; } @@ -766,7 +766,7 @@ public final class CharScript { } } } - if ( sMax < 0 ) { + if (sMax < 0) { sMax = SCRIPT_UNDETERMINED; } return sMax; @@ -779,8 +779,8 @@ public final class CharScript { * @param script a script tag * @return true if script tag is a designated 'Indic' script */ - public static boolean isIndicScript ( String script ) { - return isIndicScript ( scriptCodeFromTag ( script ) ); + public static boolean isIndicScript (String script) { + return isIndicScript (scriptCodeFromTag (script)); } /** @@ -790,8 +790,8 @@ public final class CharScript { * @param script a script code * @return true if script code is a designated 'Indic' script */ - public static boolean isIndicScript ( int script ) { - switch ( script ) { + public static boolean isIndicScript (int script) { + switch (script) { case SCRIPT_BENGALI: case SCRIPT_BENGALI_2: case SCRIPT_BURMESE: @@ -822,11 +822,11 @@ public final class CharScript { * @param code the script code * @return a script tag */ - public static String scriptTagFromCode ( int code ) { + public static String scriptTagFromCode (int code) { Map m = getScriptTagsMap(); - if ( m != null ) { + if (m != null) { String tag; - if ( ( tag = m.get ( Integer.valueOf ( code ) ) ) != null ) { + if ((tag = m.get (Integer.valueOf (code))) != null) { return tag; } else { return ""; @@ -841,11 +841,11 @@ public final class CharScript { * @param tag the script tag * @return a script code */ - public static int scriptCodeFromTag ( String tag ) { + public static int scriptCodeFromTag (String tag) { Map m = getScriptCodeMap(); - if ( m != null ) { + if (m != null) { Integer c; - if ( ( c = m.get ( tag ) ) != null ) { + if ((c = m.get (tag)) != null) { return (int) c; } else { return SCRIPT_UNDETERMINED; @@ -858,72 +858,72 @@ public final class CharScript { private static Map scriptTagsMap = null; private static Map scriptCodeMap = null; - private static void putScriptTag ( Map tm, Map cm, int code, String tag ) { + private static void putScriptTag (Map tm, Map cm, int code, String tag) { assert tag != null; assert tag.length() != 0; assert code >= 0; assert code < 2000; - tm.put ( Integer.valueOf ( code ), tag ); - cm.put ( tag, Integer.valueOf ( code ) ); + tm.put (Integer.valueOf (code), tag); + cm.put (tag, Integer.valueOf (code)); } private static void makeScriptMaps() { HashMap tm = new HashMap(); HashMap cm = new HashMap(); - putScriptTag ( tm, cm, SCRIPT_HEBREW, "hebr" ); - putScriptTag ( tm, cm, SCRIPT_MONGOLIAN, "mong" ); - putScriptTag ( tm, cm, SCRIPT_ARABIC, "arab" ); - putScriptTag ( tm, cm, SCRIPT_GREEK, "grek" ); - putScriptTag ( tm, cm, SCRIPT_LATIN, "latn" ); - putScriptTag ( tm, cm, SCRIPT_CYRILLIC, "cyrl" ); - putScriptTag ( tm, cm, SCRIPT_GEORGIAN, "geor" ); - putScriptTag ( tm, cm, SCRIPT_BOPOMOFO, "bopo" ); - putScriptTag ( tm, cm, SCRIPT_HANGUL, "hang" ); - putScriptTag ( tm, cm, SCRIPT_GURMUKHI, "guru" ); - putScriptTag ( tm, cm, SCRIPT_GURMUKHI_2, "gur2" ); - putScriptTag ( tm, cm, SCRIPT_DEVANAGARI, "deva" ); - putScriptTag ( tm, cm, SCRIPT_DEVANAGARI_2, "dev2" ); - putScriptTag ( tm, cm, SCRIPT_GUJARATI, "gujr" ); - putScriptTag ( tm, cm, SCRIPT_GUJARATI_2, "gjr2" ); - putScriptTag ( tm, cm, SCRIPT_BENGALI, "beng" ); - putScriptTag ( tm, cm, SCRIPT_BENGALI_2, "bng2" ); - putScriptTag ( tm, cm, SCRIPT_ORIYA, "orya" ); - putScriptTag ( tm, cm, SCRIPT_ORIYA_2, "ory2" ); - putScriptTag ( tm, cm, SCRIPT_TIBETAN, "tibt" ); - putScriptTag ( tm, cm, SCRIPT_TELUGU, "telu" ); - putScriptTag ( tm, cm, SCRIPT_TELUGU_2, "tel2" ); - putScriptTag ( tm, cm, SCRIPT_KANNADA, "knda" ); - putScriptTag ( tm, cm, SCRIPT_KANNADA_2, "knd2" ); - putScriptTag ( tm, cm, SCRIPT_TAMIL, "taml" ); - putScriptTag ( tm, cm, SCRIPT_TAMIL_2, "tml2" ); - putScriptTag ( tm, cm, SCRIPT_MALAYALAM, "mlym" ); - putScriptTag ( tm, cm, SCRIPT_MALAYALAM_2, "mlm2" ); - putScriptTag ( tm, cm, SCRIPT_SINHALESE, "sinh" ); - putScriptTag ( tm, cm, SCRIPT_BURMESE, "mymr" ); - putScriptTag ( tm, cm, SCRIPT_THAI, "thai" ); - putScriptTag ( tm, cm, SCRIPT_KHMER, "khmr" ); - putScriptTag ( tm, cm, SCRIPT_LAO, "laoo" ); - putScriptTag ( tm, cm, SCRIPT_HIRAGANA, "hira" ); - putScriptTag ( tm, cm, SCRIPT_ETHIOPIC, "ethi" ); - putScriptTag ( tm, cm, SCRIPT_HAN, "hani" ); - putScriptTag ( tm, cm, SCRIPT_KATAKANA, "kana" ); - putScriptTag ( tm, cm, SCRIPT_MATH, "zmth" ); - putScriptTag ( tm, cm, SCRIPT_SYMBOL, "zsym" ); - putScriptTag ( tm, cm, SCRIPT_UNDETERMINED, "zyyy" ); - putScriptTag ( tm, cm, SCRIPT_UNCODED, "zzzz" ); + putScriptTag (tm, cm, SCRIPT_HEBREW, "hebr"); + putScriptTag (tm, cm, SCRIPT_MONGOLIAN, "mong"); + putScriptTag (tm, cm, SCRIPT_ARABIC, "arab"); + putScriptTag (tm, cm, SCRIPT_GREEK, "grek"); + putScriptTag (tm, cm, SCRIPT_LATIN, "latn"); + putScriptTag (tm, cm, SCRIPT_CYRILLIC, "cyrl"); + putScriptTag (tm, cm, SCRIPT_GEORGIAN, "geor"); + putScriptTag (tm, cm, SCRIPT_BOPOMOFO, "bopo"); + putScriptTag (tm, cm, SCRIPT_HANGUL, "hang"); + putScriptTag (tm, cm, SCRIPT_GURMUKHI, "guru"); + putScriptTag (tm, cm, SCRIPT_GURMUKHI_2, "gur2"); + putScriptTag (tm, cm, SCRIPT_DEVANAGARI, "deva"); + putScriptTag (tm, cm, SCRIPT_DEVANAGARI_2, "dev2"); + putScriptTag (tm, cm, SCRIPT_GUJARATI, "gujr"); + putScriptTag (tm, cm, SCRIPT_GUJARATI_2, "gjr2"); + putScriptTag (tm, cm, SCRIPT_BENGALI, "beng"); + putScriptTag (tm, cm, SCRIPT_BENGALI_2, "bng2"); + putScriptTag (tm, cm, SCRIPT_ORIYA, "orya"); + putScriptTag (tm, cm, SCRIPT_ORIYA_2, "ory2"); + putScriptTag (tm, cm, SCRIPT_TIBETAN, "tibt"); + putScriptTag (tm, cm, SCRIPT_TELUGU, "telu"); + putScriptTag (tm, cm, SCRIPT_TELUGU_2, "tel2"); + putScriptTag (tm, cm, SCRIPT_KANNADA, "knda"); + putScriptTag (tm, cm, SCRIPT_KANNADA_2, "knd2"); + putScriptTag (tm, cm, SCRIPT_TAMIL, "taml"); + putScriptTag (tm, cm, SCRIPT_TAMIL_2, "tml2"); + putScriptTag (tm, cm, SCRIPT_MALAYALAM, "mlym"); + putScriptTag (tm, cm, SCRIPT_MALAYALAM_2, "mlm2"); + putScriptTag (tm, cm, SCRIPT_SINHALESE, "sinh"); + putScriptTag (tm, cm, SCRIPT_BURMESE, "mymr"); + putScriptTag (tm, cm, SCRIPT_THAI, "thai"); + putScriptTag (tm, cm, SCRIPT_KHMER, "khmr"); + putScriptTag (tm, cm, SCRIPT_LAO, "laoo"); + putScriptTag (tm, cm, SCRIPT_HIRAGANA, "hira"); + putScriptTag (tm, cm, SCRIPT_ETHIOPIC, "ethi"); + putScriptTag (tm, cm, SCRIPT_HAN, "hani"); + putScriptTag (tm, cm, SCRIPT_KATAKANA, "kana"); + putScriptTag (tm, cm, SCRIPT_MATH, "zmth"); + putScriptTag (tm, cm, SCRIPT_SYMBOL, "zsym"); + putScriptTag (tm, cm, SCRIPT_UNDETERMINED, "zyyy"); + putScriptTag (tm, cm, SCRIPT_UNCODED, "zzzz"); scriptTagsMap = tm; scriptCodeMap = cm; } private static Map getScriptTagsMap() { - if ( scriptTagsMap == null ) { + if (scriptTagsMap == null) { makeScriptMaps(); } return scriptTagsMap; } private static Map getScriptCodeMap() { - if ( scriptCodeMap == null ) { + if (scriptCodeMap == null) { makeScriptMaps(); } return scriptCodeMap; diff --git a/src/java/org/apache/fop/complexscripts/util/GlyphContextTester.java b/src/java/org/apache/fop/complexscripts/util/GlyphContextTester.java index 77c154777..317ccc81a 100644 --- a/src/java/org/apache/fop/complexscripts/util/GlyphContextTester.java +++ b/src/java/org/apache/fop/complexscripts/util/GlyphContextTester.java @@ -38,6 +38,6 @@ public interface GlyphContextTester { * @param flags that apply to lookup in scope * @return true if test is satisfied */ - boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ); + boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags); } diff --git a/src/java/org/apache/fop/complexscripts/util/GlyphSequence.java b/src/java/org/apache/fop/complexscripts/util/GlyphSequence.java index f23850443..82d8b0d7a 100644 --- a/src/java/org/apache/fop/complexscripts/util/GlyphSequence.java +++ b/src/java/org/apache/fop/complexscripts/util/GlyphSequence.java @@ -65,15 +65,15 @@ public class GlyphSequence implements Cloneable { * @param associations a (possibly null) array of glyph to character associations * @param predications true if predications are enabled */ - public GlyphSequence ( IntBuffer characters, IntBuffer glyphs, List associations, boolean predications ) { - if ( characters == null ) { - characters = IntBuffer.allocate ( DEFAULT_CHARS_CAPACITY ); + public GlyphSequence (IntBuffer characters, IntBuffer glyphs, List associations, boolean predications) { + if (characters == null) { + characters = IntBuffer.allocate (DEFAULT_CHARS_CAPACITY); } - if ( glyphs == null ) { - glyphs = IntBuffer.allocate ( characters.capacity() ); + if (glyphs == null) { + glyphs = IntBuffer.allocate (characters.capacity()); } - if ( associations == null ) { - associations = makeIdentityAssociations ( characters.limit(), glyphs.limit() ); + if (associations == null) { + associations = makeIdentityAssociations (characters.limit(), glyphs.limit()); } this.characters = characters; this.glyphs = glyphs; @@ -91,8 +91,8 @@ public class GlyphSequence implements Cloneable { * @param glyphs a (possibly null) buffer of glyphs * @param associations a (possibly null) array of glyph to character associations */ - public GlyphSequence ( IntBuffer characters, IntBuffer glyphs, List associations ) { - this ( characters, glyphs, associations, false ); + public GlyphSequence (IntBuffer characters, IntBuffer glyphs, List associations) { + this (characters, glyphs, associations, false); } /** @@ -101,8 +101,8 @@ public class GlyphSequence implements Cloneable { * of glyphs buffer and association list. * @param gs an existing glyph sequence */ - public GlyphSequence ( GlyphSequence gs ) { - this ( gs.characters.duplicate(), copyBuffer ( gs.glyphs ), copyAssociations ( gs.associations ), gs.predications ); + public GlyphSequence (GlyphSequence gs) { + this (gs.characters.duplicate(), copyBuffer (gs.glyphs), copyAssociations (gs.associations), gs.predications); } /** @@ -119,8 +119,8 @@ public class GlyphSequence implements Cloneable { * @param ial input association list * @param lal lookahead association list */ - public GlyphSequence ( GlyphSequence gs, int[] bga, int[] iga, int[] lga, CharAssociation[] bal, CharAssociation[] ial, CharAssociation[] lal ) { - this ( gs.characters.duplicate(), concatGlyphs ( bga, iga, lga ), concatAssociations ( bal, ial, lal ), gs.predications ); + public GlyphSequence (GlyphSequence gs, int[] bga, int[] iga, int[] lga, CharAssociation[] bal, CharAssociation[] ial, CharAssociation[] lal) { + this (gs.characters.duplicate(), concatGlyphs (bga, iga, lga), concatAssociations (bal, ial, lal), gs.predications); } /** @@ -141,9 +141,9 @@ public class GlyphSequence implements Cloneable { * @param copy true if to return a newly instantiated array of characters * @return array of characters */ - public int[] getCharacterArray ( boolean copy ) { - if ( copy ) { - return toArray ( characters ); + public int[] getCharacterArray (boolean copy) { + if (copy) { + return toArray (characters); } else { return characters.array(); } @@ -165,8 +165,8 @@ public class GlyphSequence implements Cloneable { * @throws IndexOutOfBoundsException if index is less than zero * or exceeds last valid position */ - public int getGlyph ( int index ) throws IndexOutOfBoundsException { - return glyphs.get ( index ); + public int getGlyph (int index) throws IndexOutOfBoundsException { + return glyphs.get (index); } /** @@ -176,11 +176,11 @@ public class GlyphSequence implements Cloneable { * @throws IndexOutOfBoundsException if index is greater or equal to * the limit of the underlying glyph buffer */ - public void setGlyph ( int index, int gi ) throws IndexOutOfBoundsException { - if ( gi > 65535 ) { + public void setGlyph (int index, int gi) throws IndexOutOfBoundsException { + if (gi > 65535) { gi = 65535; } - glyphs.put ( index, gi ); + glyphs.put (index, gi); } /** @@ -200,20 +200,20 @@ public class GlyphSequence implements Cloneable { * indicating all avaialble glyphs starting at offset * @return glyph array */ - public int[] getGlyphs ( int offset, int count ) { + public int[] getGlyphs (int offset, int count) { int ng = getGlyphCount(); - if ( offset < 0 ) { + if (offset < 0) { offset = 0; - } else if ( offset > ng ) { + } else if (offset > ng) { offset = ng; } - if ( count < 0 ) { + if (count < 0) { count = ng - offset; } int[] ga = new int [ count ]; - for ( int i = offset, n = offset + count, k = 0; i < n; i++ ) { - if ( k < ga.length ) { - ga [ k++ ] = glyphs.get ( i ); + for (int i = offset, n = offset + count, k = 0; i < n; i++) { + if (k < ga.length) { + ga [ k++ ] = glyphs.get (i); } } return ga; @@ -229,9 +229,9 @@ public class GlyphSequence implements Cloneable { * @param copy true if to return a newly instantiated array of glyphs * @return array of glyphs */ - public int[] getGlyphArray ( boolean copy ) { - if ( copy ) { - return toArray ( glyphs ); + public int[] getGlyphArray (boolean copy) { + if (copy) { + return toArray (glyphs); } else { return glyphs.array(); } @@ -253,8 +253,8 @@ public class GlyphSequence implements Cloneable { * @throws IndexOutOfBoundsException if index is less than zero * or exceeds last valid position */ - public CharAssociation getAssociation ( int index ) throws IndexOutOfBoundsException { - return (CharAssociation) associations.get ( index ); + public CharAssociation getAssociation (int index) throws IndexOutOfBoundsException { + return (CharAssociation) associations.get (index); } /** @@ -272,20 +272,20 @@ public class GlyphSequence implements Cloneable { * indicating all avaialble associations starting at offset * @return associations */ - public CharAssociation[] getAssociations ( int offset, int count ) { + public CharAssociation[] getAssociations (int offset, int count) { int ng = getGlyphCount(); - if ( offset < 0 ) { + if (offset < 0) { offset = 0; - } else if ( offset > ng ) { + } else if (offset > ng) { offset = ng; } - if ( count < 0 ) { + if (count < 0) { count = ng - offset; } CharAssociation[] aa = new CharAssociation [ count ]; - for ( int i = offset, n = offset + count, k = 0; i < n; i++ ) { - if ( k < aa.length ) { - aa [ k++ ] = (CharAssociation) associations.get ( i ); + for (int i = offset, n = offset + count, k = 0; i < n; i++) { + if (k < aa.length) { + aa [ k++ ] = (CharAssociation) associations.get (i); } } return aa; @@ -295,7 +295,7 @@ public class GlyphSequence implements Cloneable { * Enable or disable predications. * @param enable true if predications are to be enabled; otherwise false to disable */ - public void setPredications ( boolean enable ) { + public void setPredications (boolean enable) { this.predications = enable; } @@ -313,11 +313,11 @@ public class GlyphSequence implements Cloneable { * @param key predication key * @param value predication value */ - public void setPredication ( int offset, String key, Object value ) { - if ( predications ) { - CharAssociation[] aa = getAssociations ( offset, 1 ); + public void setPredication (int offset, String key, Object value) { + if (predications) { + CharAssociation[] aa = getAssociations (offset, 1); CharAssociation ca = aa[0]; - ca.setPredication ( key, value ); + ca.setPredication (key, value); } } @@ -327,11 +327,11 @@ public class GlyphSequence implements Cloneable { * @param key predication key * @return predication KEY at OFFSET or null if none exists */ - public Object getPredication ( int offset, String key ) { - if ( predications ) { - CharAssociation[] aa = getAssociations ( offset, 1 ); + public Object getPredication (int offset, String key) { + if (predications) { + CharAssociation[] aa = getAssociations (offset, 1); CharAssociation ca = aa[0]; - return ca.getPredication ( key ); + return ca.getPredication (key); } else { return null; } @@ -343,15 +343,15 @@ public class GlyphSequence implements Cloneable { * @return zero if glyphs are the same, otherwise returns 1 or -1 according to whether this glyph sequence's * glyphs are lexicographically greater or lesser than the glyphs in the specified string buffer */ - public int compareGlyphs ( IntBuffer gb ) { + public int compareGlyphs (IntBuffer gb) { int ng = getGlyphCount(); - for ( int i = 0, n = gb.limit(); i < n; i++ ) { - if ( i < ng ) { - int g1 = glyphs.get ( i ); - int g2 = gb.get ( i ); - if ( g1 > g2 ) { + for (int i = 0, n = gb.limit(); i < n; i++) { + if (i < ng) { + int g1 = glyphs.get (i); + int g2 = gb.get (i); + if (g1 > g2) { return 1; - } else if ( g1 < g2 ) { + } else if (g1 < g2) { return -1; } } else { @@ -365,11 +365,11 @@ public class GlyphSequence implements Cloneable { public Object clone() { try { GlyphSequence gs = (GlyphSequence) super.clone(); - gs.characters = copyBuffer ( characters ); - gs.glyphs = copyBuffer ( glyphs ); - gs.associations = copyAssociations ( associations ); + gs.characters = copyBuffer (characters); + gs.glyphs = copyBuffer (glyphs); + gs.associations = copyAssociations (associations); return gs; - } catch ( CloneNotSupportedException e ) { + } catch (CloneNotSupportedException e) { return null; } } @@ -377,15 +377,15 @@ public class GlyphSequence implements Cloneable { /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append ( '{' ); - sb.append ( "chars = [" ); - sb.append ( characters ); - sb.append ( "], glyphs = [" ); - sb.append ( glyphs ); - sb.append ( "], associations = [" ); - sb.append ( associations ); - sb.append ( "]" ); - sb.append ( '}' ); + sb.append ('{'); + sb.append ("chars = ["); + sb.append (characters); + sb.append ("], glyphs = ["); + sb.append (glyphs); + sb.append ("], associations = ["); + sb.append (associations); + sb.append ("]"); + sb.append ('}'); return sb.toString(); } @@ -395,16 +395,16 @@ public class GlyphSequence implements Cloneable { * @param ga2 second glyph array * @return true if arrays are botth null or both non-null and have identical elements */ - public static boolean sameGlyphs ( int[] ga1, int[] ga2 ) { - if ( ga1 == ga2 ) { + public static boolean sameGlyphs (int[] ga1, int[] ga2) { + if (ga1 == ga2) { return true; - } else if ( ( ga1 == null ) || ( ga2 == null ) ) { + } else if ((ga1 == null) || (ga2 == null)) { return false; - } else if ( ga1.length != ga2.length ) { + } else if (ga1.length != ga2.length) { return false; } else { - for ( int i = 0, n = ga1.length; i < n; i++ ) { - if ( ga1[i] != ga2[i] ) { + for (int i = 0, n = ga1.length; i < n; i++) { + if (ga1[i] != ga2[i]) { return false; } } @@ -419,26 +419,26 @@ public class GlyphSequence implements Cloneable { * @param lga lookahead glyph array * @return new integer buffer containing concatenated glyphs */ - public static IntBuffer concatGlyphs ( int[] bga, int[] iga, int[] lga ) { + public static IntBuffer concatGlyphs (int[] bga, int[] iga, int[] lga) { int ng = 0; - if ( bga != null ) { + if (bga != null) { ng += bga.length; } - if ( iga != null ) { + if (iga != null) { ng += iga.length; } - if ( lga != null ) { + if (lga != null) { ng += lga.length; } - IntBuffer gb = IntBuffer.allocate ( ng ); - if ( bga != null ) { - gb.put ( bga ); + IntBuffer gb = IntBuffer.allocate (ng); + if (bga != null) { + gb.put (bga); } - if ( iga != null ) { - gb.put ( iga ); + if (iga != null) { + gb.put (iga); } - if ( lga != null ) { - gb.put ( lga ); + if (lga != null) { + gb.put (lga); } gb.flip(); return gb; @@ -451,32 +451,32 @@ public class GlyphSequence implements Cloneable { * @param laa lookahead association array * @return new list containing concatenated associations */ - public static List concatAssociations ( CharAssociation[] baa, CharAssociation[] iaa, CharAssociation[] laa ) { + public static List concatAssociations (CharAssociation[] baa, CharAssociation[] iaa, CharAssociation[] laa) { int na = 0; - if ( baa != null ) { + if (baa != null) { na += baa.length; } - if ( iaa != null ) { + if (iaa != null) { na += iaa.length; } - if ( laa != null ) { + if (laa != null) { na += laa.length; } - if ( na > 0 ) { - List gl = new ArrayList ( na ); - if ( baa != null ) { - for ( int i = 0; i < baa.length; i++ ) { - gl.add ( baa[i] ); + if (na > 0) { + List gl = new ArrayList (na); + if (baa != null) { + for (int i = 0; i < baa.length; i++) { + gl.add (baa[i]); } } - if ( iaa != null ) { - for ( int i = 0; i < iaa.length; i++ ) { - gl.add ( iaa[i] ); + if (iaa != null) { + for (int i = 0; i < iaa.length; i++) { + gl.add (iaa[i]); } } - if ( laa != null ) { - for ( int i = 0; i < laa.length; i++ ) { - gl.add ( laa[i] ); + if (laa != null) { + for (int i = 0; i < laa.length; i++) { + gl.add (laa[i]); } } return gl; @@ -491,11 +491,11 @@ public class GlyphSequence implements Cloneable { * @param sa array of glyph sequences, whose glyph arrays and association lists are to be concatenated * @return new glyph sequence referring to character array of GS and concatenated glyphs and associations of SA */ - public static GlyphSequence join ( GlyphSequence gs, GlyphSequence[] sa ) { + public static GlyphSequence join (GlyphSequence gs, GlyphSequence[] sa) { assert sa != null; int tg = 0; int ta = 0; - for ( int i = 0, n = sa.length; i < n; i++ ) { + for (int i = 0, n = sa.length; i < n; i++) { GlyphSequence s = sa [ i ]; IntBuffer ga = s.getGlyphs(); assert ga != null; @@ -507,14 +507,14 @@ public class GlyphSequence implements Cloneable { tg += ng; ta += na; } - IntBuffer uga = IntBuffer.allocate ( tg ); - ArrayList ual = new ArrayList ( ta ); - for ( int i = 0, n = sa.length; i < n; i++ ) { + IntBuffer uga = IntBuffer.allocate (tg); + ArrayList ual = new ArrayList (ta); + for (int i = 0, n = sa.length; i < n; i++) { GlyphSequence s = sa [ i ]; - uga.put ( s.getGlyphs() ); - ual.addAll ( s.getAssociations() ); + uga.put (s.getGlyphs()); + ual.addAll (s.getAssociations()); } - return new GlyphSequence ( gs.getCharacters(), uga, ual, gs.getPredications() ); + return new GlyphSequence (gs.getCharacters(), uga, ual, gs.getPredications()); } /** @@ -525,93 +525,93 @@ public class GlyphSequence implements Cloneable { * @param target index to which source sub-sequence is to be moved * @return reordered sequence (or original if no reordering performed) */ - public static GlyphSequence reorder ( GlyphSequence gs, int source, int count, int target ) { - if ( source != target ) { + public static GlyphSequence reorder (GlyphSequence gs, int source, int count, int target) { + if (source != target) { int ng = gs.getGlyphCount(); - int[] ga = gs.getGlyphArray ( false ); + int[] ga = gs.getGlyphArray (false); int[] nga = new int [ ng ]; - GlyphSequence.CharAssociation[] aa = gs.getAssociations ( 0, ng ); + GlyphSequence.CharAssociation[] aa = gs.getAssociations (0, ng); GlyphSequence.CharAssociation[] naa = new GlyphSequence.CharAssociation [ ng ]; - if ( source < target ) { + if (source < target) { int t = 0; - for ( int s = 0, e = source; s < e; s++, t++ ) { + for (int s = 0, e = source; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = source + count, e = target; s < e; s++, t++ ) { + for (int s = source + count, e = target; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = source, e = source + count; s < e; s++, t++ ) { + for (int s = source, e = source + count; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = target, e = ng; s < e; s++, t++ ) { + for (int s = target, e = ng; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } } else { int t = 0; - for ( int s = 0, e = target; s < e; s++, t++ ) { + for (int s = 0, e = target; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = source, e = source + count; s < e; s++, t++ ) { + for (int s = source, e = source + count; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = target, e = source; s < e; s++, t++ ) { + for (int s = target, e = source; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } - for ( int s = source + count, e = ng; s < e; s++, t++ ) { + for (int s = source + count, e = ng; s < e; s++, t++) { nga[t] = ga[s]; naa[t] = aa[s]; } } - return new GlyphSequence ( gs, null, nga, null, null, naa, null ); + return new GlyphSequence (gs, null, nga, null, null, naa, null); } else { return gs; } } - private static int[] toArray ( IntBuffer ib ) { - if ( ib != null ) { + private static int[] toArray (IntBuffer ib) { + if (ib != null) { int n = ib.limit(); int[] ia = new int[n]; - ib.get ( ia, 0, n ); + ib.get (ia, 0, n); return ia; } else { return new int[0]; } } - private static List makeIdentityAssociations ( int numChars, int numGlyphs ) { + private static List makeIdentityAssociations (int numChars, int numGlyphs) { int nc = numChars; int ng = numGlyphs; - List av = new ArrayList ( ng ); - for ( int i = 0, n = ng; i < n; i++ ) { - int k = ( i > nc ) ? nc : i; - av.add ( new CharAssociation ( i, ( k == nc ) ? 0 : 1 ) ); + List av = new ArrayList (ng); + for (int i = 0, n = ng; i < n; i++) { + int k = (i > nc) ? nc : i; + av.add (new CharAssociation (i, (k == nc) ? 0 : 1)); } return av; } - private static IntBuffer copyBuffer ( IntBuffer ib ) { - if ( ib != null ) { + private static IntBuffer copyBuffer (IntBuffer ib) { + if (ib != null) { int[] ia = new int [ ib.capacity() ]; int p = ib.position(); int l = ib.limit(); - System.arraycopy ( ib.array(), 0, ia, 0, ia.length ); - return IntBuffer.wrap ( ia, p, l - p ); + System.arraycopy (ib.array(), 0, ia, 0, ia.length); + return IntBuffer.wrap (ia, p, l - p); } else { return null; } } - private static List copyAssociations ( List ca ) { - if ( ca != null ) { - return new ArrayList ( ca ); + private static List copyAssociations (List ca) { + if (ca != null) { + return new ArrayList (ca); } else { return ca; } @@ -645,7 +645,7 @@ public class GlyphSequence implements Cloneable { private static volatile Map predicationMergers; interface PredicationMerger { - Object merge ( String key, Object v1, Object v2 ); + Object merge (String key, Object v1, Object v2); } /** @@ -656,10 +656,10 @@ public class GlyphSequence implements Cloneable { * members of array are sub-interval starts, and odd members are sub-interval * ends (exclusive) */ - public CharAssociation ( int offset, int count, int[] subIntervals ) { + public CharAssociation (int offset, int count, int[] subIntervals) { this.offset = offset; this.count = count; - this.subIntervals = ( ( subIntervals != null ) && ( subIntervals.length > 2 ) ) ? subIntervals : null; + this.subIntervals = ((subIntervals != null) && (subIntervals.length > 2)) ? subIntervals : null; } /** @@ -667,8 +667,8 @@ public class GlyphSequence implements Cloneable { * @param offset into array of UTF-16 code elements (in associated CharSequence) * @param count of UTF-16 character code elements (in associated CharSequence) */ - public CharAssociation ( int offset, int count ) { - this ( offset, count, null ); + public CharAssociation (int offset, int count) { + this (offset, count, null); } /** @@ -677,8 +677,8 @@ public class GlyphSequence implements Cloneable { * members of array are sub-interval starts, and odd members are sub-interval * ends (exclusive) */ - public CharAssociation ( int[] subIntervals ) { - this ( getSubIntervalsStart ( subIntervals ), getSubIntervalsLength ( subIntervals ), subIntervals ); + public CharAssociation (int[] subIntervals) { + this (getSubIntervalsStart (subIntervals), getSubIntervalsLength (subIntervals), subIntervals); } /** @return offset (start of association interval) */ @@ -713,7 +713,7 @@ public class GlyphSequence implements Cloneable { /** @return count of subintervals of disjoint association */ public int getSubIntervalCount() { - return ( subIntervals != null ) ? ( subIntervals.length / 2 ) : 0; + return (subIntervals != null) ? (subIntervals.length / 2) : 0; } /** @@ -721,19 +721,19 @@ public class GlyphSequence implements Cloneable { * @param count length of interval * @return true if this association is contained within [offset,offset+count) */ - public boolean contained ( int offset, int count ) { + public boolean contained (int offset, int count) { int s = offset; int e = offset + count; - if ( ! isDisjoint() ) { + if (! isDisjoint()) { int s0 = getStart(); int e0 = getEnd(); - return ( s0 >= s ) && ( e0 <= e ); + return (s0 >= s) && (e0 <= e); } else { int ns = getSubIntervalCount(); - for ( int i = 0; i < ns; i++ ) { + for (int i = 0; i < ns; i++) { int s0 = subIntervals [ 2 * i + 0 ]; int e0 = subIntervals [ 2 * i + 1 ]; - if ( ( s0 >= s ) && ( e0 <= e ) ) { + if ((s0 >= s) && (e0 <= e)) { return true; } } @@ -746,12 +746,12 @@ public class GlyphSequence implements Cloneable { * @param key predication key * @param value predication value */ - public void setPredication ( String key, Object value ) { - if ( predications == null ) { + public void setPredication (String key, Object value) { + if (predications == null) { predications = new HashMap(); } - if ( predications != null ) { - predications.put ( key, value ); + if (predications != null) { + predications.put (key, value); } } @@ -760,9 +760,9 @@ public class GlyphSequence implements Cloneable { * @param key predication key * @return predication KEY at OFFSET or null if none exists */ - public Object getPredication ( String key ) { - if ( predications != null ) { - return predications.get ( key ); + public Object getPredication (String key) { + if (predications != null) { + return predications.get (key); } else { return null; } @@ -773,17 +773,17 @@ public class GlyphSequence implements Cloneable { * @param key predication key * @param value predication value */ - public void mergePredication ( String key, Object value ) { - if ( predications == null ) { + public void mergePredication (String key, Object value) { + if (predications == null) { predications = new HashMap(); } - if ( predications != null ) { - if ( predications.containsKey ( key ) ) { - Object v1 = predications.get ( key ); + if (predications != null) { + if (predications.containsKey (key)) { + Object v1 = predications.get (key); Object v2 = value; - predications.put ( key, mergePredicationValues ( key, v1, v2 ) ); + predications.put (key, mergePredicationValues (key, v1, v2)); } else { - predications.put ( key, value ); + predications.put (key, value); } } } @@ -796,11 +796,11 @@ public class GlyphSequence implements Cloneable { * @param v2 second (to be merged) predication value * @return merged value */ - public static Object mergePredicationValues ( String key, Object v1, Object v2 ) { - PredicationMerger pm = getPredicationMerger ( key ); - if ( pm != null ) { - return pm.merge ( key, v1, v2 ); - } else if ( v2 != null ) { + public static Object mergePredicationValues (String key, Object v1, Object v2) { + PredicationMerger pm = getPredicationMerger (key); + if (pm != null) { + return pm.merge (key, v1, v2); + } else if (v2 != null) { return v2; } else { return v1; @@ -811,10 +811,10 @@ public class GlyphSequence implements Cloneable { * Merge predications from another CA. * @param ca from which to merge */ - public void mergePredications ( CharAssociation ca ) { - if ( ca.predications != null ) { - for ( Map.Entry e : ca.predications.entrySet() ) { - mergePredication ( e.getKey(), e.getValue() ); + public void mergePredications (CharAssociation ca) { + if (ca.predications != null) { + for (Map.Entry e : ca.predications.entrySet()) { + mergePredication (e.getKey(), e.getValue()); } } } @@ -823,11 +823,11 @@ public class GlyphSequence implements Cloneable { public Object clone() { try { CharAssociation ca = (CharAssociation) super.clone(); - if ( predications != null ) { - ca.predications = new HashMap ( predications ); + if (predications != null) { + ca.predications = new HashMap (predications); } return ca; - } catch ( CloneNotSupportedException e ) { + } catch (CloneNotSupportedException e) { return null; } } @@ -837,12 +837,12 @@ public class GlyphSequence implements Cloneable { * @param key for predication merger * @param pm predication merger */ - public static void setPredicationMerger ( String key, PredicationMerger pm ) { - if ( predicationMergers == null ) { + public static void setPredicationMerger (String key, PredicationMerger pm) { + if (predicationMergers == null) { predicationMergers = new HashMap(); } - if ( predicationMergers != null ) { - predicationMergers.put ( key, pm ); + if (predicationMergers != null) { + predicationMergers.put (key, pm); } } @@ -851,9 +851,9 @@ public class GlyphSequence implements Cloneable { * @param key for predication merger * @return predication merger or null if none exists */ - public static PredicationMerger getPredicationMerger ( String key ) { - if ( predicationMergers != null ) { - return predicationMergers.get ( key ); + public static PredicationMerger getPredicationMerger (String key) { + if (predicationMergers != null) { + return predicationMergers.get (key); } else { return null; } @@ -865,9 +865,9 @@ public class GlyphSequence implements Cloneable { * @param repeat count * @return array of replicated associations */ - public static CharAssociation[] replicate ( CharAssociation a, int repeat ) { + public static CharAssociation[] replicate (CharAssociation a, int repeat) { CharAssociation[] aa = new CharAssociation [ repeat ]; - for ( int i = 0, n = aa.length; i < n; i++ ) { + for (int i = 0, n = aa.length; i < n; i++) { aa [ i ] = (CharAssociation) a.clone(); } return aa; @@ -879,71 +879,71 @@ public class GlyphSequence implements Cloneable { * @param aa array of associations to join * @return (possibly disjoint) association containing joined associations */ - public static CharAssociation join ( CharAssociation[] aa ) { + public static CharAssociation join (CharAssociation[] aa) { CharAssociation ca; // extract sorted intervals - int[] ia = extractIntervals ( aa ); - if ( ( ia == null ) || ( ia.length == 0 ) ) { - ca = new CharAssociation ( 0, 0 ); - } else if ( ia.length == 2 ) { + int[] ia = extractIntervals (aa); + if ((ia == null) || (ia.length == 0)) { + ca = new CharAssociation (0, 0); + } else if (ia.length == 2) { int s = ia[0]; int e = ia[1]; - ca = new CharAssociation ( s, e - s ); + ca = new CharAssociation (s, e - s); } else { - ca = new CharAssociation ( mergeIntervals ( ia ) ); + ca = new CharAssociation (mergeIntervals (ia)); } - return mergePredicates ( ca, aa ); + return mergePredicates (ca, aa); } - private static CharAssociation mergePredicates ( CharAssociation ca, CharAssociation[] aa ) { - for ( CharAssociation a : aa ) { - ca.mergePredications ( a ); + private static CharAssociation mergePredicates (CharAssociation ca, CharAssociation[] aa) { + for (CharAssociation a : aa) { + ca.mergePredications (a); } return ca; } - private static int getSubIntervalsStart ( int[] ia ) { + private static int getSubIntervalsStart (int[] ia) { int us = Integer.MAX_VALUE; int ue = Integer.MIN_VALUE; - if ( ia != null ) { - for ( int i = 0, n = ia.length; i < n; i += 2 ) { + if (ia != null) { + for (int i = 0, n = ia.length; i < n; i += 2) { int s = ia [ i + 0 ]; int e = ia [ i + 1 ]; - if ( s < us ) { + if (s < us) { us = s; } - if ( e > ue ) { + if (e > ue) { ue = e; } } - if ( ue < 0 ) { + if (ue < 0) { ue = 0; } - if ( us > ue ) { + if (us > ue) { us = ue; } } return us; } - private static int getSubIntervalsLength ( int[] ia ) { + private static int getSubIntervalsLength (int[] ia) { int us = Integer.MAX_VALUE; int ue = Integer.MIN_VALUE; - if ( ia != null ) { - for ( int i = 0, n = ia.length; i < n; i += 2 ) { + if (ia != null) { + for (int i = 0, n = ia.length; i < n; i += 2) { int s = ia [ i + 0 ]; int e = ia [ i + 1 ]; - if ( s < us ) { + if (s < us) { us = s; } - if ( e > ue ) { + if (e > ue) { ue = e; } } - if ( ue < 0 ) { + if (ue < 0) { ue = 0; } - if ( us > ue ) { + if (us > ue) { us = ue; } } @@ -953,11 +953,11 @@ public class GlyphSequence implements Cloneable { /** * Extract sorted sub-intervals. */ - private static int[] extractIntervals ( CharAssociation[] aa ) { + private static int[] extractIntervals (CharAssociation[] aa) { int ni = 0; - for ( int i = 0, n = aa.length; i < n; i++ ) { + for (int i = 0, n = aa.length; i < n; i++) { CharAssociation a = aa [ i ]; - if ( a.isDisjoint() ) { + if (a.isDisjoint()) { ni += a.getSubIntervalCount(); } else { ni += 1; @@ -965,11 +965,11 @@ public class GlyphSequence implements Cloneable { } int[] sa = new int [ ni ]; int[] ea = new int [ ni ]; - for ( int i = 0, k = 0; i < aa.length; i++ ) { + for (int i = 0, k = 0; i < aa.length; i++) { CharAssociation a = aa [ i ]; - if ( a.isDisjoint() ) { + if (a.isDisjoint()) { int[] da = a.getSubIntervals(); - for ( int j = 0; j < da.length; j += 2 ) { + for (int j = 0; j < da.length; j += 2) { sa [ k ] = da [ j + 0 ]; ea [ k ] = da [ j + 1 ]; k++; @@ -980,7 +980,7 @@ public class GlyphSequence implements Cloneable { k++; } } - return sortIntervals ( sa, ea ); + return sortIntervals (sa, ea); } private static final int[] sortIncrements16 // CSOK: ConstantNameCheck @@ -992,23 +992,23 @@ public class GlyphSequence implements Cloneable { /** * Sort sub-intervals using modified Shell Sort. */ - private static int[] sortIntervals ( int[] sa, int[] ea ) { + private static int[] sortIntervals (int[] sa, int[] ea) { assert sa != null; assert ea != null; assert sa.length == ea.length; int ni = sa.length; - int[] incr = ( ni < 21 ) ? sortIncrements03 : sortIncrements16; - for ( int k = 0; k < incr.length; k++ ) { - for ( int h = incr [ k ], i = h, n = ni, j; i < n; i++ ) { + int[] incr = (ni < 21) ? sortIncrements03 : sortIncrements16; + for (int k = 0; k < incr.length; k++) { + for (int h = incr [ k ], i = h, n = ni, j; i < n; i++) { int s1 = sa [ i ]; int e1 = ea [ i ]; - for ( j = i; j >= h; j -= h) { + for (j = i; j >= h; j -= h) { int s2 = sa [ j - h ]; int e2 = ea [ j - h ]; - if ( s2 > s1 ) { + if (s2 > s1) { sa [ j ] = s2; ea [ j ] = e2; - } else if ( ( s2 == s1 ) && ( e2 > e1 ) ) { + } else if ((s2 == s1) && (e2 > e1)) { sa [ j ] = s2; ea [ j ] = e2; } else { @@ -1020,9 +1020,9 @@ public class GlyphSequence implements Cloneable { } } int[] ia = new int [ ni * 2 ]; - for ( int i = 0; i < ni; i++ ) { - ia [ ( i * 2 ) + 0 ] = sa [ i ]; - ia [ ( i * 2 ) + 1 ] = ea [ i ]; + for (int i = 0; i < ni; i++) { + ia [ (i * 2) + 0 ] = sa [ i ]; + ia [ (i * 2) + 1 ] = ea [ i ]; } return ia; } @@ -1030,7 +1030,7 @@ public class GlyphSequence implements Cloneable { /** * Merge overlapping and abutting sub-intervals. */ - private static int[] mergeIntervals ( int[] ia ) { + private static int[] mergeIntervals (int[] ia) { int ni = ia.length; int i; int n; @@ -1038,33 +1038,33 @@ public class GlyphSequence implements Cloneable { int is; int ie; // count merged sub-intervals - for ( i = 0, n = ni, nm = 0, is = ie = -1; i < n; i += 2 ) { + for (i = 0, n = ni, nm = 0, is = ie = -1; i < n; i += 2) { int s = ia [ i + 0 ]; int e = ia [ i + 1 ]; - if ( ( ie < 0 ) || ( s > ie ) ) { + if ((ie < 0) || (s > ie)) { is = s; ie = e; nm++; - } else if ( s >= is ) { - if ( e > ie ) { + } else if (s >= is) { + if (e > ie) { ie = e; } } } int[] mi = new int [ nm * 2 ]; // populate merged sub-intervals - for ( i = 0, n = ni, nm = 0, is = ie = -1; i < n; i += 2 ) { + for (i = 0, n = ni, nm = 0, is = ie = -1; i < n; i += 2) { int s = ia [ i + 0 ]; int e = ia [ i + 1 ]; int k = nm * 2; - if ( ( ie < 0 ) || ( s > ie ) ) { + if ((ie < 0) || (s > ie)) { is = s; ie = e; mi [ k + 0 ] = is; mi [ k + 1 ] = ie; nm++; - } else if ( s >= is ) { - if ( e > ie ) { + } else if (s >= is) { + if (e > ie) { ie = e; } mi [ k - 1 ] = ie; diff --git a/src/java/org/apache/fop/complexscripts/util/GlyphTester.java b/src/java/org/apache/fop/complexscripts/util/GlyphTester.java index 94a7c3384..1d4b4801a 100644 --- a/src/java/org/apache/fop/complexscripts/util/GlyphTester.java +++ b/src/java/org/apache/fop/complexscripts/util/GlyphTester.java @@ -32,6 +32,6 @@ public interface GlyphTester { * @param flags that apply to lookup in scope * @return true if test is satisfied */ - boolean test ( int gi, int flags ); + boolean test (int gi, int flags); } diff --git a/src/java/org/apache/fop/complexscripts/util/NumberConverter.java b/src/java/org/apache/fop/complexscripts/util/NumberConverter.java index 24dbacefe..6e480ea81 100644 --- a/src/java/org/apache/fop/complexscripts/util/NumberConverter.java +++ b/src/java/org/apache/fop/complexscripts/util/NumberConverter.java @@ -115,15 +115,15 @@ public class NumberConverter { * @param country (may be null or empty, which is treated as null) * @throws IllegalArgumentException if format is not a valid UTF-16 string (e.g., has unpaired surrogate) */ - public NumberConverter ( String format, int groupingSeparator, int groupingSize, int letterValue, String features, String language, String country ) + public NumberConverter (String format, int groupingSeparator, int groupingSize, int letterValue, String features, String language, String country) throws IllegalArgumentException { this.groupingSeparator = groupingSeparator; this.groupingSize = groupingSize; this.letterValue = letterValue; this.features = features; - this.language = ( language != null ) ? language.toLowerCase() : null; - this.country = ( country != null ) ? country.toLowerCase() : null; - parseFormatTokens ( format ); + this.language = (language != null) ? language.toLowerCase() : null; + this.country = (country != null) ? country.toLowerCase() : null; + parseFormatTokens (format); } /** @@ -131,10 +131,10 @@ public class NumberConverter { * @param number number to conver * @return string representing converted number */ - public String convert ( long number ) { + public String convert (long number) { List numbers = new ArrayList(); - numbers.add ( number ); - return convert ( numbers ); + numbers.add (number); + return convert (numbers); } /** @@ -142,62 +142,62 @@ public class NumberConverter { * @param numbers list of numbers to convert * @return string representing converted list of numbers */ - public String convert ( List numbers ) { + public String convert (List numbers) { List scalars = new ArrayList(); - if ( prefix != null ) { - appendScalars ( scalars, prefix ); + if (prefix != null) { + appendScalars (scalars, prefix); } - convertNumbers ( scalars, numbers ); - if ( suffix != null ) { - appendScalars ( scalars, suffix ); + convertNumbers (scalars, numbers); + if (suffix != null) { + appendScalars (scalars, suffix); } - return scalarsToString ( scalars ); + return scalarsToString (scalars); } - private void parseFormatTokens ( String format ) throws IllegalArgumentException { + private void parseFormatTokens (String format) throws IllegalArgumentException { List tokens = new ArrayList(); List separators = new ArrayList(); - if ( ( format == null ) || ( format.length() == 0 ) ) { + if ((format == null) || (format.length() == 0)) { format = "1"; } int tokenType = TOKEN_NONE; List token = new ArrayList(); - Integer[] ca = UTF32.toUTF32 ( format, 0, true ); - for ( int i = 0, n = ca.length; i < n; i++ ) { + Integer[] ca = UTF32.toUTF32 (format, 0, true); + for (int i = 0, n = ca.length; i < n; i++) { int c = ca[i]; - int tokenTypeNew = isAlphaNumeric ( c ) ? TOKEN_ALPHANUMERIC : TOKEN_NONALPHANUMERIC; - if ( tokenTypeNew != tokenType ) { - if ( token.size() > 0 ) { - if ( tokenType == TOKEN_ALPHANUMERIC ) { - tokens.add ( token.toArray ( new Integer [ token.size() ] ) ); + int tokenTypeNew = isAlphaNumeric (c) ? TOKEN_ALPHANUMERIC : TOKEN_NONALPHANUMERIC; + if (tokenTypeNew != tokenType) { + if (token.size() > 0) { + if (tokenType == TOKEN_ALPHANUMERIC) { + tokens.add (token.toArray (new Integer [ token.size() ])); } else { - separators.add ( token.toArray ( new Integer [ token.size() ] ) ); + separators.add (token.toArray (new Integer [ token.size() ])); } token.clear(); } tokenType = tokenTypeNew; } - token.add ( c ); + token.add (c); } - if ( token.size() > 0 ) { - if ( tokenType == TOKEN_ALPHANUMERIC ) { - tokens.add ( token.toArray ( new Integer [ token.size() ] ) ); + if (token.size() > 0) { + if (tokenType == TOKEN_ALPHANUMERIC) { + tokens.add (token.toArray (new Integer [ token.size() ])); } else { - separators.add ( token.toArray ( new Integer [ token.size() ] ) ); + separators.add (token.toArray (new Integer [ token.size() ])); } } - if ( ! separators.isEmpty() ) { - this.prefix = separators.remove ( 0 ); + if (! separators.isEmpty()) { + this.prefix = separators.remove (0); } - if ( ! separators.isEmpty() ) { - this.suffix = separators.remove ( separators.size() - 1 ); + if (! separators.isEmpty()) { + this.suffix = separators.remove (separators.size() - 1); } - this.separators = separators.toArray ( new Integer [ separators.size() ] [] ); - this.tokens = tokens.toArray ( new Integer [ tokens.size() ] [] ); + this.separators = separators.toArray (new Integer [ separators.size() ] []); + this.tokens = tokens.toArray (new Integer [ tokens.size() ] []); } - private static boolean isAlphaNumeric ( int c ) { - switch ( Character.getType ( c ) ) { + private static boolean isAlphaNumeric (int c) { + switch (Character.getType (c)) { case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.LETTER_NUMBER: // Nl case Character.OTHER_NUMBER: // No @@ -212,19 +212,19 @@ public class NumberConverter { } } - private void convertNumbers ( List scalars, List numbers ) { + private void convertNumbers (List scalars, List numbers) { Integer[] tknLast = DEFAULT_TOKEN; int tknIndex = 0; int tknCount = tokens.length; int sepIndex = 0; int sepCount = separators.length; int numIndex = 0; - for ( Long number : numbers ) { + for (Long number : numbers) { Integer[] sep = null; Integer[] tkn; - if ( tknIndex < tknCount ) { - if ( numIndex > 0 ) { - if ( sepIndex < sepCount ) { + if (tknIndex < tknCount) { + if (numIndex > 0) { + if (sepIndex < sepCount) { sep = separators [ sepIndex++ ]; } else { sep = DEFAULT_SEPARATOR; @@ -234,40 +234,40 @@ public class NumberConverter { } else { tkn = tknLast; } - appendScalars ( scalars, convertNumber ( number, sep, tkn ) ); + appendScalars (scalars, convertNumber (number, sep, tkn)); tknLast = tkn; numIndex++; } } - private Integer[] convertNumber ( long number, Integer[] separator, Integer[] token ) { + private Integer[] convertNumber (long number, Integer[] separator, Integer[] token) { List sl = new ArrayList(); - if ( separator != null ) { - appendScalars ( sl, separator ); + if (separator != null) { + appendScalars (sl, separator); } - if ( token != null ) { - appendScalars ( sl, formatNumber ( number, token ) ); + if (token != null) { + appendScalars (sl, formatNumber (number, token)); } - return sl.toArray ( new Integer [ sl.size() ] ); + return sl.toArray (new Integer [ sl.size() ]); } - private Integer[] formatNumber ( long number, Integer[] token ) { + private Integer[] formatNumber (long number, Integer[] token) { Integer[] fn = null; assert token.length > 0; - if ( number < 0 ) { - throw new IllegalArgumentException ( "number must be non-negative" ); - } else if ( token.length == 1 ) { + if (number < 0) { + throw new IllegalArgumentException ("number must be non-negative"); + } else if (token.length == 1) { int s = token[0].intValue(); - switch ( s ) { + switch (s) { case (int) '1': { - fn = formatNumberAsDecimal ( number, (int) '1', 1 ); + fn = formatNumberAsDecimal (number, (int) '1', 1); break; } case (int) 'W': case (int) 'w': { - fn = formatNumberAsWord ( number, ( s == (int) 'W' ) ? Character.UPPERCASE_LETTER : Character.LOWERCASE_LETTER ); + fn = formatNumberAsWord (number, (s == (int) 'W') ? Character.UPPERCASE_LETTER : Character.LOWERCASE_LETTER); break; } case (int) 'A': // handled as numeric sequence @@ -276,28 +276,28 @@ public class NumberConverter { case (int) 'i': // handled as numeric special default: { - if ( isStartOfDecimalSequence ( s ) ) { - fn = formatNumberAsDecimal ( number, s, 1 ); - } else if ( isStartOfAlphabeticSequence ( s ) ) { - fn = formatNumberAsSequence ( number, s, getSequenceBase ( s ), null ); - } else if ( isStartOfNumericSpecial ( s ) ) { - fn = formatNumberAsSpecial ( number, s ); + if (isStartOfDecimalSequence (s)) { + fn = formatNumberAsDecimal (number, s, 1); + } else if (isStartOfAlphabeticSequence (s)) { + fn = formatNumberAsSequence (number, s, getSequenceBase (s), null); + } else if (isStartOfNumericSpecial (s)) { + fn = formatNumberAsSpecial (number, s); } else { fn = null; } break; } } - } else if ( ( token.length == 2 ) && ( token[0] == (int) 'W' ) && ( token[1] == (int) 'w' ) ) { - fn = formatNumberAsWord ( number, Character.TITLECASE_LETTER ); - } else if ( isPaddedOne ( token ) ) { + } else if ((token.length == 2) && (token[0] == (int) 'W') && (token[1] == (int) 'w')) { + fn = formatNumberAsWord (number, Character.TITLECASE_LETTER); + } else if (isPaddedOne (token)) { int s = token [ token.length - 1 ].intValue(); - fn = formatNumberAsDecimal ( number, s, token.length ); + fn = formatNumberAsDecimal (number, s, token.length); } else { - throw new IllegalArgumentException ( "invalid format token: \"" + UTF32.fromUTF32 ( token ) + "\"" ); + throw new IllegalArgumentException ("invalid format token: \"" + UTF32.fromUTF32 (token) + "\""); } - if ( fn == null ) { - fn = formatNumber ( number, DEFAULT_TOKEN ); + if (fn == null) { + fn = formatNumber (number, DEFAULT_TOKEN); } assert fn != null; return fn; @@ -311,40 +311,40 @@ public class NumberConverter { * @param width non-negative integer denoting field width of number, possible including padding * @return formatted number as array of unicode scalars */ - private Integer[] formatNumberAsDecimal ( long number, int one, int width ) { - assert Character.getNumericValue ( one ) == 1; - assert Character.getNumericValue ( one - 1 ) == 0; - assert Character.getNumericValue ( one + 8 ) == 9; + private Integer[] formatNumberAsDecimal (long number, int one, int width) { + assert Character.getNumericValue (one) == 1; + assert Character.getNumericValue (one - 1) == 0; + assert Character.getNumericValue (one + 8) == 9; List sl = new ArrayList(); int zero = one - 1; - while ( number > 0 ) { + while (number > 0) { long digit = number % 10; - sl.add ( 0, zero + (int) digit ); + sl.add (0, zero + (int) digit); number = number / 10; } - while ( width > sl.size() ) { - sl.add ( 0, zero ); + while (width > sl.size()) { + sl.add (0, zero); } - if ( ( groupingSize != 0 ) && ( groupingSeparator != 0 ) ) { - sl = performGrouping ( sl, groupingSize, groupingSeparator ); + if ((groupingSize != 0) && (groupingSeparator != 0)) { + sl = performGrouping (sl, groupingSize, groupingSeparator); } - return sl.toArray ( new Integer [ sl.size() ] ); + return sl.toArray (new Integer [ sl.size() ]); } - private static List performGrouping ( List sl, int groupingSize, int groupingSeparator ) { + private static List performGrouping (List sl, int groupingSize, int groupingSeparator) { assert groupingSize > 0; assert groupingSeparator != 0; - if ( sl.size() > groupingSize ) { + if (sl.size() > groupingSize) { List gl = new ArrayList(); - for ( int i = 0, n = sl.size(), g = 0; i < n; i++ ) { + for (int i = 0, n = sl.size(), g = 0; i < n; i++) { int k = n - i - 1; - if ( g == groupingSize ) { - gl.add ( 0, groupingSeparator ); + if (g == groupingSize) { + gl.add (0, groupingSeparator); g = 1; } else { g++; } - gl.add ( 0, sl.get ( k ) ); + gl.add (0, sl.get (k)); } return gl; } else { @@ -362,21 +362,21 @@ public class NumberConverter { * @param map if non-null, then maps sequences indices to unicode scalars * @return formatted number as array of unicode scalars */ - private Integer[] formatNumberAsSequence ( long number, int one, int base, int[] map ) { + private Integer[] formatNumberAsSequence (long number, int one, int base, int[] map) { assert base > 1; - assert ( map == null ) || ( map.length >= base ); + assert (map == null) || (map.length >= base); List sl = new ArrayList(); - if ( number == 0 ) { + if (number == 0) { return null; } else { long n = number; - while ( n > 0 ) { - int d = (int) ( ( n - 1 ) % (long) base ); - int s = ( map != null ) ? map [ d ] : ( one + d ); - sl.add ( 0, s ); - n = ( n - 1 ) / base; + while (n > 0) { + int d = (int) ((n - 1) % (long) base); + int s = (map != null) ? map [ d ] : (one + d); + sl.add (0, s); + n = (n - 1) / base; } - return sl.toArray ( new Integer [ sl.size() ] ); + return sl.toArray (new Integer [ sl.size() ]); } } @@ -386,10 +386,10 @@ public class NumberConverter { * @param one unicode scalar value denoting start of system (numeric value 1) * @return formatted number as array of unicode scalars */ - private Integer[] formatNumberAsSpecial ( long number, int one ) { - SpecialNumberFormatter f = getSpecialFormatter ( one, letterValue, features, language, country ); - if ( f != null ) { - return f.format ( number, one, letterValue, features, language, country ); + private Integer[] formatNumberAsSpecial (long number, int one) { + SpecialNumberFormatter f = getSpecialFormatter (one, letterValue, features, language, country); + if (f != null) { + return f.format (number, one, letterValue, features, language, country); } else { return null; } @@ -404,27 +404,27 @@ public class NumberConverter { * @param caseType unicode character type for case conversion * @return formatted number as array of unicode scalars */ - private Integer[] formatNumberAsWord ( long number, int caseType ) { + private Integer[] formatNumberAsWord (long number, int caseType) { SpecialNumberFormatter f = null; - if ( isLanguage ( "eng" ) ) { - f = new EnglishNumberAsWordFormatter ( caseType ); - } else if ( isLanguage ( "spa" ) ) { - f = new SpanishNumberAsWordFormatter ( caseType ); - } else if ( isLanguage ( "fra" ) ) { - f = new FrenchNumberAsWordFormatter ( caseType ); + if (isLanguage ("eng")) { + f = new EnglishNumberAsWordFormatter (caseType); + } else if (isLanguage ("spa")) { + f = new SpanishNumberAsWordFormatter (caseType); + } else if (isLanguage ("fra")) { + f = new FrenchNumberAsWordFormatter (caseType); } else { - f = new EnglishNumberAsWordFormatter ( caseType ); + f = new EnglishNumberAsWordFormatter (caseType); } - return f.format ( number, 0, letterValue, features, language, country ); + return f.format (number, 0, letterValue, features, language, country); } - private boolean isLanguage ( String iso3Code ) { - if ( language == null ) { + private boolean isLanguage (String iso3Code) { + if (language == null) { return false; - } else if ( language.equals ( iso3Code ) ) { + } else if (language.equals (iso3Code)) { return true; } else { - return isSameLanguage ( iso3Code, language ); + return isSameLanguage (iso3Code, language); } } @@ -434,12 +434,12 @@ public class NumberConverter { { "spa", "es" }, }; - private static boolean isSameLanguage ( String i3c, String lc ) { - for ( String[] el : equivalentLanguages ) { + private static boolean isSameLanguage (String i3c, String lc) { + for (String[] el : equivalentLanguages) { assert el.length >= 2; - if ( el[0].equals ( i3c ) ) { - for ( int i = 0, n = el.length; i < n; i++ ) { - if ( el[i].equals ( lc ) ) { + if (el[0].equals (i3c)) { + for (int i = 0, n = el.length; i < n; i++) { + if (el[i].equals (lc)) { return true; } } @@ -449,17 +449,17 @@ public class NumberConverter { return false; } - private static boolean hasFeature ( String features, String feature ) { - if ( features != null ) { + private static boolean hasFeature (String features, String feature) { + if (features != null) { assert feature != null; assert feature.length() != 0; String[] fa = features.split(","); - for ( String f : fa ) { + for (String f : fa) { String[] fp = f.split("="); assert fp.length > 0; String fn = fp[0]; - String fv = ( fp.length > 1 ) ? fp[1] : ""; - if ( fn.equals ( feature ) ) { + String fv = (fp.length > 1) ? fp[1] : ""; + if (fn.equals (feature)) { return true; } } @@ -487,23 +487,23 @@ public class NumberConverter { } */ - private static void appendScalars ( List scalars, Integer[] sa ) { - for ( Integer s : sa ) { - scalars.add ( s ); + private static void appendScalars (List scalars, Integer[] sa) { + for (Integer s : sa) { + scalars.add (s); } } - private static String scalarsToString ( List scalars ) { - Integer[] sa = scalars.toArray ( new Integer [ scalars.size() ] ); - return UTF32.fromUTF32 ( sa ); + private static String scalarsToString (List scalars) { + Integer[] sa = scalars.toArray (new Integer [ scalars.size() ]); + return UTF32.fromUTF32 (sa); } - private static boolean isPaddedOne ( Integer[] token ) { - if ( getDecimalValue ( token [ token.length - 1 ] ) != 1 ) { + private static boolean isPaddedOne (Integer[] token) { + if (getDecimalValue (token [ token.length - 1 ]) != 1) { return false; } else { - for ( int i = 0, n = token.length - 1; i < n; i++ ) { - if ( getDecimalValue ( token [ i ] ) != 0 ) { + for (int i = 0, n = token.length - 1; i < n; i++) { + if (getDecimalValue (token [ i ]) != 0) { return false; } } @@ -511,19 +511,19 @@ public class NumberConverter { } } - private static int getDecimalValue ( Integer scalar ) { + private static int getDecimalValue (Integer scalar) { int s = scalar.intValue(); - if ( Character.getType ( s ) == Character.DECIMAL_DIGIT_NUMBER ) { - return Character.getNumericValue ( s ); + if (Character.getType (s) == Character.DECIMAL_DIGIT_NUMBER) { + return Character.getNumericValue (s); } else { return -1; } } - private static boolean isStartOfDecimalSequence ( int s ) { - return ( Character.getNumericValue ( s ) == 1 ) - && ( Character.getNumericValue ( s - 1 ) == 0 ) - && ( Character.getNumericValue ( s + 8 ) == 9 ); + private static boolean isStartOfDecimalSequence (int s) { + return (Character.getNumericValue (s) == 1) + && (Character.getNumericValue (s - 1) == 0) + && (Character.getNumericValue (s + 8) == 9); } private static int[][] supportedAlphabeticSequences = { @@ -531,20 +531,20 @@ public class NumberConverter { { 'a', 26 }, // a...z }; - private static boolean isStartOfAlphabeticSequence ( int s ) { - for ( int[] ss : supportedAlphabeticSequences ) { + private static boolean isStartOfAlphabeticSequence (int s) { + for (int[] ss : supportedAlphabeticSequences) { assert ss.length >= 2; - if ( ss[0] == s ) { + if (ss[0] == s) { return true; } } return false; } - private static int getSequenceBase ( int s ) { - for ( int[] ss : supportedAlphabeticSequences ) { + private static int getSequenceBase (int s) { + for (int[] ss : supportedAlphabeticSequences) { assert ss.length >= 2; - if ( ss[0] == s ) { + if (ss[0] == s) { return ss[1]; } } @@ -566,60 +566,60 @@ public class NumberConverter { { '\u30A4' }, // kana - katakana (iroha) }; - private static boolean isStartOfNumericSpecial ( int s ) { - for ( int[] ss : supportedSpecials ) { + private static boolean isStartOfNumericSpecial (int s) { + for (int[] ss : supportedSpecials) { assert ss.length >= 1; - if ( ss[0] == s ) { + if (ss[0] == s) { return true; } } return false; } - private SpecialNumberFormatter getSpecialFormatter ( int one, int letterValue, String features, String language, String country ) { - if ( one == (int) 'I' ) { + private SpecialNumberFormatter getSpecialFormatter (int one, int letterValue, String features, String language, String country) { + if (one == (int) 'I') { return new RomanNumeralsFormatter(); - } else if ( one == (int) 'i' ) { + } else if (one == (int) 'i') { return new RomanNumeralsFormatter(); - } else if ( one == (int) '\u0391' ) { + } else if (one == (int) '\u0391') { return new IsopsephryNumeralsFormatter(); - } else if ( one == (int) '\u03B1' ) { + } else if (one == (int) '\u03B1') { return new IsopsephryNumeralsFormatter(); - } else if ( one == (int) '\u05D0' ) { + } else if (one == (int) '\u05D0') { return new GematriaNumeralsFormatter(); - } else if ( one == (int) '\u0623' ) { + } else if (one == (int) '\u0623') { return new ArabicNumeralsFormatter(); - } else if ( one == (int) '\u0627' ) { + } else if (one == (int) '\u0627') { return new ArabicNumeralsFormatter(); - } else if ( one == (int) '\u0E01' ) { + } else if (one == (int) '\u0E01') { return new ThaiNumeralsFormatter(); - } else if ( one == (int) '\u3042' ) { + } else if (one == (int) '\u3042') { return new KanaNumeralsFormatter(); - } else if ( one == (int) '\u3044' ) { + } else if (one == (int) '\u3044') { return new KanaNumeralsFormatter(); - } else if ( one == (int) '\u30A2' ) { + } else if (one == (int) '\u30A2') { return new KanaNumeralsFormatter(); - } else if ( one == (int) '\u30A4' ) { + } else if (one == (int) '\u30A4') { return new KanaNumeralsFormatter(); } else { return null; } } - private static Integer[] toUpperCase ( Integer[] sa ) { + private static Integer[] toUpperCase (Integer[] sa) { assert sa != null; - for ( int i = 0, n = sa.length; i < n; i++ ) { + for (int i = 0, n = sa.length; i < n; i++) { Integer s = sa [ i ]; - sa [ i ] = Character.toUpperCase ( s ); + sa [ i ] = Character.toUpperCase (s); } return sa; } - private static Integer[] toLowerCase ( Integer[] sa ) { + private static Integer[] toLowerCase (Integer[] sa) { assert sa != null; - for ( int i = 0, n = sa.length; i < n; i++ ) { + for (int i = 0, n = sa.length; i < n; i++) { Integer s = sa [ i ]; - sa [ i ] = Character.toLowerCase ( s ); + sa [ i ] = Character.toLowerCase (s); } return sa; } @@ -634,27 +634,27 @@ public class NumberConverter { } */ - private static List convertWordCase ( List words, int caseType ) { + private static List convertWordCase (List words, int caseType) { List wl = new ArrayList(); - for ( String w : words ) { - wl.add ( convertWordCase ( w, caseType ) ); + for (String w : words) { + wl.add (convertWordCase (w, caseType)); } return wl; } - private static String convertWordCase ( String word, int caseType ) { - if ( caseType == Character.UPPERCASE_LETTER ) { + private static String convertWordCase (String word, int caseType) { + if (caseType == Character.UPPERCASE_LETTER) { return word.toUpperCase(); - } else if ( caseType == Character.LOWERCASE_LETTER ) { + } else if (caseType == Character.LOWERCASE_LETTER) { return word.toLowerCase(); - } else if ( caseType == Character.TITLECASE_LETTER ) { + } else if (caseType == Character.TITLECASE_LETTER) { StringBuffer sb = new StringBuffer(); - for ( int i = 0, n = word.length(); i < n; i++ ) { - String s = word.substring ( i, i + 1 ); - if ( i == 0 ) { - sb.append ( s.toUpperCase() ); + for (int i = 0, n = word.length(); i < n; i++) { + String s = word.substring (i, i + 1); + if (i == 0) { + sb.append (s.toUpperCase()); } else { - sb.append ( s.toLowerCase() ); + sb.append (s.toLowerCase()); } } return sb.toString(); @@ -663,13 +663,13 @@ public class NumberConverter { } } - private static String joinWords ( List words, String separator ) { + private static String joinWords (List words, String separator) { StringBuffer sb = new StringBuffer(); - for ( String w : words ) { - if ( sb.length() > 0 ) { - sb.append ( separator ); + for (String w : words) { + if (sb.length() > 0) { + sb.append (separator); } - sb.append ( w ); + sb.append (w); } return sb.toString(); } @@ -688,7 +688,7 @@ public class NumberConverter { * @param country denotes applicable country * @return formatted number as array of unicode scalars */ - Integer[] format ( long number, int one, int letterValue, String features, String language, String country ); + Integer[] format (long number, int one, int letterValue, String features, String language, String country); } /** @@ -704,98 +704,98 @@ public class NumberConverter { private static String[] englishWordOthersOrd = { "hundredth", "thousandth", "millionth", "billionth" }; private static class EnglishNumberAsWordFormatter implements SpecialNumberFormatter { private int caseType = Character.UPPERCASE_LETTER; - EnglishNumberAsWordFormatter ( int caseType ) { + EnglishNumberAsWordFormatter (int caseType) { this.caseType = caseType; } - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { List wl = new ArrayList(); - if ( number >= 1000000000000L ) { + if (number >= 1000000000000L) { return null; } else { - boolean ordinal = hasFeature ( features, "ordinal" ); - if ( number == 0 ) { - wl.add ( englishWordOnes [ 0 ] ); - } else if ( ordinal && ( number < 10 ) ) { - wl.add ( englishWordOnesOrd [ (int) number ] ); + boolean ordinal = hasFeature (features, "ordinal"); + if (number == 0) { + wl.add (englishWordOnes [ 0 ]); + } else if (ordinal && (number < 10)) { + wl.add (englishWordOnesOrd [ (int) number ]); } else { - int ones = (int) ( number % 1000 ); - int thousands = (int) ( ( number / 1000 ) % 1000 ); - int millions = (int) ( ( number / 1000000 ) % 1000 ); - int billions = (int) ( ( number / 1000000000 ) % 1000 ); - if ( billions > 0 ) { - wl = formatOnesInThousand ( wl, billions ); - if ( ordinal && ( ( number % 1000000000 ) == 0 ) ) { - wl.add ( englishWordOthersOrd[3] ); + int ones = (int) (number % 1000); + int thousands = (int) ((number / 1000) % 1000); + int millions = (int) ((number / 1000000) % 1000); + int billions = (int) ((number / 1000000000) % 1000); + if (billions > 0) { + wl = formatOnesInThousand (wl, billions); + if (ordinal && ((number % 1000000000) == 0)) { + wl.add (englishWordOthersOrd[3]); } else { - wl.add ( englishWordOthers[3] ); + wl.add (englishWordOthers[3]); } } - if ( millions > 0 ) { - wl = formatOnesInThousand ( wl, millions ); - if ( ordinal && ( ( number % 1000000 ) == 0 ) ) { - wl.add ( englishWordOthersOrd[2] ); + if (millions > 0) { + wl = formatOnesInThousand (wl, millions); + if (ordinal && ((number % 1000000) == 0)) { + wl.add (englishWordOthersOrd[2]); } else { - wl.add ( englishWordOthers[2] ); + wl.add (englishWordOthers[2]); } } - if ( thousands > 0 ) { - wl = formatOnesInThousand ( wl, thousands ); - if ( ordinal && ( ( number % 1000 ) == 0 ) ) { - wl.add ( englishWordOthersOrd[1] ); + if (thousands > 0) { + wl = formatOnesInThousand (wl, thousands); + if (ordinal && ((number % 1000) == 0)) { + wl.add (englishWordOthersOrd[1]); } else { - wl.add ( englishWordOthers[1] ); + wl.add (englishWordOthers[1]); } } - if ( ones > 0 ) { - wl = formatOnesInThousand ( wl, ones, ordinal ); + if (ones > 0) { + wl = formatOnesInThousand (wl, ones, ordinal); } } - wl = convertWordCase ( wl, caseType ); - return UTF32.toUTF32 ( joinWords ( wl, " " ), 0, true ); + wl = convertWordCase (wl, caseType); + return UTF32.toUTF32 (joinWords (wl, " "), 0, true); } } - private List formatOnesInThousand ( List wl, int number ) { - return formatOnesInThousand ( wl, number, false ); + private List formatOnesInThousand (List wl, int number) { + return formatOnesInThousand (wl, number, false); } - private List formatOnesInThousand ( List wl, int number, boolean ordinal ) { + private List formatOnesInThousand (List wl, int number, boolean ordinal) { assert number < 1000; int ones = number % 10; - int tens = ( number / 10 ) % 10; - int hundreds = ( number / 100 ) % 10; - if ( hundreds > 0 ) { - wl.add ( englishWordOnes [ hundreds ] ); - if ( ordinal && ( ( number % 100 ) == 0 ) ) { - wl.add ( englishWordOthersOrd[0] ); + int tens = (number / 10) % 10; + int hundreds = (number / 100) % 10; + if (hundreds > 0) { + wl.add (englishWordOnes [ hundreds ]); + if (ordinal && ((number % 100) == 0)) { + wl.add (englishWordOthersOrd[0]); } else { - wl.add ( englishWordOthers[0] ); + wl.add (englishWordOthers[0]); } } - if ( tens > 0 ) { - if ( tens == 1 ) { - if ( ordinal ) { - wl.add ( englishWordTeensOrd [ ones ] ); + if (tens > 0) { + if (tens == 1) { + if (ordinal) { + wl.add (englishWordTeensOrd [ ones ]); } else { - wl.add ( englishWordTeens [ ones ] ); + wl.add (englishWordTeens [ ones ]); } } else { - if ( ordinal && ( ones == 0 ) ) { - wl.add ( englishWordTensOrd [ tens ] ); + if (ordinal && (ones == 0)) { + wl.add (englishWordTensOrd [ tens ]); } else { - wl.add ( englishWordTens [ tens ] ); + wl.add (englishWordTens [ tens ]); } - if ( ones > 0 ) { - if ( ordinal ) { - wl.add ( englishWordOnesOrd [ ones ] ); + if (ones > 0) { + if (ordinal) { + wl.add (englishWordOnesOrd [ ones ]); } else { - wl.add ( englishWordOnes [ ones ] ); + wl.add (englishWordOnes [ ones ]); } } } - } else if ( ones > 0 ) { - if ( ordinal ) { - wl.add ( englishWordOnesOrd [ ones ] ); + } else if (ones > 0) { + if (ordinal) { + wl.add (englishWordOnesOrd [ ones ]); } else { - wl.add ( englishWordOnes [ ones ] ); + wl.add (englishWordOnes [ ones ]); } } return wl; @@ -813,122 +813,122 @@ public class NumberConverter { private static String[] frenchWordOnesOrdFemale = { "premi\u00e8re", "deuxi\u00e8me", "troisi\u00e8me", "quatri\u00e8me", "cinqui\u00e8me", "sixi\u00e8me", "septi\u00e8me", "huiti\u00e8me", "neuvi\u00e8me", "dixi\u00e8me" }; private static class FrenchNumberAsWordFormatter implements SpecialNumberFormatter { private int caseType = Character.UPPERCASE_LETTER; - FrenchNumberAsWordFormatter ( int caseType ) { + FrenchNumberAsWordFormatter (int caseType) { this.caseType = caseType; } - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { List wl = new ArrayList(); - if ( number >= 1000000000000L ) { + if (number >= 1000000000000L) { return null; } else { - boolean ordinal = hasFeature ( features, "ordinal" ); - if ( number == 0 ) { - wl.add ( frenchWordOnes [ 0 ] ); - } else if ( ordinal && ( number <= 10 ) ) { - boolean female = hasFeature ( features, "female" ); - if ( female ) { - wl.add ( frenchWordOnesOrdFemale [ (int) number ] ); + boolean ordinal = hasFeature (features, "ordinal"); + if (number == 0) { + wl.add (frenchWordOnes [ 0 ]); + } else if (ordinal && (number <= 10)) { + boolean female = hasFeature (features, "female"); + if (female) { + wl.add (frenchWordOnesOrdFemale [ (int) number ]); } else { - wl.add ( frenchWordOnesOrdMale [ (int) number ] ); + wl.add (frenchWordOnesOrdMale [ (int) number ]); } } else { - int ones = (int) ( number % 1000 ); - int thousands = (int) ( ( number / 1000 ) % 1000 ); - int millions = (int) ( ( number / 1000000 ) % 1000 ); - int billions = (int) ( ( number / 1000000000 ) % 1000 ); - if ( billions > 0 ) { - wl = formatOnesInThousand ( wl, billions ); - if ( billions == 1 ) { - wl.add ( frenchWordOthers[5] ); + int ones = (int) (number % 1000); + int thousands = (int) ((number / 1000) % 1000); + int millions = (int) ((number / 1000000) % 1000); + int billions = (int) ((number / 1000000000) % 1000); + if (billions > 0) { + wl = formatOnesInThousand (wl, billions); + if (billions == 1) { + wl.add (frenchWordOthers[5]); } else { - wl.add ( frenchWordOthers[6] ); + wl.add (frenchWordOthers[6]); } } - if ( millions > 0 ) { - wl = formatOnesInThousand ( wl, millions ); - if ( millions == 1 ) { - wl.add ( frenchWordOthers[3] ); + if (millions > 0) { + wl = formatOnesInThousand (wl, millions); + if (millions == 1) { + wl.add (frenchWordOthers[3]); } else { - wl.add ( frenchWordOthers[4] ); + wl.add (frenchWordOthers[4]); } } - if ( thousands > 0 ) { - if ( thousands > 1 ) { - wl = formatOnesInThousand ( wl, thousands ); + if (thousands > 0) { + if (thousands > 1) { + wl = formatOnesInThousand (wl, thousands); } - wl.add ( frenchWordOthers[2] ); + wl.add (frenchWordOthers[2]); } - if ( ones > 0 ) { - wl = formatOnesInThousand ( wl, ones ); + if (ones > 0) { + wl = formatOnesInThousand (wl, ones); } } - wl = convertWordCase ( wl, caseType ); - return UTF32.toUTF32 ( joinWords ( wl, " " ), 0, true ); + wl = convertWordCase (wl, caseType); + return UTF32.toUTF32 (joinWords (wl, " "), 0, true); } } - private List formatOnesInThousand ( List wl, int number ) { + private List formatOnesInThousand (List wl, int number) { assert number < 1000; int ones = number % 10; - int tens = ( number / 10 ) % 10; - int hundreds = ( number / 100 ) % 10; - if ( hundreds > 0 ) { - if ( hundreds > 1 ) { - wl.add ( frenchWordOnes [ hundreds ] ); + int tens = (number / 10) % 10; + int hundreds = (number / 100) % 10; + if (hundreds > 0) { + if (hundreds > 1) { + wl.add (frenchWordOnes [ hundreds ]); } - if ( ( hundreds > 1 ) && ( tens == 0 ) && ( ones == 0 ) ) { - wl.add ( frenchWordOthers[1] ); + if ((hundreds > 1) && (tens == 0) && (ones == 0)) { + wl.add (frenchWordOthers[1]); } else { - wl.add ( frenchWordOthers[0] ); + wl.add (frenchWordOthers[0]); } } - if ( tens > 0 ) { - if ( tens == 1 ) { - wl.add ( frenchWordTeens [ ones ] ); - } else if ( tens < 7 ) { - if ( ones == 1 ) { - wl.add ( frenchWordTens [ tens ] ); - wl.add ( "et" ); - wl.add ( frenchWordOnes [ ones ] ); + if (tens > 0) { + if (tens == 1) { + wl.add (frenchWordTeens [ ones ]); + } else if (tens < 7) { + if (ones == 1) { + wl.add (frenchWordTens [ tens ]); + wl.add ("et"); + wl.add (frenchWordOnes [ ones ]); } else { StringBuffer sb = new StringBuffer(); - sb.append ( frenchWordTens [ tens ] ); - if ( ones > 0 ) { - sb.append ( '-' ); - sb.append ( frenchWordOnes [ ones ] ); + sb.append (frenchWordTens [ tens ]); + if (ones > 0) { + sb.append ('-'); + sb.append (frenchWordOnes [ ones ]); } - wl.add ( sb.toString() ); + wl.add (sb.toString()); } - } else if ( tens == 7 ) { - if ( ones == 1 ) { - wl.add ( frenchWordTens [ 6 ] ); - wl.add ( "et" ); - wl.add ( frenchWordTeens [ ones ] ); + } else if (tens == 7) { + if (ones == 1) { + wl.add (frenchWordTens [ 6 ]); + wl.add ("et"); + wl.add (frenchWordTeens [ ones ]); } else { StringBuffer sb = new StringBuffer(); - sb.append ( frenchWordTens [ 6 ] ); - sb.append ( '-' ); - sb.append ( frenchWordTeens [ ones ] ); - wl.add ( sb.toString() ); + sb.append (frenchWordTens [ 6 ]); + sb.append ('-'); + sb.append (frenchWordTeens [ ones ]); + wl.add (sb.toString()); } - } else if ( tens == 8 ) { + } else if (tens == 8) { StringBuffer sb = new StringBuffer(); - sb.append ( frenchWordTens [ tens ] ); - if ( ones > 0 ) { - sb.append ( '-' ); - sb.append ( frenchWordOnes [ ones ] ); + sb.append (frenchWordTens [ tens ]); + if (ones > 0) { + sb.append ('-'); + sb.append (frenchWordOnes [ ones ]); } else { - sb.append ( 's' ); + sb.append ('s'); } - wl.add ( sb.toString() ); - } else if ( tens == 9 ) { + wl.add (sb.toString()); + } else if (tens == 9) { StringBuffer sb = new StringBuffer(); - sb.append ( frenchWordTens [ 8 ] ); - sb.append ( '-' ); - sb.append ( frenchWordTeens [ ones ] ); - wl.add ( sb.toString() ); + sb.append (frenchWordTens [ 8 ]); + sb.append ('-'); + sb.append (frenchWordTeens [ ones ]); + wl.add (sb.toString()); } - } else if ( ones > 0 ) { - wl.add ( frenchWordOnes [ ones ] ); + } else if (ones > 0) { + wl.add (frenchWordOnes [ ones ]); } return wl; } @@ -947,88 +947,88 @@ public class NumberConverter { private static String[] spanishWordOnesOrdFemale = { "ninguna", "primera", "segunda", "tercera", "cuarta", "quinta", "sexta", "s\u00e9ptima", "octava", "noventa", "d\u00e9cima" }; private static class SpanishNumberAsWordFormatter implements SpecialNumberFormatter { private int caseType = Character.UPPERCASE_LETTER; - SpanishNumberAsWordFormatter ( int caseType ) { + SpanishNumberAsWordFormatter (int caseType) { this.caseType = caseType; } - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { List wl = new ArrayList(); - if ( number >= 1000000000000L ) { + if (number >= 1000000000000L) { return null; } else { - boolean ordinal = hasFeature ( features, "ordinal" ); - if ( number == 0 ) { - wl.add ( spanishWordOnes [ 0 ] ); - } else if ( ordinal && ( number <= 10 ) ) { - boolean female = hasFeature ( features, "female" ); - if ( female ) { - wl.add ( spanishWordOnesOrdFemale [ (int) number ] ); + boolean ordinal = hasFeature (features, "ordinal"); + if (number == 0) { + wl.add (spanishWordOnes [ 0 ]); + } else if (ordinal && (number <= 10)) { + boolean female = hasFeature (features, "female"); + if (female) { + wl.add (spanishWordOnesOrdFemale [ (int) number ]); } else { - wl.add ( spanishWordOnesOrdMale [ (int) number ] ); + wl.add (spanishWordOnesOrdMale [ (int) number ]); } } else { - int ones = (int) ( number % 1000 ); - int thousands = (int) ( ( number / 1000 ) % 1000 ); - int millions = (int) ( ( number / 1000000 ) % 1000 ); - int billions = (int) ( ( number / 1000000000 ) % 1000 ); - if ( billions > 0 ) { - if ( billions > 1 ) { - wl = formatOnesInThousand ( wl, billions ); + int ones = (int) (number % 1000); + int thousands = (int) ((number / 1000) % 1000); + int millions = (int) ((number / 1000000) % 1000); + int billions = (int) ((number / 1000000000) % 1000); + if (billions > 0) { + if (billions > 1) { + wl = formatOnesInThousand (wl, billions); } - wl.add ( spanishWordOthers[2] ); - wl.add ( spanishWordOthers[4] ); + wl.add (spanishWordOthers[2]); + wl.add (spanishWordOthers[4]); } - if ( millions > 0 ) { - if ( millions == 1 ) { - wl.add ( spanishWordOthers[0] ); + if (millions > 0) { + if (millions == 1) { + wl.add (spanishWordOthers[0]); } else { - wl = formatOnesInThousand ( wl, millions ); + wl = formatOnesInThousand (wl, millions); } - if ( millions > 1 ) { - wl.add ( spanishWordOthers[4] ); + if (millions > 1) { + wl.add (spanishWordOthers[4]); } else { - wl.add ( spanishWordOthers[3] ); + wl.add (spanishWordOthers[3]); } } - if ( thousands > 0 ) { - if ( thousands > 1 ) { - wl = formatOnesInThousand ( wl, thousands ); + if (thousands > 0) { + if (thousands > 1) { + wl = formatOnesInThousand (wl, thousands); } - wl.add ( spanishWordOthers[2] ); + wl.add (spanishWordOthers[2]); } - if ( ones > 0 ) { - wl = formatOnesInThousand ( wl, ones ); + if (ones > 0) { + wl = formatOnesInThousand (wl, ones); } } - wl = convertWordCase ( wl, caseType ); - return UTF32.toUTF32 ( joinWords ( wl, " " ), 0, true ); + wl = convertWordCase (wl, caseType); + return UTF32.toUTF32 (joinWords (wl, " "), 0, true); } } - private List formatOnesInThousand ( List wl, int number ) { + private List formatOnesInThousand (List wl, int number) { assert number < 1000; int ones = number % 10; - int tens = ( number / 10 ) % 10; - int hundreds = ( number / 100 ) % 10; - if ( hundreds > 0 ) { - if ( ( hundreds == 1 ) && ( tens == 0 ) && ( ones == 0 ) ) { - wl.add ( spanishWordOthers[1] ); + int tens = (number / 10) % 10; + int hundreds = (number / 100) % 10; + if (hundreds > 0) { + if ((hundreds == 1) && (tens == 0) && (ones == 0)) { + wl.add (spanishWordOthers[1]); } else { - wl.add ( spanishWordHundreds [ hundreds ] ); + wl.add (spanishWordHundreds [ hundreds ]); } } - if ( tens > 0 ) { - if ( tens == 1 ) { - wl.add ( spanishWordTeens [ ones ] ); - } else if ( tens == 2 ) { - wl.add ( spanishWordTweens [ ones ] ); + if (tens > 0) { + if (tens == 1) { + wl.add (spanishWordTeens [ ones ]); + } else if (tens == 2) { + wl.add (spanishWordTweens [ ones ]); } else { - wl.add ( spanishWordTens [ tens ] ); - if ( ones > 0 ) { - wl.add ( "y" ); - wl.add ( spanishWordOnes [ ones ] ); + wl.add (spanishWordTens [ tens ]); + if (ones > 0) { + wl.add ("y"); + wl.add (spanishWordOnes [ ones ]); } } - } else if ( ones > 0 ) { - wl.add ( spanishWordOnes [ ones ] ); + } else if (ones > 0) { + wl.add (spanishWordOnes [ ones ]); } return wl; } @@ -1150,40 +1150,40 @@ public class NumberConverter { "\u2160" }; private static class RomanNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { List sl = new ArrayList(); - if ( number == 0 ) { + if (number == 0) { return null; } else { String[] forms; int maxNumber; - if ( hasFeature ( features, "unicode-number-forms" ) ) { + if (hasFeature (features, "unicode-number-forms")) { forms = romanNumberForms; maxNumber = 199999; - } else if ( hasFeature ( features, "large" ) ) { + } else if (hasFeature (features, "large")) { forms = romanLargeForms; maxNumber = 199999; } else { forms = romanStandardForms; maxNumber = 4999; } - if ( number > maxNumber ) { + if (number > maxNumber) { return null; } else { - while ( number > 0 ) { - for ( int i = 0, n = romanMapping.length; i < n; i++ ) { + while (number > 0) { + for (int i = 0, n = romanMapping.length; i < n; i++) { int d = romanMapping [ i ]; - if ( ( number >= d ) && ( forms [ i ] != null ) ) { - appendScalars ( sl, UTF32.toUTF32 ( forms [ i ], 0, true ) ); + if ((number >= d) && (forms [ i ] != null)) { + appendScalars (sl, UTF32.toUTF32 (forms [ i ], 0, true)); number = number - d; break; } } } - if ( one == (int) 'I' ) { - return toUpperCase ( sl.toArray ( new Integer [ sl.size() ] ) ); - } else if ( one == (int) 'i' ) { - return toLowerCase ( sl.toArray ( new Integer [ sl.size() ] ) ); + if (one == (int) 'I') { + return toUpperCase (sl.toArray (new Integer [ sl.size() ])); + } else if (one == (int) 'i') { + return toLowerCase (sl.toArray (new Integer [ sl.size() ])); } else { return null; } @@ -1196,7 +1196,7 @@ public class NumberConverter { * Isopsephry (Greek) Numerals */ private static class IsopsephryNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { return null; } } @@ -1237,15 +1237,15 @@ public class NumberConverter { 0x05E5, // FINAL TSADHI }; private class GematriaNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { - if ( one == 0x05D0 ) { - if ( letterValue == LETTER_VALUE_ALPHABETIC ) { - return formatNumberAsSequence ( number, one, hebrewGematriaAlphabeticMap.length, hebrewGematriaAlphabeticMap ); - } else if ( letterValue == LETTER_VALUE_TRADITIONAL ) { - if ( ( number == 0 ) || ( number > 1999 ) ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { + if (one == 0x05D0) { + if (letterValue == LETTER_VALUE_ALPHABETIC) { + return formatNumberAsSequence (number, one, hebrewGematriaAlphabeticMap.length, hebrewGematriaAlphabeticMap); + } else if (letterValue == LETTER_VALUE_TRADITIONAL) { + if ((number == 0) || (number > 1999)) { return null; } else { - return formatAsGematriaNumber ( number, features, language, country ); + return formatAsGematriaNumber (number, features, language, country); } } else { return null; @@ -1254,7 +1254,7 @@ public class NumberConverter { return null; } } - private Integer[] formatAsGematriaNumber ( long number, String features, String language, String country ) { + private Integer[] formatAsGematriaNumber (long number, String features, String language, String country) { List sl = new ArrayList(); assert hebrewGematriaAlphabeticMap.length == 27; assert hebrewGematriaAlphabeticMap[0] == 0x05D0; // ALEF @@ -1262,48 +1262,48 @@ public class NumberConverter { assert number != 0; assert number < 2000; int[] map = hebrewGematriaAlphabeticMap; - int thousands = (int) ( ( number / 1000 ) % 10 ); - int hundreds = (int) ( ( number / 100 ) % 10 ); - int tens = (int) ( ( number / 10 ) % 10 ); - int ones = (int) ( ( number / 1 ) % 10 ); - if ( thousands > 0 ) { - sl.add ( map [ 0 + ( thousands - 1 ) ] ); - sl.add ( 0x05F3 ); + int thousands = (int) ((number / 1000) % 10); + int hundreds = (int) ((number / 100) % 10); + int tens = (int) ((number / 10) % 10); + int ones = (int) ((number / 1) % 10); + if (thousands > 0) { + sl.add (map [ 0 + (thousands - 1) ]); + sl.add (0x05F3); } - if ( hundreds > 0 ) { + if (hundreds > 0) { assert hundreds < 10; - if ( hundreds < 5 ) { - sl.add ( map [ 18 + ( hundreds - 1 ) ] ); - } else if ( hundreds < 9 ) { - sl.add ( map [ 18 + ( 4 - 1 ) ] ); - sl.add ( 0x05F4 ); - sl.add ( map [ 18 + ( hundreds - 5 ) ] ); - } else if ( hundreds == 9 ) { - sl.add ( map [ 18 + ( 4 - 1 ) ] ); - sl.add ( map [ 18 + ( 4 - 1 ) ] ); - sl.add ( 0x05F4 ); - sl.add ( map [ 18 + ( hundreds - 9 ) ] ); + if (hundreds < 5) { + sl.add (map [ 18 + (hundreds - 1) ]); + } else if (hundreds < 9) { + sl.add (map [ 18 + (4 - 1) ]); + sl.add (0x05F4); + sl.add (map [ 18 + (hundreds - 5) ]); + } else if (hundreds == 9) { + sl.add (map [ 18 + (4 - 1) ]); + sl.add (map [ 18 + (4 - 1) ]); + sl.add (0x05F4); + sl.add (map [ 18 + (hundreds - 9) ]); } } - if ( number == 15 ) { - sl.add ( map [ 9 - 1] ); - sl.add ( 0x05F4 ); - sl.add ( map [ 6 - 1] ); - } else if ( number == 16 ) { - sl.add ( map [ 9 - 1 ] ); - sl.add ( 0x05F4 ); - sl.add ( map [ 7 - 1 ] ); + if (number == 15) { + sl.add (map [ 9 - 1]); + sl.add (0x05F4); + sl.add (map [ 6 - 1]); + } else if (number == 16) { + sl.add (map [ 9 - 1 ]); + sl.add (0x05F4); + sl.add (map [ 7 - 1 ]); } else { - if ( tens > 0 ) { + if (tens > 0) { assert tens < 10; - sl.add ( map [ 9 + ( tens - 1 ) ] ); + sl.add (map [ 9 + (tens - 1) ]); } - if ( ones > 0 ) { + if (ones > 0) { assert ones < 10; - sl.add ( map [ 0 + ( ones - 1 ) ] ); + sl.add (map [ 0 + (ones - 1) ]); } } - return sl.toArray ( new Integer [ sl.size() ] ); + return sl.toArray (new Integer [ sl.size() ]); } } @@ -1375,28 +1375,28 @@ public class NumberConverter { 0x0649, // ALEF MAQSURA }; private class ArabicNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { - if ( one == 0x0627 ) { + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { + if (one == 0x0627) { int[] map; - if ( letterValue == LETTER_VALUE_TRADITIONAL ) { + if (letterValue == LETTER_VALUE_TRADITIONAL) { map = arabicAbjadiAlphabeticMap; - } else if ( letterValue == LETTER_VALUE_ALPHABETIC ) { + } else if (letterValue == LETTER_VALUE_ALPHABETIC) { map = arabicHijaiAlphabeticMap; } else { map = arabicAbjadiAlphabeticMap; } - return formatNumberAsSequence ( number, one, map.length, map ); - } else if ( one == 0x0623 ) { - if ( ( number == 0 ) || ( number > 1999 ) ) { + return formatNumberAsSequence (number, one, map.length, map); + } else if (one == 0x0623) { + if ((number == 0) || (number > 1999)) { return null; } else { - return formatAsAbjadiNumber ( number, features, language, country ); + return formatAsAbjadiNumber (number, features, language, country); } } else { return null; } } - private Integer[] formatAsAbjadiNumber ( long number, String features, String language, String country ) { + private Integer[] formatAsAbjadiNumber (long number, String features, String language, String country) { List sl = new ArrayList(); assert arabicAbjadiAlphabeticMap.length == 28; assert arabicAbjadiAlphabeticMap[0] == 0x0623; // ALEF WITH HAMZA ABOVE @@ -1404,27 +1404,27 @@ public class NumberConverter { assert number != 0; assert number < 2000; int[] map = arabicAbjadiAlphabeticMap; - int thousands = (int) ( ( number / 1000 ) % 10 ); - int hundreds = (int) ( ( number / 100 ) % 10 ); - int tens = (int) ( ( number / 10 ) % 10 ); - int ones = (int) ( ( number / 1 ) % 10 ); - if ( thousands > 0 ) { + int thousands = (int) ((number / 1000) % 10); + int hundreds = (int) ((number / 100) % 10); + int tens = (int) ((number / 10) % 10); + int ones = (int) ((number / 1) % 10); + if (thousands > 0) { assert thousands < 2; - sl.add ( map [ 27 + ( thousands - 1 ) ] ); + sl.add (map [ 27 + (thousands - 1) ]); } - if ( hundreds > 0 ) { + if (hundreds > 0) { assert thousands < 10; - sl.add ( map [ 18 + ( hundreds - 1 ) ] ); + sl.add (map [ 18 + (hundreds - 1) ]); } - if ( tens > 0 ) { + if (tens > 0) { assert tens < 10; - sl.add ( map [ 9 + ( tens - 1 ) ] ); + sl.add (map [ 9 + (tens - 1) ]); } - if ( ones > 0 ) { + if (ones > 0) { assert ones < 10; - sl.add ( map [ 0 + ( ones - 1 ) ] ); + sl.add (map [ 0 + (ones - 1) ]); } - return sl.toArray ( new Integer [ sl.size() ] ); + return sl.toArray (new Integer [ sl.size() ]); } } @@ -1532,11 +1532,11 @@ public class NumberConverter { 0x30F3, // N }; private class KanaNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { - if ( ( one == 0x3042 ) && ( letterValue == LETTER_VALUE_ALPHABETIC ) ) { - return formatNumberAsSequence ( number, one, hiraganaGojuonAlphabeticMap.length, hiraganaGojuonAlphabeticMap ); - } else if ( ( one == 0x30A2 ) && ( letterValue == LETTER_VALUE_ALPHABETIC ) ) { - return formatNumberAsSequence ( number, one, katakanaGojuonAlphabeticMap.length, katakanaGojuonAlphabeticMap ); + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { + if ((one == 0x3042) && (letterValue == LETTER_VALUE_ALPHABETIC)) { + return formatNumberAsSequence (number, one, hiraganaGojuonAlphabeticMap.length, hiraganaGojuonAlphabeticMap); + } else if ((one == 0x30A2) && (letterValue == LETTER_VALUE_ALPHABETIC)) { + return formatNumberAsSequence (number, one, katakanaGojuonAlphabeticMap.length, katakanaGojuonAlphabeticMap); } else { return null; } @@ -1595,9 +1595,9 @@ public class NumberConverter { 0x0E2E, }; private class ThaiNumeralsFormatter implements SpecialNumberFormatter { - public Integer[] format ( long number, int one, int letterValue, String features, String language, String country ) { - if ( ( one == 0x0E01 ) && ( letterValue == LETTER_VALUE_ALPHABETIC ) ) { - return formatNumberAsSequence ( number, one, thaiAlphabeticMap.length, thaiAlphabeticMap ); + public Integer[] format (long number, int one, int letterValue, String features, String language, String country) { + if ((one == 0x0E01) && (letterValue == LETTER_VALUE_ALPHABETIC)) { + return formatNumberAsSequence (number, one, thaiAlphabeticMap.length, thaiAlphabeticMap); } else { return null; } diff --git a/src/java/org/apache/fop/complexscripts/util/ScriptContextTester.java b/src/java/org/apache/fop/complexscripts/util/ScriptContextTester.java index 2170eac73..c63bd6dfb 100644 --- a/src/java/org/apache/fop/complexscripts/util/ScriptContextTester.java +++ b/src/java/org/apache/fop/complexscripts/util/ScriptContextTester.java @@ -31,6 +31,6 @@ public interface ScriptContextTester { * @param feature a feature identifier * @return a glyph context tester or null if none available for the specified feature */ - GlyphContextTester getTester ( String feature ); + GlyphContextTester getTester (String feature); } diff --git a/src/java/org/apache/fop/complexscripts/util/UTF32.java b/src/java/org/apache/fop/complexscripts/util/UTF32.java index c455ff474..6e0adc18b 100644 --- a/src/java/org/apache/fop/complexscripts/util/UTF32.java +++ b/src/java/org/apache/fop/complexscripts/util/UTF32.java @@ -46,35 +46,35 @@ public final class UTF32 { * @throws IllegalArgumentException if substitution required and errorOnSubstitution * is not false */ - public static Integer[] toUTF32 ( String s, int substitution, boolean errorOnSubstitution ) + public static Integer[] toUTF32 (String s, int substitution, boolean errorOnSubstitution) throws IllegalArgumentException { int n; - if ( ( n = s.length() ) == 0 ) { + if ((n = s.length()) == 0) { return new Integer[0]; } else { Integer[] sa = new Integer [ n ]; int k = 0; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { int c = (int) s.charAt(i); - if ( ( c >= 0xD800 ) && ( c < 0xE000 ) ) { + if ((c >= 0xD800) && (c < 0xE000)) { int s1 = c; - int s2 = ( ( i + 1 ) < n ) ? (int) s.charAt ( i + 1 ) : 0; - if ( s1 < 0xDC00 ) { - if ( ( s2 >= 0xDC00 ) && ( s2 < 0xE000 ) ) { - c = ( ( s1 - 0xD800 ) << 10 ) + ( s2 - 0xDC00 ) + 65536; + int s2 = ((i + 1) < n) ? (int) s.charAt (i + 1) : 0; + if (s1 < 0xDC00) { + if ((s2 >= 0xDC00) && (s2 < 0xE000)) { + c = ((s1 - 0xD800) << 10) + (s2 - 0xDC00) + 65536; i++; } else { - if ( errorOnSubstitution ) { + if (errorOnSubstitution) { throw new IllegalArgumentException - ( "isolated high (leading) surrogate" ); + ("isolated high (leading) surrogate"); } else { c = substitution; } } } else { - if ( errorOnSubstitution ) { + if (errorOnSubstitution) { throw new IllegalArgumentException - ( "isolated low (trailing) surrogate" ); + ("isolated low (trailing) surrogate"); } else { c = substitution; } @@ -82,11 +82,11 @@ public final class UTF32 { } sa[k++] = c; } - if ( k == n ) { + if (k == n) { return sa; } else { Integer[] na = new Integer [ k ]; - System.arraycopy ( sa, 0, na, 0, k ); + System.arraycopy (sa, 0, na, 0, k); return na; } } @@ -99,28 +99,28 @@ public final class UTF32 { * @throws IllegalArgumentException if an input scalar value is illegal, * e.g., a surrogate or out of range */ - public static String fromUTF32 ( Integer[] sa ) throws IllegalArgumentException { + public static String fromUTF32 (Integer[] sa) throws IllegalArgumentException { StringBuffer sb = new StringBuffer(); - for ( int s : sa ) { - if ( s < 65535 ) { - if ( ( s < 0xD800 ) || ( s > 0xDFFF ) ) { - sb.append ( (char) s ); + for (int s : sa) { + if (s < 65535) { + if ((s < 0xD800) || (s > 0xDFFF)) { + sb.append ((char) s); } else { String ncr = CharUtilities.charToNCRef(s); throw new IllegalArgumentException - ( "illegal scalar value 0x" + ncr.substring(2, ncr.length() - 1) - + "; cannot be UTF-16 surrogate" ); + ("illegal scalar value 0x" + ncr.substring(2, ncr.length() - 1) + + "; cannot be UTF-16 surrogate"); } - } else if ( s < 1114112 ) { - int s1 = ( ( ( s - 65536 ) >> 10 ) & 0x3FF ) + 0xD800; - int s2 = ( ( ( s - 65536 ) >> 0 ) & 0x3FF ) + 0xDC00; - sb.append ( (char) s1 ); - sb.append ( (char) s2 ); + } else if (s < 1114112) { + int s1 = (((s - 65536) >> 10) & 0x3FF) + 0xD800; + int s2 = (((s - 65536) >> 0) & 0x3FF) + 0xDC00; + sb.append ((char) s1); + sb.append ((char) s2); } else { String ncr = CharUtilities.charToNCRef(s); throw new IllegalArgumentException - ( "illegal scalar value 0x" + ncr.substring(2, ncr.length() - 1) - + "; out of range for UTF-16" ); + ("illegal scalar value 0x" + ncr.substring(2, ncr.length() - 1) + + "; out of range for UTF-16"); } } return sb.toString(); diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java index 6c4553228..7c5759e6b 100644 --- a/src/java/org/apache/fop/events/Event.java +++ b/src/java/org/apache/fop/events/Event.java @@ -50,7 +50,7 @@ public class Event extends EventObject { */ public Event(Object source, String eventID, EventSeverity severity, Map params) { - this ( source, eventID, severity, Locale.getDefault(), params ); + this (source, eventID, severity, Locale.getDefault(), params); } /** diff --git a/src/java/org/apache/fop/events/EventFormatter.java b/src/java/org/apache/fop/events/EventFormatter.java index 32fd7f110..36a867232 100644 --- a/src/java/org/apache/fop/events/EventFormatter.java +++ b/src/java/org/apache/fop/events/EventFormatter.java @@ -47,15 +47,15 @@ public final class EventFormatter { //utility class } - private static ResourceBundle getBundle ( String groupID, Locale locale ) { + private static ResourceBundle getBundle (String groupID, Locale locale) { ResourceBundle bundle; - String baseName = ( groupID != null ) ? groupID : EventFormatter.class.getName(); + String baseName = (groupID != null) ? groupID : EventFormatter.class.getName(); try { ClassLoader classLoader = EventFormatter.class.getClassLoader(); - bundle = XMLResourceBundle.getXMLBundle ( baseName, locale, classLoader ); - } catch ( MissingResourceException e ) { - if ( log.isTraceEnabled() ) { - log.trace ( "No XMLResourceBundle for " + baseName + " available." ); + bundle = XMLResourceBundle.getXMLBundle (baseName, locale, classLoader); + } catch (MissingResourceException e) { + if (log.isTraceEnabled()) { + log.trace ("No XMLResourceBundle for " + baseName + " available."); } bundle = null; } @@ -67,8 +67,8 @@ public final class EventFormatter { * @param event the event * @return the formatted message */ - public static String format ( Event event ) { - return format ( event, event.getLocale() ); + public static String format (Event event) { + return format (event, event.getLocale()); } /** @@ -78,19 +78,19 @@ public final class EventFormatter { * @return the formatted message */ public static String format(Event event, Locale locale) { - return format ( event, getBundle ( event.getEventGroupID(), locale ) ); + return format (event, getBundle (event.getEventGroupID(), locale)); } - private static String format ( Event event, ResourceBundle bundle ) { + private static String format (Event event, ResourceBundle bundle) { assert event != null; String key = event.getEventKey(); String template; - if ( bundle != null ) { - template = bundle.getString ( key ); + if (bundle != null) { + template = bundle.getString (key); } else { template = "Missing bundle. Can't lookup event key: '" + key + "'."; } - return format ( event, processIncludes ( template, bundle ) ); + return format (event, processIncludes (template, bundle)); } private static String processIncludes(String template, ResourceBundle bundle) { @@ -109,7 +109,7 @@ public final class EventFormatter { private static int processIncludesInner(CharSequence template, StringBuffer sb, ResourceBundle bundle) { int replacements = 0; - if ( bundle != null ) { + if (bundle != null) { Matcher m = INCLUDES_PATTERN.matcher(template); while (m.find()) { String include = m.group(); @@ -154,8 +154,8 @@ public final class EventFormatter { public void write(StringBuffer sb, Map params) { String groupID = (String) params.get("groupID"); Locale locale = (Locale) params.get("locale"); - ResourceBundle bundle = getBundle ( groupID, locale ); - if ( bundle != null ) { + ResourceBundle bundle = getBundle (groupID, locale); + if (bundle != null) { sb.append(bundle.getString(getKey(params))); } } diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index c9fd7e59a..2722498c7 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -438,8 +438,8 @@ public abstract class FONode implements Cloneable { * with the unabbreviated URI otherwise. */ public static String getNodeString(String namespaceURI, String localName) { - String prefix = getNodePrefix ( namespaceURI ); - if ( prefix != null ) { + String prefix = getNodePrefix (namespaceURI); + if (prefix != null) { return prefix + ":" + localName; } else { return "(Namespace URI: \"" + namespaceURI + "\", " @@ -552,9 +552,9 @@ public abstract class FONode implements Cloneable { protected void invalidChildError(Locator loc, String parentName, String nsURI, String lName, String ruleViolated) throws ValidationException { - String prefix = getNodePrefix ( nsURI ); + String prefix = getNodePrefix (nsURI); QName qn; // qualified name of offending node - if ( prefix != null ) { + if (prefix != null) { qn = new QName(nsURI, prefix, lName); } else { qn = new QName(nsURI, lName); @@ -926,7 +926,7 @@ public abstract class FONode implements Cloneable { * @return true if indicated boundary (or boundaries) constitute a delimited text range * boundary. */ - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return true; } @@ -936,23 +936,23 @@ public abstract class FONode implements Cloneable { * @param ranges a stack of delimited text ranges * @return the (possibly) updated stack of delimited text ranges */ - public Stack collectDelimitedTextRanges ( Stack ranges ) { + public Stack collectDelimitedTextRanges (Stack ranges) { // if boundary before, then push new range - if ( isRangeBoundaryBefore() ) { - maybeNewRange ( ranges ); + if (isRangeBoundaryBefore()) { + maybeNewRange (ranges); } // get current range, if one exists DelimitedTextRange currentRange; - if ( ranges.size() > 0 ) { + if (ranges.size() > 0) { currentRange = (DelimitedTextRange) ranges.peek(); } else { currentRange = null; } // proceses this node - ranges = collectDelimitedTextRanges ( ranges, currentRange ); + ranges = collectDelimitedTextRanges (ranges, currentRange); // if boundary after, then push new range - if ( isRangeBoundaryAfter() ) { - maybeNewRange ( ranges ); + if (isRangeBoundaryAfter()) { + maybeNewRange (ranges); } return ranges; } @@ -965,9 +965,9 @@ public abstract class FONode implements Cloneable { * @param currentRange the current range or null (if none) * @return the (possibly) updated stack of delimited text ranges */ - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - for ( Iterator it = getChildNodes(); ( it != null ) && it.hasNext();) { - ranges = ( (FONode) it.next() ).collectDelimitedTextRanges ( ranges ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) { + ranges = ((FONode) it.next()).collectDelimitedTextRanges (ranges); } return ranges; } @@ -992,23 +992,23 @@ public abstract class FONode implements Cloneable { * @param ranges stack of delimited text ranges * @return new range (if constructed and pushed onto stack) or current range (if any) or null */ - private DelimitedTextRange maybeNewRange ( Stack ranges ) { + private DelimitedTextRange maybeNewRange (Stack ranges) { DelimitedTextRange rCur = null; // current range (top of range stack) DelimitedTextRange rNew = null; // new range to be pushed onto range stack - if ( ranges.empty() ) { - if ( isBidiRangeBlockItem() ) { + if (ranges.empty()) { + if (isBidiRangeBlockItem()) { rNew = new DelimitedTextRange(this); } } else { rCur = (DelimitedTextRange) ranges.peek(); - if ( rCur != null ) { - if ( !rCur.isEmpty() || !isSelfOrDescendent ( rCur.getNode(), this ) ) { + if (rCur != null) { + if (!rCur.isEmpty() || !isSelfOrDescendent (rCur.getNode(), this)) { rNew = new DelimitedTextRange(this); } } } - if ( rNew != null ) { - ranges.push ( rNew ); + if (rNew != null) { + ranges.push (rNew); } else { rNew = rCur; } @@ -1016,19 +1016,19 @@ public abstract class FONode implements Cloneable { } private boolean isRangeBoundaryBefore() { - return isDelimitedTextRangeBoundary ( Constants.EN_BEFORE ); + return isDelimitedTextRangeBoundary (Constants.EN_BEFORE); } private boolean isRangeBoundaryAfter() { - return isDelimitedTextRangeBoundary ( Constants.EN_AFTER ); + return isDelimitedTextRangeBoundary (Constants.EN_AFTER); } /** * Determine if node N2 is the same or a descendent of node N1. */ - private static boolean isSelfOrDescendent ( FONode n1, FONode n2 ) { - for ( FONode n = n2; n != null; n = n.getParent() ) { - if ( n == n1 ) { + private static boolean isSelfOrDescendent (FONode n1, FONode n2) { + for (FONode n = n2; n != null; n = n.getParent()) { + if (n == n1) { return true; } } diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 3ae81c62a..a8a3d5bb6 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -1503,32 +1503,32 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("fox:block-progression-unit", l); } - private Property calcWritingModeDependent ( int pv, int wm ) { - if ( pv == EN_LEFT ) { - if ( wm == Constants.EN_LR_TB ) { + private Property calcWritingModeDependent (int pv, int wm) { + if (pv == EN_LEFT) { + if (wm == Constants.EN_LR_TB) { pv = EN_START; - } else if ( wm == Constants.EN_RL_TB ) { + } else if (wm == Constants.EN_RL_TB) { pv = EN_END; } else { pv = EN_START; } - } else if ( pv == EN_RIGHT ) { - if ( wm == Constants.EN_LR_TB ) { + } else if (pv == EN_RIGHT) { + if (wm == Constants.EN_LR_TB) { pv = EN_END; - } else if ( wm == Constants.EN_RL_TB ) { + } else if (wm == Constants.EN_RL_TB) { pv = EN_START; } else { pv = EN_END; } } - return makeWritingModeDependentEnum ( pv ); + return makeWritingModeDependentEnum (pv); } - private Property makeWritingModeDependentEnum ( int pv ) { - if ( pv == EN_START ) { - return getEnumProperty ( EN_START, "START" ); - } else if ( pv == EN_END ) { - return getEnumProperty ( EN_END, "END" ); + private Property makeWritingModeDependentEnum (int pv) { + if (pv == EN_START) { + return getEnumProperty (EN_START, "START"); + } else if (pv == EN_END) { + return getEnumProperty (EN_END, "END"); } else { return null; } @@ -1623,11 +1623,11 @@ public final class FOPropertyMapping implements Constants { public Property get(int subpropId, PropertyList propertyList, boolean bTryInherit, boolean bTryDefault) throws PropertyException { Property p = super.get(subpropId, propertyList, bTryInherit, bTryDefault); - if ( p != null ) { + if (p != null) { int pv = p.getEnum(); - if ( ( pv == EN_LEFT ) || ( pv == EN_RIGHT ) ) { + if ((pv == EN_LEFT) || (pv == EN_RIGHT)) { p = calcWritingModeDependent - ( pv, propertyList.get(Constants.PR_WRITING_MODE).getEnum() ); + (pv, propertyList.get(Constants.PR_WRITING_MODE).getEnum()); } } return p; @@ -1677,10 +1677,10 @@ public final class FOPropertyMapping implements Constants { return getEnumProperty(EN_CENTER, "CENTER"); } else if (correspondingValue == EN_LEFT) { return calcWritingModeDependent - ( EN_LEFT, propertyList.get(Constants.PR_WRITING_MODE).getEnum() ); + (EN_LEFT, propertyList.get(Constants.PR_WRITING_MODE).getEnum()); } else if (correspondingValue == EN_RIGHT) { return calcWritingModeDependent - ( EN_RIGHT, propertyList.get(Constants.PR_WRITING_MODE).getEnum() ); + (EN_RIGHT, propertyList.get(Constants.PR_WRITING_MODE).getEnum()); } else { return null; } diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 6806d752d..caa27ed0c 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -114,15 +114,15 @@ public class FOText extends FONode implements CharSequence { PropertyList list, Locator locator) throws FOPException { if (charBuffer == null) { // buffer not yet initialized, do so now - int newLength = ( length < 16 ) ? 16 : length; + int newLength = (length < 16) ? 16 : length; charBuffer = CharBuffer.allocate(newLength); } else { // allocate a larger buffer, and transfer contents int requires = charBuffer.position() + length; int capacity = charBuffer.capacity(); - if ( requires > capacity ) { + if (requires > capacity) { int newCapacity = capacity * 2; - if ( requires > newCapacity ) { + if (requires > newCapacity) { newCapacity = requires; } CharBuffer newBuffer = CharBuffer.allocate(newCapacity); @@ -194,7 +194,7 @@ public class FOText extends FONode implements CharSequence { /** {@inheritDoc} */ public void endOfNode() throws FOPException { - if ( charBuffer != null ) { + if (charBuffer != null) { charBuffer.rewind(); } super.endOfNode(); @@ -664,7 +664,7 @@ public class FOText extends FONode implements CharSequence { /** {@inheritDoc} */ public String toString() { - if ( charBuffer == null ) { + if (charBuffer == null) { return ""; } else { CharBuffer cb = charBuffer.duplicate(); @@ -717,7 +717,7 @@ public class FOText extends FONode implements CharSequence { } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } @@ -737,16 +737,16 @@ public class FOText extends FONode implements CharSequence { * @param start the starting index of interval * @param end the ending index of interval */ - public void setBidiLevel ( int level, int start, int end ) { - if ( start < end ) { - if ( bidiLevels == null ) { + public void setBidiLevel (int level, int start, int end) { + if (start < end) { + if (bidiLevels == null) { bidiLevels = new int [ length() ]; } - for ( int i = start, n = end; i < n; i++ ) { + for (int i = start, n = end; i < n; i++) { bidiLevels [ i ] = level; } - if ( parent != null ) { - ( (FObj) parent ).setBidiLevel ( level ); + if (parent != null) { + ((FObj) parent).setBidiLevel (level); } } else { assert start < end; @@ -771,12 +771,12 @@ public class FOText extends FONode implements CharSequence { * @return a (possibly empty) array of bidi levels or null * in case no bidi levels have been assigned */ - public int[] getBidiLevels ( int start, int end ) { - if ( this.bidiLevels != null ) { + public int[] getBidiLevels (int start, int end) { + if (this.bidiLevels != null) { assert start <= end; int n = end - start; int[] bidiLevels = new int [ n ]; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { bidiLevels[i] = this.bidiLevels [ start + i ]; } return bidiLevels; @@ -794,10 +794,10 @@ public class FOText extends FONode implements CharSequence { * @throws IndexOutOfBoundsException if position is not non-negative integer * or is greater than or equal to length */ - public int bidiLevelAt ( int position ) throws IndexOutOfBoundsException { - if ( ( position < 0 ) || ( position >= length() ) ) { + public int bidiLevelAt (int position) throws IndexOutOfBoundsException { + if ((position < 0) || (position >= length())) { throw new IndexOutOfBoundsException(); - } else if ( bidiLevels != null ) { + } else if (bidiLevels != null) { return bidiLevels [ position ]; } else { return -1; @@ -810,11 +810,11 @@ public class FOText extends FONode implements CharSequence { * @param end index in character buffer * @param mappedChars sequence of character codes denoting substituted characters */ - public void addMapping ( int start, int end, CharSequence mappedChars ) { - if ( mappings == null ) { + public void addMapping (int start, int end, CharSequence mappedChars) { + if (mappings == null) { mappings = new java.util.HashMap(); } - mappings.put ( new MapRange ( start, end ), mappedChars.toString() ); + mappings.put (new MapRange (start, end), mappedChars.toString()); } /** @@ -824,8 +824,8 @@ public class FOText extends FONode implements CharSequence { * @return true if a mapping exist such that the mapping's interval is coincident to * [start,end) */ - public boolean hasMapping ( int start, int end ) { - return ( mappings != null ) && ( mappings.containsKey ( new MapRange ( start, end ) ) ); + public boolean hasMapping (int start, int end) { + return (mappings != null) && (mappings.containsKey (new MapRange (start, end))); } /** @@ -835,9 +835,9 @@ public class FOText extends FONode implements CharSequence { * @return a string of characters representing the mapping over the interval * [start,end) */ - public String getMapping ( int start, int end ) { - if ( mappings != null ) { - return (String) mappings.get ( new MapRange ( start, end ) ); + public String getMapping (int start, int end) { + if (mappings != null) { + return (String) mappings.get (new MapRange (start, end)); } else { return null; } @@ -849,9 +849,9 @@ public class FOText extends FONode implements CharSequence { * @param end index in character buffer * @return the length of the mapping (if present) or zero */ - public int getMappingLength ( int start, int end ) { - if ( mappings != null ) { - return ( (String) mappings.get ( new MapRange ( start, end ) ) ) .length(); + public int getMappingLength (int start, int end) { + if (mappings != null) { + return ((String) mappings.get (new MapRange (start, end))) .length(); } else { return 0; } @@ -864,37 +864,37 @@ public class FOText extends FONode implements CharSequence { * @return a (possibly empty) array of bidi levels or null * in case no bidi levels have been assigned */ - public int[] getMappingBidiLevels ( int start, int end ) { - if ( hasMapping ( start, end ) ) { + public int[] getMappingBidiLevels (int start, int end) { + if (hasMapping (start, end)) { int nc = end - start; - int nm = getMappingLength ( start, end ); - int[] la = getBidiLevels ( start, end ); - if ( la == null ) { + int nm = getMappingLength (start, end); + int[] la = getBidiLevels (start, end); + if (la == null) { return null; - } else if ( nm == nc ) { // mapping is same length as mapped range + } else if (nm == nc) { // mapping is same length as mapped range return la; - } else if ( nm > nc ) { // mapping is longer than mapped range + } else if (nm > nc) { // mapping is longer than mapped range int[] ma = new int [ nm ]; - System.arraycopy ( la, 0, ma, 0, la.length ); - for ( int i = la.length, - n = ma.length, l = ( i > 0 ) ? la [ i - 1 ] : 0; i < n; i++ ) { + System.arraycopy (la, 0, ma, 0, la.length); + for (int i = la.length, + n = ma.length, l = (i > 0) ? la [ i - 1 ] : 0; i < n; i++) { ma [ i ] = l; } return ma; } else { // mapping is shorter than mapped range int[] ma = new int [ nm ]; - System.arraycopy ( la, 0, ma, 0, ma.length ); + System.arraycopy (la, 0, ma, 0, ma.length); return ma; } } else { - return getBidiLevels ( start, end ); + return getBidiLevels (start, end); } } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - if ( currentRange != null ) { - currentRange.append ( charIterator(), this ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + if (currentRange != null) { + currentRange.append (charIterator(), this); } return ranges; } @@ -907,12 +907,12 @@ public class FOText extends FONode implements CharSequence { this.end = end; } public int hashCode() { - return ( start * 31 ) + end; + return (start * 31) + end; } - public boolean equals ( Object o ) { - if ( o instanceof MapRange ) { + public boolean equals (Object o) { + if (o instanceof MapRange) { MapRange r = (MapRange) o; - return ( r.start == start ) && ( r.end == end ); + return (r.start == start) && (r.end == end); } else { return false; } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index e7b4fc2e9..96b817de3 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -608,14 +608,14 @@ public abstract class FObj extends FONode implements Constants { */ public void setBidiLevel(int bidiLevel) { assert bidiLevel >= 0; - if ( bidiLevel >= 0 ) { - if ( ( this.bidiLevel < 0 ) || ( bidiLevel < this.bidiLevel ) ) { + if (bidiLevel >= 0) { + if ((this.bidiLevel < 0) || (bidiLevel < this.bidiLevel)) { this.bidiLevel = bidiLevel; - if ( parent != null ) { + if (parent != null) { FObj foParent = (FObj) parent; int parentBidiLevel = foParent.getBidiLevel(); - if ( ( parentBidiLevel < 0 ) || ( bidiLevel < parentBidiLevel ) ) { - foParent.setBidiLevel ( bidiLevel ); + if ((parentBidiLevel < 0) || (bidiLevel < parentBidiLevel)) { + foParent.setBidiLevel (bidiLevel); } } } @@ -639,10 +639,10 @@ public abstract class FObj extends FONode implements Constants { * any ancestor */ public int getBidiLevelRecursive() { - for ( FONode fn = this; fn != null; fn = fn.getParent() ) { - if ( fn instanceof FObj ) { - int level = ( (FObj) fn).getBidiLevel(); - if ( level >= 0 ) { + for (FONode fn = this; fn != null; fn = fn.getParent()) { + if (fn instanceof FObj) { + int level = ((FObj) fn).getBidiLevel(); + if (level >= 0) { return level; } } diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index 49bbf48a0..99018636e 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -302,7 +302,7 @@ public abstract class PropertyList { propID = -1; break; } - } catch ( PropertyException e ) { + } catch (PropertyException e) { propID = -1; } return propID; @@ -311,7 +311,7 @@ public abstract class PropertyList { private String addAttributeToList(Attributes attributes, String attributeName) throws ValidationException { String attributeValue = attributes.getValue(attributeName); - if ( attributeValue != null ) { + if (attributeValue != null) { convertAttributeToProperty(attributes, attributeName, attributeValue); } return attributeValue; diff --git a/src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java b/src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java index 7eb463fb6..a3698edf1 100644 --- a/src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java @@ -42,10 +42,10 @@ public class FromNearestSpecifiedValueFunction extends FunctionBase { @Override /** {@inheritDoc} */ public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { - if ( index == 0 ) { - return getPropertyName ( pi ); + if (index == 0) { + return getPropertyName (pi); } else { - return super.getOptionalArgDefault ( index, pi ); + return super.getOptionalArgDefault (index, pi); } } diff --git a/src/java/org/apache/fop/fo/expr/FromParentFunction.java b/src/java/org/apache/fop/fo/expr/FromParentFunction.java index e24074e9d..ce6873e54 100644 --- a/src/java/org/apache/fop/fo/expr/FromParentFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromParentFunction.java @@ -43,10 +43,10 @@ public class FromParentFunction extends FunctionBase { @Override /** {@inheritDoc} */ public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { - if ( index == 0 ) { - return getPropertyName ( pi ); + if (index == 0) { + return getPropertyName (pi); } else { - return super.getOptionalArgDefault ( index, pi ); + return super.getOptionalArgDefault (index, pi); } } diff --git a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java index 48ea4e152..98d4e1d07 100644 --- a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java @@ -51,10 +51,10 @@ public class FromTableColumnFunction extends FunctionBase { @Override /** {@inheritDoc} */ public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { - if ( index == 0 ) { - return getPropertyName ( pi ); + if (index == 0) { + return getPropertyName (pi); } else { - return super.getOptionalArgDefault ( index, pi ); + return super.getOptionalArgDefault (index, pi); } } diff --git a/src/java/org/apache/fop/fo/expr/FunctionBase.java b/src/java/org/apache/fop/fo/expr/FunctionBase.java index 6e0fd6702..bb68a1201 100644 --- a/src/java/org/apache/fop/fo/expr/FunctionBase.java +++ b/src/java/org/apache/fop/fo/expr/FunctionBase.java @@ -35,9 +35,9 @@ public abstract class FunctionBase implements Function { /** {@inheritDoc} */ public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { - if ( index >= getOptionalArgsCount() ) { - PropertyException e = new PropertyException ( new IndexOutOfBoundsException ( "illegal optional argument index" ) ); - e.setPropertyInfo ( pi ); + if (index >= getOptionalArgsCount()) { + PropertyException e = new PropertyException (new IndexOutOfBoundsException ("illegal optional argument index")); + e.setPropertyInfo (pi); throw e; } else { return null; @@ -58,7 +58,7 @@ public abstract class FunctionBase implements Function { * @param pi property information instance that applies to property being evaluated * @return string property whose value is name of property being evaluated */ - protected final Property getPropertyName ( PropertyInfo pi ) { - return StringProperty.getInstance ( pi.getPropertyMaker().getName() ); + protected final Property getPropertyName (PropertyInfo pi) { + return StringProperty.getInstance (pi.getPropertyMaker().getName()); } } diff --git a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java index 6e982bd31..35d5803e9 100644 --- a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java @@ -42,10 +42,10 @@ public class InheritedPropFunction extends FunctionBase { @Override /** {@inheritDoc} */ public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { - if ( index == 0 ) { - return getPropertyName ( pi ); + if (index == 0) { + return getPropertyName (pi); } else { - return super.getOptionalArgDefault ( index, pi ); + return super.getOptionalArgDefault (index, pi); } } diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index f3e3e4a50..b910c1c12 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -370,10 +370,10 @@ public final class PropertyParser extends PropertyTokenizer { while (true) { Property p = parseAdditiveExpr(); int i = args.size(); - if ( ( i < numReq ) || ( ( i - numReq ) < numOpt ) || hasVar ) { - args.add ( p ); + if ((i < numReq) || ((i - numReq) < numOpt) || hasVar) { + args.add (p); } else { - throw new PropertyException ( "Unexpected function argument at index " + i ); + throw new PropertyException ("Unexpected function argument at index " + i); } // ignore extra args if (currentToken != TOK_COMMA) { @@ -384,16 +384,16 @@ public final class PropertyParser extends PropertyTokenizer { expectRpar(); } int numArgs = args.size(); - if ( numArgs < numReq ) { + if (numArgs < numReq) { throw new PropertyException("Expected " + numReq + " required arguments, but only " + numArgs + " specified"); } else { - for ( int i = 0; i < numOpt; i++ ) { - if ( args.size() < ( numReq + i + 1 ) ) { - args.add ( function.getOptionalArgDefault ( i, propInfo ) ); + for (int i = 0; i < numOpt; i++) { + if (args.size() < (numReq + i + 1)) { + args.add (function.getOptionalArgDefault (i, propInfo)); } } } - return (Property[]) args.toArray ( new Property [ args.size() ] ); + return (Property[]) args.toArray (new Property [ args.size() ]); } /** diff --git a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java index 3c9c81d27..159f91304 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java @@ -79,7 +79,7 @@ class PropertyTokenizer { currentTokenValue = null; currentTokenStartIndex = exprIndex; boolean bSawDecimal; - while ( true ) { + while (true) { if (exprIndex >= exprLength) { currentToken = TOK_EOF; return; @@ -254,8 +254,8 @@ class PropertyTokenizer { } private void scanRestOfName() { - while ( ++exprIndex < exprLength ) { - if ( !isNameChar ( expr.charAt ( exprIndex ) ) ) { + while (++exprIndex < exprLength) { + if (!isNameChar (expr.charAt (exprIndex))) { break; } } diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java index 2bf0061b0..f0b0bc7b5 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java +++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java @@ -254,14 +254,14 @@ public abstract class AbstractGraphics extends FObj public abstract Length getIntrinsicAlignmentAdjust(); @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - if ( currentRange != null ) { - currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + if (currentRange != null) { + currentRange.append (CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this); } return ranges; } diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java index 68582a430..2127b98ea 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java @@ -201,14 +201,14 @@ public abstract class AbstractPageNumberCitation extends FObj } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - if ( currentRange != null ) { - currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + if (currentRange != null) { + currentRange.append (CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this); } return ranges; } diff --git a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java index 018f6bb73..f69649110 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java @@ -122,7 +122,7 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { newPropertyList); addChildTo(newChild, newParent); newChild.startOfNode(); - switch ( newChild.getNameId() ) { + switch (newChild.getNameId()) { case FO_TABLE: Table t = (Table) child; cloneSubtree(t.getColumns().iterator(), diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 0c14688b7..62e4d7c5c 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -97,27 +97,27 @@ public class BidiOverride extends Inline { } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { char pfx = 0; char sfx = 0; int unicodeBidi = getUnicodeBidi(); int direction = getDirection(); - if ( unicodeBidi == Constants.EN_BIDI_OVERRIDE ) { - pfx = ( direction == Constants.EN_RTL ) ? CharUtilities.RLO : CharUtilities.LRO; + if (unicodeBidi == Constants.EN_BIDI_OVERRIDE) { + pfx = (direction == Constants.EN_RTL) ? CharUtilities.RLO : CharUtilities.LRO; sfx = CharUtilities.PDF; - } else if ( unicodeBidi == Constants.EN_EMBED ) { - pfx = ( direction == Constants.EN_RTL ) ? CharUtilities.RLE : CharUtilities.LRE; + } else if (unicodeBidi == Constants.EN_EMBED) { + pfx = (direction == Constants.EN_RTL) ? CharUtilities.RLE : CharUtilities.LRE; sfx = CharUtilities.PDF; } - if ( currentRange != null ) { - if ( pfx != 0 ) { - currentRange.append ( pfx, this ); + if (currentRange != null) { + if (pfx != 0) { + currentRange.append (pfx, this); } - for ( Iterator it = getChildNodes(); ( it != null ) && it.hasNext();) { - ranges = ( (FONode) it.next() ).collectDelimitedTextRanges ( ranges ); + for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) { + ranges = ((FONode) it.next()).collectDelimitedTextRanges (ranges); } - if ( sfx != 0 ) { - currentRange.append ( sfx, this ); + if (sfx != 0) { + currentRange.append (sfx, this); } } return ranges; diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 005f9289a..bab0f7ac5 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -98,7 +98,7 @@ public class BlockContainer extends FObj implements BreakPropertySet, WritingMod referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); span = pList.get(PR_SPAN).getEnum(); writingModeTraits = new WritingModeTraits - ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) ); + (WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum())); disableColumnBalancing = pList.get(PR_X_DISABLE_COLUMN_BALANCING).getEnum(); } diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index 2d0814301..8e59d1f9b 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.java @@ -236,14 +236,14 @@ public class Character extends FObj implements StructureTreeElementHolder { } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - if ( currentRange != null ) { - currentRange.append ( charIterator(), this ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + if (currentRange != null) { + currentRange.append (charIterator(), this); } return ranges; } diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index b8e9fd09a..e3d3bd84c 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java @@ -96,7 +96,7 @@ public class InlineContainer extends FObj { overflow = pList.get(PR_OVERFLOW).getEnum(); referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); writingModeTraits = new WritingModeTraits - ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) ); + (WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum())); } /** @@ -252,7 +252,7 @@ public class InlineContainer extends FObj { } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } diff --git a/src/java/org/apache/fop/fo/flow/InlineLevel.java b/src/java/org/apache/fop/fo/flow/InlineLevel.java index b0531f859..66c03cf7d 100644 --- a/src/java/org/apache/fop/fo/flow/InlineLevel.java +++ b/src/java/org/apache/fop/fo/flow/InlineLevel.java @@ -113,7 +113,7 @@ public abstract class InlineLevel extends FObjMixed implements CommonAccessibili } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index c1fd98002..e39996a97 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -116,12 +116,12 @@ public class Leader extends InlineLevel { protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { if (FO_URI.equals(nsURI)) { - if ( localName.equals("leader") + if (localName.equals("leader") || localName.equals("inline-container") || localName.equals("block-container") || localName.equals("float") || localName.equals("marker") - || !isInlineItem(nsURI, localName) ) { + || !isInlineItem(nsURI, localName)) { invalidChildError(loc, nsURI, localName); } } @@ -203,12 +203,12 @@ public class Leader extends InlineLevel { } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { - if ( currentRange != null ) { - if ( leaderPattern == EN_USECONTENT ) { - ranges = super.collectDelimitedTextRanges ( ranges, currentRange ); + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { + if (currentRange != null) { + if (leaderPattern == EN_USECONTENT) { + ranges = super.collectDelimitedTextRanges (ranges, currentRange); } else { - currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this ); + currentRange.append (CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this); } } return ranges; diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index bfd512f4d..2e572aac5 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -206,14 +206,14 @@ public class ListItem extends FObj implements BreakPropertySet, CommonAccessibil } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { ListItemLabel label = getLabel(); - if ( label != null ) { - ranges = label.collectDelimitedTextRanges ( ranges ); + if (label != null) { + ranges = label.collectDelimitedTextRanges (ranges); } ListItemBody body = getBody(); - if ( body != null ) { - ranges = body.collectDelimitedTextRanges ( ranges ); + if (body != null) { + ranges = body.collectDelimitedTextRanges (ranges); } return ranges; } diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 33b34e2d5..1cd76e572 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -201,7 +201,7 @@ public class PageNumber extends FObj } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index dd15187f2..a62d4f7a9 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.java @@ -150,7 +150,7 @@ public class Wrapper extends FObjMixed implements CommonAccessibilityHolder { } @Override - public boolean isDelimitedTextRangeBoundary ( int boundary ) { + public boolean isDelimitedTextRangeBoundary (int boundary) { return false; } diff --git a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java index 9f3ed195d..89cba94c9 100644 --- a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java +++ b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java @@ -77,7 +77,7 @@ public class ColumnNumberManager { for (int i = 0; i < pendingSpans.size(); i++) { pSpan = (PendingSpan) pendingSpans.get(i); if (pSpan != null) { - if ( pSpan.decrRowsLeft() == 0 ) { + if (pSpan.decrRowsLeft() == 0) { pendingSpans.set(i, null); } else { usedColumnIndices.set(i); diff --git a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java index e69439276..639e01db4 100644 --- a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java +++ b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java @@ -75,10 +75,10 @@ public class ConditionalBorder { */ ConditionalBorder(BorderSpecification borderSpecification, CollapsingBorderModel collapsingBorderModel) { - this ( borderSpecification, borderSpecification, + this (borderSpecification, borderSpecification, borderSpecification.getBorderInfo().getWidth().isDiscard() ? BorderSpecification.getDefaultBorder() : borderSpecification, - collapsingBorderModel ); + collapsingBorderModel); } /** diff --git a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java b/src/java/org/apache/fop/fo/flow/table/PendingSpan.java index feaaf304a..5b0d72120 100644 --- a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java +++ b/src/java/org/apache/fop/fo/flow/table/PendingSpan.java @@ -48,7 +48,7 @@ class PendingSpan { * @return number of rows spanned after decrementing */ public int decrRowsLeft() { - if ( rowsLeft > 0 ) { + if (rowsLeft > 0) { return --rowsLeft; } else { return 0; diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java index f23ac1cc4..46804577d 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.java @@ -139,7 +139,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break tableOmitFooterAtBreak = pList.get(PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum(); tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum(); writingModeTraits = new WritingModeTraits - ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) ); + (WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum())); //Bind extension properties widowContentLimit = pList.get(PR_X_WIDOW_CONTENT_LIMIT).getLength(); @@ -602,20 +602,20 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break } @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { // header sub-tree TableHeader header = getTableHeader(); - if ( header != null ) { - ranges = header.collectDelimitedTextRanges ( ranges ); + if (header != null) { + ranges = header.collectDelimitedTextRanges (ranges); } // footer sub-tree TableFooter footer = getTableFooter(); - if ( footer != null ) { - ranges = footer.collectDelimitedTextRanges ( ranges ); + if (footer != null) { + ranges = footer.collectDelimitedTextRanges (ranges); } // body sub-tree - for ( Iterator it = getChildNodes(); ( it != null ) && it.hasNext();) { - ranges = ( (FONode) it.next() ).collectDelimitedTextRanges ( ranges ); + for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) { + ranges = ((FONode) it.next()).collectDelimitedTextRanges (ranges); } return ranges; } diff --git a/src/java/org/apache/fop/fo/flow/table/TableCell.java b/src/java/org/apache/fop/fo/flow/table/TableCell.java index 20a80d135..b9a811328 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCell.java @@ -118,7 +118,7 @@ public class TableCell extends TableFObj implements CommonAccessibilityHolder { missingChildElementError("marker* (%block;)+", true); } if ((startsRow() || endsRow()) - && getParent().getNameId() == FO_TABLE_ROW ) { + && getParent().getNameId() == FO_TABLE_ROW) { TableEventProducer eventProducer = TableEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); eventProducer.startEndRowUnderTableRowWarning(this, getLocator()); diff --git a/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java b/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java index ddc03ff53..6bc913d1b 100644 --- a/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java +++ b/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java @@ -49,8 +49,8 @@ public class PageNumberGenerator { * @param language (may be null or empty, which is treated as null) * @param country (may be null or empty, which is treated as null) */ - public PageNumberGenerator ( String format, int groupingSeparator, int groupingSize, int letterValue, String features, String language, String country ) { - this.converter = new NumberConverter ( format, groupingSeparator, groupingSize, letterValue, features, language, country ); + public PageNumberGenerator (String format, int groupingSeparator, int groupingSize, int letterValue, String features, String language, String country) { + this.converter = new NumberConverter (format, groupingSeparator, groupingSize, letterValue, features, language, country); } /** @@ -58,8 +58,8 @@ public class PageNumberGenerator { * @param number page number to format * @return the formatted page number as a String */ - public String makeFormattedPageNumber ( int number ) { - return converter.convert ( number ); + public String makeFormattedPageNumber (int number) { + return converter.convert (number); } } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 6b1ee2ef4..c4c380059 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -96,7 +96,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra masterReference = pList.get(PR_MASTER_REFERENCE).getString(); referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); writingModeTraits = new WritingModeTraits - ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) ); + (WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum())); if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); } @@ -330,7 +330,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * @return the reference orientation trait value */ public int getReferenceOrientation() { - if ( referenceOrientation != null ) { + if (referenceOrientation != null) { return referenceOrientation.getValue(); } else { return 0; @@ -341,7 +341,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public Direction getInlineProgressionDirection() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getInlineProgressionDirection(); } else { return Direction.LR; @@ -352,7 +352,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public Direction getBlockProgressionDirection() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getBlockProgressionDirection(); } else { return Direction.TB; @@ -363,7 +363,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public Direction getColumnProgressionDirection() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getColumnProgressionDirection(); } else { return Direction.LR; @@ -374,7 +374,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public Direction getRowProgressionDirection() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getRowProgressionDirection(); } else { return Direction.TB; @@ -385,7 +385,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public Direction getShiftDirection() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getShiftDirection(); } else { return Direction.TB; @@ -396,7 +396,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra * {@inheritDoc} */ public WritingMode getWritingMode() { - if ( writingModeTraits != null ) { + if (writingModeTraits != null) { return writingModeTraits.getWritingMode(); } else { return WritingMode.LR_TB; @@ -405,20 +405,20 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra @Override - protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) { + protected Stack collectDelimitedTextRanges (Stack ranges, DelimitedTextRange currentRange) { // collect ranges from static content flows Map flows = getFlowMap(); - if ( flows != null ) { - for ( FONode fn : flows.values() ) { - if ( fn instanceof StaticContent ) { - ranges = ( (StaticContent) fn ).collectDelimitedTextRanges ( ranges ); + if (flows != null) { + for (FONode fn : flows.values()) { + if (fn instanceof StaticContent) { + ranges = ((StaticContent) fn).collectDelimitedTextRanges (ranges); } } } // collect ranges in main flow Flow main = getMainFlow(); - if ( main != null ) { - ranges = main.collectDelimitedTextRanges ( ranges ); + if (main != null) { + ranges = main.collectDelimitedTextRanges (ranges); } return ranges; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index 9c4e2fd3a..757ec4f33 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -53,7 +53,7 @@ public class RegionAfter extends RegionBA { Rectangle vpRect; // [TBD] WRITING MODE ALERT - switch ( getWritingMode().getEnumValue() ) { + switch (getWritingMode().getEnumValue()) { case Constants.EN_TB_LR: case Constants.EN_TB_RL: neighbourContext = pageHeightContext; diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index eac7723f5..0b394f63e 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -72,7 +72,7 @@ public abstract class RegionBA extends SideRegion { * @param siblingContext the context to use to resolve extent on siblings */ protected void adjustIPD - ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) { + (Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext) { int offset = 0; RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START); if (start != null) { diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index eddd290a9..1a4c07db8 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -57,7 +57,7 @@ public class RegionBefore extends RegionBA { PercentBaseContext neighbourContext; Rectangle vpRect; // [TBD] WRITING MODE ALERT - switch ( getWritingMode().getEnumValue() ) { + switch (getWritingMode().getEnumValue()) { case Constants.EN_TB_LR: case Constants.EN_TB_RL: neighbourContext = pageHeightContext; diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 1fa260ff5..cd5cddf47 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -115,7 +115,7 @@ public class RegionBody extends Region { int start; int end; // [TBD] WRITING MODE ALERT - switch ( getWritingMode().getEnumValue() ) { + switch (getWritingMode().getEnumValue()) { case Constants.EN_RL_TB: start = commonMarginBlock.marginRight.getValue(pageWidthContext); end = commonMarginBlock.marginLeft.getValue(pageWidthContext); diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index 535524c37..4a28cba55 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -52,7 +52,7 @@ public class RegionEnd extends RegionSE { PercentBaseContext neighbourContext; Rectangle vpRect; // [TBD] WRITING MODE ALERT - switch ( getWritingMode().getEnumValue() ) { + switch (getWritingMode().getEnumValue()) { case Constants.EN_RL_TB: neighbourContext = pageHeightContext; vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd); diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java index 9fc2bdc27..1b0fb9cf0 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java @@ -63,7 +63,7 @@ public abstract class RegionSE extends SideRegion { * @param siblingContext the context to use to resolve extent on siblings */ protected void adjustIPD - ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) { + (Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext) { int offset = 0; RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE); if (before != null && before.getPrecedence() == EN_TRUE) { diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index 3371a934e..31c92870f 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -52,7 +52,7 @@ public class RegionStart extends RegionSE { PercentBaseContext neighbourContext; Rectangle vpRect; // [TBD] WRITING MODE ALERT - switch ( getWritingMode().getEnumValue() ) { + switch (getWritingMode().getEnumValue()) { case Constants.EN_RL_TB: neighbourContext = pageHeightContext; vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0, diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index 60c069004..fa81ad599 100644 --- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java @@ -43,13 +43,13 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { * @param extraCorresponding an array of four element integer arrays */ public void setExtraCorresponding(int[][] extraCorresponding) { - if ( extraCorresponding == null ) { + if (extraCorresponding == null) { throw new NullPointerException(); } - for ( int i = 0; i < extraCorresponding.length; i++ ) { + for (int i = 0; i < extraCorresponding.length; i++) { int[] eca = extraCorresponding[i]; - if ( ( eca == null ) || ( eca.length != 4 ) ) { - throw new IllegalArgumentException ( "bad sub-array @ [" + i + "]" ); + if ((eca == null) || (eca.length != 4)) { + throw new IllegalArgumentException ("bad sub-array @ [" + i + "]"); } } this.extraCorresponding = extraCorresponding; diff --git a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java index 6397813e6..8d93beb30 100644 --- a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java @@ -49,7 +49,7 @@ public class FontWeightPropertyMaker extends EnumProperty.Maker { } else { String pValue = checkValueKeywords(value); Property newProp = checkEnumValues(pValue); - int enumValue = ( newProp != null ) ? newProp.getEnum() : -1; + int enumValue = (newProp != null) ? newProp.getEnum() : -1; if (enumValue == Constants.EN_BOLDER || enumValue == Constants.EN_LIGHTER) { /* check for relative enum values, compute in relation to parent */ Property parentProp = pList.getInherited(Constants.PR_FONT_WEIGHT); diff --git a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java index 6b7c58a62..dd00cd044 100644 --- a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java @@ -55,7 +55,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { * @param paddingCorresponding the corresping propids. */ public void setPaddingCorresponding(int[] paddingCorresponding) { - if ( ( paddingCorresponding == null ) || ( paddingCorresponding.length != 4 ) ) { + if ((paddingCorresponding == null) || (paddingCorresponding.length != 4)) { throw new IllegalArgumentException(); } this.paddingCorresponding = paddingCorresponding; @@ -66,7 +66,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { * @param borderWidthCorresponding the corresping propids. */ public void setBorderWidthCorresponding(int[] borderWidthCorresponding) { - if ( ( borderWidthCorresponding == null ) || ( borderWidthCorresponding.length != 4 ) ) { + if ((borderWidthCorresponding == null) || (borderWidthCorresponding.length != 4)) { throw new IllegalArgumentException(); } this.borderWidthCorresponding = borderWidthCorresponding; @@ -215,7 +215,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { PropertyList pList = getWMPropertyList(propertyList); if (pList != null) { int wmcorr = pList.selectFromWritingMode - ( corresponding[0], corresponding[1], corresponding[2], corresponding[3] ); + (corresponding[0], corresponding[1], corresponding[2], corresponding[3]); return propertyList.get(wmcorr); } else { return null; diff --git a/src/java/org/apache/fop/fo/properties/PropertyCache.java b/src/java/org/apache/fop/fo/properties/PropertyCache.java index f35ab2dad..e14d30b2a 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyCache.java +++ b/src/java/org/apache/fop/fo/properties/PropertyCache.java @@ -81,12 +81,12 @@ public final class PropertyCache { useCache = Boolean.valueOf( System.getProperty("org.apache.fop.fo.properties.use-cache", "true")) .booleanValue(); - } catch ( SecurityException e ) { + } catch (SecurityException e) { useCache = true; LOG.info("Unable to access org.apache.fop.fo.properties.use-cache" + " due to security restriction; defaulting to 'true'."); } - if ( useCache ) { + if (useCache) { this.map = new ConcurrentHashMap>(); this.putCounter = new AtomicInteger(); this.cleanupLock = new ReentrantLock(); diff --git a/src/java/org/apache/fop/fonts/CMapSegment.java b/src/java/org/apache/fop/fonts/CMapSegment.java index 816df2ca0..9a371943a 100644 --- a/src/java/org/apache/fop/fonts/CMapSegment.java +++ b/src/java/org/apache/fop/fonts/CMapSegment.java @@ -91,15 +91,15 @@ public final class CMapSegment { @Override public String toString() { StringBuilder sb = new StringBuilder("CMapSegment: "); - sb.append ( "{ UC[" ); - sb.append ( unicodeStart ); - sb.append ( ',' ); - sb.append ( unicodeEnd ); - sb.append ( "]: GC[" ); - sb.append ( glyphStartIndex ); - sb.append ( ',' ); - sb.append ( glyphStartIndex + ( unicodeEnd - unicodeStart ) ); - sb.append ( "] }" ); + sb.append ("{ UC["); + sb.append (unicodeStart); + sb.append (','); + sb.append (unicodeEnd); + sb.append ("]: GC["); + sb.append (glyphStartIndex); + sb.append (','); + sb.append (glyphStartIndex + (unicodeEnd - unicodeStart)); + sb.append ("] }"); return sb.toString(); } diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java index ca387840a..7850c1763 100644 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.java @@ -204,16 +204,16 @@ public class Font implements Substitutable, Positionable { */ public int getKernValue(int ch1, int ch2) { // TODO !BMP - if ( ch1 > 0x10000 ) { + if (ch1 > 0x10000) { return 0; - } else if ( ( ch1 >= 0xD800 ) && ( ch1 <= 0xE000 ) ) { + } else if ((ch1 >= 0xD800) && (ch1 <= 0xE000)) { return 0; - } else if ( ch2 > 0x10000 ) { + } else if (ch2 > 0x10000) { return 0; - } else if ( ( ch2 >= 0xD800 ) && ( ch2 <= 0xE000 ) ) { + } else if ((ch2 >= 0xD800) && (ch2 <= 0xE000)) { return 0; } else { - return getKernValue ( (char) ch1, (char) ch2 ); + return getKernValue ((char) ch1, (char) ch2); } } @@ -366,8 +366,8 @@ public class Font implements Substitutable, Positionable { * @return the width of the character or -1 if no width available */ public int getCharWidth(int c) { - if ( c < 0x10000 ) { - return getCharWidth ( (char) c ); + if (c < 0x10000) { + return getCharWidth ((char) c); } else { // TODO !BMP return -1; @@ -395,7 +395,7 @@ public class Font implements Substitutable, Positionable { /** {@inheritDoc} */ public boolean performsSubstitution() { - if ( metric instanceof Substitutable ) { + if (metric instanceof Substitutable) { Substitutable s = (Substitutable) metric; return s.performsSubstitution(); } else { @@ -404,20 +404,20 @@ public class Font implements Substitutable, Positionable { } /** {@inheritDoc} */ - public CharSequence performSubstitution ( CharSequence cs, String script, String language ) { - if ( metric instanceof Substitutable ) { + public CharSequence performSubstitution (CharSequence cs, String script, String language) { + if (metric instanceof Substitutable) { Substitutable s = (Substitutable) metric; - return s.performSubstitution ( cs, script, language ); + return s.performSubstitution (cs, script, language); } else { throw new UnsupportedOperationException(); } } /** {@inheritDoc} */ - public CharSequence reorderCombiningMarks ( CharSequence cs, int[][] gpa, String script, String language ) { - if ( metric instanceof Substitutable ) { + public CharSequence reorderCombiningMarks (CharSequence cs, int[][] gpa, String script, String language) { + if (metric instanceof Substitutable) { Substitutable s = (Substitutable) metric; - return s.reorderCombiningMarks ( cs, gpa, script, language ); + return s.reorderCombiningMarks (cs, gpa, script, language); } else { throw new UnsupportedOperationException(); } @@ -425,7 +425,7 @@ public class Font implements Substitutable, Positionable { /** {@inheritDoc} */ public boolean performsPositioning() { - if ( metric instanceof Positionable ) { + if (metric instanceof Positionable) { Positionable p = (Positionable) metric; return p.performsPositioning(); } else { @@ -434,18 +434,18 @@ public class Font implements Substitutable, Positionable { } /** {@inheritDoc} */ - public int[][] performPositioning ( CharSequence cs, String script, String language, int fontSize ) { - if ( metric instanceof Positionable ) { + public int[][] performPositioning (CharSequence cs, String script, String language, int fontSize) { + if (metric instanceof Positionable) { Positionable p = (Positionable) metric; - return p.performPositioning ( cs, script, language, fontSize ); + return p.performPositioning (cs, script, language, fontSize); } else { throw new UnsupportedOperationException(); } } /** {@inheritDoc} */ - public int[][] performPositioning ( CharSequence cs, String script, String language ) { - return performPositioning ( cs, script, language, fontSize ); + public int[][] performPositioning (CharSequence cs, String script, String language) { + return performPositioning (cs, script, language, fontSize); } } diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index e990e4052..fb726e6f7 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -153,7 +153,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public char mapChar(char c) { - if ( !isMetricsLoaded ) { + if (!isMetricsLoaded) { load(true); } return realFont.mapChar(c); @@ -171,7 +171,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public boolean hasChar(char c) { - if ( !isMetricsLoaded ) { + if (!isMetricsLoaded) { load(true); } return realFont.hasChar(c); @@ -254,7 +254,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public int getWidth(int i, int size) { - if ( !isMetricsLoaded ) { + if (!isMetricsLoaded) { load(true); } return realFont.getWidth(i, size); @@ -366,7 +366,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, */ public boolean performsSubstitution() { load(true); - if ( realFontDescriptor instanceof Substitutable ) { + if (realFontDescriptor instanceof Substitutable) { return ((Substitutable)realFontDescriptor).performsSubstitution(); } else { return false; @@ -376,9 +376,9 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, /** * {@inheritDoc} */ - public CharSequence performSubstitution ( CharSequence cs, String script, String language ) { + public CharSequence performSubstitution (CharSequence cs, String script, String language) { load(true); - if ( realFontDescriptor instanceof Substitutable ) { + if (realFontDescriptor instanceof Substitutable) { return ((Substitutable)realFontDescriptor).performSubstitution(cs, script, language); } else { return cs; @@ -389,11 +389,11 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public CharSequence reorderCombiningMarks - ( CharSequence cs, int[][] gpa, String script, String language ) { - if ( !isMetricsLoaded ) { + (CharSequence cs, int[][] gpa, String script, String language) { + if (!isMetricsLoaded) { load(true); } - if ( realFontDescriptor instanceof Substitutable ) { + if (realFontDescriptor instanceof Substitutable) { return ((Substitutable)realFontDescriptor) .reorderCombiningMarks(cs, gpa, script, language); } else { @@ -405,10 +405,10 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public boolean performsPositioning() { - if ( !isMetricsLoaded ) { + if (!isMetricsLoaded) { load(true); } - if ( realFontDescriptor instanceof Positionable ) { + if (realFontDescriptor instanceof Positionable) { return ((Positionable)realFontDescriptor).performsPositioning(); } else { return false; @@ -419,11 +419,11 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public int[][] - performPositioning ( CharSequence cs, String script, String language, int fontSize ) { - if ( !isMetricsLoaded ) { + performPositioning (CharSequence cs, String script, String language, int fontSize) { + if (!isMetricsLoaded) { load(true); } - if ( realFontDescriptor instanceof Positionable ) { + if (realFontDescriptor instanceof Positionable) { return ((Positionable)realFontDescriptor) .performPositioning(cs, script, language, fontSize); } else { @@ -435,11 +435,11 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, * {@inheritDoc} */ public int[][] - performPositioning ( CharSequence cs, String script, String language ) { - if ( !isMetricsLoaded ) { + performPositioning (CharSequence cs, String script, String language) { + if (!isMetricsLoaded) { load(true); } - if ( realFontDescriptor instanceof Positionable ) { + if (realFontDescriptor instanceof Positionable) { return ((Positionable)realFontDescriptor) .performPositioning(cs, script, language); } else { diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index da454c504..4cb2753af 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -197,13 +197,13 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * Add a private use mapping {PU,GI} to the existing character map. * N.B. Does not insert in order, merely appends to end of existing map. */ - private synchronized void addPrivateUseMapping ( int pu, int gi ) { - assert findGlyphIndex ( pu ) == SingleByteEncoding.NOT_FOUND_CODE_POINT; + private synchronized void addPrivateUseMapping (int pu, int gi) { + assert findGlyphIndex (pu) == SingleByteEncoding.NOT_FOUND_CODE_POINT; CMapSegment[] oldCmap = cmap; int cmapLength = oldCmap.length; CMapSegment[] newCmap = new CMapSegment [ cmapLength + 1 ]; - System.arraycopy ( oldCmap, 0, newCmap, 0, cmapLength ); - newCmap [ cmapLength ] = new CMapSegment ( pu, pu, gi ); + System.arraycopy (oldCmap, 0, newCmap, 0, cmapLength); + newCmap [ cmapLength ] = new CMapSegment (pu, pu, gi); cmap = newCmap; } @@ -219,36 +219,36 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * @param gi glyph index * @returns unicode scalar value */ - private int createPrivateUseMapping ( int gi ) { - while ( ( nextPrivateUse < 0xF900 ) - && ( findGlyphIndex(nextPrivateUse) != SingleByteEncoding.NOT_FOUND_CODE_POINT ) ) { + private int createPrivateUseMapping (int gi) { + while ((nextPrivateUse < 0xF900) + && (findGlyphIndex(nextPrivateUse) != SingleByteEncoding.NOT_FOUND_CODE_POINT)) { nextPrivateUse++; } - if ( nextPrivateUse < 0xF900 ) { + if (nextPrivateUse < 0xF900) { int pu = nextPrivateUse; - addPrivateUseMapping ( pu, gi ); - if ( firstPrivate == 0 ) { + addPrivateUseMapping (pu, gi); + if (firstPrivate == 0) { firstPrivate = pu; } lastPrivate = pu; numMapped++; if (log.isDebugEnabled()) { - log.debug ( "Create private use mapping from " - + CharUtilities.format ( pu ) + log.debug ("Create private use mapping from " + + CharUtilities.format (pu) + " to glyph index " + gi - + " in font '" + getFullName() + "'" ); + + " in font '" + getFullName() + "'"); } return pu; } else { - if ( firstUnmapped == 0 ) { + if (firstUnmapped == 0) { firstUnmapped = gi; } lastUnmapped = gi; numUnmapped++; - log.warn ( "Exhausted private use area: unable to map " + log.warn ("Exhausted private use area: unable to map " + numUnmapped + " glyphs in glyph index range [" + firstUnmapped + "," + lastUnmapped - + "] (inclusive) of font '" + getFullName() + "'" ); + + "] (inclusive) of font '" + getFullName() + "'"); return 0; } } @@ -260,25 +260,25 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * @returns unicode scalar value */ // [TBD] - needs optimization, i.e., change from linear search to binary search - private int findCharacterFromGlyphIndex ( int gi, boolean augment ) { + private int findCharacterFromGlyphIndex (int gi, boolean augment) { int cc = 0; - for ( int i = 0, n = cmap.length; i < n; i++ ) { + for (int i = 0, n = cmap.length; i < n; i++) { CMapSegment segment = cmap [ i ]; int s = segment.getGlyphStartIndex(); - int e = s + ( segment.getUnicodeEnd() - segment.getUnicodeStart() ); - if ( ( gi >= s ) && ( gi <= e ) ) { - cc = segment.getUnicodeStart() + ( gi - s ); + int e = s + (segment.getUnicodeEnd() - segment.getUnicodeStart()); + if ((gi >= s) && (gi <= e)) { + cc = segment.getUnicodeStart() + (gi - s); break; } } - if ( ( cc == 0 ) && augment ) { - cc = createPrivateUseMapping ( gi ); + if ((cc == 0) && augment) { + cc = createPrivateUseMapping (gi); } return cc; } - private int findCharacterFromGlyphIndex ( int gi ) { - return findCharacterFromGlyphIndex ( gi, true ); + private int findCharacterFromGlyphIndex (int gi) { + return findCharacterFromGlyphIndex (gi, true); } @@ -377,11 +377,11 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * Establishes the glyph definition table. * @param gdef the glyph definition table to be used by this font */ - public void setGDEF ( GlyphDefinitionTable gdef ) { - if ( ( this.gdef == null ) || ( gdef == null ) ) { + public void setGDEF (GlyphDefinitionTable gdef) { + if ((this.gdef == null) || (gdef == null)) { this.gdef = gdef; } else { - throw new IllegalStateException ( "font already associated with GDEF table" ); + throw new IllegalStateException ("font already associated with GDEF table"); } } @@ -397,11 +397,11 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * Establishes the glyph substitution table. * @param gsub the glyph substitution table to be used by this font */ - public void setGSUB ( GlyphSubstitutionTable gsub ) { - if ( ( this.gsub == null ) || ( gsub == null ) ) { + public void setGSUB (GlyphSubstitutionTable gsub) { + if ((this.gsub == null) || (gsub == null)) { this.gsub = gsub; } else { - throw new IllegalStateException ( "font already associated with GSUB table" ); + throw new IllegalStateException ("font already associated with GSUB table"); } } @@ -417,11 +417,11 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * Establishes the glyph positioning table. * @param gpos the glyph positioning table to be used by this font */ - public void setGPOS ( GlyphPositioningTable gpos ) { - if ( ( this.gpos == null ) || ( gpos == null ) ) { + public void setGPOS (GlyphPositioningTable gpos) { + if ((this.gpos == null) || (gpos == null)) { this.gpos = gpos; } else { - throw new IllegalStateException ( "font already associated with GPOS table" ); + throw new IllegalStateException ("font already associated with GPOS table"); } } @@ -439,11 +439,11 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl } /** {@inheritDoc} */ - public CharSequence performSubstitution ( CharSequence cs, String script, String language ) { - if ( gsub != null ) { - GlyphSequence igs = mapCharsToGlyphs ( cs ); - GlyphSequence ogs = gsub.substitute ( igs, script, language ); - CharSequence ocs = mapGlyphsToChars ( ogs ); + public CharSequence performSubstitution (CharSequence cs, String script, String language) { + if (gsub != null) { + GlyphSequence igs = mapCharsToGlyphs (cs); + GlyphSequence ogs = gsub.substitute (igs, script, language); + CharSequence ocs = mapGlyphsToChars (ogs); return ocs; } else { return cs; @@ -452,11 +452,11 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl /** {@inheritDoc} */ public CharSequence reorderCombiningMarks - ( CharSequence cs, int[][] gpa, String script, String language ) { - if ( gdef != null ) { - GlyphSequence igs = mapCharsToGlyphs ( cs ); - GlyphSequence ogs = gdef.reorderCombiningMarks ( igs, gpa, script, language ); - CharSequence ocs = mapGlyphsToChars ( ogs ); + (CharSequence cs, int[][] gpa, String script, String language) { + if (gdef != null) { + GlyphSequence igs = mapCharsToGlyphs (cs); + GlyphSequence ogs = gdef.reorderCombiningMarks (igs, gpa, script, language); + CharSequence ocs = mapGlyphsToChars (ogs); return ocs; } else { return cs; @@ -470,12 +470,12 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl /** {@inheritDoc} */ public int[][] - performPositioning ( CharSequence cs, String script, String language, int fontSize ) { - if ( gpos != null ) { - GlyphSequence gs = mapCharsToGlyphs ( cs ); + performPositioning (CharSequence cs, String script, String language, int fontSize) { + if (gpos != null) { + GlyphSequence gs = mapCharsToGlyphs (cs); int[][] adjustments = new int [ gs.getGlyphCount() ] [ 4 ]; - if ( gpos.position ( gs, script, language, fontSize, this.width, adjustments ) ) { - return scaleAdjustments ( adjustments, fontSize ); + if (gpos.position (gs, script, language, fontSize, this.width, adjustments)) { + return scaleAdjustments (adjustments, fontSize); } else { return null; } @@ -485,17 +485,17 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl } /** {@inheritDoc} */ - public int[][] performPositioning ( CharSequence cs, String script, String language ) { + public int[][] performPositioning (CharSequence cs, String script, String language) { throw new UnsupportedOperationException(); } - private int[][] scaleAdjustments ( int[][] adjustments, int fontSize ) { - if ( adjustments != null ) { - for ( int i = 0, n = adjustments.length; i < n; i++ ) { + private int[][] scaleAdjustments (int[][] adjustments, int fontSize) { + if (adjustments != null) { + for (int i = 0, n = adjustments.length; i < n; i++) { int[] gpa = adjustments [ i ]; - for ( int k = 0; k < 4; k++ ) { - gpa [ k ] = ( gpa [ k ] * fontSize ) / 1000; + for (int k = 0; k < 4; k++) { + gpa [ k ] = (gpa [ k ] * fontSize) / 1000; } } return adjustments; @@ -511,46 +511,46 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * @param cs a CharSequence containing UTF-16 encoded Unicode characters * @returns a CharSequence containing glyph indices */ - private GlyphSequence mapCharsToGlyphs ( CharSequence cs ) { - IntBuffer cb = IntBuffer.allocate ( cs.length() ); - IntBuffer gb = IntBuffer.allocate ( cs.length() ); + private GlyphSequence mapCharsToGlyphs (CharSequence cs) { + IntBuffer cb = IntBuffer.allocate (cs.length()); + IntBuffer gb = IntBuffer.allocate (cs.length()); int gi; - int giMissing = findGlyphIndex ( Typeface.NOT_FOUND ); - for ( int i = 0, n = cs.length(); i < n; i++ ) { - int cc = cs.charAt ( i ); - if ( ( cc >= 0xD800 ) && ( cc < 0xDC00 ) ) { - if ( ( i + 1 ) < n ) { + int giMissing = findGlyphIndex (Typeface.NOT_FOUND); + for (int i = 0, n = cs.length(); i < n; i++) { + int cc = cs.charAt (i); + if ((cc >= 0xD800) && (cc < 0xDC00)) { + if ((i + 1) < n) { int sh = cc; - int sl = cs.charAt ( ++i ); - if ( ( sl >= 0xDC00 ) && ( sl < 0xE000 ) ) { - cc = 0x10000 + ( ( sh - 0xD800 ) << 10 ) + ( ( sl - 0xDC00 ) << 0 ); + int sl = cs.charAt (++i); + if ((sl >= 0xDC00) && (sl < 0xE000)) { + cc = 0x10000 + ((sh - 0xD800) << 10) + ((sl - 0xDC00) << 0); } else { throw new IllegalArgumentException - ( "ill-formed UTF-16 sequence, " - + "contains isolated high surrogate at index " + i ); + ("ill-formed UTF-16 sequence, " + + "contains isolated high surrogate at index " + i); } } else { throw new IllegalArgumentException - ( "ill-formed UTF-16 sequence, " - + "contains isolated high surrogate at end of sequence" ); + ("ill-formed UTF-16 sequence, " + + "contains isolated high surrogate at end of sequence"); } - } else if ( ( cc >= 0xDC00 ) && ( cc < 0xE000 ) ) { + } else if ((cc >= 0xDC00) && (cc < 0xE000)) { throw new IllegalArgumentException - ( "ill-formed UTF-16 sequence, " - + "contains isolated low surrogate at index " + i ); + ("ill-formed UTF-16 sequence, " + + "contains isolated low surrogate at index " + i); } notifyMapOperation(); - gi = findGlyphIndex ( cc ); - if ( gi == SingleByteEncoding.NOT_FOUND_CODE_POINT ) { - warnMissingGlyph ( (char) cc ); + gi = findGlyphIndex (cc); + if (gi == SingleByteEncoding.NOT_FOUND_CODE_POINT) { + warnMissingGlyph ((char) cc); gi = giMissing; } - cb.put ( cc ); - gb.put ( gi ); + cb.put (cc); + gb.put (gi); } cb.flip(); gb.flip(); - return new GlyphSequence ( cb, gb, null ); + return new GlyphSequence (cb, gb, null); } /** @@ -559,30 +559,30 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl * @param gs a GlyphSequence containing glyph indices * @returns a CharSequence containing UTF-16 encoded Unicode characters */ - private CharSequence mapGlyphsToChars ( GlyphSequence gs ) { + private CharSequence mapGlyphsToChars (GlyphSequence gs) { int ng = gs.getGlyphCount(); - CharBuffer cb = CharBuffer.allocate ( ng ); + CharBuffer cb = CharBuffer.allocate (ng); int ccMissing = Typeface.NOT_FOUND; - for ( int i = 0, n = ng; i < n; i++ ) { - int gi = gs.getGlyph ( i ); - int cc = findCharacterFromGlyphIndex ( gi ); - if ( ( cc == 0 ) || ( cc > 0x10FFFF ) ) { + for (int i = 0, n = ng; i < n; i++) { + int gi = gs.getGlyph (i); + int cc = findCharacterFromGlyphIndex (gi); + if ((cc == 0) || (cc > 0x10FFFF)) { cc = ccMissing; log.warn("Unable to map glyph index " + gi + " to Unicode scalar in font '" + getFullName() + "', substituting missing character '" + (char) cc + "'"); } - if ( cc > 0x00FFFF ) { + if (cc > 0x00FFFF) { int sh; int sl; cc -= 0x10000; - sh = ( ( cc >> 10 ) & 0x3FF ) + 0xD800; - sl = ( ( cc >> 0 ) & 0x3FF ) + 0xDC00; - cb.put ( (char) sh ); - cb.put ( (char) sl ); + sh = ((cc >> 10) & 0x3FF) + 0xD800; + sl = ((cc >> 0) & 0x3FF) + 0xDC00; + cb.put ((char) sh); + cb.put ((char) sl); } else { - cb.put ( (char) cc ); + cb.put ((char) cc); } } cb.flip(); diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index 442407d6b..bc114c4ae 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@ -244,7 +244,7 @@ public class TTFFile { * @param useKerning true if kerning data should be loaded * @param useAdvanced true if advanced typographic tables should be loaded */ - public TTFFile ( boolean useKerning, boolean useAdvanced ) { + public TTFFile (boolean useKerning, boolean useAdvanced) { this.useKerning = useKerning; this.useAdvanced = useAdvanced; } @@ -284,18 +284,18 @@ public class TTFFile { /** {@inheritDoc} */ public int hashCode() { int hc = unicodeIndex; - hc = 19 * hc + ( hc ^ glyphIndex ); + hc = 19 * hc + (hc ^ glyphIndex); return hc; } /** {@inheritDoc} */ - public boolean equals ( Object o ) { - if ( o instanceof UnicodeMapping ) { + public boolean equals (Object o) { + if (o instanceof UnicodeMapping) { UnicodeMapping m = (UnicodeMapping) o; - if ( unicodeIndex != m.unicodeIndex ) { + if (unicodeIndex != m.unicodeIndex) { return false; } else { - return ( glyphIndex == m.glyphIndex ); + return (glyphIndex == m.glyphIndex); } } else { return false; @@ -303,12 +303,12 @@ public class TTFFile { } /** {@inheritDoc} */ - public int compareTo ( Object o ) { - if ( o instanceof UnicodeMapping ) { + public int compareTo (Object o) { + if (o instanceof UnicodeMapping) { UnicodeMapping m = (UnicodeMapping) o; - if ( unicodeIndex > m.unicodeIndex ) { + if (unicodeIndex > m.unicodeIndex) { return 1; - } else if ( unicodeIndex < m.unicodeIndex ) { + } else if (unicodeIndex < m.unicodeIndex) { return -1; } else { return 0; @@ -729,18 +729,18 @@ public class TTFFile { // Create cmaps for bfentries createCMaps(); - if ( useKerning ) { + if (useKerning) { readKerning(); } // Read advanced typographic tables. - if ( useAdvanced ) { + if (useAdvanced) { try { OTFAdvancedTypographicTableReader atr - = new OTFAdvancedTypographicTableReader ( this, in ); + = new OTFAdvancedTypographicTableReader (this, in); atr.readAll(); this.advancedTableReader = atr; - } catch ( AdvancedTypographicTableFormatException e ) { + } catch (AdvancedTypographicTableFormatException e) { log.warn ( "Encountered format constraint violation in advanced (typographic) table (AT) " + "in font '" + getFullName() + "', ignoring AT data: " @@ -1983,7 +1983,7 @@ public class TTFFile { * @return true if advanced (typographic) table is present */ public boolean hasAdvancedTable() { - if ( advancedTableReader != null ) { + if (advancedTableReader != null) { return advancedTableReader.hasAdvancedTable(); } else { return false; @@ -1995,7 +1995,7 @@ public class TTFFile { * @return the GDEF table */ public GlyphDefinitionTable getGDEF() { - if ( advancedTableReader != null ) { + if (advancedTableReader != null) { return advancedTableReader.getGDEF(); } else { return null; @@ -2007,7 +2007,7 @@ public class TTFFile { * @return the GSUB table */ public GlyphSubstitutionTable getGSUB() { - if ( advancedTableReader != null ) { + if (advancedTableReader != null) { return advancedTableReader.getGSUB(); } else { return null; @@ -2019,7 +2019,7 @@ public class TTFFile { * @return the GPOS table */ public GlyphPositioningTable getGPOS() { - if ( advancedTableReader != null ) { + if (advancedTableReader != null) { return advancedTableReader.getGPOS(); } else { return null; diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index a427fe54e..91ea42106 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java @@ -240,12 +240,12 @@ public class TTFFontLoader extends FontLoader { /** * Copy advanced typographic information. */ - private void copyAdvanced ( TTFFile ttf ) { - if ( returnFont instanceof MultiByteFont ) { + private void copyAdvanced (TTFFile ttf) { + if (returnFont instanceof MultiByteFont) { MultiByteFont mbf = (MultiByteFont) returnFont; - mbf.setGDEF ( ttf.getGDEF() ); - mbf.setGSUB ( ttf.getGSUB() ); - mbf.setGPOS ( ttf.getGPOS() ); + mbf.setGDEF (ttf.getGDEF()); + mbf.setGSUB (ttf.getGSUB()); + mbf.setGPOS (ttf.getGPOS()); } } diff --git a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java index 292ae191c..a68baf2c1 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java @@ -62,7 +62,7 @@ public class TTFSubSetFile extends TTFFile { * @param useKerning true if kerning data should be loaded * @param useAdvanced true if advanced typographic tables should be loaded */ - public TTFSubSetFile ( boolean useKerning, boolean useAdvanced ) { + public TTFSubSetFile (boolean useKerning, boolean useAdvanced) { super(useKerning, useAdvanced); } diff --git a/src/java/org/apache/fop/fonts/type1/AFMParser.java b/src/java/org/apache/fop/fonts/type1/AFMParser.java index f2711be3c..ecc9196ed 100644 --- a/src/java/org/apache/fop/fonts/type1/AFMParser.java +++ b/src/java/org/apache/fop/fonts/type1/AFMParser.java @@ -326,11 +326,11 @@ public class AFMParser { try { Method mth = c.getMethod(method, argType); mth.invoke(target, value); - } catch ( NoSuchMethodException e ) { + } catch (NoSuchMethodException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); - } catch ( IllegalAccessException e ) { + } catch (IllegalAccessException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); - } catch ( InvocationTargetException e ) { + } catch (InvocationTargetException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); } } @@ -452,11 +452,11 @@ public class AFMParser { try { Method mth = c.getMethod(method, boolean.class); mth.invoke(target, b); - } catch ( NoSuchMethodException e ) { + } catch (NoSuchMethodException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); - } catch ( IllegalAccessException e ) { + } catch (IllegalAccessException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); - } catch ( InvocationTargetException e ) { + } catch (InvocationTargetException e) { throw new RuntimeException("Bean error: " + e.getMessage(), e); } } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 9f94b4f49..2cdcf4505 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -420,7 +420,7 @@ public abstract class AbstractBreaker { alg.setConstantLineWidth(flowBPD); int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true, BreakingAlgorithm.ALL_BREAKS); - if ( Math.abs ( alg.getIPDdifference() ) > 1 ) { + if (Math.abs (alg.getIPDdifference()) > 1) { addAreas(alg, optimalPageCount, blockList, effectiveList); // *** redo Phase 1 *** log.trace("IPD changes after page " + optimalPageCount); @@ -911,7 +911,7 @@ public abstract class AbstractBreaker { KnuthElement firstElement; while (sequenceIterator.hasNext()) { firstElement = sequenceIterator.next(); - if ( !firstElement.isBox() ) { + if (!firstElement.isBox()) { log.debug("PLM> ignoring glue or penalty element " + "at the beginning of the sequence"); if (firstElement.isGlue()) { diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 5233bcd77..0285a41e7 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -214,7 +214,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager im return null; } List newLMs = new ArrayList(size); - while (fobjIter.hasNext() && newLMs.size() < size ) { + while (fobjIter.hasNext() && newLMs.size() < size) { Object theobj = fobjIter.next(); if (theobj instanceof FONode) { FONode foNode = (FONode) theobj; diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 78fd8893f..979868183 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -351,7 +351,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager impl contentRectOffsetY = 0; int level = fo.getBidiLevel(); - if ( ( level < 0 ) || ( ( level & 1 ) == 0 ) ) { + if ((level < 0) || ((level & 1) == 0)) { contentRectOffsetX += fo.getCommonMarginBlock().startIndent.getValue(this); } else { contentRectOffsetX += fo.getCommonMarginBlock().endIndent.getValue(this); @@ -855,8 +855,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager impl viewportBlockArea = new BlockViewport(allowBPDUpdate); viewportBlockArea.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE); - if ( level >= 0 ) { - viewportBlockArea.setBidiLevel ( level ); + if (level >= 0) { + viewportBlockArea.setBidiLevel (level); } viewportBlockArea.setIPD(getContentAreaIPD()); if (allowBPDUpdate) { @@ -892,8 +892,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager impl referenceArea = new Block(); referenceArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); - if ( level >= 0 ) { - referenceArea.setBidiLevel ( level ); + if (level >= 0) { + referenceArea.setBidiLevel (level); } TraitSetter.setProducerID(referenceArea, getBlockContainerFO().getId()); diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 1420d1b98..317623cd5 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -360,7 +360,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager implements Co curBlockArea.setIPD(super.getContentAreaIPD()); - curBlockArea.setBidiLevel ( getBlockFO().getBidiLevel() ); + curBlockArea.setBidiLevel (getBlockFO().getBidiLevel()); TraitSetter.addBreaks(curBlockArea, getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter()); diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index 02c3db6a8..8a7142084 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -285,8 +285,7 @@ public abstract class BreakingAlgorithm { * @param totalDemerits a real number * @param previous a node */ - public KnuthNode( // CSOK: ParameterNumber - int position, int line, int fitness, + public KnuthNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, int difference, double totalDemerits, KnuthNode previous) { @@ -686,8 +685,7 @@ public abstract class BreakingAlgorithm { * @param previous active node for the preceding breakpoint * @return a new node */ - protected KnuthNode createNode( // CSOK: ParameterNumber - int position, int line, int fitness, + protected KnuthNode createNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, int difference, double totalDemerits, KnuthNode previous) { diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index 684977b9c..df84aff20 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -141,7 +141,7 @@ public class InlineKnuthSequence extends KnuthSequence { .addALetterSpaceTo(oldList)); // prevBox may not be a KnuthInlineBox; // this may happen if it is a padding box; see bug 39571. - if ( prevBox instanceof KnuthInlineBox && ((KnuthInlineBox) prevBox).isAnchor()) { + if (prevBox instanceof KnuthInlineBox && ((KnuthInlineBox) prevBox).isAnchor()) { // prevBox represents a footnote citation: copy footnote info // from prevBox to the new box KnuthInlineBox newBox = (KnuthInlineBox) getLast(); diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 5f4aa5725..292251a84 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -248,7 +248,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { public static class BidiOverrideLayoutManagerMaker extends Maker { /** {@inheritDoc} */ public void make(FONode node, List lms) { - if ( node instanceof BidiOverride ) { + if (node instanceof BidiOverride) { lms.add(new BidiLayoutManager((BidiOverride) node)); } } diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index b5e21aa63..c589e4766 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -80,7 +80,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager initialize(); // perform step 5.8 of refinement process (Unicode BIDI Processing) - if ( areaTreeHandler.isComplexScriptFeaturesEnabled() ) { + if (areaTreeHandler.isComplexScriptFeaturesEnabled()) { BidiResolver.resolveInlineDirectionality(getPageSequence()); } @@ -198,13 +198,13 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager */ protected int getForcedLastPageNum(final int lastPageNum) { int forcedLastPageNum = lastPageNum; - if ( lastPageNum % 2 != 0 - && ( getPageSequence().getForcePageCount() == Constants.EN_EVEN - || getPageSequence().getForcePageCount() == Constants.EN_END_ON_EVEN )) { + if (lastPageNum % 2 != 0 + && (getPageSequence().getForcePageCount() == Constants.EN_EVEN + || getPageSequence().getForcePageCount() == Constants.EN_END_ON_EVEN)) { forcedLastPageNum++; - } else if ( lastPageNum % 2 == 0 && ( + } else if (lastPageNum % 2 == 0 && ( getPageSequence().getForcePageCount() == Constants.EN_ODD - || getPageSequence().getForcePageCount() == Constants.EN_END_ON_ODD )) { + || getPageSequence().getForcePageCount() == Constants.EN_END_ON_ODD)) { forcedLastPageNum++; } return forcedLastPageNum; diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index c3026e5e7..8afec46e1 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -78,7 +78,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage placement.y += beforeBPD; //Determine extra IPD from borders and padding - if ( ( bidiLevel == -1 ) || ( ( bidiLevel & 1 ) == 0 ) ) { + if ((bidiLevel == -1) || ((bidiLevel & 1) == 0)) { int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this); startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false); placement.x += startIPD; diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java index 593003d55..3a630f9be 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java @@ -69,7 +69,7 @@ public class BasicLinkLayoutManager extends InlineLayoutManager { res.resolveIDRef(idref, pslm.getFirstPVWithID(idref)); if (!res.isResolved()) { pslm.addUnresolvedArea(idref, res); - if ( area instanceof BasicLinkArea ) { + if (area instanceof BasicLinkArea) { // establish back-pointer from BasicLinkArea to LinkResolver to // handle inline area unflattening during line bidi reordering; // needed to create internal link trait on synthesized basic link area diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index 212170eae..3b4b84346 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -86,7 +86,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { blockProgressionOffset, level); } } else { - int[] levels = ( level >= 0 ) ? new int[] {level} : null; + int[] levels = (level >= 0) ? new int[] {level} : null; text.addWord(String.valueOf(ch), ipd, null, levels, null, blockProgressionOffset); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 3e9b85742..a1c50d45f 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -183,8 +183,8 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager Space ls = new Space(); ls.setIPD(iAdjust); int level = parentArea.getBidiLevel(); - if ( level >= 0 ) { - ls.setBidiLevel ( level ); + if (level >= 0) { + ls.setBidiLevel (level); } parentArea.addChildArea(ls); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index aa2f79759..c19519ec8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -125,26 +125,26 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { leaderArea = leader; } else { leaderArea = new Space(); - if ( level >= 0 ) { - leaderArea.setBidiLevel ( level ); + if (level >= 0) { + leaderArea.setBidiLevel (level); } } leaderArea.setBPD(fobj.getRuleThickness().getValue(this)); leaderArea.addTrait(Trait.COLOR, fobj.getColor()); - if ( level >= 0 ) { - leaderArea.setBidiLevel ( level ); + if (level >= 0) { + leaderArea.setBidiLevel (level); } } else if (fobj.getLeaderPattern() == EN_SPACE) { leaderArea = new Space(); leaderArea.setBPD(fobj.getRuleThickness().getValue(this)); - if ( level >= 0 ) { - leaderArea.setBidiLevel ( level ); + if (level >= 0) { + leaderArea.setBidiLevel (level); } } else if (fobj.getLeaderPattern() == EN_DOTS) { TextArea t = new TextArea(); char dot = '.'; // userAgent.getLeaderDotCharacter(); int width = font.getCharWidth(dot); - int[] levels = ( level < 0 ) ? null : new int[] {level}; + int[] levels = (level < 0) ? null : new int[] {level}; t.addWord("" + dot, width, null, levels, null, 0); t.setIPD(width); t.setBPD(width); @@ -156,8 +156,8 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { if (widthLeaderPattern > width) { spacer = new Space(); spacer.setIPD(widthLeaderPattern - width); - if ( level >= 0 ) { - spacer.setBidiLevel ( level ); + if (level >= 0) { + spacer.setBidiLevel (level); } width = widthLeaderPattern; } @@ -200,8 +200,8 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { if (fobj.getLeaderPatternWidth().getValue(this) > width) { spacer = new Space(); spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); - if ( level >= 0 ) { - spacer.setBidiLevel ( level ); + if (level >= 0) { + spacer.setBidiLevel (level); } width = fobj.getLeaderPatternWidth().getValue(this); } @@ -214,7 +214,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { //Content collapsed to nothing, so use a space leaderArea = new Space(); leaderArea.setBPD(fobj.getRuleThickness().getValue(this)); - leaderArea.setBidiLevel ( fobj.getBidiLevelRecursive() ); + leaderArea.setBidiLevel (fobj.getBidiLevelRecursive()); } } TraitSetter.setProducerID(leaderArea, fobj.getId()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 6623b6319..5a191e922 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -120,8 +120,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private final int spaceAfter; private final int baseline; - LineBreakPosition( // CSOK: ParameterNumber - LayoutManager lm, int index, int startIndex, int breakIndex, + LineBreakPosition(LayoutManager lm, int index, int startIndex, int breakIndex, int shrink, int stretch, int diff, double ipdA, double adjust, int si, int ei, int lh, int lw, int sb, int sa, int bl) { super(lm, breakIndex); @@ -311,8 +310,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private final int follow; private static final double MAX_DEMERITS = 10e6; - public LineBreakingAlgorithm( // CSOK: ParameterNumber - int pageAlign, int textAlign, int textAlignLast, int indent, int fillerWidth, + public LineBreakingAlgorithm(int pageAlign, int textAlign, int textAlignLast, int indent, int fillerWidth, int lh, int ld, int fl, boolean first, int maxFlagCount, LineLayoutManager llm) { super(textAlign, textAlignLast, first, false, maxFlagCount); pageAlignment = pageAlign; @@ -343,7 +341,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int difference = bestActiveNode.difference; int textAlign = (bestActiveNode.line < total) ? alignment : alignmentLast; - switch ( textAlign ) { + switch (textAlign) { case Constants.EN_START: startIndent = 0; endIndent = difference > 0 ? difference : 0; @@ -425,10 +423,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager activePossibility = -1; } - private LineBreakPosition makeLineBreakPosition( // CSOK: ParameterNumber - KnuthSequence par, int firstElementIndex, int lastElementIndex, int availableShrink, - int availableStretch, int difference, double ratio, int startIndent, - int endIndent) { + private LineBreakPosition makeLineBreakPosition(KnuthSequence par, int firstElementIndex, int lastElementIndex, + int availableShrink, int availableStretch, int difference, double ratio, + int startIndent, int endIndent) { // line height calculation - spaceBefore may differ from spaceAfter // by 1mpt due to rounding int spaceBefore = (lineHeight - lead - follow) / 2; @@ -453,7 +450,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager j <= lastElementIndex; j++) { KnuthElement element = (KnuthElement) inlineIterator.next(); - if (element instanceof KnuthInlineBox ) { + if (element instanceof KnuthInlineBox) { AlignmentContext ac = ((KnuthInlineBox) element).getAlignmentContext(); if (ac != null && lastAC != ac) { if (!ac.usesInitialBaselineTable() @@ -1555,8 +1552,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter()); } lineArea.finish(); - if ( lineArea.getBidiLevel() >= 0 ) { - BidiResolver.reorder ( lineArea ); + if (lineArea.getBidiLevel() >= 0) { + BidiResolver.reorder (lineArea); } parentLayoutManager.addChildArea(lineArea); } @@ -1607,8 +1604,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager blocklc.setTrailingSpace(new SpaceSpecifier(false)); } lineArea.updateExtentsFromChildren(); - if ( lineArea.getBidiLevel() >= 0 ) { - BidiResolver.reorder ( lineArea ); + if (lineArea.getBidiLevel() >= 0) { + BidiResolver.reorder (lineArea); } parentLayoutManager.addChildArea(lineArea); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index fc7110efa..2bfe65d13 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -111,9 +111,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager { * memoize thius length upon first invocation of this method. */ private int getWordLength() { - if ( wordCharLength == -1 ) { - if ( foText.hasMapping ( startIndex, breakIndex ) ) { - wordCharLength = foText.getMapping ( startIndex, breakIndex ).length(); + if (wordCharLength == -1) { + if (foText.hasMapping (startIndex, breakIndex)) { + wordCharLength = foText.getMapping (startIndex, breakIndex).length(); } else { assert breakIndex >= startIndex; wordCharLength = breakIndex - startIndex; @@ -293,8 +293,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager { if (tbpNext.getLeafPos() != -1) { areaInfo = (AreaInfo) areaInfos.get(tbpNext.getLeafPos()); if (lastAreaInfo == null - || ( areaInfo.font != lastAreaInfo.font ) - || ( areaInfo.level != lastAreaInfo.level ) ) { + || (areaInfo.font != lastAreaInfo.font) + || (areaInfo.level != lastAreaInfo.level)) { if (lastAreaInfo != null) { addAreaInfoAreas(lastAreaInfo, wordSpaceCount, letterSpaceCount, firstAreaInfoIndex, @@ -567,7 +567,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { AreaInfo wordAreaInfo = getAreaInfo(i); addWordChars(wordAreaInfo); addLetterAdjust(wordAreaInfo); - if ( addGlyphPositionAdjustments(wordAreaInfo) ) { + if (addGlyphPositionAdjustments(wordAreaInfo)) { gposAdjusted = true; } } @@ -575,7 +575,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { // TODO may be problematic in some I18N contexts [GA] addHyphenationChar(); } - if ( !gposAdjusted ) { + if (!gposAdjusted) { gposAdjustments = null; } textArea.addWord(wordChars.toString(), wordIPD, letterSpaceAdjust, @@ -583,11 +583,11 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } private int[] getNonEmptyLevels() { - if ( wordLevels != null ) { + if (wordLevels != null) { assert wordLevelsIndex <= wordLevels.length; boolean empty = true; - for ( int i = 0, n = wordLevelsIndex; i < n; i++ ) { - if ( wordLevels [ i ] >= 0 ) { + for (int i = 0, n = wordLevelsIndex; i < n; i++) { + if (wordLevels [ i ] >= 0) { empty = false; break; } @@ -610,7 +610,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { letterSpaceAdjustIndex = 0; wordLevels = new int[wordLength]; wordLevelsIndex = 0; - Arrays.fill ( wordLevels, -1 ); + Arrays.fill (wordLevels, -1); gposAdjustments = new int[wordLength][4]; gposAdjustmentsIndex = 0; wordIPD = 0; @@ -637,14 +637,14 @@ public class TextLayoutManager extends LeafNodeLayoutManager { private void addWordChars(AreaInfo wordAreaInfo) { int s = wordAreaInfo.startIndex; int e = wordAreaInfo.breakIndex; - if ( foText.hasMapping ( s, e ) ) { - wordChars.append ( foText.getMapping ( s, e ) ); - addWordLevels ( foText.getMappingBidiLevels ( s, e ) ); + if (foText.hasMapping (s, e)) { + wordChars.append (foText.getMapping (s, e)); + addWordLevels (foText.getMappingBidiLevels (s, e)); } else { for (int i = s; i < e; i++) { wordChars.append(foText.charAt(i)); } - addWordLevels ( foText.getBidiLevels ( s, e ) ); + addWordLevels (foText.getBidiLevels (s, e)); } wordIPD += wordAreaInfo.areaIPD.getOpt(); } @@ -654,16 +654,16 @@ public class TextLayoutManager extends LeafNodeLayoutManager { * concatenante (possibly mapped) word bidi levels to levels buffer. * @param levels bidi levels array or null */ - private void addWordLevels ( int[] levels ) { - int numLevels = ( levels != null ) ? levels.length : 0; - if ( numLevels > 0 ) { + private void addWordLevels (int[] levels) { + int numLevels = (levels != null) ? levels.length : 0; + if (numLevels > 0) { int need = wordLevelsIndex + numLevels; - if ( need <= wordLevels.length ) { - System.arraycopy ( levels, 0, wordLevels, wordLevelsIndex, numLevels ); + if (need <= wordLevels.length) { + System.arraycopy (levels, 0, wordLevels, wordLevelsIndex, numLevels); } else { throw new IllegalStateException - ( "word levels array too short: expect at least " - + need + " entries, but has only " + wordLevels.length + " entries" ); + ("word levels array too short: expect at least " + + need + " entries, but has only " + wordLevels.length + " entries"); } } wordLevelsIndex += numLevels; @@ -678,15 +678,15 @@ public class TextLayoutManager extends LeafNodeLayoutManager { int letterSpaceCount = wordAreaInfo.letterSpaceCount; int wordLength = wordAreaInfo.getWordLength(); int taAdjust = textArea.getTextLetterSpaceAdjust(); - for ( int i = 0, n = wordLength; i < n; i++ ) { + for (int i = 0, n = wordLength; i < n; i++) { int j = letterSpaceAdjustIndex + i; - if ( j > 0 ) { + if (j > 0) { int k = wordAreaInfo.startIndex + i; - MinOptMax adj = ( k < letterSpaceAdjustArray.length ) + MinOptMax adj = (k < letterSpaceAdjustArray.length) ? letterSpaceAdjustArray [ k ] : null; - letterSpaceAdjust [ j ] = ( adj == null ) ? 0 : adj.getOpt(); + letterSpaceAdjust [ j ] = (adj == null) ? 0 : adj.getOpt(); } - if ( letterSpaceCount > 0 ) { + if (letterSpaceCount > 0) { letterSpaceAdjust [ j ] += taAdjust; letterSpaceCount--; } @@ -703,18 +703,18 @@ public class TextLayoutManager extends LeafNodeLayoutManager { private boolean addGlyphPositionAdjustments(AreaInfo wordAreaInfo) { boolean adjusted = false; int[][] gpa = wordAreaInfo.gposAdjustments; - int numAdjusts = ( gpa != null ) ? gpa.length : 0; + int numAdjusts = (gpa != null) ? gpa.length : 0; int wordLength = wordAreaInfo.getWordLength(); - if ( numAdjusts > 0 ) { + if (numAdjusts > 0) { int need = gposAdjustmentsIndex + numAdjusts; - if ( need <= gposAdjustments.length ) { - for ( int i = 0, n = wordLength, j = 0; i < n; i++ ) { - if ( i < numAdjusts ) { + if (need <= gposAdjustments.length) { + for (int i = 0, n = wordLength, j = 0; i < n; i++) { + if (i < numAdjusts) { int[] wpa1 = gposAdjustments [ gposAdjustmentsIndex + i ]; int[] wpa2 = gpa [ j++ ]; - for ( int k = 0; k < 4; k++ ) { + for (int k = 0; k < 4; k++) { int a = wpa2 [ k ]; - if ( a != 0 ) { + if (a != 0) { wpa1 [ k ] += a; adjusted = true; } @@ -723,9 +723,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } } else { throw new IllegalStateException - ( "gpos adjustments array too short: expect at least " + ("gpos adjustments array too short: expect at least " + need + " entries, but has only " + gposAdjustments.length - + " entries" ); + + " entries"); } } gposAdjustmentsIndex += wordLength; @@ -750,32 +750,32 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } } int numSpaces = areaInfo.breakIndex - areaInfo.startIndex - numZeroWidthSpaces; - int spaceIPD = areaInfo.areaIPD.getOpt() / ( ( numSpaces > 0 ) ? numSpaces : 1 ); + int spaceIPD = areaInfo.areaIPD.getOpt() / ((numSpaces > 0) ? numSpaces : 1); // add space area children, one for each non-zero-width space character for (int i = areaInfo.startIndex; i < areaInfo.breakIndex; i++) { char spaceChar = foText.charAt(i); int level = foText.bidiLevelAt(i); if (!CharUtilities.isZeroWidthSpace(spaceChar)) { textArea.addSpace - ( spaceChar, spaceIPD, + (spaceChar, spaceIPD, CharUtilities.isAdjustableSpace(spaceChar), - blockProgressionOffset, level ); + blockProgressionOffset, level); } } } } - private void addAreaInfo ( AreaInfo ai ) { - addAreaInfo ( areaInfos.size(), ai ); + private void addAreaInfo (AreaInfo ai) { + addAreaInfo (areaInfos.size(), ai); } - private void addAreaInfo ( int index, AreaInfo ai ) { - areaInfos.add ( index, ai ); + private void addAreaInfo (int index, AreaInfo ai) { + areaInfos.add (index, ai); } - private void removeAreaInfo ( int index ) { - areaInfos.remove ( index ); + private void removeAreaInfo (int index) { + areaInfos.remove (index); } private AreaInfo getAreaInfo(int index) { @@ -815,7 +815,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { returnList.add(sequence); if (LOG.isDebugEnabled()) { - LOG.debug ( "GK: [" + nextStart + "," + foText.length() + "]" ); + LOG.debug ("GK: [" + nextStart + "," + foText.length() + "]"); } LineBreakStatus lineBreakStatus = new LineBreakStatus(); thisStart = nextStart; @@ -846,20 +846,20 @@ public class TextLayoutManager extends LeafNodeLayoutManager { TextLayoutManager.LOG.error("Unexpected breakAction: " + breakAction); } if (LOG.isDebugEnabled()) { - LOG.debug ( "GK: {" + LOG.debug ("GK: {" + " index = " + nextStart - + ", char = " + CharUtilities.charToNCRef ( ch ) + + ", char = " + CharUtilities.charToNCRef (ch) + ", level = " + level + ", levelPrev = " + prevLevel + ", inWord = " + inWord + ", inSpace = " + inWhitespace - + "}" ); + + "}"); } if (inWord) { - if ( breakOpportunity + if (breakOpportunity || TextLayoutManager.isSpace(ch) || CharUtilities.isExplicitBreak(ch) - || ( ( prevLevel != -1 ) && ( level != prevLevel ) ) ) { + || ((prevLevel != -1) && (level != prevLevel))) { // this.foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN prevAreaInfo = processWord(alignment, sequence, prevAreaInfo, ch, breakOpportunity, true, prevLevel); @@ -960,16 +960,16 @@ public class TextLayoutManager extends LeafNodeLayoutManager { final KnuthSequence sequence, final boolean breakOpportunity, int level) { if (LOG.isDebugEnabled()) { - LOG.debug ( "PS: [" + thisStart + "," + nextStart + "]" ); + LOG.debug ("PS: [" + thisStart + "," + nextStart + "]"); } // End of whitespace // create the AreaInfo object assert nextStart >= thisStart; AreaInfo areaInfo = new AreaInfo - ( thisStart, nextStart, nextStart - thisStart, 0, + (thisStart, nextStart, nextStart - thisStart, 0, wordSpaceIPD.mult(nextStart - thisStart), - false, true, breakOpportunity, spaceFont, level, null ); + false, true, breakOpportunity, spaceFont, level, null); addAreaInfo(areaInfo); @@ -981,8 +981,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } private AreaInfo processWordMapping - ( int lastIndex, final Font font, AreaInfo prevAreaInfo, final char breakOpportunityChar, - final boolean endsWithHyphen, int level ) { + (int lastIndex, final Font font, AreaInfo prevAreaInfo, final char breakOpportunityChar, + final boolean endsWithHyphen, int level) { int s = this.thisStart; // start index of word in FOText character buffer int e = lastIndex; // end index of word in FOText character buffer int nLS = 0; // # of letter spaces @@ -990,68 +990,68 @@ public class TextLayoutManager extends LeafNodeLayoutManager { String language = foText.getLanguage(); if (LOG.isDebugEnabled()) { - LOG.debug ( "PW: [" + thisStart + "," + lastIndex + "]: {" + LOG.debug ("PW: [" + thisStart + "," + lastIndex + "]: {" + " +M" + ", level = " + level - + " }" ); + + " }"); } // 1. extract unmapped character sequence - CharSequence ics = foText.subSequence ( s, e ); + CharSequence ics = foText.subSequence (s, e); // 2. if script is not specified (by FO property) or it is specified as 'auto', // then compute dominant script - if ( ( script == null ) || "auto".equals(script) ) { - script = CharScript.scriptTagFromCode ( CharScript.dominantScript ( ics ) ); + if ((script == null) || "auto".equals(script)) { + script = CharScript.scriptTagFromCode (CharScript.dominantScript (ics)); } - if ( ( language == null ) || "none".equals(language) ) { + if ((language == null) || "none".equals(language)) { language = "dflt"; } // 3. perform mapping of chars to glyphs ... to glyphs ... to chars - CharSequence mcs = font.performSubstitution ( ics, script, language ); + CharSequence mcs = font.performSubstitution (ics, script, language); // 4. compute glyph position adjustments on (substituted) characters int[][] gpa; - if ( font.performsPositioning() ) { + if (font.performsPositioning()) { // handle GPOS adjustments - gpa = font.performPositioning ( mcs, script, language ); - } else if ( font.hasKerning() ) { + gpa = font.performPositioning (mcs, script, language); + } else if (font.hasKerning()) { // handle standard (non-GPOS) kerning adjustments - gpa = getKerningAdjustments ( mcs, font ); + gpa = getKerningAdjustments (mcs, font); } else { gpa = null; } // 5. reorder combining marks so that they precede (within the mapped char sequence) the // base to which they are applied; N.B. position adjustments (gpa) are reordered in place - mcs = font.reorderCombiningMarks ( mcs, gpa, script, language ); + mcs = font.reorderCombiningMarks (mcs, gpa, script, language); // 6. if mapped sequence differs from input sequence, then memoize mapped sequence - if ( !CharUtilities.isSameSequence ( mcs, ics ) ) { - foText.addMapping ( s, e, mcs ); + if (!CharUtilities.isSameSequence (mcs, ics)) { + foText.addMapping (s, e, mcs); } // 7. compute word ipd based on final position adjustments MinOptMax ipd = MinOptMax.ZERO; - for ( int i = 0, n = mcs.length(); i < n; i++ ) { - int c = mcs.charAt ( i ); + for (int i = 0, n = mcs.length(); i < n; i++) { + int c = mcs.charAt (i); // TODO !BMP - int w = font.getCharWidth ( c ); - if ( w < 0 ) { + int w = font.getCharWidth (c); + if (w < 0) { w = 0; } - if ( gpa != null ) { + if (gpa != null) { w += gpa [ i ] [ GlyphPositioningTable.Value.IDX_X_ADVANCE ]; } - ipd = ipd.plus ( w ); + ipd = ipd.plus (w); } // [TBD] - handle letter spacing return new AreaInfo - ( s, e, 0, nLS, ipd, endsWithHyphen, false, - breakOpportunityChar != 0, font, level, gpa ); + (s, e, 0, nLS, ipd, endsWithHyphen, false, + breakOpportunityChar != 0, font, level, gpa); } /** @@ -1061,31 +1061,31 @@ public class TextLayoutManager extends LeafNodeLayoutManager { * @param font applicable font * @return glyph position adjustments (or null if no kerning) */ - private int[][] getKerningAdjustments ( CharSequence mcs, final Font font ) { + private int[][] getKerningAdjustments (CharSequence mcs, final Font font) { int nc = mcs.length(); // extract kerning array int[] ka = new int [ nc ]; // kerning array - for ( int i = 0, n = nc, cPrev = -1; i < n; i++ ) { - int c = mcs.charAt ( i ); + for (int i = 0, n = nc, cPrev = -1; i < n; i++) { + int c = mcs.charAt (i); // TODO !BMP - if ( cPrev >= 0 ) { - ka[i] = font.getKernValue ( cPrev, c ); + if (cPrev >= 0) { + ka[i] = font.getKernValue (cPrev, c); } cPrev = c; } // was there a non-zero kerning? boolean hasKerning = false; - for ( int i = 0, n = nc; i < n; i++ ) { - if ( ka[i] != 0 ) { + for (int i = 0, n = nc; i < n; i++) { + if (ka[i] != 0) { hasKerning = true; break; } } // if non-zero kerning, then create and return glyph position adjustment array - if ( hasKerning ) { + if (hasKerning) { int[][] gpa = new int [ nc ] [ 4 ]; - for ( int i = 0, n = nc; i < n; i++ ) { - if ( i > 0 ) { + for (int i = 0, n = nc; i < n; i++) { + if (i > 0) { gpa [ i - 1 ] [ GlyphPositioningTable.Value.IDX_X_ADVANCE ] = ka [ i ]; } } @@ -1101,10 +1101,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager { MinOptMax wordIPD = MinOptMax.ZERO; if (LOG.isDebugEnabled()) { - LOG.debug ( "PW: [" + thisStart + "," + lastIndex + "]: {" + LOG.debug ("PW: [" + thisStart + "," + lastIndex + "]: {" + " -M" + ", level = " + level - + " }" ); + + " }"); } for (int i = thisStart; i < lastIndex; i++) { @@ -1132,7 +1132,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } } if (kerning - && ( breakOpportunityChar != 0 ) + && (breakOpportunityChar != 0) && !TextLayoutManager.isSpace(breakOpportunityChar) && lastIndex > 0 && endsWithHyphen) { @@ -1151,7 +1151,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { // if there is a break opportunity and the next one (break character) // is not a space, it could be used as a line end; // add one more letter space, in case other text follows - if (( breakOpportunityChar != 0 ) && !TextLayoutManager.isSpace(breakOpportunityChar)) { + if ((breakOpportunityChar != 0) && !TextLayoutManager.isSpace(breakOpportunityChar)) { letterSpaces++; } } @@ -1177,14 +1177,14 @@ public class TextLayoutManager extends LeafNodeLayoutManager { final boolean endsWithHyphen = checkEndsWithHyphen && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN; Font font = FontSelector.selectFontForCharactersInText - ( foText, thisStart, lastIndex, foText, this ); + (foText, thisStart, lastIndex, foText, this); AreaInfo areaInfo; - if ( font.performsSubstitution() || font.performsPositioning() ) { + if (font.performsSubstitution() || font.performsPositioning()) { areaInfo = processWordMapping - ( lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level ); + (lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level); } else { areaInfo = processWordNoMapping - ( lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level ); + (lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level); } prevAreaInfo = areaInfo; addAreaInfo(areaInfo); @@ -1296,8 +1296,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager { if (!(nothingChanged && stopIndex == areaInfo.breakIndex && !hyphenFollows)) { // the new AreaInfo object is not equal to the old one changeList.add - ( new PendingChange - ( new AreaInfo(startIndex, stopIndex, 0, + (new PendingChange + (new AreaInfo(startIndex, stopIndex, 0, letterSpaceCount, newIPD, hyphenFollows, false, false, font, -1, null), ((LeafPosition) pos).getLeafPos() + changeOffset)); @@ -1704,7 +1704,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { public String toString() { return super.toString() + "{" + "chars = \'" - + CharUtilities.toNCRefs ( foText.getCharSequence().toString() ) + + CharUtilities.toNCRefs (foText.getCharSequence().toString()) + "\'" + ", len = " + foText.length() + "}"; diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java index cde19e67b..7dd2bc201 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CellPart.java +++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java @@ -61,8 +61,7 @@ class CellPart { * @param bpAfterLast width of (possibly optional) border- and padding-after if this * part will be the last one on the page */ - protected CellPart( // CSOK: ParameterNumber - PrimaryGridUnit pgu, int start, int end, boolean last, + protected CellPart(PrimaryGridUnit pgu, int start, int end, boolean last, int condBeforeContentLength, int length, int condAfterContentLength, int bpBeforeNormal, int bpBeforeFirst, int bpAfterNormal, int bpAfterLast) { diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java index 88b89e1db..f2a87b75a 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java @@ -63,7 +63,7 @@ public abstract class CollapsingBorderModel { } return collapse; case Constants.EN_COLLAPSE_WITH_PRECEDENCE: - throw new UnsupportedOperationException ( "collapse-with-precedence not yet supported" ); + throw new UnsupportedOperationException ("collapse-with-precedence not yet supported"); default: throw new IllegalArgumentException("Illegal border-collapse mode."); } diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index b0ad22386..bb5661a07 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -59,7 +59,7 @@ public class ColumnSetup { public ColumnSetup(Table table) { assert table != null; this.table = table; - this.wmTraits = WritingModeTraits.getWritingModeTraitsGetter ( table ); + this.wmTraits = WritingModeTraits.getWritingModeTraitsGetter (table); prepareColumns(); initializeColumnWidths(); } @@ -251,7 +251,7 @@ public class ColumnSetup { */ public int getXOffset(int col, int nrColSpan, PercentBaseContext context) { // TODO handle vertical WMs [GA] - if ( (wmTraits != null) && (wmTraits.getColumnProgressionDirection() == Direction.RL) ) { + if ((wmTraits != null) && (wmTraits.getColumnProgressionDirection() == Direction.RL)) { return getXOffsetRTL(col, nrColSpan, context); } else { return getXOffsetLTR(col, context); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index fbd753d58..878a1285a 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -390,8 +390,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager * this row is placed on a previous page). Used to calculate the placement of the * row's background image if any */ - public void addAreas( // CSOK: ParameterNumber - PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights, + public void addAreas(PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights, int startRow, int endRow, int borderBeforeWhich, int borderAfterWhich, boolean firstOnPage, boolean lastOnPage, RowPainter painter, int firstRowHeight) { getParentArea(null); diff --git a/src/java/org/apache/fop/pdf/PDFCIDFont.java b/src/java/org/apache/fop/pdf/PDFCIDFont.java index 46374d869..e24071846 100644 --- a/src/java/org/apache/fop/pdf/PDFCIDFont.java +++ b/src/java/org/apache/fop/pdf/PDFCIDFont.java @@ -56,8 +56,7 @@ public class PDFCIDFont extends PDFObject { * @param supplement Supplement number * @param descriptor CID font descriptor */ - public PDFCIDFont( // CSOK: ParameterNumber - String basefont, CIDFontType cidtype, int dw, + public PDFCIDFont(String basefont, CIDFontType cidtype, int dw, int[] w, String registry, String ordering, int supplement, PDFCIDFontDescriptor descriptor) { diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index 31be73a00..2feeece32 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -40,7 +40,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.java2d.color.ColorUtil; import org.apache.xmlgraphics.java2d.color.NamedColorSpace; - import org.apache.xmlgraphics.xmp.Metadata; import org.apache.fop.fonts.CIDFont; @@ -295,8 +294,7 @@ public class PDFFactory { * It should be 0 as this is the constructor for sampled functions. * @return the PDF function that was created */ - public PDFFunction makeFunction( // CSOK: ParameterNumber - int theFunctionType, List theDomain, + public PDFFunction makeFunction(int theFunctionType, List theDomain, List theRange, List theSize, int theBitsPerSample, int theOrder, List theEncode, List theDecode, @@ -469,8 +467,7 @@ public class PDFFactory { * @param theFunction The PDF Function that maps an (x,y) location to a color * @return the PDF shading that was created */ - public PDFShading makeShading( // CSOK: ParameterNumber - PDFResourceContext res, int theShadingType, + public PDFShading makeShading(PDFResourceContext res, int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, List theDomain, @@ -522,8 +519,7 @@ public class PDFFactory { * The default is [false, false] * @return the PDF shading that was created */ - public PDFShading makeShading( // CSOK: ParameterNumber - PDFResourceContext res, int theShadingType, + public PDFShading makeShading(PDFResourceContext res, int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, List theCoords, @@ -576,8 +572,7 @@ public class PDFFactory { * @param theFunction the PDFFunction * @return the PDF shading that was created */ - public PDFShading makeShading( // CSOK: ParameterNumber - PDFResourceContext res, int theShadingType, + public PDFShading makeShading(PDFResourceContext res, int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, @@ -632,8 +627,7 @@ public class PDFFactory { * @param theFunction The PDFFunction that's mapped on to this shape * @return the PDF shading that was created */ - public PDFShading makeShading( // CSOK: ParameterNumber - PDFResourceContext res, int theShadingType, + public PDFShading makeShading(PDFResourceContext res, int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, @@ -683,8 +677,7 @@ public class PDFFactory { * @param thePatternDataStream The stream of pattern data to be tiled. * @return the PDF pattern that was created */ - public PDFPattern makePattern( // CSOK: ParameterNumber - PDFResourceContext res, int thePatternType, // 1 + public PDFPattern makePattern(PDFResourceContext res, int thePatternType, PDFResources theResources, int thePaintType, int theTilingType, List theBBox, double theXStep, double theYStep, List theMatrix, diff --git a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java index 9d255545f..ec4e99101 100644 --- a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java +++ b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java @@ -40,8 +40,7 @@ public class PDFFontDescriptor extends PDFDictionary { * @param italicAngle the angle of the vertical dominant strokes * @param stemV the width of the dominant vertical stems of glyphs */ - public PDFFontDescriptor( // CSOK: ParameterNumber - String basefont, int ascent, + public PDFFontDescriptor(String basefont, int ascent, int descent, int capHeight, int flags, PDFRectangle fontBBox, int italicAngle, int stemV) { diff --git a/src/java/org/apache/fop/pdf/PDFFunction.java b/src/java/org/apache/fop/pdf/PDFFunction.java index 44198105b..1329e24df 100644 --- a/src/java/org/apache/fop/pdf/PDFFunction.java +++ b/src/java/org/apache/fop/pdf/PDFFunction.java @@ -211,8 +211,7 @@ public class PDFFunction extends PDFObject { * @param theFunctionType This is the type of function (0,2,3, or 4). * It should be 0 as this is the constructor for sampled functions. */ - public PDFFunction( // CSOK: ParameterNumber - int theFunctionType, List theDomain, + public PDFFunction(int theFunctionType, List theDomain, List theRange, List theSize, int theBitsPerSample, int theOrder, List theEncode, List theDecode, StringBuffer theFunctionDataStream, List theFilter) { diff --git a/src/java/org/apache/fop/pdf/PDFPattern.java b/src/java/org/apache/fop/pdf/PDFPattern.java index 88a2ff492..46a6a7378 100644 --- a/src/java/org/apache/fop/pdf/PDFPattern.java +++ b/src/java/org/apache/fop/pdf/PDFPattern.java @@ -116,8 +116,7 @@ public class PDFPattern extends PDFPathPaint { * @param theXUID Optional vector of Integers that uniquely identify the pattern * @param thePatternDataStream The stream of pattern data to be tiled. */ - public PDFPattern( // CSOK: ParameterNumber - PDFResources theResources, int thePatternType, // 1 + public PDFPattern(PDFResources theResources, int thePatternType, int thePaintType, int theTilingType, List theBBox, double theXStep, double theYStep, List theMatrix, List theXUID, diff --git a/src/java/org/apache/fop/pdf/PDFShading.java b/src/java/org/apache/fop/pdf/PDFShading.java index 90953968c..82f4c03ed 100644 --- a/src/java/org/apache/fop/pdf/PDFShading.java +++ b/src/java/org/apache/fop/pdf/PDFShading.java @@ -164,8 +164,7 @@ public class PDFShading extends PDFObject { * It's optional, the default is the identity matrix * @param theFunction The PDF Function that maps an (x,y) location to a color */ - public PDFShading( // CSOK: ParameterNumber - int theShadingType, PDFDeviceColorSpace theColorSpace, + public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, List theDomain, List theMatrix, PDFFunction theFunction) { @@ -203,8 +202,7 @@ public class PDFShading extends PDFObject { * and end colors past the start and end points * The default is [false, false] */ - public PDFShading( // CSOK: ParameterNumber - int theShadingType, PDFDeviceColorSpace theColorSpace, + public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, List theCoords, List theDomain, PDFFunction theFunction, @@ -244,8 +242,7 @@ public class PDFShading extends PDFObject { * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312. * @param theFunction the PDFFunction */ - public PDFShading( // CSOK: ParameterNumber - int theShadingType, PDFDeviceColorSpace theColorSpace, + public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, int theBitsPerFlag, @@ -284,8 +281,7 @@ public class PDFShading extends PDFObject { * @param theVerticesPerRow number of vertices in each "row" of the lattice. * @param theFunction The PDFFunction that's mapped on to this shape */ - public PDFShading( // CSOK: ParameterNumber - int theShadingType, PDFDeviceColorSpace theColorSpace, + public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace, List theBackground, List theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, List theDecode, diff --git a/src/java/org/apache/fop/pdf/PDFTextUtil.java b/src/java/org/apache/fop/pdf/PDFTextUtil.java index aae214fd3..cf7168e1c 100644 --- a/src/java/org/apache/fop/pdf/PDFTextUtil.java +++ b/src/java/org/apache/fop/pdf/PDFTextUtil.java @@ -113,7 +113,7 @@ public abstract class PDFTextUtil { } private void writeChar(char ch, StringBuffer sb) { - writeChar ( ch, sb, useMultiByte ); + writeChar (ch, sb, useMultiByte); } private void checkInTextObject() { @@ -325,7 +325,7 @@ public abstract class PDFTextUtil { * @param x coordinate * @param y coordinate */ - public void writeTd ( double x, double y ) { + public void writeTd (double x, double y) { StringBuffer sb = new StringBuffer(); PDFNumber.doubleOut(x, DEC, sb); sb.append(' '); @@ -338,7 +338,7 @@ public abstract class PDFTextUtil { * Writes a "Tj" command with specified character code. * @param ch character code to write */ - public void writeTj ( char ch ) { + public void writeTj (char ch) { StringBuffer sb = new StringBuffer(); sb.append('<'); writeChar(ch, sb, true); diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index eba4460b0..b374e1a2d 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -85,7 +85,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { float height = block.getBPD() / 1000f; int level = block.getBidiLevel(); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { startx += block.getStartIndent() / 1000f; startx -= borderPaddingStart; } else { @@ -118,7 +118,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { // adjust the current position according to region borders and padding currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore(); int level = region.getBidiLevel(); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { currentIPPosition = referenceArea.getBorderAndPaddingWidthStart(); } else { currentIPPosition = referenceArea.getBorderAndPaddingWidthEnd(); @@ -198,15 +198,14 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsEnd the border-end traits * @param level of bidirectional embedding */ - protected void drawBackground( // CSOK: ParameterNumber - float startx, float starty, float width, float height, Trait.Background back, + protected void drawBackground(float startx, float starty, float width, float height, Trait.Background back, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd, int level) { BorderProps bpsTop = bpsBefore; BorderProps bpsBottom = bpsAfter; BorderProps bpsLeft; BorderProps bpsRight; - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { bpsLeft = bpsStart; bpsRight = bpsEnd; } else { @@ -230,8 +229,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsLeft the border specification on the left edge * @param bpsRight the border specification on the right edge */ - protected void drawBackground( // CSOK: ParameterNumber - float startx, float starty, float width, float height, Trait.Background back, + protected void drawBackground(float startx, float starty, float width, float height, Trait.Background back, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight) { if (back != null) { @@ -347,8 +345,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param level of bidirectional embedding * @param innerBackgroundColor the background color of the block */ - protected void drawBorders( // CSOK: ParameterNumber - float startx, float starty, float width, float height, + protected void drawBorders(float startx, float starty, float width, float height, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd, int level, Color innerBackgroundColor) { Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height); @@ -356,7 +353,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { BorderProps bpsBottom = bpsAfter; BorderProps bpsLeft; BorderProps bpsRight; - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { bpsLeft = bpsStart; bpsRight = bpsEnd; } else { @@ -380,8 +377,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsRight the border specification on the right edge * @param innerBackgroundColor the background color of the block */ - protected void drawBorders( // CSOK: MethodLength - Rectangle2D.Float borderRect, + protected void drawBorders(Rectangle2D.Float borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, Color innerBackgroundColor) { //TODO generalize each of the four conditions into using a parameterized drawBorder() @@ -616,7 +612,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { int borderPaddingEnd = bv.getBorderAndPaddingWidthEnd(); //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { positionTransform.translate(-borderPaddingStart, -borderPaddingBefore); } else { positionTransform.translate(-borderPaddingEnd, -borderPaddingBefore); @@ -648,7 +644,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { //Shift to content rectangle after border painting AffineTransform contentRectTransform = new AffineTransform(); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); } else { contentRectTransform.translate(borderPaddingEnd, borderPaddingBefore); @@ -820,7 +816,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (viewport.hasClip()) { saveGraphicsState(); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height); } else { clipRect(x + borderPaddingEnd, y + borderPaddingBefore, width, height); @@ -978,8 +974,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param style the border style (one of Constants.EN_DASHED etc.) * @param col the color for the border segment */ - protected abstract void drawBorderLine( // CSOK: ParameterNumber - float x1, float y1, float x2, float y2, boolean horz, + protected abstract void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col); /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 770f5a797..ca4a24512 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -410,10 +410,10 @@ public abstract class AbstractRenderer for (int count = 0; count < spans.size(); count++) { span = (Span) spans.get(count); int level = span.getBidiLevel(); - if ( level < 0 ) { + if (level < 0) { level = 0; } - if ( ( level & 1 ) == 1 ) { + if ((level & 1) == 1) { currentIPPosition += span.getIPD(); currentIPPosition += mr.getColumnGap(); } @@ -421,12 +421,12 @@ public abstract class AbstractRenderer NormalFlow flow = span.getNormalFlow(c); if (flow != null) { currentBPPosition = saveSpanBPPos; - if ( ( level & 1 ) == 1 ) { + if ((level & 1) == 1) { currentIPPosition -= flow.getIPD(); currentIPPosition -= mr.getColumnGap(); } renderFlow(flow); - if ( ( level & 1 ) == 0 ) { + if ((level & 1) == 0) { currentIPPosition += flow.getIPD(); currentIPPosition += mr.getColumnGap(); } @@ -550,9 +550,9 @@ public abstract class AbstractRenderer // a line area is rendered from the top left position // of the line, each inline object is offset from there LineArea line = (LineArea) obj; - if ( parent != null ) { + if (parent != null) { int level = parent.getBidiLevel(); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { currentIPPosition += parent.getStartIndent(); } else { currentIPPosition += parent.getEndIndent(); @@ -622,16 +622,16 @@ public abstract class AbstractRenderer int saveBP = currentBPPosition; currentBPPosition += line.getSpaceBefore(); int bl = line.getBidiLevel(); - if ( bl >= 0 ) { - if ( ( bl & 1 ) == 0 ) { + if (bl >= 0) { + if ((bl & 1) == 0) { currentIPPosition += line.getStartIndent(); } else { currentIPPosition += line.getEndIndent(); // if line's content overflows line area, then // ensure that overflow is drawn (extends) // outside of left side of line area - int overflow = computeInlinesOverflow ( line ); - if ( overflow > 0 ) { + int overflow = computeInlinesOverflow (line); + if (overflow > 0) { currentIPPosition -= overflow; } } @@ -645,7 +645,7 @@ public abstract class AbstractRenderer currentBPPosition = saveBP; } - private int computeInlinesOverflow ( LineArea line ) { + private int computeInlinesOverflow (LineArea line) { List children = line.getInlineAreas(); int ipdConsumed = 0; for (int i = 0, l = children.size(); i < l; i++) { @@ -755,7 +755,7 @@ public abstract class AbstractRenderer // it is right-to-left, then adjust starting ip position in order to // align children to starting (right) edge of filled area int ipAdjust; - if ( ( ip instanceof FilledArea ) && ( ( level & 1 ) != 0 ) ) { + if ((ip instanceof FilledArea) && ((level & 1) != 0)) { int ipdChildren = 0; for (int i = 0, l = children.size(); i < l; i++) { InlineArea inline = (InlineArea) children.get(i); @@ -766,11 +766,11 @@ public abstract class AbstractRenderer ipAdjust = 0; } // perform inline position adjustments - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { currentIPPosition += ip.getBorderAndPaddingWidthStart(); } else { currentIPPosition += ip.getBorderAndPaddingWidthEnd(); - if ( ipAdjust > 0 ) { + if (ipAdjust > 0) { currentIPPosition += ipAdjust; } } @@ -791,7 +791,7 @@ public abstract class AbstractRenderer protected void renderInlineBlockParent(InlineBlockParent ibp) { int level = ibp.getBidiLevel(); renderInlineAreaBackAndBorders(ibp); - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { currentIPPosition += ibp.getBorderAndPaddingWidthStart(); } else { currentIPPosition += ibp.getBorderAndPaddingWidthEnd(); diff --git a/src/java/org/apache/fop/render/afp/AFPPainter.java b/src/java/org/apache/fop/render/afp/AFPPainter.java index 014b70735..f7424c89c 100644 --- a/src/java/org/apache/fop/render/afp/AFPPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPPainter.java @@ -894,8 +894,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawText( // CSOK: MethodLength - int x, int y, final int letterSpacing, final int wordSpacing, + public void drawText(int x, int y, final int letterSpacing, final int wordSpacing, final int[][] dp, final String text) throws IFException { final int fontSize = this.state.getFontSize(); getPaintingState().setFontSize(fontSize); @@ -941,7 +940,7 @@ public class AFPPainter extends AbstractIFPainter { builder.setCodedFont((byte) fontReference); int l = text.length(); - int[] dx = IFUtil.convertDPToDX ( dp ); + int[] dx = IFUtil.convertDPToDX (dp); int dxl = (dx != null ? dx.length : 0); StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java index c850c35e7..ab5d78a64 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -399,7 +399,7 @@ public class PreviewPanel extends JPanel { int value = +e.getValue(); int min = a.getMinimum(); int max = a.getMaximum(); - int page = ( (renderer.getNumberOfPages() * value) / (max - min) ); + int page = ((renderer.getNumberOfPages() * value) / (max - min)); if (page != currentPage) { int oldPage = currentPage; currentPage = page; diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java index 12dd46c20..2dd046fa9 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java @@ -460,7 +460,7 @@ public abstract class AbstractIFPainter implements } /** {@inheritDoc} */ - public boolean isBackgroundRequired( BorderProps bpsBefore, BorderProps bpsAfter, + public boolean isBackgroundRequired(BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) { return true; } diff --git a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java index 8c3f998a9..cc7015a71 100644 --- a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java @@ -57,7 +57,7 @@ public class IFGraphicContext extends GraphicContext { * {@inheritDoc} */ public Object clone() { - return new IFGraphicContext ( this ); + return new IFGraphicContext (this); } /** @param group a group */ diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 484e8d559..c0fef8423 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -643,8 +643,8 @@ public class IFParser implements IFConstants { int[][] dp = XMLUtil.getAttributeAsPositionAdjustments(lastAttributes, "dp"); // if only DX present, then convert DX to DP; otherwise use only DP, // effectively ignoring DX - if ( ( dp == null ) && ( dx != null ) ) { - dp = IFUtil.convertDXToDP ( dx ); + if ((dp == null) && (dx != null)) { + dp = IFUtil.convertDXToDP (dx); } establishStructureTreeElement(lastAttributes); boolean isHyphenated = Boolean.valueOf(lastAttributes.getValue("hyphenated")); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index f429efb2c..5cdac7c88 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -1046,11 +1046,11 @@ public class IFRenderer extends AbstractPathOrientedRenderer { String s = word.getWord(); int[][] dp = word.getGlyphPositionAdjustments(); - if ( dp == null ) { + if (dp == null) { renderTextWithAdjustments(s, word.getLetterAdjustArray(), word.isReversed(), font, (AbstractTextArea)word.getParentArea()); - } else if ( IFUtil.isDPOnlyDX ( dp ) ) { - renderTextWithAdjustments(s, IFUtil.convertDPToDX ( dp ), word.isReversed(), + } else if (IFUtil.isDPOnlyDX (dp)) { + renderTextWithAdjustments(s, IFUtil.convertDPToDX (dp), word.isReversed(), font, (AbstractTextArea)word.getParentArea()); } else { renderTextWithAdjustments(s, dp, word.isReversed(), @@ -1122,10 +1122,10 @@ public class IFRenderer extends AbstractPathOrientedRenderer { int[][] dp, boolean reversed, Font font, AbstractTextArea parentArea) { assert !textUtil.combined; - for ( int i = 0, n = s.length(); i < n; i++ ) { - textUtil.addChar ( s.charAt ( i ) ); - if ( dp != null ) { - textUtil.adjust ( dp[i] ); + for (int i = 0, n = s.length(); i < n; i++) { + textUtil.addChar (s.charAt (i)); + if (dp != null) { + textUtil.adjust (dp[i]); } } } @@ -1146,17 +1146,17 @@ public class IFRenderer extends AbstractPathOrientedRenderer { void adjust(int dx) { if (dx != 0) { - adjust ( new int[] { + adjust (new int[] { dx, // xPlaAdjust 0, // yPlaAdjust dx, // xAdvAdjust 0 // yAdvAdjust - } ); + }); } } void adjust(int[] pa) { - if ( !IFUtil.isPAIdentity ( pa ) ) { + if (!IFUtil.isPAIdentity (pa)) { int idx = text.length(); if (idx > dp.length - 1) { int newSize = Math.max(dp.length, idx + 1) + INITIAL_BUFFER_SIZE; @@ -1166,17 +1166,17 @@ public class IFRenderer extends AbstractPathOrientedRenderer { // switch to new DP, leaving DP[dp.length]...DP[newDP.length-1] unpopulated dp = newDP; } - if ( dp[idx - 1] == null ) { + if (dp[idx - 1] == null) { dp[idx - 1] = new int[4]; } - IFUtil.adjustPA ( dp[idx - 1], pa ); + IFUtil.adjustPA (dp[idx - 1], pa); } } void reset() { if (text.length() > 0) { text.setLength(0); - for ( int i = 0, n = dp.length; i < n; i++ ) { + for (int i = 0, n = dp.length; i < n; i++) { dp[i] = null; } } @@ -1197,10 +1197,10 @@ public class IFRenderer extends AbstractPathOrientedRenderer { try { if (combined) { painter.drawText(startx, starty, 0, 0, - trimAdjustments ( dp, text.length() ), text.toString()); + trimAdjustments (dp, text.length()), text.toString()); } else { painter.drawText(startx, starty, tls, tws, - trimAdjustments ( dp, text.length() ), text.toString()); + trimAdjustments (dp, text.length()), text.toString()); } } catch (IFException e) { handleIFException(e); @@ -1219,23 +1219,23 @@ public class IFRenderer extends AbstractPathOrientedRenderer { * no greater than text length, and the last entry has a non-zero * adjustment. */ - private int[][] trimAdjustments ( int[][] dp, int textLength ) { - if ( dp != null ) { + private int[][] trimAdjustments (int[][] dp, int textLength) { + if (dp != null) { int tl = textLength; int pl = dp.length; - int i = ( tl < pl ) ? tl : pl; - while ( i > 0 ) { + int i = (tl < pl) ? tl : pl; + while (i > 0) { int[] pa = dp [ i - 1 ]; - if ( ( pa != null ) && !IFUtil.isPAIdentity ( pa ) ) { + if ((pa != null) && !IFUtil.isPAIdentity (pa)) { break; } else { i--; } } - if ( i == 0 ) { + if (i == 0) { dp = null; - } else if ( i < pl ) { - dp = IFUtil.copyDP ( dp, 0, i ); + } else if (i < pl) { + dp = IFUtil.copyDP (dp, 0, i); } } return dp; @@ -1328,7 +1328,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { pushGroup(new IFGraphicContext.Group()); Rectangle rect = toMillipointRectangle(startx, starty, width, height); try { - painter.clipBackground( rect, + painter.clipBackground(rect, bpsBefore, bpsAfter, bpsStart, bpsEnd); } catch (IFException ife) { handleIFException(ife); @@ -1353,8 +1353,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void drawBorders( // CSOK: ParameterNumber - float startx, float starty, + protected void drawBorders(float startx, float starty, float width, float height, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd, int level, Color innerBackgroundColor) { @@ -1364,7 +1363,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { BorderProps bpsBottom = bpsAfter; BorderProps bpsLeft; BorderProps bpsRight; - if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) { + if ((level == -1) || ((level & 1) == 0)) { bpsLeft = bpsStart; bpsRight = bpsEnd; } else { @@ -1378,8 +1377,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void drawBorderLine( // CSOK: ParameterNumber - float x1, float y1, float x2, float y2, boolean horz, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { //Simplified implementation that is only used by renderTextDecoration() //drawBorders() is overridden and uses the Painter's high-level method drawBorderRect() diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index bba8c744d..62e4cc67d 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -678,9 +678,9 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { addAttribute(atts, "word-spacing", Integer.toString(wordSpacing)); } if (dp != null) { - if ( IFUtil.isDPIdentity(dp) ) { + if (IFUtil.isDPIdentity(dp)) { // don't add dx or dp attribute - } else if ( IFUtil.isDPOnlyDX(dp) ) { + } else if (IFUtil.isDPOnlyDX(dp)) { // add dx attribute only int[] dx = IFUtil.convertDPToDX(dp); addAttribute(atts, "dx", IFUtil.toString(dx)); diff --git a/src/java/org/apache/fop/render/intermediate/IFUtil.java b/src/java/org/apache/fop/render/intermediate/IFUtil.java index 8906e901b..1b9223913 100644 --- a/src/java/org/apache/fop/render/intermediate/IFUtil.java +++ b/src/java/org/apache/fop/render/intermediate/IFUtil.java @@ -212,12 +212,12 @@ public final class IFUtil { * @return if dp is not null, then an array of adjustments to the current * x position prior to rendering individual glyphs; otherwise, null */ - public static int[] convertDPToDX ( int[][] dp, int count ) { + public static int[] convertDPToDX (int[][] dp, int count) { int[] dx; - if ( dp != null ) { + if (dp != null) { dx = new int [ count ]; - for ( int i = 0, n = count; i < n; i++ ) { - if ( dp [ i ] != null ) { + for (int i = 0, n = count; i < n; i++) { + if (dp [ i ] != null) { dx [ i ] = dp [ i ] [ 0 ]; // xPlaAdjust[i] } } @@ -236,8 +236,8 @@ public final class IFUtil { * @return if dp is not null, then an array of adjustments to the current * x position prior to rendering individual glyphs; otherwise, null */ - public static int[] convertDPToDX ( int[][] dp ) { - return convertDPToDX ( dp, ( dp != null ) ? dp.length : 0 ); + public static int[] convertDPToDX (int[][] dp) { + return convertDPToDX (dp, (dp != null) ? dp.length : 0); } /** @@ -250,11 +250,11 @@ public final class IFUtil { * @return if dx is not null, then an array of 4-tuples, expressing [X,Y] * placment adjustments and [X,Y] advancement adjustments, in that order; otherwise, null */ - public static int[][] convertDXToDP ( int[] dx, int count ) { + public static int[][] convertDXToDP (int[] dx, int count) { int[][] dp; - if ( dx != null ) { + if (dx != null) { dp = new int [ count ] [ 4 ]; - for ( int i = 0, n = count; i < n; i++ ) { + for (int i = 0, n = count; i < n; i++) { int[] pa = dp [ i ]; int d = dx [ i ]; pa [ 0 ] = d; // xPlaAdjust[i] @@ -275,8 +275,8 @@ public final class IFUtil { * @return if dx is not null, then an array of 4-tuples, expressing [X,Y] * placment adjustments and [X,Y] advancement adjustments, in that order; otherwise, null */ - public static int[][] convertDXToDP ( int[] dx ) { - return convertDXToDP ( dx, ( dx != null ) ? dx.length : 0 ); + public static int[][] convertDXToDP (int[] dx) { + return convertDXToDP (dx, (dx != null) ? dx.length : 0); } /** @@ -284,12 +284,12 @@ public final class IFUtil { * @param pa a 4-tuple, expressing [X,Y] placment and [X,Y] advance adjuustments (may be null) * @return true if dp is null or contains no non-zero adjustment */ - public static boolean isPAIdentity ( int[] pa ) { - if ( pa == null ) { + public static boolean isPAIdentity (int[] pa) { + if (pa == null) { return true; } else { - for ( int k = 0; k < 4; k++ ) { - if ( pa[k] != 0 ) { + for (int k = 0; k < 4; k++) { + if (pa[k] != 0) { return false; } } @@ -303,12 +303,12 @@ public final class IFUtil { * adjustments and [X,Y] advancement adjustments, in that order (may be null) * @return true if dp is null or contains no non-zero adjustment */ - public static boolean isDPIdentity ( int[][] dp ) { - if ( dp == null ) { + public static boolean isDPIdentity (int[][] dp) { + if (dp == null) { return true; } else { - for ( int i = 0, n = dp.length; i < n; i++ ) { - if ( !isPAIdentity ( dp[i] ) ) { + for (int i = 0, n = dp.length; i < n; i++) { + if (!isPAIdentity (dp[i])) { return false; } } @@ -326,13 +326,13 @@ public final class IFUtil { * @return true if dp is not null and contains only xPlaAdjust * and xAdvAdjust values consistent with the output of {@link #convertDPToDX}. */ - public static boolean isDPOnlyDX ( int[][] dp ) { - if ( dp == null ) { + public static boolean isDPOnlyDX (int[][] dp) { + if (dp == null) { return false; } else { - for ( int i = 0, n = dp.length; i < n; i++ ) { + for (int i = 0, n = dp.length; i < n; i++) { int[] pa = dp[i]; - if ( ( pa != null ) && ( pa[0] != pa[2] ) ) { + if ((pa != null) && (pa[0] != pa[2])) { return false; } } @@ -348,11 +348,11 @@ public final class IFUtil { * @param paSrc a 4-tuple, expressing [X,Y] placment * and [X,Y] advance adjuustments (may be null) */ - public static void adjustPA ( int[] paDst, int[] paSrc ) { - if ( ( paDst != null ) && ( paSrc != null ) ) { + public static void adjustPA (int[] paDst, int[] paSrc) { + if ((paDst != null) && (paSrc != null)) { assert paDst.length == 4; assert paSrc.length == 4; - for ( int i = 0; i < 4; i++ ) { + for (int i = 0; i < 4; i++) { paDst[i] += paSrc[i]; } } @@ -367,16 +367,16 @@ public final class IFUtil { * @return a deep copy of the count position adjustment entries start at * offset */ - public static int[][] copyDP ( int[][] dp, int offset, int count ) { - if ( ( dp == null ) || ( offset > dp.length ) || ( ( offset + count ) > dp.length ) ) { + public static int[][] copyDP (int[][] dp, int offset, int count) { + if ((dp == null) || (offset > dp.length) || ((offset + count) > dp.length)) { throw new IllegalArgumentException(); } else { int[][] dpNew = new int [ count ] []; - for ( int i = 0, n = count; i < n; i++ ) { + for (int i = 0, n = count; i < n; i++) { int[] paSrc = dp [ i + offset ]; - if ( paSrc != null ) { + if (paSrc != null) { int[] paDst = new int [ 4 ]; - for ( int k = 0; k < 4; k++ ) { + for (int k = 0; k < 4; k++) { paDst [ k ] = paSrc [ k ]; } dpNew [ i ] = paDst; diff --git a/src/java/org/apache/fop/render/java2d/Java2DPainter.java b/src/java/org/apache/fop/render/java2d/Java2DPainter.java index dc9cf9dab..e49f17988 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DPainter.java @@ -234,7 +234,7 @@ public class Java2DPainter extends AbstractIFPainter { Point2D cursor = new Point2D.Float(0, 0); int l = text.length(); - int[] dx = IFUtil.convertDPToDX ( dp ); + int[] dx = IFUtil.convertDPToDX (dp); int dxl = (dx != null ? dx.length : 0); if (dx != null && dxl > 0 && dx[0] != 0) { diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 91d38675d..a98aff353 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -546,8 +546,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** {@inheritDoc} */ - protected void drawBorderLine( // CSOK: ParameterNumber - float x1, float y1, float x2, float y2, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { Graphics2D g2d = state.getGraph(); float width = x2 - x1; diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java index 0fbf86c2c..009306620 100644 --- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java +++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java @@ -159,7 +159,7 @@ public class PCLGraphics2D extends AbstractGraphics2D { } } if (len == 1) { - gen.writeText("," + gen.formatDouble2(da[0] * 100 / patternLen )); + gen.writeText("," + gen.formatDouble2(da[0] * 100 / patternLen)); } gen.writeText(";"); diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java index 179a4f527..974f5d7da 100644 --- a/src/java/org/apache/fop/render/pcl/PCLPainter.java +++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java @@ -346,7 +346,7 @@ public class PCLPainter extends AbstractIFPainter implements float fontSize = state.getFontSize() / 1000f; Font font = getFontInfo().getFontInstance(triplet, state.getFontSize()); int l = text.length(); - int[] dx = IFUtil.convertDPToDX ( dp ); + int[] dx = IFUtil.convertDPToDX (dp); int dxl = (dx != null ? dx.length : 0); StringBuffer sb = new StringBuffer(Math.max(16, l)); @@ -390,8 +390,7 @@ public class PCLPainter extends AbstractIFPainter implements private static final double SAFETY_MARGIN_FACTOR = 0.05; - private Rectangle getTextBoundingBox( // CSOK: ParameterNumber - int x, int y, + private Rectangle getTextBoundingBox(int x, int y, int letterSpacing, int wordSpacing, int[][] dp, String text, Font font, FontMetricsMapper metrics) { @@ -403,7 +402,7 @@ public class PCLPainter extends AbstractIFPainter implements 0, maxAscent - descent + 2 * safetyMargin); int l = text.length(); - int[] dx = IFUtil.convertDPToDX ( dp ); + int[] dx = IFUtil.convertDPToDX (dp); int dxl = (dx != null ? dx.length : 0); if (dx != null && dxl > 0 && dx[0] != 0) { diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java index 1ef637726..ce43fc14b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java @@ -184,7 +184,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler private void updateTargetLocation(PDFGoTo pdfGoTo, GoToXYAction action) throws IFException { PageReference pageRef = this.documentHandler.getPageReference(action.getPageIndex()); - if ( pageRef == null ) { + if (pageRef == null) { throw new IFException("Can't resolve page reference @ index: " + action.getPageIndex(), null); } else { diff --git a/src/java/org/apache/fop/render/pdf/PDFPainter.java b/src/java/org/apache/fop/render/pdf/PDFPainter.java index d8e02cd93..33687069b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFPainter.java +++ b/src/java/org/apache/fop/render/pdf/PDFPainter.java @@ -201,7 +201,7 @@ public class PDFPainter extends AbstractIFPainter { generator.add(format(rect.width) + " 0 0 " + format(-rect.height) + " " + format(rect.x) + " " - + format(rect.y + rect.height ) + + format(rect.y + rect.height) + " cm " + xobj.getName() + " Do\n"); generator.restoreGraphicsState(); } @@ -215,7 +215,7 @@ public class PDFPainter extends AbstractIFPainter { generator.add(format(rect.width) + " 0 0 " + format(-rect.height) + " " + format(rect.x) + " " - + format(rect.y + rect.height ) + + format(rect.y + rect.height) + " cm " + xobj.getName() + " Do\n"); generator.restoreGraphicsStateAccess(); } @@ -355,12 +355,12 @@ public class PDFPainter extends AbstractIFPainter { FontTriplet triplet = new FontTriplet( state.getFontFamily(), state.getFontStyle(), state.getFontWeight()); - if ( ( dp == null ) || IFUtil.isDPOnlyDX ( dp ) ) { - drawTextWithDX ( x, y, text, triplet, letterSpacing, - wordSpacing, IFUtil.convertDPToDX ( dp ) ); + if ((dp == null) || IFUtil.isDPOnlyDX (dp)) { + drawTextWithDX (x, y, text, triplet, letterSpacing, + wordSpacing, IFUtil.convertDPToDX (dp)); } else { - drawTextWithDP ( x, y, text, triplet, letterSpacing, - wordSpacing, dp ); + drawTextWithDP (x, y, text, triplet, letterSpacing, + wordSpacing, dp); } } @@ -434,14 +434,14 @@ public class PDFPainter extends AbstractIFPainter { private static int[] paZero = new int[4]; - private void drawTextWithDP ( int x, int y, String text, FontTriplet triplet, - int letterSpacing, int wordSpacing, int[][] dp ) { + private void drawTextWithDP (int x, int y, String text, FontTriplet triplet, + int letterSpacing, int wordSpacing, int[][] dp) { assert text != null; assert triplet != null; assert dp != null; String fk = getFontInfo().getInternalFontKey(triplet); Typeface tf = getTypeface(fk); - if ( tf.isMultiByte() ) { + if (tf.isMultiByte()) { int fs = state.getFontSize(); float fsPoints = fs / 1000f; Font f = getFontInfo().getFontInstance(triplet, fs); @@ -451,20 +451,20 @@ public class PDFPainter extends AbstractIFPainter { double xoLast = 0f; double yoLast = 0f; double wox = wordSpacing; - tu.writeTextMatrix ( new AffineTransform ( 1, 0, 0, -1, x / 1000f, y / 1000f ) ); - tu.updateTf ( fk, fsPoints, true ); - generator.updateCharacterSpacing ( letterSpacing / 1000f ); - for ( int i = 0, n = text.length(); i < n; i++ ) { - char ch = text.charAt ( i ); - int[] pa = ( ( i >= dp.length ) || ( dp[i] == null ) ) ? paZero : dp[i]; + tu.writeTextMatrix (new AffineTransform (1, 0, 0, -1, x / 1000f, y / 1000f)); + tu.updateTf (fk, fsPoints, true); + generator.updateCharacterSpacing (letterSpacing / 1000f); + for (int i = 0, n = text.length(); i < n; i++) { + char ch = text.charAt (i); + int[] pa = ((i >= dp.length) || (dp[i] == null)) ? paZero : dp[i]; double xo = xc + pa[0]; double yo = yc + pa[1]; - double xa = f.getCharWidth(ch) + maybeWordOffsetX ( wox, ch, null ); + double xa = f.getCharWidth(ch) + maybeWordOffsetX (wox, ch, null); double ya = 0; - double xd = ( xo - xoLast ) / 1000f; - double yd = ( yo - yoLast ) / 1000f; - tu.writeTd ( xd, yd ); - tu.writeTj ( f.mapChar ( ch ) ); + double xd = (xo - xoLast) / 1000f; + double yd = (yo - yoLast) / 1000f; + tu.writeTd (xd, yd); + tu.writeTj (f.mapChar (ch)); xc += xa + pa[2]; yc += ya + pa[3]; xoLast = xo; @@ -473,10 +473,10 @@ public class PDFPainter extends AbstractIFPainter { } } - private double maybeWordOffsetX ( double wox, char ch, Direction dir ) { - if ( ( wox != 0 ) - && CharUtilities.isAdjustableSpace ( ch ) - && ( ( dir == null ) || dir.isHorizontal() ) ) { + private double maybeWordOffsetX (double wox, char ch, Direction dir) { + if ((wox != 0) + && CharUtilities.isAdjustableSpace (ch) + && ((dir == null) || dir.isHorizontal())) { return wox; } else { return 0; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java index ebae5baaf..4ddc8f60f 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java @@ -51,8 +51,8 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement { */ public void startOfNode() throws FOPException { super.startOfNode(); - if ( !((parent.getNameId() == Constants.FO_DECLARATIONS) - || (parent.getNameId() == Constants.FO_SIMPLE_PAGE_MASTER)) ) { + if (!((parent.getNameId() == Constants.FO_DECLARATIONS) + || (parent.getNameId() == Constants.FO_SIMPLE_PAGE_MASTER))) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), "rule.childOfSPMorDeclarations"); } diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index 6c2d7c03d..61f4203e7 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -1521,15 +1521,15 @@ public class RTFHandler extends FOEventHandler { private void invokeDeferredEvent(FONode foNode, boolean bStart) { // CSOK: MethodLength if (foNode instanceof PageSequence) { if (bStart) { - startPageSequence( (PageSequence) foNode); + startPageSequence((PageSequence) foNode); } else { - endPageSequence( (PageSequence) foNode); + endPageSequence((PageSequence) foNode); } } else if (foNode instanceof Flow) { if (bStart) { - startFlow( (Flow) foNode); + startFlow((Flow) foNode); } else { - endFlow( (Flow) foNode); + endFlow((Flow) foNode); } } else if (foNode instanceof StaticContent) { if (bStart) { @@ -1539,36 +1539,36 @@ public class RTFHandler extends FOEventHandler { } } else if (foNode instanceof ExternalGraphic) { if (bStart) { - image( (ExternalGraphic) foNode ); + image((ExternalGraphic) foNode); } } else if (foNode instanceof InstreamForeignObject) { if (bStart) { - endInstreamForeignObject( (InstreamForeignObject) foNode ); + endInstreamForeignObject((InstreamForeignObject) foNode); } } else if (foNode instanceof Block) { if (bStart) { - startBlock( (Block) foNode); + startBlock((Block) foNode); } else { - endBlock( (Block) foNode); + endBlock((Block) foNode); } } else if (foNode instanceof BlockContainer) { if (bStart) { - startBlockContainer( (BlockContainer) foNode); + startBlockContainer((BlockContainer) foNode); } else { - endBlockContainer( (BlockContainer) foNode); + endBlockContainer((BlockContainer) foNode); } } else if (foNode instanceof BasicLink) { //BasicLink must be placed before Inline if (bStart) { - startLink( (BasicLink) foNode); + startLink((BasicLink) foNode); } else { endLink(null); } } else if (foNode instanceof Inline) { if (bStart) { - startInline( (Inline) foNode); + startInline((Inline) foNode); } else { - endInline( (Inline) foNode); + endInline((Inline) foNode); } } else if (foNode instanceof FOText) { if (bStart) { @@ -1582,27 +1582,27 @@ public class RTFHandler extends FOEventHandler { } } else if (foNode instanceof PageNumber) { if (bStart) { - startPageNumber( (PageNumber) foNode); + startPageNumber((PageNumber) foNode); } else { - endPageNumber( (PageNumber) foNode); + endPageNumber((PageNumber) foNode); } } else if (foNode instanceof Footnote) { if (bStart) { - startFootnote( (Footnote) foNode); + startFootnote((Footnote) foNode); } else { - endFootnote( (Footnote) foNode); + endFootnote((Footnote) foNode); } } else if (foNode instanceof FootnoteBody) { if (bStart) { - startFootnoteBody( (FootnoteBody) foNode); + startFootnoteBody((FootnoteBody) foNode); } else { - endFootnoteBody( (FootnoteBody) foNode); + endFootnoteBody((FootnoteBody) foNode); } } else if (foNode instanceof ListBlock) { if (bStart) { - startList( (ListBlock) foNode); + startList((ListBlock) foNode); } else { - endList( (ListBlock) foNode); + endList((ListBlock) foNode); } } else if (foNode instanceof ListItemBody) { if (bStart) { @@ -1612,9 +1612,9 @@ public class RTFHandler extends FOEventHandler { } } else if (foNode instanceof ListItem) { if (bStart) { - startListItem( (ListItem) foNode); + startListItem((ListItem) foNode); } else { - endListItem( (ListItem) foNode); + endListItem((ListItem) foNode); } } else if (foNode instanceof ListItemLabel) { if (bStart) { @@ -1624,45 +1624,45 @@ public class RTFHandler extends FOEventHandler { } } else if (foNode instanceof Table) { if (bStart) { - startTable( (Table) foNode); + startTable((Table) foNode); } else { - endTable( (Table) foNode); + endTable((Table) foNode); } } else if (foNode instanceof TableHeader) { if (bStart) { - startHeader( (TableHeader) foNode); + startHeader((TableHeader) foNode); } else { - endHeader( (TableHeader) foNode); + endHeader((TableHeader) foNode); } } else if (foNode instanceof TableFooter) { if (bStart) { - startFooter( (TableFooter) foNode); + startFooter((TableFooter) foNode); } else { - endFooter( (TableFooter) foNode); + endFooter((TableFooter) foNode); } } else if (foNode instanceof TableBody) { if (bStart) { - startBody( (TableBody) foNode); + startBody((TableBody) foNode); } else { - endBody( (TableBody) foNode); + endBody((TableBody) foNode); } } else if (foNode instanceof TableColumn) { if (bStart) { - startColumn( (TableColumn) foNode); + startColumn((TableColumn) foNode); } else { - endColumn( (TableColumn) foNode); + endColumn((TableColumn) foNode); } } else if (foNode instanceof TableRow) { if (bStart) { - startRow( (TableRow) foNode); + startRow((TableRow) foNode); } else { - endRow( (TableRow) foNode); + endRow((TableRow) foNode); } } else if (foNode instanceof TableCell) { if (bStart) { - startCell( (TableCell) foNode); + startCell((TableCell) foNode); } else { - endCell( (TableCell) foNode); + endCell((TableCell) foNode); } } else if (foNode instanceof Leader) { if (bStart) { @@ -1716,7 +1716,7 @@ public class RTFHandler extends FOEventHandler { } - recurseFONode( pageSequence.getMainFlow() ); + recurseFONode(pageSequence.getMainFlow()); } else if (foNode instanceof Table) { Table table = (Table) foNode; @@ -1726,7 +1726,7 @@ public class RTFHandler extends FOEventHandler { prepareTable(table); for (Iterator it = table.getColumns().iterator(); it.hasNext();) { - recurseFONode( (FONode) it.next() ); + recurseFONode((FONode) it.next()); } } else { //TODO Implement implicit column setup handling! @@ -1737,17 +1737,17 @@ public class RTFHandler extends FOEventHandler { //recurse table-header if (table.getTableHeader() != null) { - recurseFONode( table.getTableHeader() ); + recurseFONode(table.getTableHeader()); } //recurse table-footer if (table.getTableFooter() != null) { - recurseFONode( table.getTableFooter() ); + recurseFONode(table.getTableFooter()); } if (foNode.getChildNodes() != null) { for (Iterator it = foNode.getChildNodes(); it.hasNext();) { - recurseFONode( (FONode) it.next() ); + recurseFONode((FONode) it.next()); } } } else if (foNode instanceof ListItem) { diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java index 02a31ed35..e5faf94bc 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java @@ -475,12 +475,12 @@ public class RtfExternalGraphic extends RtfElement { int i = 0; i = ImageUtil.getIntFromByteArray(imagedata, 151, 4, false); - if (i != 0 ) { + if (i != 0) { width = i; } i = ImageUtil.getIntFromByteArray(imagedata, 155, 4, false); - if (i != 0 ) { + if (i != 0) { height = i; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java index cf334f716..8ddad6c1d 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java @@ -107,8 +107,8 @@ public class RtfExtraRowSet extends RtfContainer { public int hashCode() { int hc = super.hashCode(); - hc ^= ( hc * 11 ) + xOffset; - hc ^= ( hc * 19 ) + rowIndex; + hc ^= (hc * 11) + xOffset; + hc ^= (hc * 19) + rowIndex; return hc; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphBreak.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphBreak.java index 851deb84b..0d3ebd742 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphBreak.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphBreak.java @@ -46,7 +46,7 @@ public class RtfParagraphBreak extends RtfElement { * @throws IOException for I/O problems */ protected void writeRtfContent() throws IOException { - if (controlWord != null ) { + if (controlWord != null) { writeControlWord(controlWord); } } @@ -57,7 +57,7 @@ public class RtfParagraphBreak extends RtfElement { * @return boolean */ public boolean canHide() { - return this.controlWord.equals ( DEFAULT_PARAGRAPH ); + return this.controlWord.equals (DEFAULT_PARAGRAPH); } /** diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java index 150a46986..ae2ab2b94 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java @@ -195,7 +195,7 @@ implements protected void writeRtfSuffix() throws IOException { // write suffix /sect only if this section is not last section (see bug #51484) List siblings = parent.getChildren(); - if ( ( siblings.indexOf ( this ) + 1 ) < siblings.size() ) { + if ((siblings.indexOf (this) + 1) < siblings.size()) { writeControlWord("sect"); } } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java index 643757b71..2d0444927 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java @@ -63,7 +63,7 @@ public class PercentContext implements PercentBaseContext { // Special handler for TableColumn width specifications, needs to be // relative to the parent! - if ( ( fobj instanceof TableColumn ) && ( fobj.getParent() instanceof FObj ) ) { + if ((fobj instanceof TableColumn) && (fobj.getParent() instanceof FObj)) { fobj = (FObj) fobj.getParent(); } diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index 9492018fc..bf4a46e19 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -501,8 +501,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { /** * {@inheritDoc} */ - protected void drawBorderLine( // CSOK: ParameterNumber - float x1, float y1, float x2, float y2, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { int borderHeight = bm.getHeight(); diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 4a920d18d..fae50e900 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -817,7 +817,7 @@ public class XMLRenderer extends AbstractXMLRenderer { protected void renderWord(WordArea word) { atts.clear(); int offset = word.getBlockProgressionOffset(); - if ( offset != 0 ) { + if (offset != 0) { addAttribute("offset", offset); } int[] letterAdjust = word.getLetterAdjustArray(); @@ -852,7 +852,7 @@ public class XMLRenderer extends AbstractXMLRenderer { protected void renderSpace(SpaceArea space) { atts.clear(); int offset = space.getBlockProgressionOffset(); - if ( offset != 0 ) { + if (offset != 0) { addAttribute("offset", offset); } maybeAddLevelAttribute(space); @@ -914,22 +914,22 @@ public class XMLRenderer extends AbstractXMLRenderer { return XML_MIME_TYPE; } - private void maybeAddLevelAttribute ( Area a ) { + private void maybeAddLevelAttribute (Area a) { int level = a.getBidiLevel(); - if ( level >= 0 ) { - addAttribute ( "level", level ); + if (level >= 0) { + addAttribute ("level", level); } } - private void maybeAddPositionAdjustAttribute ( WordArea w ) { + private void maybeAddPositionAdjustAttribute (WordArea w) { int[][] adjustments = w.getGlyphPositionAdjustments(); - if ( adjustments != null ) { - addAttribute ( "position-adjust", XMLUtil.encodePositionAdjustments ( adjustments ) ); + if (adjustments != null) { + addAttribute ("position-adjust", XMLUtil.encodePositionAdjustments (adjustments)); } } - private void maybeAddReversedAttribute ( WordArea w, String text ) { - if ( w.isReversed() && ( text.length() > 1 ) ) { + private void maybeAddReversedAttribute (WordArea w, String text) { + if (w.isReversed() && (text.length() > 1)) { addAttribute("reversed", "true"); } } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java index d413e3274..0c0335a8b 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java @@ -55,7 +55,7 @@ public class PDFDocumentGraphics2DConfigurator { * @throws ConfigurationException if an error occurs while configuring the object */ public void configure(PDFDocumentGraphics2D graphics, Configuration cfg, - boolean useComplexScriptFeatures ) + boolean useComplexScriptFeatures) throws ConfigurationException { PDFDocument pdfDoc = graphics.getPDFDocument(); try { diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index e914df0f6..5d82ade23 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -1135,8 +1135,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand val = line[x]; mask[maskIdx++] = (byte)(val >>> 24); rgb[rgbIdx++] = (byte)((val >> 16) & 0x0FF); - rgb[rgbIdx++] = (byte)((val >> 8 ) & 0x0FF); - rgb[rgbIdx++] = (byte)((val ) & 0x0FF); + rgb[rgbIdx++] = (byte)((val >> 8) & 0x0FF); + rgb[rgbIdx++] = (byte)(val & 0x0FF); } } } else { @@ -1146,8 +1146,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand for (x = 0; x < devW; x++) { val = line[x]; rgb[rgbIdx++] = (byte)((val >> 16) & 0x0FF); - rgb[rgbIdx++] = (byte)((val >> 8 ) & 0x0FF); - rgb[rgbIdx++] = (byte)((val ) & 0x0FF); + rgb[rgbIdx++] = (byte)((val >> 8) & 0x0FF); + rgb[rgbIdx++] = (byte)(val & 0x0FF); } } } diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java index 5e6c5141e..4a34ce46d 100644 --- a/src/java/org/apache/fop/tools/anttasks/Fop.java +++ b/src/java/org/apache/fop/tools/anttasks/Fop.java @@ -527,11 +527,11 @@ class FOPTaskStarter { // OR output file doesn't exist OR // output file is older than input file if (task.getForce() || !outf.exists() - || (task.getFofile().lastModified() > outf.lastModified() )) { + || (task.getFofile().lastModified() > outf.lastModified())) { render(task.getFofile(), outf, outputFormat); actioncount++; } else if (outf.exists() - && (task.getFofile().lastModified() <= outf.lastModified() )) { + && (task.getFofile().lastModified() <= outf.lastModified())) { skippedcount++; } } @@ -609,14 +609,14 @@ class FOPTaskStarter { // OR output file doesn't exist OR // output file is older than input file if (task.getForce() || !outf.exists() - || (f.lastModified() > outf.lastModified() )) { + || (f.lastModified() > outf.lastModified())) { if (xsltFile != null) { render(f, xsltFile, outf, outputFormat); } else { render(f, outf, outputFormat); } actioncount++; - } else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) { + } else if (outf.exists() && (f.lastModified() <= outf.lastModified())) { skippedcount++; } } diff --git a/src/java/org/apache/fop/traits/Direction.java b/src/java/org/apache/fop/traits/Direction.java index 5eb36058e..378c8dd2a 100644 --- a/src/java/org/apache/fop/traits/Direction.java +++ b/src/java/org/apache/fop/traits/Direction.java @@ -57,7 +57,7 @@ public final class Direction extends TraitEnum { * @return true if vertical */ public boolean isVertical() { - return ( getEnumValue() == Constants.EN_TB ) || ( getEnumValue() == Constants.EN_BT ); + return (getEnumValue() == Constants.EN_TB) || (getEnumValue() == Constants.EN_BT); } /** @@ -65,7 +65,7 @@ public final class Direction extends TraitEnum { * @return true if horizontal */ public boolean isHorizontal() { - return ( getEnumValue() == Constants.EN_LR ) || ( getEnumValue() == Constants.EN_RL ); + return (getEnumValue() == Constants.EN_LR) || (getEnumValue() == Constants.EN_RL); } /** diff --git a/src/java/org/apache/fop/traits/WritingMode.java b/src/java/org/apache/fop/traits/WritingMode.java index 2d87a4715..8241dcedf 100644 --- a/src/java/org/apache/fop/traits/WritingMode.java +++ b/src/java/org/apache/fop/traits/WritingMode.java @@ -55,13 +55,13 @@ public final class WritingMode extends TraitEnum { * writing mode traits setter. * @param wms a writing mode traits setter */ - public void assignWritingModeTraits ( WritingModeTraitsSetter wms ) { + public void assignWritingModeTraits (WritingModeTraitsSetter wms) { Direction inlineProgressionDirection; Direction blockProgressionDirection; Direction columnProgressionDirection; Direction rowProgressionDirection; Direction shiftDirection; - switch ( getEnumValue() ) { + switch (getEnumValue()) { case Constants.EN_RL_TB: inlineProgressionDirection = Direction.RL; blockProgressionDirection = Direction.TB; @@ -92,12 +92,12 @@ public final class WritingMode extends TraitEnum { shiftDirection = Direction.BT; break; } - wms.setInlineProgressionDirection ( inlineProgressionDirection ); - wms.setBlockProgressionDirection ( blockProgressionDirection ); - wms.setColumnProgressionDirection ( columnProgressionDirection ); - wms.setRowProgressionDirection ( rowProgressionDirection ); - wms.setShiftDirection ( shiftDirection ); - wms.setWritingMode ( this ); + wms.setInlineProgressionDirection (inlineProgressionDirection); + wms.setBlockProgressionDirection (blockProgressionDirection); + wms.setColumnProgressionDirection (columnProgressionDirection); + wms.setRowProgressionDirection (rowProgressionDirection); + wms.setShiftDirection (shiftDirection); + wms.setWritingMode (this); } /** @@ -105,7 +105,7 @@ public final class WritingMode extends TraitEnum { * @return true if horizontal */ public boolean isHorizontal() { - switch ( getEnumValue() ) { + switch (getEnumValue()) { case Constants.EN_LR_TB: case Constants.EN_RL_TB: return true; diff --git a/src/java/org/apache/fop/traits/WritingModeTraits.java b/src/java/org/apache/fop/traits/WritingModeTraits.java index c96cd73c3..0a2d303c1 100644 --- a/src/java/org/apache/fop/traits/WritingModeTraits.java +++ b/src/java/org/apache/fop/traits/WritingModeTraits.java @@ -36,15 +36,15 @@ public class WritingModeTraits implements WritingModeTraitsSetter { * Default writing mode traits constructor. */ public WritingModeTraits() { - this ( WritingMode.LR_TB ); + this (WritingMode.LR_TB); } /** * Construct writing mode traits using the specified writing mode. * @param writingMode a writing mode traits object */ - public WritingModeTraits ( WritingMode writingMode ) { - assignWritingModeTraits ( writingMode ); + public WritingModeTraits (WritingMode writingMode) { + assignWritingModeTraits (writingMode); } /** @@ -57,7 +57,7 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param direction the "inline-progression-direction" trait. */ - public void setInlineProgressionDirection ( Direction direction ) { + public void setInlineProgressionDirection (Direction direction) { this.inlineProgressionDirection = direction; } @@ -71,7 +71,7 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param direction the "block-progression-direction" trait. */ - public void setBlockProgressionDirection ( Direction direction ) { + public void setBlockProgressionDirection (Direction direction) { this.blockProgressionDirection = direction; } @@ -85,7 +85,7 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param direction the "column-progression-direction" trait. */ - public void setColumnProgressionDirection ( Direction direction ) { + public void setColumnProgressionDirection (Direction direction) { this.columnProgressionDirection = direction; } @@ -99,7 +99,7 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param direction the "row-progression-direction" trait. */ - public void setRowProgressionDirection ( Direction direction ) { + public void setRowProgressionDirection (Direction direction) { this.rowProgressionDirection = direction; } @@ -113,7 +113,7 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param direction the "shift-direction" trait. */ - public void setShiftDirection ( Direction direction ) { + public void setShiftDirection (Direction direction) { this.shiftDirection = direction; } @@ -127,15 +127,15 @@ public class WritingModeTraits implements WritingModeTraitsSetter { /** * @param writingMode the "writing-mode" trait. */ - public void setWritingMode ( WritingMode writingMode ) { + public void setWritingMode (WritingMode writingMode) { this.writingMode = writingMode; } /** * @param writingMode the "writing-mode" trait. */ - public void assignWritingModeTraits ( WritingMode writingMode ) { - writingMode.assignWritingModeTraits ( this ); + public void assignWritingModeTraits (WritingMode writingMode) { + writingMode.assignWritingModeTraits (this); } /** @@ -145,9 +145,9 @@ public class WritingModeTraits implements WritingModeTraitsSetter { * @return the applicable writing mode traits getter, or null if none applies */ public static WritingModeTraitsGetter - getWritingModeTraitsGetter ( org.apache.fop.fo.FONode fn ) { - for ( org.apache.fop.fo.FONode n = fn; n != null; n = n.getParent() ) { - if ( n instanceof WritingModeTraitsGetter ) { + getWritingModeTraitsGetter (org.apache.fop.fo.FONode fn) { + for (org.apache.fop.fo.FONode n = fn; n != null; n = n.getParent()) { + if (n instanceof WritingModeTraitsGetter) { return (WritingModeTraitsGetter) n; } } diff --git a/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java b/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java index 1b94e22de..b5c862cd4 100644 --- a/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java +++ b/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java @@ -28,43 +28,43 @@ public interface WritingModeTraitsSetter extends WritingModeTraitsGetter { * Set value of inline-progression-direction trait. * @param direction the "inline-progression-direction" trait */ - void setInlineProgressionDirection ( Direction direction ); + void setInlineProgressionDirection (Direction direction); /** * Set value of block-progression-direction trait. * @param direction the "block-progression-direction" trait */ - void setBlockProgressionDirection ( Direction direction ); + void setBlockProgressionDirection (Direction direction); /** * Set value of column-progression-direction trait. * @param direction the "column-progression-direction" trait */ - void setColumnProgressionDirection ( Direction direction ); + void setColumnProgressionDirection (Direction direction); /** * Set value of row-progression-direction trait. * @param direction the "row-progression-direction" trait */ - void setRowProgressionDirection ( Direction direction ); + void setRowProgressionDirection (Direction direction); /** * Set value of shift-direction trait. * @param direction the "shift-direction" trait */ - void setShiftDirection ( Direction direction ); + void setShiftDirection (Direction direction); /** * Set value of writing-mode trait. * @param writingMode the "writing-mode" trait */ - void setWritingMode ( WritingMode writingMode ); + void setWritingMode (WritingMode writingMode); /** * Collectivelly assign values to all writing mode traits based upon a specific * writing mode. * @param writingMode the "writing-mode" trait */ - void assignWritingModeTraits ( WritingMode writingMode ); + void assignWritingModeTraits (WritingMode writingMode); } diff --git a/src/java/org/apache/fop/util/CharUtilities.java b/src/java/org/apache/fop/util/CharUtilities.java index 04390d938..d5f0c9a21 100644 --- a/src/java/org/apache/fop/util/CharUtilities.java +++ b/src/java/org/apache/fop/util/CharUtilities.java @@ -118,7 +118,7 @@ public class CharUtilities { * @param c character to inspect * @return the determined character class */ - public static int classOf ( int c ) { + public static int classOf (int c) { switch (c) { case CODE_EOT: return EOT; @@ -141,7 +141,7 @@ public class CharUtilities { * @param c character to inspect * @return True if the character is a normal space */ - public static boolean isBreakableSpace ( int c ) { + public static boolean isBreakableSpace (int c) { return (c == SPACE || isFixedWidthSpace(c)); } @@ -150,7 +150,7 @@ public class CharUtilities { * @param c the character to check * @return true if the character is a zero-width space */ - public static boolean isZeroWidthSpace ( int c ) { + public static boolean isZeroWidthSpace (int c) { return c == ZERO_WIDTH_SPACE // 200Bh || c == WORD_JOINER // 2060h || c == ZERO_WIDTH_NOBREAK_SPACE; // FEFFh (also used as BOM) @@ -161,7 +161,7 @@ public class CharUtilities { * @param c the character to check * @return true if the character has a fixed-width */ - public static boolean isFixedWidthSpace ( int c ) { + public static boolean isFixedWidthSpace (int c) { return (c >= '\u2000' && c <= '\u200B') || c == '\u3000'; // c == '\u2000' // en quad @@ -185,7 +185,7 @@ public class CharUtilities { * @param c character to check * @return True if the character is a nbsp */ - public static boolean isNonBreakableSpace ( int c ) { + public static boolean isNonBreakableSpace (int c) { return (c == NBSPACE // no-break space || c == '\u202F' // narrow no-break space @@ -200,7 +200,7 @@ public class CharUtilities { * @param c character to check * @return True if the character is adjustable */ - public static boolean isAdjustableSpace ( int c ) { + public static boolean isAdjustableSpace (int c) { //TODO: are there other kinds of adjustable spaces? return (c == '\u0020' // normal space @@ -212,7 +212,7 @@ public class CharUtilities { * @param c character to check * @return True if the character represents any kind of space */ - public static boolean isAnySpace ( int c ) { + public static boolean isAnySpace (int c) { return (isBreakableSpace(c) || isNonBreakableSpace(c)); } @@ -221,7 +221,7 @@ public class CharUtilities { * @param c the character * @return true if the character is "Alphabetic" */ - public static boolean isAlphabetic ( int c ) { + public static boolean isAlphabetic (int c) { //http://www.unicode.org/Public/UNIDATA/UCD.html#Alphabetic //Generated from: Other_Alphabetic + Lu + Ll + Lt + Lm + Lo + Nl int generalCategory = Character.getType((char)c); @@ -245,7 +245,7 @@ public class CharUtilities { * @param c the character to check * @return true if the character represents an explicit break */ - public static boolean isExplicitBreak ( int c ) { + public static boolean isExplicitBreak (int c) { return (c == LINEFEED_CHAR || c == CARRIAGE_RETURN || c == NEXT_LINE @@ -259,17 +259,17 @@ public class CharUtilities { * @param c a unicode scalar value * @return a string representing a numeric character reference */ - public static String charToNCRef ( int c ) { + public static String charToNCRef (int c) { StringBuffer sb = new StringBuffer(); - for ( int i = 0, nDigits = ( c > 0xFFFF ) ? 6 : 4; i < nDigits; i++, c >>= 4 ) { + for (int i = 0, nDigits = (c > 0xFFFF) ? 6 : 4; i < nDigits; i++, c >>= 4) { int d = c & 0xF; char hd; - if ( d < 10 ) { - hd = (char) ( (int) '0' + d ); + if (d < 10) { + hd = (char) ((int) '0' + d); } else { - hd = (char) ( (int) 'A' + ( d - 10 ) ); + hd = (char) ((int) 'A' + (d - 10)); } - sb.append ( hd ); + sb.append (hd); } return "&#x" + sb.reverse() + ";"; } @@ -280,23 +280,23 @@ public class CharUtilities { * @return a string representing a sequence of numeric character reference or * ASCII characters */ - public static String toNCRefs ( String s ) { + public static String toNCRefs (String s) { StringBuffer sb = new StringBuffer(); - if ( s != null ) { - for ( int i = 0; i < s.length(); i++ ) { + if (s != null) { + for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if ( ( c >= 32 ) && ( c < 127 ) ) { - if ( c == '<' ) { - sb.append ( "<" ); - } else if ( c == '>' ) { - sb.append ( ">" ); - } else if ( c == '&' ) { - sb.append ( "&" ); + if ((c >= 32) && (c < 127)) { + if (c == '<') { + sb.append ("<"); + } else if (c == '>') { + sb.append (">"); + } else if (c == '&') { + sb.append ("&"); } else { - sb.append ( c ); + sb.append (c); } } else { - sb.append ( charToNCRef ( c ) ); + sb.append (charToNCRef (c)); } } } @@ -310,12 +310,12 @@ public class CharUtilities { * @param pad character to use for padding * @return padded string */ - public static String padLeft ( String s, int width, char pad ) { + public static String padLeft (String s, int width, char pad) { StringBuffer sb = new StringBuffer(); - for ( int i = s.length(); i < width; i++ ) { + for (int i = s.length(); i < width; i++) { sb.append(pad); } - sb.append ( s ); + sb.append (s); return sb.toString(); } @@ -325,9 +325,9 @@ public class CharUtilities { * @param c character code * @return formatted character string */ - public static String format ( int c ) { - if ( c < 1114112 ) { - return "0x" + padLeft ( Integer.toString ( c, 16 ), ( c < 65536 ) ? 4 : 6, '0' ); + public static String format (int c) { + if (c < 1114112) { + return "0x" + padLeft (Integer.toString (c, 16), (c < 65536) ? 4 : 6, '0'); } else { return "!NOT A CHARACTER!"; } @@ -339,14 +339,14 @@ public class CharUtilities { * @param cs2 second character sequence * @return true if both sequences have same length and same character sequence */ - public static boolean isSameSequence ( CharSequence cs1, CharSequence cs2 ) { + public static boolean isSameSequence (CharSequence cs1, CharSequence cs2) { assert cs1 != null; assert cs2 != null; - if ( cs1.length() != cs2.length() ) { + if (cs1.length() != cs2.length()) { return false; } else { - for ( int i = 0, n = cs1.length(); i < n; i++ ) { - if ( cs1.charAt(i) != cs2.charAt(i) ) { + for (int i = 0, n = cs1.length(); i < n; i++) { + if (cs1.charAt(i) != cs2.charAt(i)) { return false; } } diff --git a/src/java/org/apache/fop/util/ColorExt.java b/src/java/org/apache/fop/util/ColorExt.java index f92e7c2a6..a910a54dd 100644 --- a/src/java/org/apache/fop/util/ColorExt.java +++ b/src/java/org/apache/fop/util/ColorExt.java @@ -120,8 +120,7 @@ public final class ColorExt extends Color { * ICC color values * @return the requested color object */ - public static ColorExt createFromSvgIccColor( // CSOK: ParameterNumber - float red, float green, + public static ColorExt createFromSvgIccColor(float red, float green, float blue, float opacity, String profileName, String profileHref, ColorSpace profileCS, float[] colorValues) { //TODO this method is not referenced by FOP, can it be deleted? diff --git a/src/java/org/apache/fop/util/XMLUtil.java b/src/java/org/apache/fop/util/XMLUtil.java index 87bf6c6d4..ce71b20af 100644 --- a/src/java/org/apache/fop/util/XMLUtil.java +++ b/src/java/org/apache/fop/util/XMLUtil.java @@ -186,19 +186,19 @@ public final class XMLUtil implements XMLConstants { * @param paCount the number of entries to encode from adjustments array * @return the encoded value */ - public static String encodePositionAdjustments ( int[][] dp, int paCount ) { + public static String encodePositionAdjustments (int[][] dp, int paCount) { assert dp != null; StringBuffer sb = new StringBuffer(); int na = paCount; int nz = 0; - sb.append ( na ); - for ( int i = 0; i < na; i++ ) { + sb.append (na); + for (int i = 0; i < na; i++) { int[] pa = dp [ i ]; - if ( pa != null ) { - for ( int k = 0; k < 4; k++ ) { + if (pa != null) { + for (int k = 0; k < 4; k++) { int a = pa [ k ]; - if ( a != 0 ) { - encodeNextAdjustment ( sb, nz, a ); + if (a != 0) { + encodeNextAdjustment (sb, nz, a); nz = 0; } else { nz++; @@ -208,7 +208,7 @@ public final class XMLUtil implements XMLConstants { nz += 4; } } - encodeNextAdjustment ( sb, nz, 0 ); + encodeNextAdjustment (sb, nz, 0); return sb.toString(); } @@ -223,32 +223,32 @@ public final class XMLUtil implements XMLConstants { * @param dp the adjustments array * @return the encoded value */ - public static String encodePositionAdjustments ( int[][] dp ) { + public static String encodePositionAdjustments (int[][] dp) { assert dp != null; - return encodePositionAdjustments ( dp, dp.length ); + return encodePositionAdjustments (dp, dp.length); } - private static void encodeNextAdjustment ( StringBuffer sb, int nz, int a ) { - encodeZeroes ( sb, nz ); - encodeAdjustment ( sb, a ); + private static void encodeNextAdjustment (StringBuffer sb, int nz, int a) { + encodeZeroes (sb, nz); + encodeAdjustment (sb, a); } - private static void encodeZeroes ( StringBuffer sb, int nz ) { - if ( nz > 0 ) { - sb.append ( ' ' ); - if ( nz == 1 ) { - sb.append ( '0' ); + private static void encodeZeroes (StringBuffer sb, int nz) { + if (nz > 0) { + sb.append (' '); + if (nz == 1) { + sb.append ('0'); } else { - sb.append ( 'Z' ); - sb.append ( nz ); + sb.append ('Z'); + sb.append (nz); } } } - private static void encodeAdjustment ( StringBuffer sb, int a ) { - if ( a != 0 ) { - sb.append ( ' ' ); - sb.append ( a ); + private static void encodeAdjustment (StringBuffer sb, int a) { + if (a != 0) { + sb.append (' '); + sb.append (a); } } @@ -258,21 +258,21 @@ public final class XMLUtil implements XMLConstants { * @param value the encoded value * @return the position adjustments array */ - public static int[][] decodePositionAdjustments ( String value ) { + public static int[][] decodePositionAdjustments (String value) { int[][] dp = null; - if ( value != null ) { - String[] sa = value.split ( "\\s" ); - if ( sa != null ) { - if ( sa.length > 0 ) { - int na = Integer.parseInt ( sa[0] ); + if (value != null) { + String[] sa = value.split ("\\s"); + if (sa != null) { + if (sa.length > 0) { + int na = Integer.parseInt (sa[0]); dp = new int [ na ] [ 4 ]; - for ( int i = 1, n = sa.length, k = 0; i < n; i++ ) { + for (int i = 1, n = sa.length, k = 0; i < n; i++) { String s = sa [ i ]; - if ( s.charAt(0) == 'Z' ) { - int nz = Integer.parseInt ( s.substring ( 1 ) ); + if (s.charAt(0) == 'Z') { + int nz = Integer.parseInt (s.substring (1)); k += nz; } else { - dp [ k / 4 ] [ k % 4 ] = Integer.parseInt ( s ); + dp [ k / 4 ] [ k % 4 ] = Integer.parseInt (s); k += 1; } } diff --git a/src/sandbox/org/apache/fop/render/mif/MIFHandler.java b/src/sandbox/org/apache/fop/render/mif/MIFHandler.java index 008c090e4..157cdbf3f 100644 --- a/src/sandbox/org/apache/fop/render/mif/MIFHandler.java +++ b/src/sandbox/org/apache/fop/render/mif/MIFHandler.java @@ -351,12 +351,12 @@ public class MIFHandler extends FOEventHandler { } public void character(Character c) { - appendCharacters ( new String ( new char[] {c.getCharacter()} ) ); + appendCharacters (new String (new char[] {c.getCharacter()})); } /** {@inheritDoc} */ public void characters(FOText foText) { - appendCharacters ( foText.getCharSequence().toString() ); + appendCharacters (foText.getCharSequence().toString()); } /** {@inheritDoc} */ @@ -367,7 +367,7 @@ public class MIFHandler extends FOEventHandler { public void endPageNumber(PageNumber pagenum) { } - private void appendCharacters ( String str ) { + private void appendCharacters (String str) { if (para != null) { str = str.trim(); // break into nice length chunks diff --git a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java index 451616ad9..65c0224c2 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java +++ b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java @@ -45,7 +45,7 @@ public abstract class AbstractAFPObjectTest { } protected final void setSut(S sut) { - if ( this.sut == null) { + if (this.sut == null) { this.sut = sut; } } diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java index 6593ef1ba..dbc67d4e0 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java @@ -76,54 +76,54 @@ public class BidiAlgorithmTestCase { public void testBidiAlgorithm() throws Exception { String ldPfx = BidiTestData.LD_PFX; int ldCount = BidiTestData.LD_CNT; - for ( int i = 0; i < ldCount; i++ ) { - int[] da = BidiTestData.readTestData ( ldPfx, i ); - if ( da != null ) { - testBidiAlgorithm ( i, da ); + for (int i = 0; i < ldCount; i++) { + int[] da = BidiTestData.readTestData (ldPfx, i); + if (da != null) { + testBidiAlgorithm (i, da); } else { - fail ( "unable to read bidi test data for resource at index " + i ); + fail ("unable to read bidi test data for resource at index " + i); } } // ensure we passed all test sequences - assertEquals ( "did not pass all test sequences", BidiTestData.NUM_TEST_SEQUENCES, passedSequences ); - if ( log.isDebugEnabled() ) { - log.debug ( "Included Sequences : " + includedSequences ); - log.debug ( "Excluded Sequences : " + excludedSequences ); - log.debug( "Passed Sequences : " + passedSequences ); + assertEquals ("did not pass all test sequences", BidiTestData.NUM_TEST_SEQUENCES, passedSequences); + if (log.isDebugEnabled()) { + log.debug ("Included Sequences : " + includedSequences); + log.debug ("Excluded Sequences : " + excludedSequences); + log.debug("Passed Sequences : " + passedSequences); } } - private void testBidiAlgorithm ( int testSet, int[] da ) throws Exception { - if ( da.length < 1 ) { - fail ( "test data is empty" ); - } else if ( da.length < ( ( da[0] * 2 ) + 1 ) ) { - fail ( "test data is truncated" ); + private void testBidiAlgorithm (int testSet, int[] da) throws Exception { + if (da.length < 1) { + fail ("test data is empty"); + } else if (da.length < ((da[0] * 2) + 1)) { + fail ("test data is truncated"); } else { int k = 0; // extract level count int n = da[k++]; // extract level array int[] la = new int [ n ]; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { la[i] = da[k++]; } // extract reorder array int[] ra = new int [ n ]; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { ra[i] = da[k++]; } // extract and test each test sequence int testSequence = 0; int[] ta = new int [ n ]; - while ( ( k + ( 1 + n ) ) <= da.length ) { + while ((k + (1 + n)) <= da.length) { int bs = da[k++]; - for ( int i = 0; i < n; i++ ) { + for (int i = 0; i < n; i++) { ta[i] = da[k++]; } - if ( includeSequence ( testSet, testSequence ) ) { + if (includeSequence (testSet, testSequence)) { includedSequences++; - if ( ! excludeSequence ( testSet, testSequence ) ) { - if ( testBidiAlgorithm ( testSet, testSequence, la, ra, ta, bs ) ) { + if (! excludeSequence (testSet, testSequence)) { + if (testBidiAlgorithm (testSet, testSequence, la, ra, ta, bs)) { passedSequences++; } } else { @@ -133,16 +133,16 @@ public class BidiAlgorithmTestCase { testSequence++; } // ensure we exhausted test data - assertEquals ( "extraneous test data", da.length, k ); + assertEquals ("extraneous test data", da.length, k); } } - private boolean includeTestSet ( int testSet ) { - for ( int i = 0, n = TEST_SET_RANGES.length / 2; i < n; i++ ) { - int s = TEST_SET_RANGES [ ( i * 2 ) + 0 ]; - int e = TEST_SET_RANGES [ ( i * 2 ) + 1 ]; - if ( testSet >= s ) { - if ( ( e < 0 ) || ( testSet <= e ) ) { + private boolean includeTestSet (int testSet) { + for (int i = 0, n = TEST_SET_RANGES.length / 2; i < n; i++) { + int s = TEST_SET_RANGES [ (i * 2) + 0 ]; + int e = TEST_SET_RANGES [ (i * 2) + 1 ]; + if (testSet >= s) { + if ((e < 0) || (testSet <= e)) { return true; } } @@ -150,23 +150,23 @@ public class BidiAlgorithmTestCase { return false; } - private boolean includeSequence ( int testSet, int testSequence ) { - if ( ! includeTestSet ( testSet ) ) { + private boolean includeSequence (int testSet, int testSequence) { + if (! includeTestSet (testSet)) { return false; } else { - for ( int i = 0, n = INCLUSIONS.length / 2; i < n; i++ ) { - int setno = INCLUSIONS [ ( i * 2 ) + 0 ]; - int seqno = INCLUSIONS [ ( i * 2 ) + 1 ]; - if ( setno < 0 ) { - if ( seqno < 0 ) { + for (int i = 0, n = INCLUSIONS.length / 2; i < n; i++) { + int setno = INCLUSIONS [ (i * 2) + 0 ]; + int seqno = INCLUSIONS [ (i * 2) + 1 ]; + if (setno < 0) { + if (seqno < 0) { return true; - } else if ( seqno == testSequence ) { + } else if (seqno == testSequence) { return true; } - } else if ( setno == testSet ) { - if ( seqno < 0 ) { + } else if (setno == testSet) { + if (seqno < 0) { return true; - } else if ( seqno == testSequence ) { + } else if (seqno == testSequence) { return true; } } @@ -175,20 +175,20 @@ public class BidiAlgorithmTestCase { } } - private boolean excludeSequence ( int testSet, int testSequence ) { - for ( int i = 0, n = EXCLUSIONS.length / 2; i < n; i++ ) { - int setno = EXCLUSIONS [ ( i * 2 ) + 0 ]; - int seqno = EXCLUSIONS [ ( i * 2 ) + 1 ]; - if ( setno < 0 ) { - if ( seqno < 0 ) { + private boolean excludeSequence (int testSet, int testSequence) { + for (int i = 0, n = EXCLUSIONS.length / 2; i < n; i++) { + int setno = EXCLUSIONS [ (i * 2) + 0 ]; + int seqno = EXCLUSIONS [ (i * 2) + 1 ]; + if (setno < 0) { + if (seqno < 0) { return true; - } else if ( seqno == testSequence ) { + } else if (seqno == testSequence) { return true; } - } else if ( setno == testSet ) { - if ( seqno < 0 ) { + } else if (setno == testSet) { + if (seqno < 0) { return true; - } else if ( seqno == testSequence ) { + } else if (seqno == testSequence) { return true; } } @@ -196,29 +196,29 @@ public class BidiAlgorithmTestCase { return false; } - private boolean testBidiAlgorithm ( int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs ) throws Exception { + private boolean testBidiAlgorithm (int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs) throws Exception { boolean passed = true; int n = la.length; - if ( ra.length != n ) { - fail ( "bad reorder array length, expected " + n + ", got " + ra.length ); - } else if ( ta.length != n ) { - fail ( "bad test array length, expected " + n + ", got " + ta.length ); + if (ra.length != n) { + fail ("bad reorder array length, expected " + n + ", got " + ra.length); + } else if (ta.length != n) { + fail ("bad test array length, expected " + n + ", got " + ta.length); } else { // auto-LTR - if ( ( bs & 1 ) != 0 ) { + if ((bs & 1) != 0) { // auto-LTR is performed at higher level } // LTR - if ( ( bs & 2 ) != 0 ) { - int[] levels = UnicodeBidiAlgorithm.resolveLevels ( null, ta, 0, new int [ n ], true ); - if ( ! verifyResults ( la, levels, ta, 0, testSet, testSequence ) ) { + if ((bs & 2) != 0) { + int[] levels = UnicodeBidiAlgorithm.resolveLevels (null, ta, 0, new int [ n ], true); + if (! verifyResults (la, levels, ta, 0, testSet, testSequence)) { passed = false; } } // RTL - if ( ( bs & 4 ) != 0 ) { - int[] levels = UnicodeBidiAlgorithm.resolveLevels ( null, ta, 1, new int [ n ], true ); - if ( ! verifyResults ( la, levels, ta, 1, testSet, testSequence ) ) { + if ((bs & 4) != 0) { + int[] levels = UnicodeBidiAlgorithm.resolveLevels (null, ta, 1, new int [ n ], true); + if (! verifyResults (la, levels, ta, 1, testSet, testSequence)) { passed = false; } } @@ -226,18 +226,18 @@ public class BidiAlgorithmTestCase { return passed; } - private boolean verifyResults ( int[] laExp, int[] laOut, int[] ta, int dl, int testSet, int testSequence ) { - if ( laOut.length != laExp.length ) { - fail ( "output levels array length mismatch, expected " + laExp.length + ", got " + laOut.length ); + private boolean verifyResults (int[] laExp, int[] laOut, int[] ta, int dl, int testSet, int testSequence) { + if (laOut.length != laExp.length) { + fail ("output levels array length mismatch, expected " + laExp.length + ", got " + laOut.length); return false; } else { int numMatch = 0; - for ( int i = 0, n = laExp.length; i < n; i++ ) { - if ( laExp[i] >= 0 ) { + for (int i = 0, n = laExp.length; i < n; i++) { + if (laExp[i] >= 0) { int lo = laOut[i]; int le = laExp[i]; - if ( lo != le ) { - assertEquals ( getMismatchMessage ( testSet, testSequence, i, dl ), le, lo ); + if (lo != le) { + assertEquals (getMismatchMessage (testSet, testSequence, i, dl), le, lo); } else { numMatch++; } @@ -249,16 +249,16 @@ public class BidiAlgorithmTestCase { } } - private String getMismatchMessage ( int testSet, int testSequence, int seqIndex, int defaultLevel ) { + private String getMismatchMessage (int testSet, int testSequence, int seqIndex, int defaultLevel) { StringBuffer sb = new StringBuffer(); - sb.append ( "level mismatch for default level " ); - sb.append ( defaultLevel ); - sb.append ( " at sequence index " ); - sb.append ( seqIndex ); - sb.append ( " in test sequence " ); - sb.append ( testSequence ); - sb.append ( " of test set " ); - sb.append ( testSet ); + sb.append ("level mismatch for default level "); + sb.append (defaultLevel); + sb.append (" at sequence index "); + sb.append (seqIndex); + sb.append (" in test sequence "); + sb.append (testSequence); + sb.append (" of test set "); + sb.append (testSet); return sb.toString(); } diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java index 0ea9017bc..f3ce4c5d5 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java @@ -33,24 +33,24 @@ public class BidiClassTestCase { public void testBidiClasses() throws Exception { String tdPfx = BidiTestData.TD_PFX; int tdCount = BidiTestData.TD_CNT; - for ( int i = 0; i < tdCount; i++ ) { - int[] da = BidiTestData.readTestData ( tdPfx, i ); - if ( da != null ) { - testBidiClass ( da ); + for (int i = 0; i < tdCount; i++) { + int[] da = BidiTestData.readTestData (tdPfx, i); + if (da != null) { + testBidiClass (da); } else { - fail ( "unable to read bidi test data for resource at index " + i ); + fail ("unable to read bidi test data for resource at index " + i); } } } - private void testBidiClass ( int[] da ) throws Exception { + private void testBidiClass (int[] da) throws Exception { int bc = da[0]; - for ( int i = 1, n = da.length; i < n; i += 2 ) { + for (int i = 1, n = da.length; i < n; i += 2) { int s = da[i+0]; int e = da[i+1]; - for ( int c = s; c < e; c++ ) { - int cbc = BidiClass.getBidiClass ( c ); - assertEquals ( "bad bidi class for CH(" + CharUtilities.format ( c ) + ")", bc, cbc ); + for (int c = s; c < e; c++) { + int cbc = BidiClass.getBidiClass (c); + assertEquals ("bad bidi class for CH(" + CharUtilities.format (c) + ")", bc, cbc); } } } diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java index 273240a27..0489505ea 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java @@ -49,24 +49,24 @@ public final class BidiTestData { public static final int NUM_TEST_SEQUENCES = 216357; - public static int[] readTestData ( String prefix, int index ) { + public static int[] readTestData (String prefix, int index) { int[] data = null; InputStream is = null; Class btc = BidiTestData.class; String name = btc.getSimpleName() + "$" + prefix + index + ".ser"; try { - if ( ( is = btc.getResourceAsStream ( name ) ) != null ) { - ObjectInputStream ois = new ObjectInputStream ( is ); + if ((is = btc.getResourceAsStream (name)) != null) { + ObjectInputStream ois = new ObjectInputStream (is); data = (int[]) ois.readObject(); ois.close(); } - } catch ( IOException e ) { + } catch (IOException e) { data = null; - } catch ( ClassNotFoundException e ) { + } catch (ClassNotFoundException e) { data = null; } finally { - if ( is != null ) { - try { is.close(); } catch ( Exception e ) {} + if (is != null) { + try { is.close(); } catch (Exception e) {} } } return data; diff --git a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java index 3b7263795..79895d3ad 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java @@ -3056,33 +3056,33 @@ public class GDEFTestCase { @Test public void testGDEFGlyphClass() throws Exception { - performLookups ( ltGlyphClass ); + performLookups (ltGlyphClass); } @Test public void testGDEFAttachmentPoint() throws Exception { - performLookups ( ltAttachmentPoint ); + performLookups (ltAttachmentPoint); } @Test public void testGDEFLigatureCaret() throws Exception { - performLookups ( ltLigatureCaret ); + performLookups (ltLigatureCaret); } @Test public void testGDEFMarkAttachment() throws Exception { - performLookups ( ltMarkAttachment ); + performLookups (ltMarkAttachment); } /** * Perform lookups on all test data in test specification TS. * @param ts test specification */ - private void performLookups ( Object[][] ts ) { + private void performLookups (Object[][] ts) { assert ts.length > 0; Object[] tp = ts[0]; - for ( int i = 1; i < ts.length; i++ ) { - performLookups ( tp, ts[i] ); + for (int i = 1; i < ts.length; i++) { + performLookups (tp, ts[i]); } } @@ -3091,70 +3091,70 @@ public class GDEFTestCase { * @param tp test parameters * @param td test data */ - private void performLookups ( Object[] tp, Object[] td ) { + private void performLookups (Object[] tp, Object[] td) { assert tp.length > 0; - if ( td.length > 1 ) { + if (td.length > 1) { String fid = (String) td[0]; String lid = (String) td[1]; - TTXFile tf = findTTX ( fid ); - assertTrue ( tf != null ); + TTXFile tf = findTTX (fid); + assertTrue (tf != null); GlyphDefinitionTable gdef = tf.getGDEF(); - assertTrue ( gdef != null ); + assertTrue (gdef != null); String[][] tia = (String[][]) td[2]; - switch ( (int) ( (Integer) tp[0] ) ) { + switch ((int) ((Integer) tp[0])) { case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS: - performGlyphClassLookups ( tf, lid, tia ); + performGlyphClassLookups (tf, lid, tia); break; case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_ATTACHMENT_POINT: - performAttachmentPointLookups ( tf, lid, tia ); + performAttachmentPointLookups (tf, lid, tia); break; case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_LIGATURE_CARET: - performLigatureCaretLookups ( tf, lid, tia ); + performLigatureCaretLookups (tf, lid, tia); break; case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT: - performMarkAttachmentLookups ( tf, lid, tia ); + performMarkAttachmentLookups (tf, lid, tia); break; default: - assertTrue ( "bad lookup type", false ); + assertTrue ("bad lookup type", false); break; } } } - private void performGlyphClassLookups ( TTXFile tf, String lid, String[][] tia ) { + private void performGlyphClassLookups (TTXFile tf, String lid, String[][] tia) { GlyphDefinitionTable gdef = tf.getGDEF(); assert gdef != null; - for ( String[] ti : tia ) { + for (String[] ti : tia) { assert ti != null; assert ti.length > 1; String gn = ti[0]; assert gn != null; String cn = ti[1]; assert cn != null; - int g = tf.getGlyph ( gn ); - assertTrue ( g >= 0 ); - int oc = Integer.parseInt ( cn ); - int tc = gdef.getGlyphClass ( g ); - assertEquals ( "bad glyph class for glyph \'" + gn + "\', gid(" + g + ")", oc, tc ); + int g = tf.getGlyph (gn); + assertTrue (g >= 0); + int oc = Integer.parseInt (cn); + int tc = gdef.getGlyphClass (g); + assertEquals ("bad glyph class for glyph \'" + gn + "\', gid(" + g + ")", oc, tc); } } - private void performAttachmentPointLookups ( TTXFile tf, String lid, String[][] tia ) { + private void performAttachmentPointLookups (TTXFile tf, String lid, String[][] tia) { // not yet supported by GDEF or test TTX files } - private void performLigatureCaretLookups ( TTXFile tf, String lid, String[][] tia ) { + private void performLigatureCaretLookups (TTXFile tf, String lid, String[][] tia) { // not yet supported by GDEF or test TTX files } - private void performMarkAttachmentLookups ( TTXFile tf, String lid, String[][] tia ) { + private void performMarkAttachmentLookups (TTXFile tf, String lid, String[][] tia) { // not yet supported by GDEF or test TTX files } - private String findTTXPath ( String fid ) { - for ( String[] fs : ttxFonts ) { - if ( ( fs != null ) && ( fs.length > 1 ) ) { - if ( fs[0].equals ( fid ) ) { + private String findTTXPath (String fid) { + for (String[] fs : ttxFonts) { + if ((fs != null) && (fs.length > 1)) { + if (fs[0].equals (fid)) { return ttxFilesRoot + File.separator + fs[1]; } } @@ -3162,14 +3162,14 @@ public class GDEFTestCase { return null; } - private TTXFile findTTX ( String fid ) { - String pn = findTTXPath ( fid ); - assertTrue ( pn != null ); + private TTXFile findTTX (String fid) { + String pn = findTTXPath (fid); + assertTrue (pn != null); try { - TTXFile tf = TTXFile.getFromCache ( pn ); + TTXFile tf = TTXFile.getFromCache (pn); return tf; - } catch ( Exception e ) { - fail ( e.getMessage() ); + } catch (Exception e) { + fail (e.getMessage()); return null; } } diff --git a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java index a2a37e627..a6fc52ebc 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java @@ -319,53 +319,53 @@ public class GPOSTestCase implements ScriptContextTester, GlyphContextTester { @Test public void testGPOSSingle() throws Exception { - performPositioning ( ltSingle ); + performPositioning (ltSingle); } @Test public void testGPOSPair() throws Exception { - performPositioning ( ltPair ); + performPositioning (ltPair); } @Test public void testGPOSCursive() throws Exception { - performPositioning ( ltCursive ); + performPositioning (ltCursive); } @Test public void testGPOSMarkToBase() throws Exception { - performPositioning ( ltMarkToBase ); + performPositioning (ltMarkToBase); } @Test public void testGPOSMarkToLigature() throws Exception { - performPositioning ( ltMarkToLigature ); + performPositioning (ltMarkToLigature); } @Test public void testGPOSMarkToMark() throws Exception { - performPositioning ( ltMarkToMark ); + performPositioning (ltMarkToMark); } @Test public void testGPOSContextual() throws Exception { - performPositioning ( ltContextual ); + performPositioning (ltContextual); } @Test public void testGPOSChainedContextual() throws Exception { - performPositioning ( ltChainedContextual ); + performPositioning (ltChainedContextual); } /** * Perform positioning on all test data in test specification TS. * @param ts test specification */ - private void performPositioning ( Object[][] ts ) { + private void performPositioning (Object[][] ts) { assert ts.length > 0; Object[] tp = ts[0]; - for ( int i = 1; i < ts.length; i++ ) { - performPositioning ( tp, ts[i] ); + for (int i = 1; i < ts.length; i++) { + performPositioning (tp, ts[i]); } } @@ -374,44 +374,44 @@ public class GPOSTestCase implements ScriptContextTester, GlyphContextTester { * @param tp test parameters * @param td test data */ - private void performPositioning ( Object[] tp, Object[] td ) { + private void performPositioning (Object[] tp, Object[] td) { assert tp.length > 0; - if ( td.length > 5 ) { + if (td.length > 5) { String fid = (String) td[0]; String lid = (String) td[1]; String script = (String) td[2]; String language = (String) td[3]; String feature = (String) td[4]; - TTXFile tf = findTTX ( fid ); - assertTrue ( tf != null ); + TTXFile tf = findTTX (fid); + assertTrue (tf != null); GlyphPositioningTable gpos = tf.getGPOS(); - assertTrue ( gpos != null ); - GlyphPositioningSubtable[] sta = findGPOSSubtables ( gpos, script, language, feature, lid ); - assertTrue ( sta != null ); - assertTrue ( sta.length > 0 ); - ScriptContextTester sct = findScriptContextTester ( script, language, feature ); + assertTrue (gpos != null); + GlyphPositioningSubtable[] sta = findGPOSSubtables (gpos, script, language, feature, lid); + assertTrue (sta != null); + assertTrue (sta.length > 0); + ScriptContextTester sct = findScriptContextTester (script, language, feature); Object[][] tia = (Object[][]) td[5]; // test instance array - for ( Object[] ti : tia ) { // test instance - if ( ti != null ) { - if ( ti.length > 0 ) { // must have at least input glyphs + for (Object[] ti : tia) { // test instance + if (ti != null) { + if (ti.length > 0) { // must have at least input glyphs String[] igia = (String[]) ti[0]; // input glyph id array int[][] ogpa = (int[][]) ti[1]; // output glyph positioning array - GlyphSequence igs = tf.getGlyphSequence ( igia ); + GlyphSequence igs = tf.getGlyphSequence (igia); int[] widths = tf.getWidths(); int[][] tgpa = new int [ igia.length ] [ 4 ]; - boolean adjusted = GlyphPositioningSubtable.position ( igs, script, language, feature, 1000, sta, widths, tgpa, sct ); - assertTrue ( adjusted ); - assertSamePositions ( ogpa, tgpa ); + boolean adjusted = GlyphPositioningSubtable.position (igs, script, language, feature, 1000, sta, widths, tgpa, sct); + assertTrue (adjusted); + assertSamePositions (ogpa, tgpa); } } } } } - private String findTTXPath ( String fid ) { - for ( String[] fs : ttxFonts ) { - if ( ( fs != null ) && ( fs.length > 1 ) ) { - if ( fs[0].equals ( fid ) ) { + private String findTTXPath (String fid) { + for (String[] fs : ttxFonts) { + if ((fs != null) && (fs.length > 1)) { + if (fs[0].equals (fid)) { return ttxFilesRoot + File.separator + fs[1]; } } @@ -419,54 +419,54 @@ public class GPOSTestCase implements ScriptContextTester, GlyphContextTester { return null; } - private TTXFile findTTX ( String fid ) { - String pn = findTTXPath ( fid ); - assertTrue ( pn != null ); + private TTXFile findTTX (String fid) { + String pn = findTTXPath (fid); + assertTrue (pn != null); try { - TTXFile tf = TTXFile.getFromCache ( pn ); + TTXFile tf = TTXFile.getFromCache (pn); return tf; - } catch ( Exception e ) { - fail ( e.getMessage() ); + } catch (Exception e) { + fail (e.getMessage()); return null; } } - private GlyphPositioningSubtable[] findGPOSSubtables ( GlyphPositioningTable gpos, String script, String language, String feature, String lid ) { - LookupTable lt = gpos.getLookupTable ( lid ); - if ( lt != null ) { + private GlyphPositioningSubtable[] findGPOSSubtables (GlyphPositioningTable gpos, String script, String language, String feature, String lid) { + LookupTable lt = gpos.getLookupTable (lid); + if (lt != null) { return (GlyphPositioningSubtable[]) lt.getSubtables(); } else { return null; } } - private ScriptContextTester findScriptContextTester ( String script, String language, String feature ) { + private ScriptContextTester findScriptContextTester (String script, String language, String feature) { return this; } - public GlyphContextTester getTester ( String feature ) { + public GlyphContextTester getTester (String feature) { return this; } - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { return true; } - private void assertSamePositions ( int[][] pa1, int[][] pa2 ) { - assertNotNull ( pa1 ); - assertNotNull ( pa2 ); - assertEquals ( "unequal adjustment count", pa1.length, pa2.length ); - for ( int i = 0; i < pa1.length; i++ ) { + private void assertSamePositions (int[][] pa1, int[][] pa2) { + assertNotNull (pa1); + assertNotNull (pa2); + assertEquals ("unequal adjustment count", pa1.length, pa2.length); + for (int i = 0; i < pa1.length; i++) { int[] a1 = pa1 [ i ]; int[] a2 = pa2 [ i ]; - assertNotNull ( a1 ); - assertNotNull ( a2 ); - assertEquals ( "bad adjustment array length", 4, a1.length ); - assertEquals ( "bad adjustment array length", 4, a2.length ); - for ( int k = 0; k < a1.length; k++ ) { + assertNotNull (a1); + assertNotNull (a2); + assertEquals ("bad adjustment array length", 4, a1.length); + assertEquals ("bad adjustment array length", 4, a2.length); + for (int k = 0; k < a1.length; k++) { int p1 = a1[k]; int p2 = a2[k]; - assertEquals ( "bad adjustment", p1, p2 ); + assertEquals ("bad adjustment", p1, p2); } } } diff --git a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java index 8510f5e1f..e8c333fac 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java @@ -2129,43 +2129,43 @@ public class GSUBTestCase implements ScriptContextTester, GlyphContextTester { @Test public void testGSUBSingle() throws Exception { - performSubstitutions ( ltSingle ); + performSubstitutions (ltSingle); } @Test public void testGSUBMultiple() throws Exception { - performSubstitutions ( ltMultiple ); + performSubstitutions (ltMultiple); } @Test public void testGSUBAlternate() throws Exception { - performSubstitutions ( ltAlternate ); + performSubstitutions (ltAlternate); } @Test public void testGSUBLigature() throws Exception { - performSubstitutions ( ltLigature ); + performSubstitutions (ltLigature); } @Test public void testGSUBContextual() throws Exception { - performSubstitutions ( ltContextual ); + performSubstitutions (ltContextual); } @Test public void testGSUBChainedContextual() throws Exception { - performSubstitutions ( ltChainedContextual ); + performSubstitutions (ltChainedContextual); } /** * Perform substitutions on all test data in test specification TS. * @param ts test specification */ - private void performSubstitutions ( Object[][] ts ) { + private void performSubstitutions (Object[][] ts) { assert ts.length > 0; Object[] tp = ts[0]; - for ( int i = 1; i < ts.length; i++ ) { - performSubstitutions ( tp, ts[i] ); + for (int i = 1; i < ts.length; i++) { + performSubstitutions (tp, ts[i]); } } @@ -2174,42 +2174,42 @@ public class GSUBTestCase implements ScriptContextTester, GlyphContextTester { * @param tp test parameters * @param td test data */ - private void performSubstitutions ( Object[] tp, Object[] td ) { + private void performSubstitutions (Object[] tp, Object[] td) { assert tp.length > 0; - if ( td.length > 5 ) { + if (td.length > 5) { String fid = (String) td[0]; String lid = (String) td[1]; String script = (String) td[2]; String language = (String) td[3]; String feature = (String) td[4]; - TTXFile tf = findTTX ( fid ); - assertTrue ( tf != null ); + TTXFile tf = findTTX (fid); + assertTrue (tf != null); GlyphSubstitutionTable gsub = tf.getGSUB(); - assertTrue ( gsub != null ); - GlyphSubstitutionSubtable[] sta = findGSUBSubtables ( gsub, script, language, feature, lid ); - assertTrue ( sta != null ); - assertTrue ( sta.length > 0 ); - ScriptContextTester sct = findScriptContextTester ( script, language, feature ); + assertTrue (gsub != null); + GlyphSubstitutionSubtable[] sta = findGSUBSubtables (gsub, script, language, feature, lid); + assertTrue (sta != null); + assertTrue (sta.length > 0); + ScriptContextTester sct = findScriptContextTester (script, language, feature); String[][][] tia = (String[][][]) td[5]; // test instance array - for ( String[][] ti : tia ) { // test instance - if ( ti != null ) { - if ( ti.length > 1 ) { // must have at least input and output glyph id arrays + for (String[][] ti : tia) { // test instance + if (ti != null) { + if (ti.length > 1) { // must have at least input and output glyph id arrays String[] igia = ti[0]; // input glyph id array String[] ogia = ti[1]; // output glyph id array - GlyphSequence igs = tf.getGlyphSequence ( igia ); - GlyphSequence ogs = tf.getGlyphSequence ( ogia ); - GlyphSequence tgs = GlyphSubstitutionSubtable.substitute ( igs, script, language, feature, sta, sct ); - assertSameGlyphs ( ogs, tgs ); + GlyphSequence igs = tf.getGlyphSequence (igia); + GlyphSequence ogs = tf.getGlyphSequence (ogia); + GlyphSequence tgs = GlyphSubstitutionSubtable.substitute (igs, script, language, feature, sta, sct); + assertSameGlyphs (ogs, tgs); } } } } } - private String findTTXPath ( String fid ) { - for ( String[] fs : ttxFonts ) { - if ( ( fs != null ) && ( fs.length > 1 ) ) { - if ( fs[0].equals ( fid ) ) { + private String findTTXPath (String fid) { + for (String[] fs : ttxFonts) { + if ((fs != null) && (fs.length > 1)) { + if (fs[0].equals (fid)) { return ttxFilesRoot + File.separator + fs[1]; } } @@ -2217,49 +2217,49 @@ public class GSUBTestCase implements ScriptContextTester, GlyphContextTester { return null; } - private TTXFile findTTX ( String fid ) { - String pn = findTTXPath ( fid ); - assertTrue ( pn != null ); + private TTXFile findTTX (String fid) { + String pn = findTTXPath (fid); + assertTrue (pn != null); try { - TTXFile tf = TTXFile.getFromCache ( pn ); + TTXFile tf = TTXFile.getFromCache (pn); return tf; - } catch ( Exception e ) { - fail ( e.getMessage() ); + } catch (Exception e) { + fail (e.getMessage()); return null; } } - private GlyphSubstitutionSubtable[] findGSUBSubtables ( GlyphSubstitutionTable gsub, String script, String language, String feature, String lid ) { - LookupTable lt = gsub.getLookupTable ( lid ); - if ( lt != null ) { + private GlyphSubstitutionSubtable[] findGSUBSubtables (GlyphSubstitutionTable gsub, String script, String language, String feature, String lid) { + LookupTable lt = gsub.getLookupTable (lid); + if (lt != null) { return (GlyphSubstitutionSubtable[]) lt.getSubtables(); } else { return null; } } - private ScriptContextTester findScriptContextTester ( String script, String language, String feature ) { + private ScriptContextTester findScriptContextTester (String script, String language, String feature) { return this; } - public GlyphContextTester getTester ( String feature ) { + public GlyphContextTester getTester (String feature) { return this; } - public boolean test ( String script, String language, String feature, GlyphSequence gs, int index, int flags ) { + public boolean test (String script, String language, String feature, GlyphSequence gs, int index, int flags) { return true; } - private void assertSameGlyphs ( GlyphSequence gs1, GlyphSequence gs2 ) { - assertNotNull ( gs1 ); - assertNotNull ( gs2 ); + private void assertSameGlyphs (GlyphSequence gs1, GlyphSequence gs2) { + assertNotNull (gs1); + assertNotNull (gs2); IntBuffer gb1 = gs1.getGlyphs(); IntBuffer gb2 = gs2.getGlyphs(); - assertEquals ( "unequal glyph count", gb1.limit(), gb2.limit() ); - for ( int i = 0; i < gb1.limit(); i++ ) { + assertEquals ("unequal glyph count", gb1.limit(), gb2.limit()); + for (int i = 0; i < gb1.limit(); i++) { int g1 = gb1.get(i); int g2 = gb2.get(i); - assertEquals ( "unequal glyph code", g1, g2 ); + assertEquals ("unequal glyph code", g1, g2); } } diff --git a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java index cc695ad42..00bdd5acd 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java +++ b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java @@ -230,47 +230,47 @@ public class TTXFile { v2 = null; upem = -1; } - public void parse ( String filename ) { - parse ( new File ( filename ) ); + public void parse (String filename) { + parse (new File (filename)); } - public void parse ( File f ) { + public void parse (File f) { assert f != null; try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); - sp.parse ( f, new Handler() ); - } catch ( FactoryConfigurationError e ) { - throw new RuntimeException ( e.getMessage() ); - } catch ( ParserConfigurationException e ) { - throw new RuntimeException ( e.getMessage() ); - } catch ( SAXException e ) { - throw new RuntimeException ( e.getMessage() ); - } catch ( IOException e ) { - throw new RuntimeException ( e.getMessage() ); + sp.parse (f, new Handler()); + } catch (FactoryConfigurationError e) { + throw new RuntimeException (e.getMessage()); + } catch (ParserConfigurationException e) { + throw new RuntimeException (e.getMessage()); + } catch (SAXException e) { + throw new RuntimeException (e.getMessage()); + } catch (IOException e) { + throw new RuntimeException (e.getMessage()); } } - public GlyphSequence mapCharsToGlyphs ( String s ) { - Integer[] ca = UTF32.toUTF32 ( s, 0, true ); + public GlyphSequence mapCharsToGlyphs (String s) { + Integer[] ca = UTF32.toUTF32 (s, 0, true); int ng = ca.length; - IntBuffer cb = IntBuffer.allocate ( ng ); - IntBuffer gb = IntBuffer.allocate ( ng ); - for ( Integer c : ca ) { - int g = mapCharToGlyph ( (int) c ); - if ( g >= 0 ) { - cb.put ( c ); - gb.put ( g ); + IntBuffer cb = IntBuffer.allocate (ng); + IntBuffer gb = IntBuffer.allocate (ng); + for (Integer c : ca) { + int g = mapCharToGlyph ((int) c); + if (g >= 0) { + cb.put (c); + gb.put (g); } else { - throw new IllegalArgumentException ( "character " + CharUtilities.format ( c ) + " has no corresponding glyph" ); + throw new IllegalArgumentException ("character " + CharUtilities.format (c) + " has no corresponding glyph"); } } cb.rewind(); gb.rewind(); - return new GlyphSequence ( cb, gb, null ); + return new GlyphSequence (cb, gb, null); } - public int mapCharToGlyph ( int c ) { - if ( cmap != null ) { - Integer g = cmap.get ( Integer.valueOf ( c ) ); - if ( g != null ) { + public int mapCharToGlyph (int c) { + if (cmap != null) { + Integer g = cmap.get (Integer.valueOf (c)); + if (g != null) { return (int) g; } else { return -1; @@ -279,41 +279,41 @@ public class TTXFile { return -1; } } - public int getGlyph ( String gid ) { - return mapGlyphId0 ( gid ); + public int getGlyph (String gid) { + return mapGlyphId0 (gid); } - public GlyphSequence getGlyphSequence ( String[] gids ) { + public GlyphSequence getGlyphSequence (String[] gids) { assert gids != null; int ng = gids.length; - IntBuffer cb = IntBuffer.allocate ( ng ); - IntBuffer gb = IntBuffer.allocate ( ng ); - for ( String gid : gids ) { - int g = mapGlyphId0 ( gid ); - if ( g >= 0 ) { - int c = mapGlyphIdToChar ( gid ); - if ( c < 0 ) { + IntBuffer cb = IntBuffer.allocate (ng); + IntBuffer gb = IntBuffer.allocate (ng); + for (String gid : gids) { + int g = mapGlyphId0 (gid); + if (g >= 0) { + int c = mapGlyphIdToChar (gid); + if (c < 0) { c = CharUtilities.NOT_A_CHARACTER; } - cb.put ( c ); - gb.put ( g ); + cb.put (c); + gb.put (g); } else { - throw new IllegalArgumentException ( "unmapped glyph id \"" + gid + "\"" ); + throw new IllegalArgumentException ("unmapped glyph id \"" + gid + "\""); } } cb.rewind(); gb.rewind(); - return new GlyphSequence ( cb, gb, null ); + return new GlyphSequence (cb, gb, null); } - public int[] getWidths ( String[] gids ) { + public int[] getWidths (String[] gids) { assert gids != null; int ng = gids.length; int[] widths = new int [ ng ]; int i = 0; - for ( String gid : gids ) { - int g = mapGlyphId0 ( gid ); + for (String gid : gids) { + int g = mapGlyphId0 (gid); int w = 0; - if ( g >= 0 ) { - if ( ( hmtx != null ) && ( g < hmtx.length ) ) { + if (g >= 0) { + if ((hmtx != null) && (g < hmtx.length)) { int[] mtx = hmtx [ g ]; assert mtx != null; assert mtx.length > 0; @@ -326,27 +326,27 @@ public class TTXFile { return widths; } public int[] getWidths() { - if ( this.widths == null ) { - if ( ( hmtx != null ) && ( upem > 0 ) ) { + if (this.widths == null) { + if ((hmtx != null) && (upem > 0)) { int[] widths = new int [ hmtx.length ]; - for ( int i = 0, n = widths.length; i < n; i++ ) { - widths [ i ] = getPDFWidth ( hmtx [ i ] [ 0 ], upem ); + for (int i = 0, n = widths.length; i < n; i++) { + widths [ i ] = getPDFWidth (hmtx [ i ] [ 0 ], upem); } this.widths = widths; } } return this.widths; } - public static int getPDFWidth ( int tw, int upem ) { + public static int getPDFWidth (int tw, int upem) { // N.B. The following is copied (with minor edits) from TTFFile to insure same results int pw; - if ( tw < 0 ) { + if (tw < 0) { long rest1 = tw % upem; long storrest = 1000 * rest1; - long ledd2 = ( storrest != 0 ) ? ( rest1 / storrest ) : 0; - pw = - ( ( -1000 * tw ) / upem - (int) ledd2 ); + long ledd2 = (storrest != 0) ? (rest1 / storrest) : 0; + pw = - ((-1000 * tw) / upem - (int) ledd2); } else { - pw = ( tw / upem ) * 1000 + ( ( tw % upem ) * 1000 ) / upem; + pw = (tw / upem) * 1000 + ((tw % upem) * 1000) / upem; } return pw; } @@ -359,13 +359,13 @@ public class TTXFile { public GlyphPositioningTable getGPOS() { return gpos; } - public static synchronized TTXFile getFromCache ( String filename ) { + public static synchronized TTXFile getFromCache (String filename) { assert cache != null; TTXFile f; - if ( ( f = (TTXFile) cache.get ( filename ) ) == null ) { + if ((f = (TTXFile) cache.get (filename)) == null) { f = new TTXFile(); - f.parse ( filename ); - cache.put ( filename, f ); + f.parse (filename); + cache.put (filename, f); } return f; } @@ -382,56 +382,56 @@ public class TTXFile { public void endDocument() { } @Override - public void setDocumentLocator ( Locator locator ) { + public void setDocumentLocator (Locator locator) { TTXFile.this.locator = locator; } @Override - public void startElement ( String uri, String localName, String qName, Attributes attrs ) throws SAXException { - String[] en = makeExpandedName ( uri, localName, qName ); - if ( en[0] != null ) { - unsupportedElement ( en ); - } else if ( en[1].equals ( "Alternate" ) ) { + public void startElement (String uri, String localName, String qName, Attributes attrs) throws SAXException { + String[] en = makeExpandedName (uri, localName, qName); + if (en[0] != null) { + unsupportedElement (en); + } else if (en[1].equals ("Alternate")) { String[] pn = new String[] { null, "AlternateSet" }; - if ( isParent ( pn ) ) { - String glyph = attrs.getValue ( "glyph" ); - if ( glyph == null ) { - missingRequiredAttribute ( en, "glyph" ); + if (isParent (pn)) { + String glyph = attrs.getValue ("glyph"); + if (glyph == null) { + missingRequiredAttribute (en, "glyph"); } - int gid = mapGlyphId ( glyph, en ); - alternates.add ( Integer.valueOf ( gid ) ); + int gid = mapGlyphId (glyph, en); + alternates.add (Integer.valueOf (gid)); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "AlternateSet" ) ) { + } else if (en[1].equals ("AlternateSet")) { String[] pn = new String[] { null, "AlternateSubst" }; - if ( isParent ( pn ) ) { - String glyph = attrs.getValue ( "glyph" ); - if ( glyph == null ) { - missingRequiredAttribute ( en, "glyph" ); + if (isParent (pn)) { + String glyph = attrs.getValue ("glyph"); + if (glyph == null) { + missingRequiredAttribute (en, "glyph"); } - int gid = mapGlyphId ( glyph, en ); - coverageEntries.add ( Integer.valueOf ( gid ) ); + int gid = mapGlyphId (glyph, en); + coverageEntries.add (Integer.valueOf (gid)); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "AlternateSubst" ) ) { + } else if (en[1].equals ("AlternateSubst")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -442,32 +442,32 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "BacktrackCoverage" ) ) { + } else if (en[1].equals ("BacktrackCoverage")) { String[] pn1 = new String[] { null, "ChainContextSubst" }; String[] pn2 = new String[] { null, "ChainContextPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); int ci = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - ci = Integer.parseInt ( index ); + ci = Integer.parseInt (index); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -475,44 +475,44 @@ public class TTXFile { ctIndex = ci; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "BaseAnchor" ) ) { + } else if (en[1].equals ("BaseAnchor")) { String[] pn = new String[] { null, "BaseRecord" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "BaseArray" ) ) { + } else if (en[1].equals ("BaseArray")) { String[] pn = new String[] { null, "MarkBasePos" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "BaseCoverage" ) ) { + } else if (en[1].equals ("BaseCoverage")) { String[] pn = new String[] { null, "MarkBasePos" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -520,38 +520,38 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "BaseRecord" ) ) { + } else if (en[1].equals ("BaseRecord")) { String[] pn = new String[] { null, "BaseArray" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ChainContextPos" ) || en[1].equals ( "ChainContextSubst" ) ) { + } else if (en[1].equals ("ChainContextPos") || en[1].equals ("ChainContextSubst")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: case 3: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -559,85 +559,85 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Class" ) ) { + } else if (en[1].equals ("Class")) { String[] pn = new String[] { null, "MarkRecord" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } assert markClass == -1; markClass = v; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ClassDef" ) ) { + } else if (en[1].equals ("ClassDef")) { String[] pn1 = new String[] { null, "GlyphClassDef" }; String[] pn2 = new String[] { null, "MarkAttachClassDef" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String glyph = attrs.getValue ( "glyph" ); - if ( glyph == null ) { - missingRequiredAttribute ( en, "glyph" ); - } - String glyphClass = attrs.getValue ( "class" ); - if ( glyphClass == null ) { - missingRequiredAttribute ( en, "class" ); - } - if ( ! glyphIds.containsKey ( glyph ) ) { - unsupportedGlyph ( en, glyph ); - } else if ( isParent ( pn1 ) ) { - if ( glyphClasses.containsKey ( glyph ) ) { - duplicateGlyphClass ( en, glyph, glyphClass ); + if (isParent (pnx)) { + String glyph = attrs.getValue ("glyph"); + if (glyph == null) { + missingRequiredAttribute (en, "glyph"); + } + String glyphClass = attrs.getValue ("class"); + if (glyphClass == null) { + missingRequiredAttribute (en, "class"); + } + if (! glyphIds.containsKey (glyph)) { + unsupportedGlyph (en, glyph); + } else if (isParent (pn1)) { + if (glyphClasses.containsKey (glyph)) { + duplicateGlyphClass (en, glyph, glyphClass); } else { - glyphClasses.put ( glyph, Integer.parseInt(glyphClass) ); + glyphClasses.put (glyph, Integer.parseInt(glyphClass)); } - } else if ( isParent ( pn2 ) ) { - if ( glyphClasses.containsKey ( glyph ) ) { - duplicateGlyphClass ( en, glyph, glyphClass ); + } else if (isParent (pn2)) { + if (glyphClasses.containsKey (glyph)) { + duplicateGlyphClass (en, glyph, glyphClass); } else { - glyphClasses.put ( glyph, Integer.parseInt(glyphClass) ); + glyphClasses.put (glyph, Integer.parseInt(glyphClass)); } } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "ComponentRecord" ) ) { + } else if (en[1].equals ("ComponentRecord")) { String[] pn = new String[] { null, "LigatureAttach" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } assert anchors.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Coverage" ) ) { + } else if (en[1].equals ("Coverage")) { String[] pn1 = new String[] { null, "CursivePos" }; String[] pn2 = new String[] { null, "LigCaretList" }; String[] pn3 = new String[] { null, "MultipleSubst" }; String[] pn4 = new String[] { null, "PairPos" }; String[] pn5 = new String[] { null, "SinglePos" }; String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5 }; - if ( isParent ( pnx ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pnx)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -645,26 +645,26 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "CursivePos" ) ) { + } else if (en[1].equals ("CursivePos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -673,143 +673,143 @@ public class TTXFile { stFormat = sf; assert attachmentAnchors.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "DefaultLangSys" ) ) { + } else if (en[1].equals ("DefaultLangSys")) { String[] pn = new String[] { null, "Script" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } else { assertLanguageFeaturesClear(); assert languageTag == null; languageTag = defaultLanguageTag; } - } else if ( en[1].equals ( "EntryAnchor" ) ) { + } else if (en[1].equals ("EntryAnchor")) { String[] pn = new String[] { null, "EntryExitRecord" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "EntryExitRecord" ) ) { + } else if (en[1].equals ("EntryExitRecord")) { String[] pn = new String[] { null, "CursivePos" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ExitAnchor" ) ) { + } else if (en[1].equals ("ExitAnchor")) { String[] pn = new String[] { null, "EntryExitRecord" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Feature" ) ) { + } else if (en[1].equals ("Feature")) { String[] pn = new String[] { null, "FeatureRecord" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } else { assertFeatureLookupsClear(); } - } else if ( en[1].equals ( "FeatureIndex" ) ) { + } else if (en[1].equals ("FeatureIndex")) { String[] pn1 = new String[] { null, "DefaultLangSys" }; String[] pn2 = new String[] { null, "LangSys" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String value = attrs.getValue ( "value" ); + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } - if ( languageFeatures.size() == 0 ) { - languageFeatures.add ( null ); + if (languageFeatures.size() == 0) { + languageFeatures.add (null); } - if ( ( v >= 0 ) && ( v < 65535 ) ) { - languageFeatures.add ( makeFeatureId ( v ) ); + if ((v >= 0) && (v < 65535)) { + languageFeatures.add (makeFeatureId (v)); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "FeatureList" ) ) { + } else if (en[1].equals ("FeatureList")) { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( ! isParent ( pnx ) ) { - notPermittedInElementContext ( en, getParent(), pnx ); + if (! isParent (pnx)) { + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "FeatureRecord" ) ) { + } else if (en[1].equals ("FeatureRecord")) { String[] pn = new String[] { null, "FeatureList" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); int fi = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - fi = Integer.parseInt ( index ); + fi = Integer.parseInt (index); } assertFeatureClear(); assert flIndex == -1; flIndex = fi; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "FeatureTag" ) ) { + } else if (en[1].equals ("FeatureTag")) { String[] pn = new String[] { null, "FeatureRecord" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { assert featureTag == null; featureTag = value; } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "GDEF" ) ) { + } else if (en[1].equals ("GDEF")) { String[] pn = new String[] { null, "ttFont" }; - if ( isParent ( pn ) ) { + if (isParent (pn)) { assertSubtablesClear(); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "GPOS" ) ) { + } else if (en[1].equals ("GPOS")) { String[] pn = new String[] { null, "ttFont" }; - if ( isParent ( pn ) ) { + if (isParent (pn)) { assertCoveragesClear(); assertSubtablesClear(); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "GSUB" ) ) { + } else if (en[1].equals ("GSUB")) { String[] pn = new String[] { null, "ttFont" }; - if ( isParent ( pn ) ) { + if (isParent (pn)) { assertCoveragesClear(); assertSubtablesClear(); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Glyph" ) ) { + } else if (en[1].equals ("Glyph")) { String[] pn1 = new String[] { null, "Coverage" }; String[] pn2 = new String[] { null, "InputCoverage" }; String[] pn3 = new String[] { null, "LookAheadCoverage" }; @@ -820,100 +820,100 @@ public class TTXFile { String[] pn8 = new String[] { null, "BaseCoverage" }; String[] pn9 = new String[] { null, "LigatureCoverage" }; String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6, pn7, pn8, pn9 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - int gid = mapGlyphId ( value, en ); - coverageEntries.add ( Integer.valueOf ( gid ) ); + int gid = mapGlyphId (value, en); + coverageEntries.add (Integer.valueOf (gid)); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "GlyphClassDef" ) ) { + } else if (en[1].equals ("GlyphClassDef")) { String[] pn = new String[] { null, "GDEF" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } assertSubtableClear(); assert sf >= 0; // force format 1 since TTX always writes entries as non-range entries - if ( sf != 1 ) { + if (sf != 1) { sf = 1; } stFormat = sf; assert glyphClasses.isEmpty(); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "GlyphID" ) ) { + } else if (en[1].equals ("GlyphID")) { String[] pn = new String[] { null, "GlyphOrder" }; - if ( isParent ( pn ) ) { - String id = attrs.getValue ( "id" ); + if (isParent (pn)) { + String id = attrs.getValue ("id"); int gid = -1; - if ( id == null ) { - missingRequiredAttribute ( en, "id" ); + if (id == null) { + missingRequiredAttribute (en, "id"); } else { - gid = Integer.parseInt ( id ); + gid = Integer.parseInt (id); } - String name = attrs.getValue ( "name" ); - if ( name == null ) { - missingRequiredAttribute ( en, "name" ); + String name = attrs.getValue ("name"); + if (name == null) { + missingRequiredAttribute (en, "name"); } - if ( glyphIds.containsKey ( name ) ) { - duplicateGlyph ( en, name, gid ); + if (glyphIds.containsKey (name)) { + duplicateGlyph (en, name, gid); } else { - if ( gid > glyphIdMax ) { + if (gid > glyphIdMax) { glyphIdMax = gid; } - glyphIds.put ( name, gid ); + glyphIds.put (name, gid); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "GlyphOrder" ) ) { + } else if (en[1].equals ("GlyphOrder")) { String[] pn = new String[] { null, "ttFont" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "InputCoverage" ) ) { + } else if (en[1].equals ("InputCoverage")) { String[] pn1 = new String[] { null, "ChainContextSubst" }; String[] pn2 = new String[] { null, "ChainContextPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); int ci = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - ci = Integer.parseInt ( index ); + ci = Integer.parseInt (index); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -921,107 +921,107 @@ public class TTXFile { ctIndex = ci; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "LangSys" ) ) { + } else if (en[1].equals ("LangSys")) { String[] pn = new String[] { null, "LangSysRecord" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } else { assertLanguageFeaturesClear(); } - } else if ( en[1].equals ( "LangSysRecord" ) ) { + } else if (en[1].equals ("LangSysRecord")) { String[] pn = new String[] { null, "Script" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LangSysTag" ) ) { + } else if (en[1].equals ("LangSysTag")) { String[] pn = new String[] { null, "LangSysRecord" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { assert languageTag == null; languageTag = value; } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigCaretList" ) ) { + } else if (en[1].equals ("LigCaretList")) { String[] pn = new String[] { null, "GDEF" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Ligature" ) ) { + } else if (en[1].equals ("Ligature")) { String[] pn = new String[] { null, "LigatureSet" }; - if ( isParent ( pn ) ) { - String components = attrs.getValue ( "components" ); - if ( components == null ) { - missingRequiredAttribute ( en, "components" ); + if (isParent (pn)) { + String components = attrs.getValue ("components"); + if (components == null) { + missingRequiredAttribute (en, "components"); } - int[] cids = mapGlyphIds ( components, en ); - String glyph = attrs.getValue ( "glyph" ); - if ( glyph == null ) { - missingRequiredAttribute ( en, "glyph" ); + int[] cids = mapGlyphIds (components, en); + String glyph = attrs.getValue ("glyph"); + if (glyph == null) { + missingRequiredAttribute (en, "glyph"); } - int gid = mapGlyphId ( glyph, en ); - ligatures.add ( new Ligature ( gid, cids ) ); + int gid = mapGlyphId (glyph, en); + ligatures.add (new Ligature (gid, cids)); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureAnchor" ) ) { + } else if (en[1].equals ("LigatureAnchor")) { String[] pn = new String[] { null, "ComponentRecord" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureArray" ) ) { + } else if (en[1].equals ("LigatureArray")) { String[] pn = new String[] { null, "MarkLigPos" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureAttach" ) ) { + } else if (en[1].equals ("LigatureAttach")) { String[] pn = new String[] { null, "LigatureArray" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } assert components.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureCoverage" ) ) { + } else if (en[1].equals ("LigatureCoverage")) { String[] pn = new String[] { null, "MarkLigPos" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -1029,38 +1029,38 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureSet" ) ) { + } else if (en[1].equals ("LigatureSet")) { String[] pn = new String[] { null, "LigatureSubst" }; - if ( isParent ( pn ) ) { - String glyph = attrs.getValue ( "glyph" ); - if ( glyph == null ) { - missingRequiredAttribute ( en, "glyph" ); + if (isParent (pn)) { + String glyph = attrs.getValue ("glyph"); + if (glyph == null) { + missingRequiredAttribute (en, "glyph"); } - int gid = mapGlyphId ( glyph, en ); - coverageEntries.add ( Integer.valueOf ( gid ) ); + int gid = mapGlyphId (glyph, en); + coverageEntries.add (Integer.valueOf (gid)); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LigatureSubst" ) ) { + } else if (en[1].equals ("LigatureSubst")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1071,32 +1071,32 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LookAheadCoverage" ) ) { + } else if (en[1].equals ("LookAheadCoverage")) { String[] pn1 = new String[] { null, "ChainContextSubst" }; String[] pn2 = new String[] { null, "ChainContextPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); int ci = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - ci = Integer.parseInt ( index ); + ci = Integer.parseInt (index); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -1104,101 +1104,101 @@ public class TTXFile { ctIndex = ci; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "Lookup" ) ) { + } else if (en[1].equals ("Lookup")) { String[] pn = new String[] { null, "LookupList" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); int li = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - li = Integer.parseInt ( index ); + li = Integer.parseInt (index); } assertLookupClear(); assert ltIndex == -1; ltIndex = li; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LookupFlag" ) ) { + } else if (en[1].equals ("LookupFlag")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int lf = 0; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - lf = Integer.parseInt ( value ); + lf = Integer.parseInt (value); } assert ltFlags == 0; ltFlags = lf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "LookupList" ) ) { + } else if (en[1].equals ("LookupList")) { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( ! isParent ( pnx ) ) { - notPermittedInElementContext ( en, getParent(), pnx ); + if (! isParent (pnx)) { + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "LookupListIndex" ) ) { + } else if (en[1].equals ("LookupListIndex")) { String[] pn1 = new String[] { null, "Feature" }; String[] pn2 = new String[] { null, "SubstLookupRecord" }; String[] pn3 = new String[] { null, "PosLookupRecord" }; String[][] pnx = new String[][] { pn1, pn2, pn3 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); - String value = attrs.getValue ( "value" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } String[][] pny = new String[][] { pn2, pn3 }; - if ( isParent ( pny ) ) { + if (isParent (pny)) { assert rlLookup == -1; assert v != -1; rlLookup = v; } else { - featureLookups.add ( makeLookupId ( v ) ); + featureLookups.add (makeLookupId (v)); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "LookupType" ) ) { + } else if (en[1].equals ("LookupType")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark1Array" ) ) { + } else if (en[1].equals ("Mark1Array")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark1Coverage" ) ) { + } else if (en[1].equals ("Mark1Coverage")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -1206,40 +1206,40 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark2Anchor" ) ) { + } else if (en[1].equals ("Mark2Anchor")) { String[] pn = new String[] { null, "Mark2Record" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark2Array" ) ) { + } else if (en[1].equals ("Mark2Array")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark2Coverage" ) ) { + } else if (en[1].equals ("Mark2Coverage")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -1247,84 +1247,84 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Mark2Record" ) ) { + } else if (en[1].equals ("Mark2Record")) { String[] pn = new String[] { null, "Mark2Array" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkAnchor" ) ) { + } else if (en[1].equals ("MarkAnchor")) { String[] pn = new String[] { null, "MarkRecord" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); + if (format == null) { + missingRequiredAttribute (en, "Format"); } assert xCoord == Integer.MIN_VALUE; assert yCoord == Integer.MIN_VALUE; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkArray" ) ) { + } else if (en[1].equals ("MarkArray")) { String[] pn1 = new String[] { null, "MarkBasePos" }; String[] pn2 = new String[] { null, "MarkLigPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( ! isParent ( pnx ) ) { - notPermittedInElementContext ( en, getParent(), pnx ); + if (! isParent (pnx)) { + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "MarkAttachClassDef" ) ) { + } else if (en[1].equals ("MarkAttachClassDef")) { String[] pn = new String[] { null, "GDEF" }; - if ( isParent ( pn ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pn)) { + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } assertSubtableClear(); assert sf >= 0; // force format 1 since TTX always writes entries as non-range entries - if ( sf != 1 ) { + if (sf != 1) { sf = 1; } stFormat = sf; assert glyphClasses.isEmpty(); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkBasePos" ) ) { + } else if (en[1].equals ("MarkBasePos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1334,25 +1334,25 @@ public class TTXFile { assert markAnchors.size() == 0; assert baseOrMarkAnchors.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkCoverage" ) ) { + } else if (en[1].equals ("MarkCoverage")) { String[] pn1 = new String[] { null, "MarkBasePos" }; String[] pn2 = new String[] { null, "MarkLigPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String format = attrs.getValue ( "Format" ); + if (isParent (pnx)) { + String format = attrs.getValue ("Format"); int cf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - cf = Integer.parseInt ( format ); - switch ( cf ) { + cf = Integer.parseInt (format); + switch (cf) { case 1: case 2: break; default: - unsupportedFormat ( en, cf ); + unsupportedFormat (en, cf); break; } } @@ -1360,26 +1360,26 @@ public class TTXFile { ctIndex = 0; ctFormat = cf; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "MarkLigPos" ) ) { + } else if (en[1].equals ("MarkLigPos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1389,26 +1389,26 @@ public class TTXFile { assert markAnchors.size() == 0; assert ligatureAnchors.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkMarkPos" ) ) { + } else if (en[1].equals ("MarkMarkPos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1418,38 +1418,38 @@ public class TTXFile { assert markAnchors.size() == 0; assert baseOrMarkAnchors.size() == 0; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "MarkRecord" ) ) { + } else if (en[1].equals ("MarkRecord")) { String[] pn1 = new String[] { null, "MarkArray" }; String[] pn2 = new String[] { null, "Mark1Array" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "MultipleSubst" ) ) { + } else if (en[1].equals ("MultipleSubst")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1457,27 +1457,27 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "PairPos" ) ) { + } else if (en[1].equals ("PairPos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1485,171 +1485,171 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "PairSet" ) ) { + } else if (en[1].equals ("PairSet")) { String[] pn = new String[] { null, "PairPos" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); int psi = -1; - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { - psi = Integer.parseInt ( index ); + psi = Integer.parseInt (index); } assert psIndex == -1; psIndex = psi; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "PairValueRecord" ) ) { + } else if (en[1].equals ("PairValueRecord")) { String[] pn = new String[] { null, "PairSet" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } else { assertPairClear(); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "PosLookupRecord" ) ) { + } else if (en[1].equals ("PosLookupRecord")) { String[] pn1 = new String[] { null, "ChainContextSubst" }; String[] pn2 = new String[] { null, "ChainContextPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pnx)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "ReqFeatureIndex" ) ) { + } else if (en[1].equals ("ReqFeatureIndex")) { String[] pn1 = new String[] { null, "DefaultLangSys" }; String[] pn2 = new String[] { null, "LangSys" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } String fid; - if ( ( v >= 0 ) && ( v < 65535 ) ) { - fid = makeFeatureId ( v ); + if ((v >= 0) && (v < 65535)) { + fid = makeFeatureId (v); } else { fid = null; } assertLanguageFeaturesClear(); - languageFeatures.add ( fid ); + languageFeatures.add (fid); } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "Script" ) ) { + } else if (en[1].equals ("Script")) { String[] pn = new String[] { null, "ScriptRecord" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ScriptList" ) ) { + } else if (en[1].equals ("ScriptList")) { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( ! isParent ( pnx ) ) { - notPermittedInElementContext ( en, getParent(), pnx ); + if (! isParent (pnx)) { + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "ScriptRecord" ) ) { + } else if (en[1].equals ("ScriptRecord")) { String[] pn = new String[] { null, "ScriptList" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ScriptTag" ) ) { + } else if (en[1].equals ("ScriptTag")) { String[] pn = new String[] { null, "ScriptRecord" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { assert scriptTag == null; scriptTag = value; } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "SecondGlyph" ) ) { + } else if (en[1].equals ("SecondGlyph")) { String[] pn = new String[] { null, "PairValueRecord" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - int gid = mapGlyphId ( value, en ); + int gid = mapGlyphId (value, en); assert g2 == -1; g2 = gid; } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Sequence" ) ) { + } else if (en[1].equals ("Sequence")) { String[] pn = new String[] { null, "MultipleSubst" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); - } else { - int i = Integer.parseInt ( index ); - if ( i != subtableEntries.size() ) { - invalidIndex ( en, i, subtableEntries.size() ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); + } else { + int i = Integer.parseInt (index); + if (i != subtableEntries.size()) { + invalidIndex (en, i, subtableEntries.size()); } } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "SequenceIndex" ) ) { + } else if (en[1].equals ("SequenceIndex")) { String[] pn1 = new String[] { null, "PosLookupRecord" }; String[] pn2 = new String[] { null, "SubstLookupRecord" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } assert rlSequence == -1; assert v != -1; rlSequence = v; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "SinglePos" ) ) { + } else if (en[1].equals ("SinglePos")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1657,27 +1657,27 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "SingleSubst" ) ) { + } else if (en[1].equals ("SingleSubst")) { String[] pn = new String[] { null, "Lookup" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } - String format = attrs.getValue ( "Format" ); + String format = attrs.getValue ("Format"); int sf = -1; - if ( format == null ) { - missingRequiredAttribute ( en, "Format" ); + if (format == null) { + missingRequiredAttribute (en, "Format"); } else { - sf = Integer.parseInt ( format ); - switch ( sf ) { + sf = Integer.parseInt (format); + switch (sf) { case 1: case 2: break; default: - unsupportedFormat ( en, sf ); + unsupportedFormat (en, sf); break; } } @@ -1688,157 +1688,157 @@ public class TTXFile { assert sf >= 0; stFormat = sf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "SubstLookupRecord" ) ) { + } else if (en[1].equals ("SubstLookupRecord")) { String[] pn = new String[] { null, "ChainContextSubst" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Substitute" ) ) { + } else if (en[1].equals ("Substitute")) { String[] pn = new String[] { null, "Sequence" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( index == null ) { - missingRequiredAttribute ( en, "index" ); - } else { - int i = Integer.parseInt ( index ); - if ( i != substitutes.size() ) { - invalidIndex ( en, i, substitutes.size() ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (index == null) { + missingRequiredAttribute (en, "index"); + } else { + int i = Integer.parseInt (index); + if (i != substitutes.size()) { + invalidIndex (en, i, substitutes.size()); } } - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - int gid = mapGlyphId ( value, en ); - substitutes.add ( Integer.valueOf ( gid ) ); + int gid = mapGlyphId (value, en); + substitutes.add (Integer.valueOf (gid)); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Substitution" ) ) { + } else if (en[1].equals ("Substitution")) { String[] pn = new String[] { null, "SingleSubst" }; - if ( isParent ( pn ) ) { - String in = attrs.getValue ( "in" ); + if (isParent (pn)) { + String in = attrs.getValue ("in"); int igid = -1; int ogid = -1; - if ( in == null ) { - missingRequiredAttribute ( en, "in" ); + if (in == null) { + missingRequiredAttribute (en, "in"); } else { - igid = mapGlyphId ( in, en ); + igid = mapGlyphId (in, en); } - String out = attrs.getValue ( "out" ); - if ( out == null ) { - missingRequiredAttribute ( en, "out" ); + String out = attrs.getValue ("out"); + if (out == null) { + missingRequiredAttribute (en, "out"); } else { - ogid = mapGlyphId ( out, en ); + ogid = mapGlyphId (out, en); } - coverageEntries.add ( Integer.valueOf ( igid ) ); - subtableEntries.add ( Integer.valueOf ( ogid ) ); + coverageEntries.add (Integer.valueOf (igid)); + subtableEntries.add (Integer.valueOf (ogid)); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Value" ) ) { + } else if (en[1].equals ("Value")) { String[] pn = new String[] { null, "SinglePos" }; - if ( isParent ( pn ) ) { - String index = attrs.getValue ( "index" ); - if ( vf1 < 0 ) { - missingParameter ( en, "value format" ); + if (isParent (pn)) { + String index = attrs.getValue ("index"); + if (vf1 < 0) { + missingParameter (en, "value format"); } else { - subtableEntries.add ( parseValue ( en, attrs, vf1 ) ); + subtableEntries.add (parseValue (en, attrs, vf1)); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Value1" ) ) { + } else if (en[1].equals ("Value1")) { String[] pn = new String[] { null, "PairValueRecord" }; - if ( isParent ( pn ) ) { - if ( vf1 < 0 ) { - missingParameter ( en, "value format 1" ); + if (isParent (pn)) { + if (vf1 < 0) { + missingParameter (en, "value format 1"); } else { assert v1 == null; - v1 = parseValue ( en, attrs, vf1 ); + v1 = parseValue (en, attrs, vf1); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Value2" ) ) { + } else if (en[1].equals ("Value2")) { String[] pn = new String[] { null, "PairValueRecord" }; - if ( isParent ( pn ) ) { - if ( vf2 < 0 ) { - missingParameter ( en, "value format 2" ); + if (isParent (pn)) { + if (vf2 < 0) { + missingParameter (en, "value format 2"); } else { assert v2 == null; - v2 = parseValue ( en, attrs, vf2 ); + v2 = parseValue (en, attrs, vf2); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ValueFormat" ) ) { + } else if (en[1].equals ("ValueFormat")) { String[] pn = new String[] { null, "SinglePos" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int vf = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - vf = Integer.parseInt ( value ); + vf = Integer.parseInt (value); } assert vf1 == -1; vf1 = vf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ValueFormat1" ) ) { + } else if (en[1].equals ("ValueFormat1")) { String[] pn = new String[] { null, "PairPos" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int vf = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - vf = Integer.parseInt ( value ); + vf = Integer.parseInt (value); } assert vf1 == -1; vf1 = vf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "ValueFormat2" ) ) { + } else if (en[1].equals ("ValueFormat2")) { String[] pn = new String[] { null, "PairPos" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int vf = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - vf = Integer.parseInt ( value ); + vf = Integer.parseInt (value); } assert vf2 == -1; vf2 = vf; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "Version" ) ) { + } else if (en[1].equals ("Version")) { String[] pn1 = new String[] { null, "GDEF" }; String[] pn2 = new String[] { null, "GPOS" }; String[] pn3 = new String[] { null, "GSUB" }; String[][] pnx = new String[][] { pn1, pn2, pn3 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "XCoordinate" ) ) { + } else if (en[1].equals ("XCoordinate")) { String[] pn1 = new String[] { null, "BaseAnchor" }; String[] pn2 = new String[] { null, "EntryAnchor" }; String[] pn3 = new String[] { null, "ExitAnchor" }; @@ -1846,20 +1846,20 @@ public class TTXFile { String[] pn5 = new String[] { null, "MarkAnchor" }; String[] pn6 = new String[] { null, "Mark2Anchor" }; String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); int x = 0; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - x = Integer.parseInt ( value ); + x = Integer.parseInt (value); } assert xCoord == Integer.MIN_VALUE; xCoord = x; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "YCoordinate" ) ) { + } else if (en[1].equals ("YCoordinate")) { String[] pn1 = new String[] { null, "BaseAnchor" }; String[] pn2 = new String[] { null, "EntryAnchor" }; String[] pn3 = new String[] { null, "ExitAnchor" }; @@ -1867,75 +1867,75 @@ public class TTXFile { String[] pn5 = new String[] { null, "MarkAnchor" }; String[] pn6 = new String[] { null, "Mark2Anchor" }; String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6 }; - if ( isParent ( pnx ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pnx)) { + String value = attrs.getValue ("value"); int y = 0; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - y = Integer.parseInt ( value ); + y = Integer.parseInt (value); } assert yCoord == Integer.MIN_VALUE; yCoord = y; } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "checkSumAdjustment" ) ) { + } else if (en[1].equals ("checkSumAdjustment")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "cmap" ) ) { + } else if (en[1].equals ("cmap")) { String[] pn = new String[] { null, "ttFont" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "cmap_format_0" ) ) { + } else if (en[1].equals ("cmap_format_0")) { String[] pn = new String[] { null, "cmap" }; - if ( isParent ( pn ) ) { - String platformID = attrs.getValue ( "platformID" ); - if ( platformID == null ) { - missingRequiredAttribute ( en, "platformID" ); + if (isParent (pn)) { + String platformID = attrs.getValue ("platformID"); + if (platformID == null) { + missingRequiredAttribute (en, "platformID"); } - String platEncID = attrs.getValue ( "platEncID" ); - if ( platEncID == null ) { - missingRequiredAttribute ( en, "platEncID" ); + String platEncID = attrs.getValue ("platEncID"); + if (platEncID == null) { + missingRequiredAttribute (en, "platEncID"); } - String language = attrs.getValue ( "language" ); - if ( language == null ) { - missingRequiredAttribute ( en, "language" ); + String language = attrs.getValue ("language"); + if (language == null) { + missingRequiredAttribute (en, "language"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "cmap_format_4" ) ) { + } else if (en[1].equals ("cmap_format_4")) { String[] pn = new String[] { null, "cmap" }; - if ( isParent ( pn ) ) { - String platformID = attrs.getValue ( "platformID" ); + if (isParent (pn)) { + String platformID = attrs.getValue ("platformID"); int pid = -1; - if ( platformID == null ) { - missingRequiredAttribute ( en, "platformID" ); + if (platformID == null) { + missingRequiredAttribute (en, "platformID"); } else { - pid = Integer.parseInt ( platformID ); + pid = Integer.parseInt (platformID); } - String platEncID = attrs.getValue ( "platEncID" ); + String platEncID = attrs.getValue ("platEncID"); int eid = -1; - if ( platEncID == null ) { - missingRequiredAttribute ( en, "platEncID" ); + if (platEncID == null) { + missingRequiredAttribute (en, "platEncID"); } else { - eid = Integer.parseInt ( platEncID ); + eid = Integer.parseInt (platEncID); } - String language = attrs.getValue ( "language" ); + String language = attrs.getValue ("language"); int lid = -1; - if ( language == null ) { - missingRequiredAttribute ( en, "language" ); + if (language == null) { + missingRequiredAttribute (en, "language"); } else { - lid = Integer.parseInt ( language ); + lid = Integer.parseInt (language); } assert cmapEntries.size() == 0; assert cmPlatform == -1; @@ -1945,639 +1945,639 @@ public class TTXFile { cmEncoding = eid; cmLanguage = lid; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "created" ) ) { + } else if (en[1].equals ("created")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "flags" ) ) { + } else if (en[1].equals ("flags")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "fontDirectionHint" ) ) { + } else if (en[1].equals ("fontDirectionHint")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "fontRevision" ) ) { + } else if (en[1].equals ("fontRevision")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "glyphDataFormat" ) ) { + } else if (en[1].equals ("glyphDataFormat")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "head" ) ) { + } else if (en[1].equals ("head")) { String[] pn = new String[] { null, "ttFont" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "hmtx" ) ) { + } else if (en[1].equals ("hmtx")) { String[] pn = new String[] { null, "ttFont" }; - if ( ! isParent ( pn ) ) { - notPermittedInElementContext ( en, getParent(), pn ); - } else if ( glyphIdMax > 0 ) { - hmtxEntries.setSize ( glyphIdMax + 1 ); + if (! isParent (pn)) { + notPermittedInElementContext (en, getParent(), pn); + } else if (glyphIdMax > 0) { + hmtxEntries.setSize (glyphIdMax + 1); } - } else if ( en[1].equals ( "indexToLocFormat" ) ) { + } else if (en[1].equals ("indexToLocFormat")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "lowestRecPPEM" ) ) { + } else if (en[1].equals ("lowestRecPPEM")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "macStyle" ) ) { + } else if (en[1].equals ("macStyle")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "magicNumber" ) ) { + } else if (en[1].equals ("magicNumber")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "map" ) ) { + } else if (en[1].equals ("map")) { String[] pn1 = new String[] { null, "cmap_format_0" }; String[] pn2 = new String[] { null, "cmap_format_4" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pnx ) ) { - String code = attrs.getValue ( "code" ); + if (isParent (pnx)) { + String code = attrs.getValue ("code"); int cid = -1; - if ( code == null ) { - missingRequiredAttribute ( en, "code" ); + if (code == null) { + missingRequiredAttribute (en, "code"); } else { code = code.toLowerCase(); - if ( code.startsWith ( "0x" ) ) { - cid = Integer.parseInt ( code.substring ( 2 ), 16 ); + if (code.startsWith ("0x")) { + cid = Integer.parseInt (code.substring (2), 16); } else { - cid = Integer.parseInt ( code, 10 ); + cid = Integer.parseInt (code, 10); } } - String name = attrs.getValue ( "name" ); + String name = attrs.getValue ("name"); int gid = -1; - if ( name == null ) { - missingRequiredAttribute ( en, "name" ); + if (name == null) { + missingRequiredAttribute (en, "name"); } else { - gid = mapGlyphId ( name, en ); + gid = mapGlyphId (name, en); } - if ( ( cmPlatform == 3 ) && ( cmEncoding == 1 ) ) { - cmapEntries.add ( new int[] { cid, gid } ); + if ((cmPlatform == 3) && (cmEncoding == 1)) { + cmapEntries.add (new int[] { cid, gid }); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "modified" ) ) { + } else if (en[1].equals ("modified")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "mtx" ) ) { + } else if (en[1].equals ("mtx")) { String[] pn = new String[] { null, "hmtx" }; - if ( isParent ( pn ) ) { - String name = attrs.getValue ( "name" ); + if (isParent (pn)) { + String name = attrs.getValue ("name"); int gid = -1; - if ( name == null ) { - missingRequiredAttribute ( en, "name" ); + if (name == null) { + missingRequiredAttribute (en, "name"); } else { - gid = mapGlyphId ( name, en ); + gid = mapGlyphId (name, en); } - String width = attrs.getValue ( "width" ); + String width = attrs.getValue ("width"); int w = -1; - if ( width == null ) { - missingRequiredAttribute ( en, "width" ); + if (width == null) { + missingRequiredAttribute (en, "width"); } else { - w = Integer.parseInt ( width ); + w = Integer.parseInt (width); } - String lsb = attrs.getValue ( "lsb" ); + String lsb = attrs.getValue ("lsb"); int l = -1; - if ( lsb == null ) { - missingRequiredAttribute ( en, "lsb" ); + if (lsb == null) { + missingRequiredAttribute (en, "lsb"); } else { - l = Integer.parseInt ( lsb ); + l = Integer.parseInt (lsb); } - hmtxEntries.set ( gid, new int[] { w, l } ); + hmtxEntries.set (gid, new int[] { w, l }); } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "tableVersion" ) ) { + } else if (en[1].equals ("tableVersion")) { String[] pn1 = new String[] { null, "cmap" }; String[] pn2 = new String[] { null, "head" }; String[][] pnx = new String[][] { pn1, pn2 }; - if ( isParent ( pn1 ) ) { // child of cmap - String version = attrs.getValue ( "version" ); - if ( version == null ) { - missingRequiredAttribute ( en, "version" ); + if (isParent (pn1)) { // child of cmap + String version = attrs.getValue ("version"); + if (version == null) { + missingRequiredAttribute (en, "version"); } - } else if ( isParent ( pn2 ) ) { // child of head - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + } else if (isParent (pn2)) { // child of head + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pnx ); + notPermittedInElementContext (en, getParent(), pnx); } - } else if ( en[1].equals ( "ttFont" ) ) { + } else if (en[1].equals ("ttFont")) { String[] pn = new String[] { null, null }; - if ( isParent ( pn ) ) { - String sfntVersion = attrs.getValue ( "sfntVersion" ); - if ( sfntVersion == null ) { - missingRequiredAttribute ( en, "sfntVersion" ); + if (isParent (pn)) { + String sfntVersion = attrs.getValue ("sfntVersion"); + if (sfntVersion == null) { + missingRequiredAttribute (en, "sfntVersion"); } - String ttLibVersion = attrs.getValue ( "ttLibVersion" ); - if ( ttLibVersion == null ) { - missingRequiredAttribute ( en, "ttLibVersion" ); + String ttLibVersion = attrs.getValue ("ttLibVersion"); + if (ttLibVersion == null) { + missingRequiredAttribute (en, "ttLibVersion"); } } else { - notPermittedInElementContext ( en, getParent(), null ); + notPermittedInElementContext (en, getParent(), null); } - } else if ( en[1].equals ( "unitsPerEm" ) ) { + } else if (en[1].equals ("unitsPerEm")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); int v = -1; - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (value == null) { + missingRequiredAttribute (en, "value"); } else { - v = Integer.parseInt ( value ); + v = Integer.parseInt (value); } assert upem == -1; upem = v; } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "xMax" ) ) { + } else if (en[1].equals ("xMax")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "xMin" ) ) { + } else if (en[1].equals ("xMin")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "yMax" ) ) { + } else if (en[1].equals ("yMax")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } - } else if ( en[1].equals ( "yMin" ) ) { + } else if (en[1].equals ("yMin")) { String[] pn = new String[] { null, "head" }; - if ( isParent ( pn ) ) { - String value = attrs.getValue ( "value" ); - if ( value == null ) { - missingRequiredAttribute ( en, "value" ); + if (isParent (pn)) { + String value = attrs.getValue ("value"); + if (value == null) { + missingRequiredAttribute (en, "value"); } } else { - notPermittedInElementContext ( en, getParent(), pn ); + notPermittedInElementContext (en, getParent(), pn); } } else { - unsupportedElement ( en ); + unsupportedElement (en); } - elements.push ( en ); + elements.push (en); } @Override - public void endElement ( String uri, String localName, String qName ) throws SAXException { - if ( elements.empty() ) { - throw new SAXException ( "element stack is unbalanced, no elements on stack!" ); + public void endElement (String uri, String localName, String qName) throws SAXException { + if (elements.empty()) { + throw new SAXException ("element stack is unbalanced, no elements on stack!"); } String[] enParent = elements.peek(); - if ( enParent == null ) { - throw new SAXException ( "element stack is empty, elements are not balanced" ); + if (enParent == null) { + throw new SAXException ("element stack is empty, elements are not balanced"); } - String[] en = makeExpandedName ( uri, localName, qName ); - if ( ! sameExpandedName ( enParent, en ) ) { - throw new SAXException ( "element stack is unbalanced, expanded name mismatch" ); + String[] en = makeExpandedName (uri, localName, qName); + if (! sameExpandedName (enParent, en)) { + throw new SAXException ("element stack is unbalanced, expanded name mismatch"); } - if ( en[0] != null ) { - unsupportedElement ( en ); - } else if ( isAnchorElement ( en[1] ) ) { - if ( xCoord == Integer.MIN_VALUE ) { - missingParameter ( en, "x coordinate" ); - } else if ( yCoord == Integer.MIN_VALUE ) { - missingParameter ( en, "y coordinate" ); - } else { - if ( en[1].equals ( "EntryAnchor" ) ) { - if ( anchors.size() > 0 ) { - duplicateParameter ( en, "entry anchor" ); + if (en[0] != null) { + unsupportedElement (en); + } else if (isAnchorElement (en[1])) { + if (xCoord == Integer.MIN_VALUE) { + missingParameter (en, "x coordinate"); + } else if (yCoord == Integer.MIN_VALUE) { + missingParameter (en, "y coordinate"); + } else { + if (en[1].equals ("EntryAnchor")) { + if (anchors.size() > 0) { + duplicateParameter (en, "entry anchor"); } - } else if ( en[1].equals ( "ExitAnchor" ) ) { - if ( anchors.size() > 1 ) { - duplicateParameter ( en, "exit anchor" ); - } else if ( anchors.size() == 0 ) { - anchors.add ( null ); + } else if (en[1].equals ("ExitAnchor")) { + if (anchors.size() > 1) { + duplicateParameter (en, "exit anchor"); + } else if (anchors.size() == 0) { + anchors.add (null); } } - anchors.add ( new GlyphPositioningTable.Anchor ( xCoord, yCoord ) ); + anchors.add (new GlyphPositioningTable.Anchor (xCoord, yCoord)); xCoord = yCoord = Integer.MIN_VALUE; } - } else if ( en[1].equals ( "AlternateSet" ) ) { - subtableEntries.add ( extractAlternates() ); - } else if ( en[1].equals ( "AlternateSubst" ) ) { - if ( ! sortEntries ( coverageEntries, subtableEntries ) ) { - mismatchedEntries ( en, coverageEntries.size(), subtableEntries.size() ); - } - addGSUBSubtable ( GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage() ); - } else if ( en[1].equals ( "BacktrackCoverage" ) ) { - String ck = makeCoverageKey ( "bk", ctIndex ); - if ( coverages.containsKey ( ck ) ) { - duplicateCoverageIndex ( en, ctIndex ); - } else { - coverages.put ( ck, extractCoverage() ); - } - } else if ( en[1].equals ( "BaseCoverage" ) ) { - coverages.put ( "base", extractCoverage() ); - } else if ( en[1].equals ( "BaseRecord" ) ) { - baseOrMarkAnchors.add ( extractAnchors() ); - } else if ( en[1].equals ( "ChainContextPos" ) || en[1].equals ( "ChainContextSubst" ) ) { + } else if (en[1].equals ("AlternateSet")) { + subtableEntries.add (extractAlternates()); + } else if (en[1].equals ("AlternateSubst")) { + if (! sortEntries (coverageEntries, subtableEntries)) { + mismatchedEntries (en, coverageEntries.size(), subtableEntries.size()); + } + addGSUBSubtable (GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage()); + } else if (en[1].equals ("BacktrackCoverage")) { + String ck = makeCoverageKey ("bk", ctIndex); + if (coverages.containsKey (ck)) { + duplicateCoverageIndex (en, ctIndex); + } else { + coverages.put (ck, extractCoverage()); + } + } else if (en[1].equals ("BaseCoverage")) { + coverages.put ("base", extractCoverage()); + } else if (en[1].equals ("BaseRecord")) { + baseOrMarkAnchors.add (extractAnchors()); + } else if (en[1].equals ("ChainContextPos") || en[1].equals ("ChainContextSubst")) { GlyphCoverageTable coverage = null; - if ( stFormat == 3 ) { - GlyphCoverageTable igca[] = getCoveragesWithPrefix ( "in" ); - GlyphCoverageTable bgca[] = getCoveragesWithPrefix ( "bk" ); - GlyphCoverageTable lgca[] = getCoveragesWithPrefix ( "la" ); - if ( ( igca.length == 0 ) || hasMissingCoverage ( igca ) ) { - missingCoverage ( en, "input", igca.length ); - } else if ( hasMissingCoverage ( bgca ) ) { - missingCoverage ( en, "backtrack", bgca.length ); - } else if ( hasMissingCoverage ( lgca ) ) { - missingCoverage ( en, "lookahead", lgca.length ); - } else { - GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule ( extractRuleLookups(), igca.length, igca, bgca, lgca ); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet ( new GlyphTable.Rule[] {r} ); + if (stFormat == 3) { + GlyphCoverageTable igca[] = getCoveragesWithPrefix ("in"); + GlyphCoverageTable bgca[] = getCoveragesWithPrefix ("bk"); + GlyphCoverageTable lgca[] = getCoveragesWithPrefix ("la"); + if ((igca.length == 0) || hasMissingCoverage (igca)) { + missingCoverage (en, "input", igca.length); + } else if (hasMissingCoverage (bgca)) { + missingCoverage (en, "backtrack", bgca.length); + } else if (hasMissingCoverage (lgca)) { + missingCoverage (en, "lookahead", lgca.length); + } else { + GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule (extractRuleLookups(), igca.length, igca, bgca, lgca); + GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet (new GlyphTable.Rule[] {r}); GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; coverage = igca [ 0 ]; - subtableEntries.add ( rsa ); + subtableEntries.add (rsa); } } else { - unsupportedFormat ( en, stFormat ); + unsupportedFormat (en, stFormat); } - if ( en[1].equals ( "ChainContextPos" ) ) { - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage ); - } else if ( en[1].equals ( "ChainContextSubst" ) ) { - addGSUBSubtable ( GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage ); + if (en[1].equals ("ChainContextPos")) { + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage); + } else if (en[1].equals ("ChainContextSubst")) { + addGSUBSubtable (GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage); } - } else if ( en[1].equals ( "ComponentRecord" ) ) { - components.add ( extractAnchors() ); - } else if ( en[1].equals ( "Coverage" ) ) { - coverages.put ( "main", extractCoverage() ); - } else if ( en[1].equals ( "DefaultLangSys" ) || en[1].equals ( "LangSysRecord" ) ) { - if ( languageTag == null ) { - missingTag ( en, "language" ); - } else if ( languages.containsKey ( languageTag ) ) { - duplicateTag ( en, "language", languageTag ); + } else if (en[1].equals ("ComponentRecord")) { + components.add (extractAnchors()); + } else if (en[1].equals ("Coverage")) { + coverages.put ("main", extractCoverage()); + } else if (en[1].equals ("DefaultLangSys") || en[1].equals ("LangSysRecord")) { + if (languageTag == null) { + missingTag (en, "language"); + } else if (languages.containsKey (languageTag)) { + duplicateTag (en, "language", languageTag); } else { - languages.put ( languageTag, extractLanguageFeatures() ); + languages.put (languageTag, extractLanguageFeatures()); languageTag = null; } - } else if ( en[1].equals ( "CursivePos" ) ) { - GlyphCoverageTable ct = coverages.get ( "main" ); - if ( ct == null ) { - missingParameter ( en, "coverages" ); - } else if ( stFormat == 1 ) { - subtableEntries.add ( extractAttachmentAnchors() ); + } else if (en[1].equals ("CursivePos")) { + GlyphCoverageTable ct = coverages.get ("main"); + if (ct == null) { + missingParameter (en, "coverages"); + } else if (stFormat == 1) { + subtableEntries.add (extractAttachmentAnchors()); } else { - unsupportedFormat ( en, stFormat ); + unsupportedFormat (en, stFormat); } - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_CURSIVE, ct ); - } else if ( en[1].equals ( "EntryExitRecord" ) ) { + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_CURSIVE, ct); + } else if (en[1].equals ("EntryExitRecord")) { int na = anchors.size(); - if ( na == 0 ) { - missingParameter ( en, "entry or exit anchor" ); - } else if ( na == 1 ) { - anchors.add ( null ); - } else if ( na > 2 ) { - duplicateParameter ( en, "entry or exit anchor" ); - } - attachmentAnchors.add ( extractAnchors() ); - } else if ( en[1].equals ( "BaseRecord" ) ) { - baseOrMarkAnchors.add ( extractAnchors() ); - } else if ( en[1].equals ( "FeatureRecord" ) ) { - if ( flIndex != flSequence ) { - mismatchedIndex ( en, "feature", flIndex, flSequence ); - } else if ( featureTag == null ) { - missingTag ( en, "feature" ); - } else { - String fid = makeFeatureId ( flIndex ); - features.put ( fid, extractFeature() ); + if (na == 0) { + missingParameter (en, "entry or exit anchor"); + } else if (na == 1) { + anchors.add (null); + } else if (na > 2) { + duplicateParameter (en, "entry or exit anchor"); + } + attachmentAnchors.add (extractAnchors()); + } else if (en[1].equals ("BaseRecord")) { + baseOrMarkAnchors.add (extractAnchors()); + } else if (en[1].equals ("FeatureRecord")) { + if (flIndex != flSequence) { + mismatchedIndex (en, "feature", flIndex, flSequence); + } else if (featureTag == null) { + missingTag (en, "feature"); + } else { + String fid = makeFeatureId (flIndex); + features.put (fid, extractFeature()); nextFeature(); } - } else if ( en[1].equals ( "GDEF" ) ) { - if ( subtables.size() > 0 ) { - gdef = new GlyphDefinitionTable ( subtables ); + } else if (en[1].equals ("GDEF")) { + if (subtables.size() > 0) { + gdef = new GlyphDefinitionTable (subtables); } clearTable(); - } else if ( en[1].equals ( "GPOS" ) ) { - if ( subtables.size() > 0 ) { - gpos = new GlyphPositioningTable ( gdef, extractLookups(), subtables ); + } else if (en[1].equals ("GPOS")) { + if (subtables.size() > 0) { + gpos = new GlyphPositioningTable (gdef, extractLookups(), subtables); } clearTable(); - } else if ( en[1].equals ( "GSUB" ) ) { - if ( subtables.size() > 0 ) { - gsub = new GlyphSubstitutionTable ( gdef, extractLookups(), subtables ); + } else if (en[1].equals ("GSUB")) { + if (subtables.size() > 0) { + gsub = new GlyphSubstitutionTable (gdef, extractLookups(), subtables); } clearTable(); - } else if ( en[1].equals ( "GlyphClassDef" ) ) { - GlyphMappingTable mapping = extractClassDefMapping ( glyphClasses, stFormat, true ); - addGDEFSubtable ( GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS, mapping ); - } else if ( en[1].equals ( "InputCoverage" ) ) { - String ck = makeCoverageKey ( "in", ctIndex ); - if ( coverages.containsKey ( ck ) ) { - duplicateCoverageIndex ( en, ctIndex ); - } else { - coverages.put ( ck, extractCoverage() ); - } - } else if ( en[1].equals ( "LigatureAttach" ) ) { - ligatureAnchors.add ( extractComponents() ); - } else if ( en[1].equals ( "LigatureCoverage" ) ) { - coverages.put ( "liga", extractCoverage() ); - } else if ( en[1].equals ( "LigatureSet" ) ) { - subtableEntries.add ( extractLigatures() ); - } else if ( en[1].equals ( "LigatureSubst" ) ) { - if ( ! sortEntries ( coverageEntries, subtableEntries ) ) { - mismatchedEntries ( en, coverageEntries.size(), subtableEntries.size() ); + } else if (en[1].equals ("GlyphClassDef")) { + GlyphMappingTable mapping = extractClassDefMapping (glyphClasses, stFormat, true); + addGDEFSubtable (GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS, mapping); + } else if (en[1].equals ("InputCoverage")) { + String ck = makeCoverageKey ("in", ctIndex); + if (coverages.containsKey (ck)) { + duplicateCoverageIndex (en, ctIndex); + } else { + coverages.put (ck, extractCoverage()); + } + } else if (en[1].equals ("LigatureAttach")) { + ligatureAnchors.add (extractComponents()); + } else if (en[1].equals ("LigatureCoverage")) { + coverages.put ("liga", extractCoverage()); + } else if (en[1].equals ("LigatureSet")) { + subtableEntries.add (extractLigatures()); + } else if (en[1].equals ("LigatureSubst")) { + if (! sortEntries (coverageEntries, subtableEntries)) { + mismatchedEntries (en, coverageEntries.size(), subtableEntries.size()); } GlyphCoverageTable coverage = extractCoverage(); - addGSUBSubtable ( GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_LIGATURE, coverage ); - } else if ( en[1].equals ( "LookAheadCoverage" ) ) { - String ck = makeCoverageKey ( "la", ctIndex ); - if ( coverages.containsKey ( ck ) ) { - duplicateCoverageIndex ( en, ctIndex ); + addGSUBSubtable (GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_LIGATURE, coverage); + } else if (en[1].equals ("LookAheadCoverage")) { + String ck = makeCoverageKey ("la", ctIndex); + if (coverages.containsKey (ck)) { + duplicateCoverageIndex (en, ctIndex); } else { - coverages.put ( ck, extractCoverage() ); + coverages.put (ck, extractCoverage()); } - } else if ( en[1].equals ( "Lookup" ) ) { - if ( ltIndex != ltSequence ) { - mismatchedIndex ( en, "lookup", ltIndex, ltSequence ); + } else if (en[1].equals ("Lookup")) { + if (ltIndex != ltSequence) { + mismatchedIndex (en, "lookup", ltIndex, ltSequence); } else { nextLookup(); } - } else if ( en[1].equals ( "MarkAttachClassDef" ) ) { - GlyphMappingTable mapping = extractClassDefMapping ( glyphClasses, stFormat, true ); - addGDEFSubtable ( GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT, mapping ); - } else if ( en[1].equals ( "MarkCoverage" ) ) { - coverages.put ( "mark", extractCoverage() ); - } else if ( en[1].equals ( "Mark1Coverage" ) ) { - coverages.put ( "mrk1", extractCoverage() ); - } else if ( en[1].equals ( "Mark2Coverage" ) ) { - coverages.put ( "mrk2", extractCoverage() ); - } else if ( en[1].equals ( "MarkBasePos" ) ) { - GlyphCoverageTable mct = coverages.get ( "mark" ); - GlyphCoverageTable bct = coverages.get ( "base" ); - if ( mct == null ) { - missingParameter ( en, "mark coverages" ); - } else if ( bct == null ) { - missingParameter ( en, "base coverages" ); - } else if ( stFormat == 1 ) { + } else if (en[1].equals ("MarkAttachClassDef")) { + GlyphMappingTable mapping = extractClassDefMapping (glyphClasses, stFormat, true); + addGDEFSubtable (GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT, mapping); + } else if (en[1].equals ("MarkCoverage")) { + coverages.put ("mark", extractCoverage()); + } else if (en[1].equals ("Mark1Coverage")) { + coverages.put ("mrk1", extractCoverage()); + } else if (en[1].equals ("Mark2Coverage")) { + coverages.put ("mrk2", extractCoverage()); + } else if (en[1].equals ("MarkBasePos")) { + GlyphCoverageTable mct = coverages.get ("mark"); + GlyphCoverageTable bct = coverages.get ("base"); + if (mct == null) { + missingParameter (en, "mark coverages"); + } else if (bct == null) { + missingParameter (en, "base coverages"); + } else if (stFormat == 1) { MarkAnchor[] maa = extractMarkAnchors(); Anchor[][] bam = extractBaseOrMarkAnchors(); - subtableEntries.add ( bct ); - subtableEntries.add ( computeClassCount ( bam ) ); - subtableEntries.add ( maa ); - subtableEntries.add ( bam ); - } else { - unsupportedFormat ( en, stFormat ); - } - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_BASE, mct ); - } else if ( en[1].equals ( "MarkLigPos" ) ) { - GlyphCoverageTable mct = coverages.get ( "mark" ); - GlyphCoverageTable lct = coverages.get ( "liga" ); - if ( mct == null ) { - missingParameter ( en, "mark coverages" ); - } else if ( lct == null ) { - missingParameter ( en, "ligature coverages" ); - } else if ( stFormat == 1 ) { + subtableEntries.add (bct); + subtableEntries.add (computeClassCount (bam)); + subtableEntries.add (maa); + subtableEntries.add (bam); + } else { + unsupportedFormat (en, stFormat); + } + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_BASE, mct); + } else if (en[1].equals ("MarkLigPos")) { + GlyphCoverageTable mct = coverages.get ("mark"); + GlyphCoverageTable lct = coverages.get ("liga"); + if (mct == null) { + missingParameter (en, "mark coverages"); + } else if (lct == null) { + missingParameter (en, "ligature coverages"); + } else if (stFormat == 1) { MarkAnchor[] maa = extractMarkAnchors(); Anchor[][][] lam = extractLigatureAnchors(); - subtableEntries.add ( lct ); - subtableEntries.add ( computeLigaturesClassCount ( lam ) ); - subtableEntries.add ( computeLigaturesComponentCount ( lam ) ); - subtableEntries.add ( maa ); - subtableEntries.add ( lam ); - } else { - unsupportedFormat ( en, stFormat ); - } - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE, mct ); - } else if ( en[1].equals ( "MarkMarkPos" ) ) { - GlyphCoverageTable mct1 = coverages.get ( "mrk1" ); - GlyphCoverageTable mct2 = coverages.get ( "mrk2" ); - if ( mct1 == null ) { - missingParameter ( en, "mark coverages 1" ); - } else if ( mct2 == null ) { - missingParameter ( en, "mark coverages 2" ); - } else if ( stFormat == 1 ) { + subtableEntries.add (lct); + subtableEntries.add (computeLigaturesClassCount (lam)); + subtableEntries.add (computeLigaturesComponentCount (lam)); + subtableEntries.add (maa); + subtableEntries.add (lam); + } else { + unsupportedFormat (en, stFormat); + } + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE, mct); + } else if (en[1].equals ("MarkMarkPos")) { + GlyphCoverageTable mct1 = coverages.get ("mrk1"); + GlyphCoverageTable mct2 = coverages.get ("mrk2"); + if (mct1 == null) { + missingParameter (en, "mark coverages 1"); + } else if (mct2 == null) { + missingParameter (en, "mark coverages 2"); + } else if (stFormat == 1) { MarkAnchor[] maa = extractMarkAnchors(); Anchor[][] mam = extractBaseOrMarkAnchors(); - subtableEntries.add ( mct2 ); - subtableEntries.add ( computeClassCount ( mam ) ); - subtableEntries.add ( maa ); - subtableEntries.add ( mam ); - } else { - unsupportedFormat ( en, stFormat ); - } - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_MARK, mct1 ); - } else if ( en[1].equals ( "MarkRecord" ) ) { - if ( markClass == -1 ) { - missingParameter ( en, "mark class" ); - } else if ( anchors.size() == 0 ) { - missingParameter ( en, "mark anchor" ); - } else if ( anchors.size() > 1 ) { - duplicateParameter ( en, "mark anchor" ); - } else { - markAnchors.add ( new GlyphPositioningTable.MarkAnchor ( markClass, anchors.get(0) ) ); + subtableEntries.add (mct2); + subtableEntries.add (computeClassCount (mam)); + subtableEntries.add (maa); + subtableEntries.add (mam); + } else { + unsupportedFormat (en, stFormat); + } + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_MARK, mct1); + } else if (en[1].equals ("MarkRecord")) { + if (markClass == -1) { + missingParameter (en, "mark class"); + } else if (anchors.size() == 0) { + missingParameter (en, "mark anchor"); + } else if (anchors.size() > 1) { + duplicateParameter (en, "mark anchor"); + } else { + markAnchors.add (new GlyphPositioningTable.MarkAnchor (markClass, anchors.get(0))); markClass = -1; anchors.clear(); } - } else if ( en[1].equals ( "Mark2Record" ) ) { - baseOrMarkAnchors.add ( extractAnchors() ); - } else if ( en[1].equals ( "MultipleSubst" ) ) { - GlyphCoverageTable coverage = coverages.get ( "main" ); - addGSUBSubtable ( GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_MULTIPLE, coverage, extractSequenceEntries() ); - } else if ( en[1].equals ( "PairPos" ) ) { + } else if (en[1].equals ("Mark2Record")) { + baseOrMarkAnchors.add (extractAnchors()); + } else if (en[1].equals ("MultipleSubst")) { + GlyphCoverageTable coverage = coverages.get ("main"); + addGSUBSubtable (GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_MULTIPLE, coverage, extractSequenceEntries()); + } else if (en[1].equals ("PairPos")) { assertSubtableEntriesClear(); - if ( stFormat == 1 ) { - if ( pairSets.size() == 0 ) { - missingParameter ( en, "pair set" ); + if (stFormat == 1) { + if (pairSets.size() == 0) { + missingParameter (en, "pair set"); } else { - subtableEntries.add ( extractPairSets() ); + subtableEntries.add (extractPairSets()); } - } else if ( stFormat == 2 ) { - unsupportedFormat ( en, stFormat ); + } else if (stFormat == 2) { + unsupportedFormat (en, stFormat); } - GlyphCoverageTable coverage = coverages.get ( "main" ); - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage ); + GlyphCoverageTable coverage = coverages.get ("main"); + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage); vf1 = vf2 = -1; psIndex = -1; - } else if ( en[1].equals ( "PairSet" ) ) { - if ( psIndex != pairSets.size() ) { - invalidIndex ( en, psIndex, pairSets.size() ); + } else if (en[1].equals ("PairSet")) { + if (psIndex != pairSets.size()) { + invalidIndex (en, psIndex, pairSets.size()); } else { - pairSets.add ( extractPairs() ); + pairSets.add (extractPairs()); } - } else if ( en[1].equals ( "PairValueRecord" ) ) { - if ( g2 == -1 ) { - missingParameter ( en, "second glyph" ); - } else if ( ( v1 == null ) && ( v2 == null ) ) { - missingParameter ( en, "first or second value" ); + } else if (en[1].equals ("PairValueRecord")) { + if (g2 == -1) { + missingParameter (en, "second glyph"); + } else if ((v1 == null) && (v2 == null)) { + missingParameter (en, "first or second value"); } else { - pairs.add ( new PairValues ( g2, v1, v2 ) ); + pairs.add (new PairValues (g2, v1, v2)); clearPair(); } - } else if ( en[1].equals ( "PosLookupRecord" ) || en[1].equals ( "SubstLookupRecord" ) ) { - if ( rlSequence < 0 ) { - missingParameter ( en, "sequence index" ); - } else if ( rlLookup < 0 ) { - missingParameter ( en, "lookup index" ); + } else if (en[1].equals ("PosLookupRecord") || en[1].equals ("SubstLookupRecord")) { + if (rlSequence < 0) { + missingParameter (en, "sequence index"); + } else if (rlLookup < 0) { + missingParameter (en, "lookup index"); } else { - ruleLookups.add ( new GlyphTable.RuleLookup ( rlSequence, rlLookup ) ); + ruleLookups.add (new GlyphTable.RuleLookup (rlSequence, rlLookup)); rlSequence = rlLookup = -1; } - } else if ( en[1].equals ( "Script" ) ) { - if ( scriptTag == null ) { - missingTag ( en, "script" ); - } else if ( scripts.containsKey ( scriptTag ) ) { - duplicateTag ( en, "script", scriptTag ); + } else if (en[1].equals ("Script")) { + if (scriptTag == null) { + missingTag (en, "script"); + } else if (scripts.containsKey (scriptTag)) { + duplicateTag (en, "script", scriptTag); } else { - scripts.put ( scriptTag, extractLanguages() ); + scripts.put (scriptTag, extractLanguages()); scriptTag = null; } - } else if ( en[1].equals ( "Sequence" ) ) { - subtableEntries.add ( extractSubstitutes() ); - } else if ( en[1].equals ( "SinglePos" ) ) { + } else if (en[1].equals ("Sequence")) { + subtableEntries.add (extractSubstitutes()); + } else if (en[1].equals ("SinglePos")) { int nv = subtableEntries.size(); - if ( stFormat == 1 ) { - if ( nv < 0 ) { - missingParameter ( en, "value" ); - } else if ( nv > 1 ) { - duplicateParameter ( en, "value" ); - } - } else if ( stFormat == 2 ) { - GlyphPositioningTable.Value[] pva = (GlyphPositioningTable.Value[]) subtableEntries.toArray ( new GlyphPositioningTable.Value [ nv ] ); + if (stFormat == 1) { + if (nv < 0) { + missingParameter (en, "value"); + } else if (nv > 1) { + duplicateParameter (en, "value"); + } + } else if (stFormat == 2) { + GlyphPositioningTable.Value[] pva = (GlyphPositioningTable.Value[]) subtableEntries.toArray (new GlyphPositioningTable.Value [ nv ]); subtableEntries.clear(); - subtableEntries.add ( pva ); + subtableEntries.add (pva); } - GlyphCoverageTable coverage = coverages.get ( "main" ); - addGPOSSubtable ( GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage ); + GlyphCoverageTable coverage = coverages.get ("main"); + addGPOSSubtable (GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage); vf1 = -1; - } else if ( en[1].equals ( "SingleSubst" ) ) { - if ( ! sortEntries ( coverageEntries, subtableEntries ) ) { - mismatchedEntries ( en, coverageEntries.size(), subtableEntries.size() ); + } else if (en[1].equals ("SingleSubst")) { + if (! sortEntries (coverageEntries, subtableEntries)) { + mismatchedEntries (en, coverageEntries.size(), subtableEntries.size()); } GlyphCoverageTable coverage = extractCoverage(); - addGSUBSubtable ( GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_SINGLE, coverage ); - } else if ( en[1].equals ( "cmap" ) ) { + addGSUBSubtable (GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_SINGLE, coverage); + } else if (en[1].equals ("cmap")) { cmap = getCMAP(); gmap = getGMAP(); cmapEntries.clear(); - } else if ( en[1].equals ( "cmap_format_4" ) ) { + } else if (en[1].equals ("cmap_format_4")) { cmPlatform = cmEncoding = cmLanguage = -1; - } else if ( en[1].equals ( "hmtx" ) ) { + } else if (en[1].equals ("hmtx")) { hmtx = getHMTX(); hmtxEntries.clear(); - } else if ( en[1].equals ( "ttFont" ) ) { - if ( cmap == null ) { - missingParameter ( en, "cmap" ); + } else if (en[1].equals ("ttFont")) { + if (cmap == null) { + missingParameter (en, "cmap"); } - if ( hmtx == null ) { - missingParameter ( en, "hmtx" ); + if (hmtx == null) { + missingParameter (en, "hmtx"); } } elements.pop(); } @Override - public void characters ( char[] chars, int start, int length ) { + public void characters (char[] chars, int start, int length) { } private String[] getParent() { - if ( ! elements.empty() ) { + if (! elements.empty()) { return elements.peek(); } else { return new String[] { null, null }; } } - private boolean isParent ( Object enx ) { - if ( enx instanceof String[][] ) { - for ( String[] en : (String[][]) enx ) { - if ( isParent ( en ) ) { + private boolean isParent (Object enx) { + if (enx instanceof String[][]) { + for (String[] en : (String[][]) enx) { + if (isParent (en)) { return true; } } return false; - } else if ( enx instanceof String[] ) { + } else if (enx instanceof String[]) { String[] en = (String[]) enx; - if ( ! elements.empty() ) { + if (! elements.empty()) { String[] pn = elements.peek(); - return ( pn != null ) && sameExpandedName ( en, pn ); - } else if ( ( en[0] == null ) && ( en[1] == null ) ) { + return (pn != null) && sameExpandedName (en, pn); + } else if ((en[0] == null) && (en[1] == null)) { return true; } else { return false; @@ -2586,18 +2586,18 @@ public class TTXFile { return false; } } - private boolean isAnchorElement ( String ln ) { - if ( ln.equals ( "BaseAnchor" ) ) { + private boolean isAnchorElement (String ln) { + if (ln.equals ("BaseAnchor")) { return true; - } else if ( ln.equals ( "EntryAnchor" ) ) { + } else if (ln.equals ("EntryAnchor")) { return true; - } else if ( ln.equals ( "ExitAnchor" ) ) { + } else if (ln.equals ("ExitAnchor")) { return true; - } else if ( ln.equals ( "LigatureAnchor" ) ) { + } else if (ln.equals ("LigatureAnchor")) { return true; - } else if ( ln.equals ( "MarkAnchor" ) ) { + } else if (ln.equals ("MarkAnchor")) { return true; - } else if ( ln.equals ( "Mark2Anchor" ) ) { + } else if (ln.equals ("Mark2Anchor")) { return true; } else { return false; @@ -2605,79 +2605,79 @@ public class TTXFile { } private Map getCMAP() { Map cmap = new TreeMap(); - for ( int[] cme : cmapEntries ) { - Integer c = Integer.valueOf ( cme[0] ); - Integer g = Integer.valueOf ( cme[1] ); - cmap.put ( c, g ); + for (int[] cme : cmapEntries) { + Integer c = Integer.valueOf (cme[0]); + Integer g = Integer.valueOf (cme[1]); + cmap.put (c, g); } return cmap; } private Map getGMAP() { Map gmap = new TreeMap(); - for ( int[] cme : cmapEntries ) { - Integer c = Integer.valueOf ( cme[0] ); - Integer g = Integer.valueOf ( cme[1] ); - gmap.put ( g, c ); + for (int[] cme : cmapEntries) { + Integer c = Integer.valueOf (cme[0]); + Integer g = Integer.valueOf (cme[1]); + gmap.put (g, c); } return gmap; } private int[][] getHMTX() { int ne = hmtxEntries.size(); int[][] hmtx = new int [ ne ] [ 2 ]; - for ( int i = 0; i < ne; i++ ) { + for (int i = 0; i < ne; i++) { int[] ea = hmtxEntries.get(i); - if ( ea != null ) { + if (ea != null) { hmtx [ i ] [ 0 ] = ea[0]; hmtx [ i ] [ 1 ] = ea[1]; } } return hmtx; } - private GlyphClassTable extractClassDefMapping ( Map glyphClasses, int format, boolean clearSourceMap ) { + private GlyphClassTable extractClassDefMapping (Map glyphClasses, int format, boolean clearSourceMap) { GlyphClassTable ct; - if ( format == 1 ) { - ct = extractClassDefMapping1 ( extractClassMappings ( glyphClasses, clearSourceMap ) ); - } else if ( format == 2 ) { - ct = extractClassDefMapping2 ( extractClassMappings ( glyphClasses, clearSourceMap ) ); + if (format == 1) { + ct = extractClassDefMapping1 (extractClassMappings (glyphClasses, clearSourceMap)); + } else if (format == 2) { + ct = extractClassDefMapping2 (extractClassMappings (glyphClasses, clearSourceMap)); } else { ct = null; } return ct; } - private GlyphClassTable extractClassDefMapping1 ( int[][] cma ) { + private GlyphClassTable extractClassDefMapping1 (int[][] cma) { List entries = new ArrayList(); int s = -1; int l = -1; Integer zero = Integer.valueOf(0); - for ( int[] m : cma ) { + for (int[] m : cma) { int g = m[0]; int c = m[1]; - if ( s < 0 ) { + if (s < 0) { s = g; l = g - 1; - entries.add ( Integer.valueOf ( s ) ); + entries.add (Integer.valueOf (s)); } - while ( g > ( l + 1 ) ) { - entries.add ( zero ); + while (g > (l + 1)) { + entries.add (zero); l++; } - assert l == ( g - 1 ); - entries.add ( Integer.valueOf ( c ) ); + assert l == (g - 1); + entries.add (Integer.valueOf (c)); l = g; } - return GlyphClassTable.createClassTable ( entries ); + return GlyphClassTable.createClassTable (entries); } - private GlyphClassTable extractClassDefMapping2 ( int[][] cma ) { + private GlyphClassTable extractClassDefMapping2 (int[][] cma) { List entries = new ArrayList(); int s = -1; int e = s; int l = -1; - for ( int[] m : cma ) { + for (int[] m : cma) { int g = m[0]; int c = m[1]; - if ( c != l ) { - if ( s >= 0 ) { - entries.add ( new GlyphClassTable.MappingRange ( s, e, l ) ); + if (c != l) { + if (s >= 0) { + entries.add (new GlyphClassTable.MappingRange (s, e, l)); } s = e = g; } else { @@ -2685,33 +2685,33 @@ public class TTXFile { } l = c; } - return GlyphClassTable.createClassTable ( entries ); + return GlyphClassTable.createClassTable (entries); } - private int[][] extractClassMappings ( Map glyphClasses, boolean clearSourceMap ) { + private int[][] extractClassMappings (Map glyphClasses, boolean clearSourceMap) { int nc = glyphClasses.size(); int i = 0; int[][] cma = new int [ nc ] [ 2 ]; - for ( Map.Entry e : glyphClasses.entrySet() ) { - Integer gid = glyphIds.get ( e.getKey() ); + for (Map.Entry e : glyphClasses.entrySet()) { + Integer gid = glyphIds.get (e.getKey()); assert gid != null; int[] m = cma [ i ]; m [ 0 ] = (int) gid; m [ 1 ] = (int) e.getValue(); i++; } - if ( clearSourceMap ) { + if (clearSourceMap) { glyphClasses.clear(); } - return sortClassMappings ( cma ); + return sortClassMappings (cma); } - private int[][] sortClassMappings ( int[][] cma ) { - Arrays.sort ( cma, new Comparator() { - public int compare ( int[] m1, int[] m2 ) { + private int[][] sortClassMappings (int[][] cma) { + Arrays.sort (cma, new Comparator() { + public int compare (int[] m1, int[] m2) { assert m1.length > 0; assert m2.length > 0; - if ( m1[0] < m2[0] ) { + if (m1[0] < m2[0]) { return -1; - } else if ( m1[0] > m2[0] ) { + } else if (m1[0] > m2[0]) { return 1; } else { return 0; @@ -2722,25 +2722,25 @@ public class TTXFile { return cma; } // sort coverage entries and subtable entries together - private boolean sortEntries ( List cel, List sel ) { + private boolean sortEntries (List cel, List sel) { assert cel != null; assert sel != null; - if ( cel.size() == sel.size() ) { + if (cel.size() == sel.size()) { int np = cel.size(); Object[][] pa = new Object [ np ] [ 2 ]; - for ( int i = 0; i < np; i++ ) { - pa [ i ] [ 0 ] = cel.get ( i ); - pa [ i ] [ 1 ] = sel.get ( i ); + for (int i = 0; i < np; i++) { + pa [ i ] [ 0 ] = cel.get (i); + pa [ i ] [ 1 ] = sel.get (i); } - Arrays.sort ( pa, new Comparator() { - public int compare ( Object[] p1, Object[] p2 ) { + Arrays.sort (pa, new Comparator() { + public int compare (Object[] p1, Object[] p2) { assert p1.length == 2; assert p2.length == 2; int c1 = (Integer) p1[0]; int c2 = (Integer) p2[0]; - if ( c1 < c2 ) { + if (c1 < c2) { return -1; - } else if ( c1 > c2 ) { + } else if (c1 > c2) { return 1; } else { return 0; @@ -2750,9 +2750,9 @@ public class TTXFile { ); cel.clear(); sel.clear(); - for ( int i = 0; i < np; i++ ) { - cel.add ( pa [ i ] [ 0 ] ); - sel.add ( pa [ i ] [ 1 ] ); + for (int i = 0; i < np; i++) { + cel.add (pa [ i ] [ 0 ]); + sel.add (pa [ i ] [ 1 ]); } assert cel.size() == sel.size(); return true; @@ -2760,14 +2760,14 @@ public class TTXFile { return false; } } - private String makeCoverageKey ( String prefix, int index ) { + private String makeCoverageKey (String prefix, int index) { assert prefix != null; assert prefix.length() == 2; assert index < 100; - return prefix + CharUtilities.padLeft ( Integer.toString ( index, 10 ), 2, '0' ); + return prefix + CharUtilities.padLeft (Integer.toString (index, 10), 2, '0'); } private List extractCoverageEntries() { - List entries = new ArrayList ( coverageEntries ); + List entries = new ArrayList (coverageEntries); clearCoverage(); return entries; } @@ -2780,9 +2780,9 @@ public class TTXFile { assert coverageEntries.size() == 0; } private GlyphCoverageTable extractCoverage() { - assert ( ctFormat == 1 ) || ( ctFormat == 2 ); + assert (ctFormat == 1) || (ctFormat == 2); assert ctIndex >= 0; - GlyphCoverageTable coverage = GlyphCoverageTable.createCoverageTable ( extractCoverageEntries() ); + GlyphCoverageTable coverage = GlyphCoverageTable.createCoverageTable (extractCoverageEntries()); clearCoverage(); return coverage; } @@ -2802,45 +2802,45 @@ public class TTXFile { private void assertCoveragesClear() { assert coverages.size() == 0; } - private GlyphCoverageTable[] getCoveragesWithPrefix ( String prefix ) { + private GlyphCoverageTable[] getCoveragesWithPrefix (String prefix) { assert prefix != null; int prefixLength = prefix.length(); Set keys = coverages.keySet(); int mi = -1; // maximum coverage table index - for ( String k : keys ) { - if ( k.startsWith ( prefix ) ) { - int i = Integer.parseInt ( k.substring ( prefixLength ) ); - if ( i > mi ) { + for (String k : keys) { + if (k.startsWith (prefix)) { + int i = Integer.parseInt (k.substring (prefixLength)); + if (i > mi) { mi = i; } } } GlyphCoverageTable[] gca = new GlyphCoverageTable [ mi + 1 ]; - for ( String k : keys ) { - if ( k.startsWith ( prefix ) ) { - int i = Integer.parseInt ( k.substring ( prefixLength ) ); - if ( i >= 0 ) { - gca [ i ] = coverages.get ( k ); + for (String k : keys) { + if (k.startsWith (prefix)) { + int i = Integer.parseInt (k.substring (prefixLength)); + if (i >= 0) { + gca [ i ] = coverages.get (k); } } } return gca; } - private boolean hasMissingCoverage ( GlyphCoverageTable[] gca ) { + private boolean hasMissingCoverage (GlyphCoverageTable[] gca) { assert gca != null; int nc = 0; - for ( int i = 0, n = gca.length; i < n; i++ ) { - if ( gca [ i ] != null ) { + for (int i = 0, n = gca.length; i < n; i++) { + if (gca [ i ] != null) { nc++; } } return nc != gca.length; } - private String makeFeatureId ( int fid ) { + private String makeFeatureId (int fid) { assert fid >= 0; return "f" + fid; } - private String makeLookupId ( int lid ) { + private String makeLookupId (int lid) { assert lid >= 0; return "lu" + lid; } @@ -2859,7 +2859,7 @@ public class TTXFile { languageFeatures.clear(); } private Map> extractLanguages() { - Map> lm = new HashMap ( languages ); + Map> lm = new HashMap (languages); clearLanguages(); return lm; } @@ -2870,7 +2870,7 @@ public class TTXFile { assert featureLookups.size() == 0; } private List extractFeatureLookups() { - List lookups = new ArrayList ( featureLookups ); + List lookups = new ArrayList (featureLookups); clearFeatureLookups(); return lookups; } @@ -2927,22 +2927,22 @@ public class TTXFile { } private Map> extractLookups() { Map> lookups = new LinkedHashMap>(); - for ( String st : scripts.keySet() ) { - Map> lm = scripts.get ( st ); - if ( lm != null ) { - for ( String lt : lm.keySet() ) { - List fids = lm.get ( lt ); - if ( fids != null ) { - for ( String fid : fids ) { - if ( fid != null ) { - Object[] fa = features.get ( fid ); - if ( fa != null ) { + for (String st : scripts.keySet()) { + Map> lm = scripts.get (st); + if (lm != null) { + for (String lt : lm.keySet()) { + List fids = lm.get (lt); + if (fids != null) { + for (String fid : fids) { + if (fid != null) { + Object[] fa = features.get (fid); + if (fa != null) { assert fa.length == 2; String ft = (String) fa[0]; List lids = (List) fa[1]; - if ( ( lids != null ) && ( lids.size() > 0 ) ) { - GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec ( st, lt, ft ); - lookups.put ( ls, lids ); + if ((lids != null) && (lids.size() > 0)) { + GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec (st, lt, ft); + lookups.put (ls, lids); } } } @@ -2984,14 +2984,14 @@ public class TTXFile { assert subtableEntries.size() == 0; } private List extractSubtableEntries() { - List entries = new ArrayList ( subtableEntries ); + List entries = new ArrayList (subtableEntries); clearSubtableEntries(); return entries; } private int[] extractAlternates() { int[] aa = new int [ alternates.size() ]; int i = 0; - for ( Integer a : alternates ) { + for (Integer a : alternates) { aa[i++] = (int) a; } clearAlternates(); @@ -3001,7 +3001,7 @@ public class TTXFile { alternates.clear(); } private LigatureSet extractLigatures() { - LigatureSet ls = new LigatureSet ( ligatures ); + LigatureSet ls = new LigatureSet (ligatures); clearLigatures(); return ls; } @@ -3011,7 +3011,7 @@ public class TTXFile { private int[] extractSubstitutes() { int[] aa = new int [ substitutes.size() ]; int i = 0; - for ( Integer a : substitutes ) { + for (Integer a : substitutes) { aa[i++] = (int) a; } clearSubstitutes(); @@ -3024,53 +3024,53 @@ public class TTXFile { List sequences = extractSubtableEntries(); int[][] sa = new int [ sequences.size() ] []; int i = 0; - for ( Object s : sequences ) { - if ( s instanceof int[] ) { + for (Object s : sequences) { + if (s instanceof int[]) { sa[i++] = (int[]) s; } } List entries = new ArrayList(); - entries.add ( sa ); + entries.add (sa); return entries; } private RuleLookup[] extractRuleLookups() { - RuleLookup[] lookups = (RuleLookup[]) ruleLookups.toArray ( new RuleLookup [ ruleLookups.size() ] ); + RuleLookup[] lookups = (RuleLookup[]) ruleLookups.toArray (new RuleLookup [ ruleLookups.size() ]); clearRuleLookups(); return lookups; } private void clearRuleLookups() { ruleLookups.clear(); } - private GlyphPositioningTable.Value parseValue ( String[] en, Attributes attrs, int format ) throws SAXException { - String xPlacement = attrs.getValue ( "XPlacement" ); + private GlyphPositioningTable.Value parseValue (String[] en, Attributes attrs, int format) throws SAXException { + String xPlacement = attrs.getValue ("XPlacement"); int xp = 0; - if ( xPlacement != null ) { - xp = Integer.parseInt ( xPlacement ); - } else if ( ( format & GlyphPositioningTable.Value.X_PLACEMENT ) != 0 ) { - missingParameter ( en, "xPlacement" ); + if (xPlacement != null) { + xp = Integer.parseInt (xPlacement); + } else if ((format & GlyphPositioningTable.Value.X_PLACEMENT) != 0) { + missingParameter (en, "xPlacement"); } - String yPlacement = attrs.getValue ( "YPlacement" ); + String yPlacement = attrs.getValue ("YPlacement"); int yp = 0; - if ( yPlacement != null ) { - yp = Integer.parseInt ( yPlacement ); - } else if ( ( format & GlyphPositioningTable.Value.Y_PLACEMENT ) != 0 ) { - missingParameter ( en, "yPlacement" ); + if (yPlacement != null) { + yp = Integer.parseInt (yPlacement); + } else if ((format & GlyphPositioningTable.Value.Y_PLACEMENT) != 0) { + missingParameter (en, "yPlacement"); } - String xAdvance = attrs.getValue ( "XAdvance" ); + String xAdvance = attrs.getValue ("XAdvance"); int xa = 0; - if ( xAdvance != null ) { - xa = Integer.parseInt ( xAdvance ); - } else if ( ( format & GlyphPositioningTable.Value.X_ADVANCE ) != 0 ) { - missingParameter ( en, "xAdvance" ); + if (xAdvance != null) { + xa = Integer.parseInt (xAdvance); + } else if ((format & GlyphPositioningTable.Value.X_ADVANCE) != 0) { + missingParameter (en, "xAdvance"); } - String yAdvance = attrs.getValue ( "YAdvance" ); + String yAdvance = attrs.getValue ("YAdvance"); int ya = 0;; - if ( yAdvance != null ) { - ya = Integer.parseInt ( yAdvance ); - } else if ( ( format & GlyphPositioningTable.Value.Y_ADVANCE ) != 0 ) { - missingParameter ( en, "yAdvance" ); + if (yAdvance != null) { + ya = Integer.parseInt (yAdvance); + } else if ((format & GlyphPositioningTable.Value.Y_ADVANCE) != 0) { + missingParameter (en, "yAdvance"); } - return new GlyphPositioningTable.Value ( xp, yp, xa, ya, null, null, null, null ); + return new GlyphPositioningTable.Value (xp, yp, xa, ya, null, null, null, null); } private void assertPairClear() { assert g2 == -1; @@ -3090,7 +3090,7 @@ public class TTXFile { psIndex = -1; } private PairValues[] extractPairs() { - PairValues[] pva = (PairValues[]) pairs.toArray ( new PairValues [ pairs.size() ] ); + PairValues[] pva = (PairValues[]) pairs.toArray (new PairValues [ pairs.size() ]); clearPairs(); return pva; } @@ -3101,38 +3101,38 @@ public class TTXFile { pairSets.clear(); } private PairValues[][] extractPairSets() { - PairValues[][] pvm = (PairValues[][]) pairSets.toArray ( new PairValues [ pairSets.size() ][] ); + PairValues[][] pvm = (PairValues[][]) pairSets.toArray (new PairValues [ pairSets.size() ][]); clearPairSets(); return pvm; } private Anchor[] extractAnchors() { - Anchor[] aa = (Anchor[]) anchors.toArray ( new Anchor [ anchors.size() ] ); + Anchor[] aa = (Anchor[]) anchors.toArray (new Anchor [ anchors.size() ]); anchors.clear(); return aa; } private MarkAnchor[] extractMarkAnchors() { MarkAnchor[] maa = new MarkAnchor [ markAnchors.size() ]; - maa = (MarkAnchor[]) markAnchors.toArray ( new MarkAnchor [ maa.length ] ); + maa = (MarkAnchor[]) markAnchors.toArray (new MarkAnchor [ maa.length ]); markAnchors.clear(); return maa; } private Anchor[][] extractBaseOrMarkAnchors() { int na = baseOrMarkAnchors.size(); int ncMax = 0; - for ( Anchor[] aa : baseOrMarkAnchors ) { - if ( aa != null ) { + for (Anchor[] aa : baseOrMarkAnchors) { + if (aa != null) { int nc = aa.length; - if ( nc > ncMax ) { + if (nc > ncMax) { ncMax = nc; } } } Anchor[][] am = new Anchor [ na ][ ncMax ]; - for ( int i = 0; i < na; i++ ) { + for (int i = 0; i < na; i++) { Anchor[] aa = baseOrMarkAnchors.get(i); - if ( aa != null ) { - for ( int j = 0; j < ncMax; j++ ) { - if ( j < aa.length ) { + if (aa != null) { + for (int j = 0; j < ncMax; j++) { + if (j < aa.length) { am [ i ] [ j ] = aa [ j ]; } } @@ -3141,22 +3141,22 @@ public class TTXFile { baseOrMarkAnchors.clear(); return am; } - private Integer computeClassCount ( Anchor[][] am ) { + private Integer computeClassCount (Anchor[][] am) { int ncMax = 0; - for ( int i = 0, n = am.length; i < n; i++ ) { + for (int i = 0, n = am.length; i < n; i++) { Anchor[] aa = am [ i ]; - if ( aa != null ) { + if (aa != null) { int nc = aa.length; - if ( nc > ncMax ) { + if (nc > ncMax) { ncMax = nc; } } } - return Integer.valueOf ( ncMax ); + return Integer.valueOf (ncMax); } private Anchor[][] extractComponents() { Anchor[][] cam = new Anchor [ components.size() ][]; - cam = (Anchor[][]) components.toArray ( new Anchor [ cam.length ][] ); + cam = (Anchor[][]) components.toArray (new Anchor [ cam.length ][]); components.clear(); return cam; } @@ -3164,16 +3164,16 @@ public class TTXFile { int na = ligatureAnchors.size(); int ncMax = 0; int nxMax = 0; - for ( Anchor[][] cm : ligatureAnchors ) { - if ( cm != null ) { + for (Anchor[][] cm : ligatureAnchors) { + if (cm != null) { int nx = cm.length; - if ( nx > nxMax ) { + if (nx > nxMax) { nxMax = nx; } - for ( Anchor[] aa : cm ) { - if ( aa != null ) { + for (Anchor[] aa : cm) { + if (aa != null) { int nc = aa.length; - if ( nc > ncMax ) { + if (nc > ncMax) { ncMax = nc; } } @@ -3182,15 +3182,15 @@ public class TTXFile { } } Anchor[][][] lam = new Anchor [ na ] [ nxMax ] [ ncMax ]; - for ( int i = 0; i < na; i++ ) { + for (int i = 0; i < na; i++) { Anchor[][] cm = ligatureAnchors.get(i); - if ( cm != null ) { - for ( int j = 0; j < nxMax; j++ ) { - if ( j < cm.length ) { + if (cm != null) { + for (int j = 0; j < nxMax; j++) { + if (j < cm.length) { Anchor[] aa = cm [ j ]; - if ( aa != null ) { - for ( int k = 0; k < ncMax; k++ ) { - if ( k < aa.length ) { + if (aa != null) { + for (int k = 0; k < ncMax; k++) { + if (k < aa.length) { lam [ i ] [ j ] [ k ] = aa [ k ]; } } @@ -3202,15 +3202,15 @@ public class TTXFile { ligatureAnchors.clear(); return lam; } - private Integer computeLigaturesClassCount ( Anchor[][][] lam ) { + private Integer computeLigaturesClassCount (Anchor[][][] lam) { int ncMax = 0; - if ( lam != null ) { - for ( Anchor[][] cm : lam ) { - if ( cm != null ) { - for ( Anchor[] aa : cm ) { - if ( aa != null ) { + if (lam != null) { + for (Anchor[][] cm : lam) { + if (cm != null) { + for (Anchor[] aa : cm) { + if (aa != null) { int nc = aa.length;; - if ( nc > ncMax ) { + if (nc > ncMax) { ncMax = nc; } } @@ -3218,91 +3218,91 @@ public class TTXFile { } } } - return Integer.valueOf ( ncMax ); + return Integer.valueOf (ncMax); } - private Integer computeLigaturesComponentCount ( Anchor[][][] lam ) { + private Integer computeLigaturesComponentCount (Anchor[][][] lam) { int nxMax = 0; - if ( lam != null ) { - for ( Anchor[][] cm : lam ) { - if ( cm != null ) { + if (lam != null) { + for (Anchor[][] cm : lam) { + if (cm != null) { int nx = cm.length;; - if ( nx > nxMax ) { + if (nx > nxMax) { nxMax = nx; } } } } - return Integer.valueOf ( nxMax ); + return Integer.valueOf (nxMax); } private Anchor[] extractAttachmentAnchors() { int na = attachmentAnchors.size(); Anchor[] aa = new Anchor [ na * 2 ]; - for ( int i = 0; i < na; i++ ) { + for (int i = 0; i < na; i++) { Anchor[] ea = attachmentAnchors.get(i); int ne = ea.length; - if ( ne > 0 ) { - aa [ ( i * 2 ) + 0 ] = ea[0]; + if (ne > 0) { + aa [ (i * 2) + 0 ] = ea[0]; } - if ( ne > 1 ) { - aa [ ( i * 2 ) + 1 ] = ea[1]; + if (ne > 1) { + aa [ (i * 2) + 1 ] = ea[1]; } } attachmentAnchors.clear(); return aa; } - private void addGDEFSubtable ( int stType, GlyphMappingTable mapping ) { - subtables.add ( GlyphDefinitionTable.createSubtable ( stType, makeLookupId ( ltSequence ), stSequence, ltFlags, stFormat, mapping, extractSubtableEntries() ) ); + private void addGDEFSubtable (int stType, GlyphMappingTable mapping) { + subtables.add (GlyphDefinitionTable.createSubtable (stType, makeLookupId (ltSequence), stSequence, ltFlags, stFormat, mapping, extractSubtableEntries())); nextSubtableInLookup(); } - private void addGSUBSubtable ( int stType, GlyphCoverageTable coverage, List entries ) { - subtables.add ( GlyphSubstitutionTable.createSubtable ( stType, makeLookupId ( ltSequence ), stSequence, ltFlags, stFormat, coverage, entries ) ); + private void addGSUBSubtable (int stType, GlyphCoverageTable coverage, List entries) { + subtables.add (GlyphSubstitutionTable.createSubtable (stType, makeLookupId (ltSequence), stSequence, ltFlags, stFormat, coverage, entries)); nextSubtableInLookup(); } - private void addGSUBSubtable ( int stType, GlyphCoverageTable coverage ) { - addGSUBSubtable ( stType, coverage, extractSubtableEntries() ); + private void addGSUBSubtable (int stType, GlyphCoverageTable coverage) { + addGSUBSubtable (stType, coverage, extractSubtableEntries()); } - private void addGPOSSubtable ( int stType, GlyphCoverageTable coverage, List entries ) { - subtables.add ( GlyphPositioningTable.createSubtable ( stType, makeLookupId ( ltSequence ), stSequence, ltFlags, stFormat, coverage, entries ) ); + private void addGPOSSubtable (int stType, GlyphCoverageTable coverage, List entries) { + subtables.add (GlyphPositioningTable.createSubtable (stType, makeLookupId (ltSequence), stSequence, ltFlags, stFormat, coverage, entries)); nextSubtableInLookup(); } - private void addGPOSSubtable ( int stType, GlyphCoverageTable coverage ) { - addGPOSSubtable ( stType, coverage, extractSubtableEntries() ); + private void addGPOSSubtable (int stType, GlyphCoverageTable coverage) { + addGPOSSubtable (stType, coverage, extractSubtableEntries()); } } - private int mapGlyphId0 ( String glyph ) { + private int mapGlyphId0 (String glyph) { assert glyphIds != null; - Integer gid = glyphIds.get ( glyph ); - if ( gid != null ) { + Integer gid = glyphIds.get (glyph); + if (gid != null) { return (int) gid; } else { return -1; } } - private int mapGlyphId ( String glyph, String[] currentElement ) throws SAXException { - int g = mapGlyphId0 ( glyph ); - if ( g < 0 ) { - unsupportedGlyph ( currentElement, glyph ); + private int mapGlyphId (String glyph, String[] currentElement) throws SAXException { + int g = mapGlyphId0 (glyph); + if (g < 0) { + unsupportedGlyph (currentElement, glyph); return -1; } else { return g; } } - private int[] mapGlyphIds ( String glyphs, String[] currentElement ) throws SAXException { + private int[] mapGlyphIds (String glyphs, String[] currentElement) throws SAXException { String[] ga = glyphs.split(","); int[] gids = new int [ ga.length ]; int i = 0; - for ( String glyph : ga ) { - gids[i++] = mapGlyphId ( glyph, currentElement ); + for (String glyph : ga) { + gids[i++] = mapGlyphId (glyph, currentElement); } return gids; } - private int mapGlyphIdToChar ( String glyph ) { + private int mapGlyphIdToChar (String glyph) { assert glyphIds != null; - Integer gid = glyphIds.get ( glyph ); - if ( gid != null ) { - if ( gmap != null ) { - Integer cid = gmap.get ( gid ); - if ( cid != null ) { + Integer gid = glyphIds.get (glyph); + if (gid != null) { + if (gmap != null) { + Integer cid = gmap.get (gid); + if (cid != null) { return cid.intValue(); } } @@ -3310,141 +3310,141 @@ public class TTXFile { return -1; } private String formatLocator() { - if ( locator == null ) { + if (locator == null) { return "{null}"; } else { return "{" + locator.getSystemId() + ":" + locator.getLineNumber() + ":" + locator.getColumnNumber() + "}"; } } - private void unsupportedElement ( String[] en ) throws SAXException { - throw new SAXException ( formatLocator() + ": unsupported element " + formatExpandedName ( en ) ); + private void unsupportedElement (String[] en) throws SAXException { + throw new SAXException (formatLocator() + ": unsupported element " + formatExpandedName (en)); } - private void notPermittedInElementContext ( String[] en, String[] cn, Object xns ) throws SAXException { + private void notPermittedInElementContext (String[] en, String[] cn, Object xns) throws SAXException { assert en != null; assert cn != null; String s = "element " + formatExpandedName(en) + " not permitted in current element context " + formatExpandedName(cn); - if ( xns == null ) { + if (xns == null) { s += ", expected root context"; - } else if ( xns instanceof String[][] ) { + } else if (xns instanceof String[][]) { int nxn = 0; s += ", expected one of { "; - for ( String[] xn : (String[][]) xns ) { - if ( nxn++ > 0 ) { + for (String[] xn : (String[][]) xns) { + if (nxn++ > 0) { s += ", "; } - s += formatExpandedName ( xn ); + s += formatExpandedName (xn); } s += " }"; - } else if ( xns instanceof String[] ) { - s += ", expected " + formatExpandedName ( (String[]) xns ); + } else if (xns instanceof String[]) { + s += ", expected " + formatExpandedName ((String[]) xns); } - throw new SAXException ( formatLocator() + ": " + s ); + throw new SAXException (formatLocator() + ": " + s); } - private void missingRequiredAttribute ( String[] en, String name ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " missing required attribute " + name ); + private void missingRequiredAttribute (String[] en, String name) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " missing required attribute " + name); } - private void duplicateGlyph ( String[] en, String name, int gid ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate name \"" + name + "\", with identifier value " + gid ); + private void duplicateGlyph (String[] en, String name, int gid) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate name \"" + name + "\", with identifier value " + gid); } - private void unsupportedGlyph ( String[] en, String name ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported glyph id \"" + name + "\"" ); + private void unsupportedGlyph (String[] en, String name) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported glyph id \"" + name + "\""); } - private void duplicateCMAPCharacter ( String[] en, int cid ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap character code: " + CharUtilities.format ( cid ) ); + private void duplicateCMAPCharacter (String[] en, int cid) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap character code: " + CharUtilities.format (cid)); } - private void duplicateCMAPGlyph ( String[] en, int gid ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap glyph code: " + gid ); + private void duplicateCMAPGlyph (String[] en, int gid) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap glyph code: " + gid); } - private void duplicateGlyphClass ( String[] en, String name, String glyphClass ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate glyph class for \"" + name + "\", with class value " + glyphClass ); + private void duplicateGlyphClass (String[] en, String name, String glyphClass) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate glyph class for \"" + name + "\", with class value " + glyphClass); } - private void unsupportedFormat ( String[] en, int format ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported table format \"" + format + "\"" ); + private void unsupportedFormat (String[] en, int format) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported table format \"" + format + "\""); } - private void invalidIndex ( String[] en, int actual, int expected ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " specifies invalid index " + actual + ", expected " + expected ); + private void invalidIndex (String[] en, int actual, int expected) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " specifies invalid index " + actual + ", expected " + expected); } - private void mismatchedIndex ( String[] en, String label, int actual, int expected ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " mismatched " + label + " index: got " + actual + ", expected " + expected ); + private void mismatchedIndex (String[] en, String label, int actual, int expected) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " mismatched " + label + " index: got " + actual + ", expected " + expected); } - private void mismatchedEntries ( String[] en, int nce, int nse ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " mismatched coverage and subtable entry counts, # coverages " + nce + ", # entries " + nse ); + private void mismatchedEntries (String[] en, int nce, int nse) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " mismatched coverage and subtable entry counts, # coverages " + nce + ", # entries " + nse); } - private void missingParameter ( String[] en, String label ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " parameter" ); + private void missingParameter (String[] en, String label) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " parameter"); } - private void duplicateParameter ( String[] en, String label ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " parameter" ); + private void duplicateParameter (String[] en, String label) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " parameter"); } - private void duplicateCoverageIndex ( String[] en, int index ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " duplicate coverage table index " + index ); + private void duplicateCoverageIndex (String[] en, int index) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " duplicate coverage table index " + index); } - private void missingCoverage ( String[] en, String type, int expected ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " missing " + type + " coverage table, expected " + ( ( expected > 0 ) ? expected : 1 ) + " table(s)" ); + private void missingCoverage (String[] en, String type, int expected) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " missing " + type + " coverage table, expected " + ((expected > 0) ? expected : 1) + " table(s)"); } - private void missingTag ( String[] en, String label ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " tag" ); + private void missingTag (String[] en, String label) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " tag"); } - private void duplicateTag ( String[] en, String label, String tag ) throws SAXException { - throw new SAXException ( formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " tag: " + tag ); + private void duplicateTag (String[] en, String label, String tag) throws SAXException { + throw new SAXException (formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " tag: " + tag); } - private static String[] makeExpandedName ( String uri, String localName, String qName ) { - if ( ( uri != null ) && ( uri.length() == 0 ) ) { + private static String[] makeExpandedName (String uri, String localName, String qName) { + if ((uri != null) && (uri.length() == 0)) { uri = null; } - if ( ( localName != null ) && ( localName.length() == 0 ) ) { + if ((localName != null) && (localName.length() == 0)) { localName = null; } - if ( ( uri == null ) && ( localName == null ) ) { - uri = extractPrefix ( qName ); - localName = extractLocalName ( qName ); + if ((uri == null) && (localName == null)) { + uri = extractPrefix (qName); + localName = extractLocalName (qName); } return new String[] { uri, localName }; } - private static String extractPrefix ( String qName ) { + private static String extractPrefix (String qName) { String[] sa = qName.split(":"); - if ( sa.length == 2 ) { + if (sa.length == 2) { return sa[0]; } else { return null; } } - private static String extractLocalName ( String qName ) { + private static String extractLocalName (String qName) { String[] sa = qName.split(":"); - if ( sa.length == 2 ) { + if (sa.length == 2) { return sa[1]; - } else if ( sa.length == 1 ) { + } else if (sa.length == 1) { return sa[0]; } else { return null; } } - private static boolean sameExpandedName ( String[] n1, String[] n2 ) { + private static boolean sameExpandedName (String[] n1, String[] n2) { String u1 = n1[0]; String u2 = n2[0]; - if ( ( u1 == null ) ^ ( u2 == null ) ) { + if ((u1 == null) ^ (u2 == null)) { return false; } - if ( ( u1 != null ) && ( u2 != null ) ) { - if ( ! u1.equals ( u2 ) ) { + if ((u1 != null) && (u2 != null)) { + if (! u1.equals (u2)) { return false; } } String l1 = n1[1]; String l2 = n2[1]; - if ( ( l1 == null ) ^ ( l2 == null ) ) { + if ((l1 == null) ^ (l2 == null)) { return false; } - if ( ( l1 != null ) && ( l2 != null ) ) { - if ( ! l1.equals ( l2 ) ) { + if ((l1 != null) && (l2 != null)) { + if (! l1.equals (l2)) { return false; } } return true; } - private static String formatExpandedName ( String[] n ) { - String u = ( n[0] != null ) ? n[0] : "null"; - String l = ( n[1] != null ) ? n[1] : "null"; + private static String formatExpandedName (String[] n) { + String u = (n[0] != null) ? n[0] : "null"; + String l = (n[1] != null) ? n[1] : "null"; return "{" + u + "}" + l; } } diff --git a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java index b28eb49c1..9aeff626a 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java @@ -39,12 +39,12 @@ public class TTXFileTestCase { @Test public void testTTXFiles() throws Exception { - for ( String tfn : ttxFiles ) { + for (String tfn : ttxFiles) { try { - TTXFile tf = TTXFile.getFromCache ( ttxFilesRoot + File.separator + tfn ); - assertTrue ( tf != null ); - } catch ( Exception e ) { - fail ( e.getMessage() ); + TTXFile tf = TTXFile.getFromCache (ttxFilesRoot + File.separator + tfn); + assertTrue (tf != null); + } catch (Exception e) { + fail (e.getMessage()); } } } diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java index ef1ea37bf..82abe9de8 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java +++ b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java @@ -52,68 +52,68 @@ public class ArabicTestCase implements ArabicTestConstants { @Test public void testArabicWordForms() { - for ( String sfn : srcFiles ) { + for (String sfn : srcFiles) { try { - processWordForms ( new File ( datFilesDir ) ); - } catch ( Exception e ) { - fail ( e.getMessage() ); + processWordForms (new File (datFilesDir)); + } catch (Exception e) { + fail (e.getMessage()); } } } - private void processWordForms ( File dfd ) { - String[] files = listWordFormFiles ( dfd ); - for ( String fn : files ) { - File dff = new File ( dfd, fn ); - processWordForms ( dff.getAbsolutePath() ); + private void processWordForms (File dfd) { + String[] files = listWordFormFiles (dfd); + for (String fn : files) { + File dff = new File (dfd, fn); + processWordForms (dff.getAbsolutePath()); } } - private String[] listWordFormFiles ( File dfd ) { - return dfd.list ( new FilenameFilter() { - public boolean accept ( File f, String name ) { - return hasPrefixFrom ( name, srcFiles ) && hasExtension ( name, WF_FILE_DAT_EXT ); + private String[] listWordFormFiles (File dfd) { + return dfd.list (new FilenameFilter() { + public boolean accept (File f, String name) { + return hasPrefixFrom (name, srcFiles) && hasExtension (name, WF_FILE_DAT_EXT); } - private boolean hasPrefixFrom ( String name, String[] prefixes ) { - for ( String p : prefixes ) { - if ( name.startsWith ( p ) ) { + private boolean hasPrefixFrom (String name, String[] prefixes) { + for (String p : prefixes) { + if (name.startsWith (p)) { return true; } } return false; } - private boolean hasExtension ( String name, String extension ) { - return name.endsWith ( "." + extension ); + private boolean hasExtension (String name, String extension) { + return name.endsWith ("." + extension); } - } ); + }); } - private void processWordForms ( String dpn ) { + private void processWordForms (String dpn) { FileInputStream fis = null; try { - fis = new FileInputStream ( dpn ); - if ( fis != null ) { - ObjectInputStream ois = new ObjectInputStream ( fis ); + fis = new FileInputStream (dpn); + if (fis != null) { + ObjectInputStream ois = new ObjectInputStream (fis); List data = (List) ois.readObject(); - if ( data != null ) { - processWordForms ( data ); + if (data != null) { + processWordForms (data); } ois.close(); } - } catch ( FileNotFoundException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( IOException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( Exception e ) { - throw new RuntimeException ( e.getMessage(), e ); + } catch (FileNotFoundException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (IOException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (Exception e) { + throw new RuntimeException (e.getMessage(), e); } finally { - if ( fis != null ) { - try { fis.close(); } catch ( Exception e ) {} + if (fis != null) { + try { fis.close(); } catch (Exception e) {} } } } - private void processWordForms ( List data ) { + private void processWordForms (List data) { assert data != null; assert data.size() > 0; String script = null; @@ -123,20 +123,20 @@ public class ArabicTestCase implements ArabicTestConstants { GlyphSubstitutionTable gsub = null; GlyphPositioningTable gpos = null; int[] widths = null; - for ( Object[] d : data ) { - if ( script == null ) { + for (Object[] d : data) { + if (script == null) { assert d.length >= 4; script = (String) d[0]; language = (String) d[1]; tfn = (String) d[3]; - tf = TTXFile.getFromCache ( ttxFontsDir + File.separator + tfn ); - assertTrue ( tf != null ); + tf = TTXFile.getFromCache (ttxFontsDir + File.separator + tfn); + assertTrue (tf != null); gsub = tf.getGSUB(); - assertTrue ( gsub != null ); + assertTrue (gsub != null); gpos = tf.getGPOS(); - assertTrue ( gpos != null ); + assertTrue (gpos != null); widths = tf.getWidths(); - assertTrue ( widths != null ); + assertTrue (widths != null); } else { assert tf != null; assert gsub != null; @@ -147,48 +147,48 @@ public class ArabicTestCase implements ArabicTestConstants { int[] iga = (int[]) d[1]; int[] oga = (int[]) d[2]; int[][] paa = (int[][]) d[3]; - GlyphSequence tigs = tf.mapCharsToGlyphs ( wf ); - assertSameGlyphs ( iga, getGlyphs ( tigs ), "input glyphs", wf, tfn ); - GlyphSequence togs = gsub.substitute ( tigs, script, language ); - assertSameGlyphs ( oga, getGlyphs ( togs ), "output glyphs", wf, tfn ); + GlyphSequence tigs = tf.mapCharsToGlyphs (wf); + assertSameGlyphs (iga, getGlyphs (tigs), "input glyphs", wf, tfn); + GlyphSequence togs = gsub.substitute (tigs, script, language); + assertSameGlyphs (oga, getGlyphs (togs), "output glyphs", wf, tfn); int[][] tpaa = new int [ togs.getGlyphCount() ] [ 4 ]; - if ( gpos.position ( togs, script, language, 1000, widths, tpaa ) ) { - assertSameAdjustments ( paa, tpaa, wf, tfn ); - } else if ( paa != null ) { - assertEquals ( "unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", paa.length, 0 ); + if (gpos.position (togs, script, language, 1000, widths, tpaa)) { + assertSameAdjustments (paa, tpaa, wf, tfn); + } else if (paa != null) { + assertEquals ("unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", paa.length, 0); } } } } - private void assertSameGlyphs ( int[] expected, int[] actual, String label, String wf, String tfn ) { - assertEquals ( label + ": unequal glyph count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length ); - for ( int i = 0, n = expected.length; i < n; i++ ) { + private void assertSameGlyphs (int[] expected, int[] actual, String label, String wf, String tfn) { + assertEquals (label + ": unequal glyph count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length); + for (int i = 0, n = expected.length; i < n; i++) { int e = expected[i]; int a = actual[i]; - assertEquals ( label + ": unequal glyphs[" + i + "], word form(" + wf + "), font (" + tfn + ")", e, a ); + assertEquals (label + ": unequal glyphs[" + i + "], word form(" + wf + "), font (" + tfn + ")", e, a); } } - private void assertSameAdjustments ( int[][] expected, int[][] actual, String wf, String tfn ) { - assertEquals ( "unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length ); - for ( int i = 0, n = expected.length; i < n; i++ ) { + private void assertSameAdjustments (int[][] expected, int[][] actual, String wf, String tfn) { + assertEquals ("unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length); + for (int i = 0, n = expected.length; i < n; i++) { int[] ea = expected[i]; int[] aa = actual[i]; - assertEquals ( "bad adjustments length, word form(" + wf + "), font (" + tfn + ")", ea.length, aa.length ); - for ( int k = 0; k < 4; k++ ) { + assertEquals ("bad adjustments length, word form(" + wf + "), font (" + tfn + ")", ea.length, aa.length); + for (int k = 0; k < 4; k++) { int e = ea[k]; int a = aa[k]; - assertEquals ( "unequal adjustment[" + i + "][" + k + "], word form(" + wf + "), font (" + tfn + ")", e, a ); + assertEquals ("unequal adjustment[" + i + "][" + k + "], word form(" + wf + "), font (" + tfn + ")", e, a); } } } - private static int[] getGlyphs ( GlyphSequence gs ) { + private static int[] getGlyphs (GlyphSequence gs) { IntBuffer gb = gs.getGlyphs(); int[] ga = new int [ gb.limit() ]; gb.rewind(); - gb.get ( ga ); + gb.get (ga); return ga; } diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java index 4ae551344..718e80ff2 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java +++ b/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java @@ -42,136 +42,136 @@ import org.apache.fop.complexscripts.util.GlyphSequence; */ public class GenerateArabicTestData implements ArabicTestConstants { - public static void main ( String[] args ) { + public static void main (String[] args) { boolean compile = false; boolean help = false; - for ( String a : args ) { - if ( a.equals("-c") ) { + for (String a : args) { + if (a.equals("-c")) { compile = true; } - if ( a.equals("-?") ) { + if (a.equals("-?")) { help = true; } } - if ( help ) { + if (help) { help(); - } else if ( compile ) { + } else if (compile) { compile(); } } private static void help() { StringBuffer sb = new StringBuffer(); - sb.append ( "org.apache.fop.complexscripts.arabic.ArabicTestCase" ); - sb.append ( " [-compile]" ); - sb.append ( " [-?]" ); - System.out.println ( sb.toString() ); + sb.append ("org.apache.fop.complexscripts.arabic.ArabicTestCase"); + sb.append (" [-compile]"); + sb.append (" [-?]"); + System.out.println (sb.toString()); } private static void compile() { - for ( String sfn : srcFiles ) { + for (String sfn : srcFiles) { try { String spn = srcFilesDir + File.separator + sfn + "." + WF_FILE_SRC_EXT; - compile ( WF_FILE_SCRIPT, WF_FILE_LANGUAGE, spn ); - } catch ( Exception e ) { - System.err.println ( e.getMessage() ); + compile (WF_FILE_SCRIPT, WF_FILE_LANGUAGE, spn); + } catch (Exception e) { + System.err.println (e.getMessage()); } } } - private static void compile ( String script, String language, String spn ) { + private static void compile (String script, String language, String spn) { int fno = 0; - for ( String tfn : ttxFonts ) { - TTXFile tf = TTXFile.getFromCache ( ttxFontsDir + File.separator + tfn ); + for (String tfn : ttxFonts) { + TTXFile tf = TTXFile.getFromCache (ttxFontsDir + File.separator + tfn); assert tf != null; - List data = compile ( script, language, spn, tfn, tf ); - output ( makeDataPathName ( spn, fno++ ), data ); + List data = compile (script, language, spn, tfn, tf); + output (makeDataPathName (spn, fno++), data); } } - private static List compile ( String script, String language, String spn, String tfn, TTXFile tf ) { + private static List compile (String script, String language, String spn, String tfn, TTXFile tf) { List data = new ArrayList(); - data.add ( new Object[] { script, language, spn, tfn } ); + data.add (new Object[] { script, language, spn, tfn }); GlyphSubstitutionTable gsub = tf.getGSUB(); GlyphPositioningTable gpos = tf.getGPOS(); int[] widths = tf.getWidths(); - if ( ( gsub != null ) && ( gpos != null ) ) { + if ((gsub != null) && (gpos != null)) { FileInputStream fis = null; try { - fis = new FileInputStream ( spn ); - if ( fis != null ) { - LineNumberReader lr = new LineNumberReader ( new InputStreamReader ( fis, Charset.forName ( "UTF-8" ) ) ); + fis = new FileInputStream (spn); + if (fis != null) { + LineNumberReader lr = new LineNumberReader (new InputStreamReader (fis, Charset.forName ("UTF-8"))); String wf; - while ( ( wf = lr.readLine() ) != null ) { - GlyphSequence igs = tf.mapCharsToGlyphs ( wf ); - GlyphSequence ogs = gsub.substitute ( igs, script, language ); + while ((wf = lr.readLine()) != null) { + GlyphSequence igs = tf.mapCharsToGlyphs (wf); + GlyphSequence ogs = gsub.substitute (igs, script, language); int[][] paa = new int [ ogs.getGlyphCount() ] [ 4 ]; - if ( ! gpos.position ( ogs, script, language, 1000, widths, paa ) ) { + if (! gpos.position (ogs, script, language, 1000, widths, paa)) { paa = null; } - data.add ( new Object[] { wf, getGlyphs ( igs ), getGlyphs ( ogs ), paa } ); + data.add (new Object[] { wf, getGlyphs (igs), getGlyphs (ogs), paa }); } lr.close(); } - } catch ( FileNotFoundException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( IOException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( Exception e ) { - throw new RuntimeException ( e.getMessage(), e ); + } catch (FileNotFoundException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (IOException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (Exception e) { + throw new RuntimeException (e.getMessage(), e); } finally { - if ( fis != null ) { - try { fis.close(); } catch ( Exception e ) {} + if (fis != null) { + try { fis.close(); } catch (Exception e) {} } } } else { assert gsub != null; assert gpos != null; } - System.err.println ( "compiled " + ( data.size() - 1 ) + " word forms using font " + tfn ); + System.err.println ("compiled " + (data.size() - 1) + " word forms using font " + tfn); return data; } - private static int[] getGlyphs ( GlyphSequence gs ) { + private static int[] getGlyphs (GlyphSequence gs) { IntBuffer gb = gs.getGlyphs(); int[] ga = new int [ gb.limit() ]; gb.rewind(); - gb.get ( ga ); + gb.get (ga); return ga; } - private static String makeDataPathName ( String spn, int fno ) { - File f = new File ( spn ); - return datFilesDir + File.separator + stripExtension ( f.getName() ) + "-f" + fno + "." + WF_FILE_DAT_EXT; + private static String makeDataPathName (String spn, int fno) { + File f = new File (spn); + return datFilesDir + File.separator + stripExtension (f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT; } - private static String stripExtension ( String s ) { - int i = s.lastIndexOf ( '.' ); - if ( i >= 0 ) { - return s.substring ( 0, i ); + private static String stripExtension (String s) { + int i = s.lastIndexOf ('.'); + if (i >= 0) { + return s.substring (0, i); } else { return s; } } - private static void output ( String dpn, List data ) { + private static void output (String dpn, List data) { FileOutputStream fos = null; try { - fos = new FileOutputStream ( dpn ); - if ( fos != null ) { - ObjectOutputStream oos = new ObjectOutputStream ( fos ); - oos.writeObject ( data ); + fos = new FileOutputStream (dpn); + if (fos != null) { + ObjectOutputStream oos = new ObjectOutputStream (fos); + oos.writeObject (data); oos.close(); } - } catch ( FileNotFoundException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( IOException e ) { - throw new RuntimeException ( e.getMessage(), e ); - } catch ( Exception e ) { - throw new RuntimeException ( e.getMessage(), e ); + } catch (FileNotFoundException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (IOException e) { + throw new RuntimeException (e.getMessage(), e); + } catch (Exception e) { + throw new RuntimeException (e.getMessage(), e); } finally { - if ( fos != null ) { - try { fos.close(); } catch ( Exception e ) {} + if (fos != null) { + try { fos.close(); } catch (Exception e) {} } } } diff --git a/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java b/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java index 385612b3a..aa6ca0db3 100644 --- a/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java +++ b/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java @@ -1329,10 +1329,10 @@ public class NumberConverterTestCase { */ @Test public void testFormatDecimal() throws Exception { - performConversions ( formatDecimal ); - performConversions ( formatDecimalPadded ); - performConversions ( formatDecimalGrouped ); - performConversions ( formatDecimalGroupedPadded ); + performConversions (formatDecimal); + performConversions (formatDecimalPadded); + performConversions (formatDecimalGrouped); + performConversions (formatDecimalGroupedPadded); } /** @@ -1341,10 +1341,10 @@ public class NumberConverterTestCase { */ @Test public void testFormatDecimalArabic() throws Exception { - performConversions ( formatDecimalArabic ); - performConversions ( formatDecimalArabicPadded ); - performConversions ( formatDecimalArabicGrouped ); - performConversions ( formatDecimalArabicGroupedPadded ); + performConversions (formatDecimalArabic); + performConversions (formatDecimalArabicPadded); + performConversions (formatDecimalArabicGrouped); + performConversions (formatDecimalArabicGroupedPadded); } /** @@ -1353,8 +1353,8 @@ public class NumberConverterTestCase { */ @Test public void testFormatDecimalThai() throws Exception { - performConversions ( formatDecimalThai ); - performConversions ( formatDecimalThaiPadded ); + performConversions (formatDecimalThai); + performConversions (formatDecimalThaiPadded); } /** @@ -1363,12 +1363,12 @@ public class NumberConverterTestCase { */ @Test public void testFormatRoman() throws Exception { - performConversions ( formatRomanLower ); - performConversions ( formatRomanUpper ); - performConversions ( formatRomanLargeLower ); - performConversions ( formatRomanLargeUpper ); - performConversions ( formatRomanNumberFormsLower ); - performConversions ( formatRomanNumberFormsUpper ); + performConversions (formatRomanLower); + performConversions (formatRomanUpper); + performConversions (formatRomanLargeLower); + performConversions (formatRomanLargeUpper); + performConversions (formatRomanNumberFormsLower); + performConversions (formatRomanNumberFormsUpper); } /** @@ -1377,8 +1377,8 @@ public class NumberConverterTestCase { */ @Test public void testAlphabeticLatin() throws Exception { - performConversions ( formatAlphabeticLatinLower ); - performConversions ( formatAlphabeticLatinUpper ); + performConversions (formatAlphabeticLatinLower); + performConversions (formatAlphabeticLatinUpper); } /** @@ -1387,8 +1387,8 @@ public class NumberConverterTestCase { */ @Test public void testAlphabeticArabic() throws Exception { - performConversions ( formatAlphabeticArabicHijai ); - performConversions ( formatAlphabeticArabicAbjadi ); + performConversions (formatAlphabeticArabicHijai); + performConversions (formatAlphabeticArabicAbjadi); } /** @@ -1397,7 +1397,7 @@ public class NumberConverterTestCase { */ @Test public void testAlphabeticHebrew() throws Exception { - performConversions ( formatAlphabeticHebrew ); + performConversions (formatAlphabeticHebrew); } /** @@ -1406,7 +1406,7 @@ public class NumberConverterTestCase { */ @Test public void testAlphabeticThai() throws Exception { - performConversions ( formatAlphabeticThai ); + performConversions (formatAlphabeticThai); } /** @@ -1415,7 +1415,7 @@ public class NumberConverterTestCase { */ @Test public void testNumeralArabic() throws Exception { - performConversions ( formatNumeralArabicAbjadi ); + performConversions (formatNumeralArabicAbjadi); } /** @@ -1424,7 +1424,7 @@ public class NumberConverterTestCase { */ @Test public void testNumeralHebrew() throws Exception { - performConversions ( formatNumeralHebrewGematria ); + performConversions (formatNumeralHebrewGematria); } /** @@ -1433,9 +1433,9 @@ public class NumberConverterTestCase { */ @Test public void testWordEnglish() throws Exception { - performConversions ( formatWordEnglishLower ); - performConversions ( formatWordEnglishUpper ); - performConversions ( formatWordEnglishTitle ); + performConversions (formatWordEnglishLower); + performConversions (formatWordEnglishUpper); + performConversions (formatWordEnglishTitle); } /** @@ -1444,9 +1444,9 @@ public class NumberConverterTestCase { */ @Test public void testWordSpanish() throws Exception { - performConversions ( formatWordSpanishLower ); - performConversions ( formatWordSpanishUpper ); - performConversions ( formatWordSpanishTitle ); + performConversions (formatWordSpanishLower); + performConversions (formatWordSpanishUpper); + performConversions (formatWordSpanishTitle); } /** @@ -1455,16 +1455,16 @@ public class NumberConverterTestCase { */ @Test public void testWordFrench() throws Exception { - performConversions ( formatWordFrenchLower ); - performConversions ( formatWordFrenchUpper ); - performConversions ( formatWordFrenchTitle ); + performConversions (formatWordFrenchLower); + performConversions (formatWordFrenchUpper); + performConversions (formatWordFrenchTitle); } /** * Perform conversions according to test specification. * @param ts test specification */ - private void performConversions ( String[][] ts ) { + private void performConversions (String[][] ts) { assert ts != null; assert ts.length >= 2; String[] args = ts[0]; @@ -1473,9 +1473,9 @@ public class NumberConverterTestCase { String format = args[0]; assert format.length() > 0; char groupingSeparator; - if ( args.length > 1 ) { + if (args.length > 1) { String s = args[1]; - if ( ( s != null ) && ( s.length() > 0 ) ) { + if ((s != null) && (s.length() > 0)) { groupingSeparator = s.charAt(0); } else { groupingSeparator = 0; @@ -1484,10 +1484,10 @@ public class NumberConverterTestCase { groupingSeparator = 0; } int groupingSize; - if ( args.length > 2 ) { + if (args.length > 2) { String s = args[2]; - if ( ( s != null ) && ( s.length() > 0 ) ) { - groupingSize = Integer.parseInt ( s ); + if ((s != null) && (s.length() > 0)) { + groupingSize = Integer.parseInt (s); } else { groupingSize = 0; } @@ -1495,13 +1495,13 @@ public class NumberConverterTestCase { groupingSize = 0; } int letterValue; - if ( args.length > 3 ) { + if (args.length > 3) { String s = args[3]; - if ( ( s != null ) && ( s.length() > 0 ) ) { + if ((s != null) && (s.length() > 0)) { s = s.toLowerCase(); - if ( s.equals("alphabetic") ) { + if (s.equals("alphabetic")) { letterValue = NumberConverter.LETTER_VALUE_ALPHABETIC; - } else if ( s.equals("traditional") ) { + } else if (s.equals("traditional")) { letterValue = NumberConverter.LETTER_VALUE_TRADITIONAL; } else { letterValue = 0; @@ -1513,9 +1513,9 @@ public class NumberConverterTestCase { letterValue = 0; } String features; - if ( args.length > 4 ) { + if (args.length > 4) { String s = args[4]; - if ( ( s != null ) && ( s.length() > 0 ) ) { + if ((s != null) && (s.length() > 0)) { features = s; } else { features = null; @@ -1524,9 +1524,9 @@ public class NumberConverterTestCase { features = null; } String language; - if ( args.length > 5 ) { + if (args.length > 5) { String s = args[5]; - if ( ( s != null ) && ( s.length() > 0 ) ) { + if ((s != null) && (s.length() > 0)) { language = s; } else { language = null; @@ -1535,9 +1535,9 @@ public class NumberConverterTestCase { language = null; } String country; - if ( args.length > 6 ) { + if (args.length > 6) { String s = args[6]; - if ( ( s != null ) && ( s.length() > 0 ) ) { + if ((s != null) && (s.length() > 0)) { country = s; } else { country = null; @@ -1545,19 +1545,19 @@ public class NumberConverterTestCase { } else { country = null; } - NumberConverter nc = new NumberConverter ( format, groupingSeparator, groupingSize, letterValue, features, language, country ); - for ( int i = 1, nt = ts.length; i < nt; i++ ) { + NumberConverter nc = new NumberConverter (format, groupingSeparator, groupingSize, letterValue, features, language, country); + for (int i = 1, nt = ts.length; i < nt; i++) { String[] sa = ts[i]; assert sa != null; assert sa.length >= 2; List numbers = new ArrayList(); - for ( int k = 0, nn = sa.length - 1; k < nn; k++ ) { + for (int k = 0, nn = sa.length - 1; k < nn; k++) { String s = sa[k]; - numbers.add ( Long.valueOf ( s ) ); + numbers.add (Long.valueOf (s)); } String expected = sa [ sa.length - 1 ]; - String actual = nc.convert ( numbers ); - assertEquals ( expected, actual ); + String actual = nc.convert (numbers); + assertEquals (expected, actual); } } diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index c92455f4b..f4763512a 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -216,7 +216,7 @@ public class ImageLoaderTestCase { assertEquals(400000, info.getSize().getHeightMpt()); Raster raster = renImg.getData(); // This pixel is white - int[] pixel1 = raster.getPixel(1, 1, (int[] )null); + int[] pixel1 = raster.getPixel(1, 1, (int[])null); // This pixel is from the embedded JPG and is not white int[] pixel80 = raster.getPixel(80, 80, (int[]) null); assertEquals(pixel1.length, pixel80.length); -- 2.39.5