git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1543560 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
<!-- ===================================================================================================== --> | <!-- ===================================================================================================== --> | ||||
<module name="SuppressionCommentFilter"> | <module name="SuppressionCommentFilter"> | ||||
<property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/> | |||||
<property name="offCommentFormat" value="CSOFF\: (LineLength)"/> | |||||
<property name="onCommentFormat" value="CSON\: ([\w\|]+)"/> | <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/> | ||||
<property name="checkFormat" value="$1"/> | <property name="checkFormat" value="$1"/> | ||||
</module> | </module> | ||||
<!-- ===================================================================================================== --> | <!-- ===================================================================================================== --> | ||||
<module name="SuppressionFilter"> | |||||
<property name="file" value="${samedir}/checkstyle-suppressions.xml"/> | |||||
</module> | |||||
<!-- ===================================================================================================== --> | <!-- ===================================================================================================== --> | ||||
<module name="TreeWalker"> | <module name="TreeWalker"> | ||||
<property name="allowLineBreaks" value="false"/> | <property name="allowLineBreaks" value="false"/> | ||||
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/> | <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/> | ||||
</module> | </module> | ||||
<module name="NoWhitespaceAfter"> | |||||
<property name="allowLineBreaks" value="true"/> | |||||
<property name="tokens" value="ARRAY_INIT"/> | |||||
</module> | |||||
<!-- ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... --> | <!-- ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... --> | ||||
<!-- ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... --> | <!-- ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... --> |
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> | <!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> | ||||
<suppressions> | <suppressions> | ||||
<suppress files="org/apache/fop/fo/FOPropertyMapping.java" checks="FileLengthCheck"/> | |||||
<suppress files="org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java" checks="FileLengthCheck"/> | |||||
<suppress files="org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java" checks="FileLengthCheck"/> | |||||
<suppress files="org/apache/fop/Version.java" lines="40-50" checks="LineLengthCheck"/> | |||||
<suppress files="org/apache/fop/afp/fonts/CharactersetEncoder.java" checks="FinalClass"/> | |||||
<suppress files="org/apache/fop/complexscripts/bidi/BidiClass.java" checks="WhitespaceAfter"/> | |||||
<suppress files="org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java" checks="SimplifyBooleanReturn"/> | |||||
<suppress files="org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java" checks="SimplifyBooleanReturn"/> | |||||
<suppress files="org/apache/fop/complexscripts/util/CharScript.java" checks="SimplifyBooleanReturn"/> | |||||
</suppressions> | </suppressions> |
import org.apache.fop.util.License; | import org.apache.fop.util.License; | ||||
// CSOFF: LineLength | // CSOFF: LineLength | ||||
// CSOFF: NoWhitespaceAfter | |||||
/** | /** | ||||
* <p>Utility for generating a Java class representing bidirectional | * <p>Utility for generating a Java class representing bidirectional | ||||
sb.setLength(0); | sb.setLength(0); | ||||
out.println("private static byte[] bcL1 = {"); | out.println("private static byte[] bcL1 = {"); | ||||
for (int i = 0; i < bcL1.length; i++) { | for (int i = 0; i < bcL1.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(","); | sb.append(","); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.setLength(0); | sb.setLength(0); | ||||
out.println("private static byte[] bcR1 = {"); | out.println("private static byte[] bcR1 = {"); | ||||
for (int i = 0; i < bcR1.length; i++) { | for (int i = 0; i < bcR1.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(","); | sb.append(","); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.setLength(0); | sb.setLength(0); | ||||
out.println("private static int[] bcS1 = {"); | out.println("private static int[] bcS1 = {"); | ||||
for (int i = 0; i < bcS1.length; i++) { | for (int i = 0; i < bcS1.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(","); | sb.append(","); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.setLength(0); | sb.setLength(0); | ||||
out.println("private static int[] bcE1 = {"); | out.println("private static int[] bcE1 = {"); | ||||
for (int i = 0; i < bcE1.length; i++) { | for (int i = 0; i < bcE1.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(","); | sb.append(","); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.setLength(0); | sb.setLength(0); | ||||
out.println("private static byte[] bcC1 = {"); | out.println("private static byte[] bcC1 = {"); | ||||
for (int i = 0; i < bcC1.length; i++) { | for (int i = 0; i < bcC1.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(","); | sb.append(","); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
if (k >= 0) { | if (k >= 0) { | ||||
return ca [ k ]; | return ca [ k ]; | ||||
} else { | } else { | ||||
k = - (k + 1); | |||||
k = -(k + 1); | |||||
if (k == 0) { | if (k == 0) { | ||||
return BidiConstants.L; | return BidiConstants.L; | ||||
} else if (ch <= ea [ k - 1 ]) { | } else if (ch <= ea [ k - 1 ]) { |
import org.apache.fop.util.License; | import org.apache.fop.util.License; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: EmptyForIteratorPadCheck | |||||
/** | /** | ||||
* <p>Utility for generating a Java class and associated data files representing | * <p>Utility for generating a Java class and associated data files representing | ||||
String ucName = sa[1]; | String ucName = sa[1]; | ||||
if (isBlockStart(ucName)) { | if (isBlockStart(ucName)) { | ||||
String ucBlock = getBlockName(ucName); | String ucBlock = getBlockName(ucName); | ||||
if (! im.containsKey(ucBlock)) { | |||||
if (!im.containsKey(ucBlock)) { | |||||
im.put(ucBlock, new int[] { uc, -1, bc }); | im.put(ucBlock, new int[] { uc, -1, bc }); | ||||
} else { | } else { | ||||
throw new IllegalArgumentException("duplicate start of block '" + ucBlock + "' at entry: " + line); | throw new IllegalArgumentException("duplicate start of block '" + ucBlock + "' at entry: " + line); | ||||
} else { | } else { | ||||
Integer k = Integer.valueOf(bc); | Integer k = Integer.valueOf(bc); | ||||
List sl; | List sl; | ||||
if (! sm.containsKey(k)) { | |||||
if (!sm.containsKey(k)) { | |||||
sl = new ArrayList(); | sl = new ArrayList(); | ||||
sm.put(k, sl); | sm.put(k, sl); | ||||
} else { | } else { | ||||
} | } | ||||
} | } | ||||
// populate intervals from (block) interval map | // populate intervals from (block) interval map | ||||
if (! im.isEmpty()) { | |||||
if (!im.isEmpty()) { | |||||
for (Iterator it = im.values().iterator(); it.hasNext(); ) { | for (Iterator it = im.values().iterator(); it.hasNext(); ) { | ||||
int[] ba = (int[]) it.next(); | int[] ba = (int[]) it.next(); | ||||
assert (ba != null) && (ba.length > 2); | assert (ba != null) && (ba.length > 2); | ||||
continue; | continue; | ||||
} else if (line.startsWith("#")) { | } else if (line.startsWith("#")) { | ||||
continue; | continue; | ||||
} else if (line.startsWith(PFX_TYPE) && ! ignoreDeprecatedTypeData) { | |||||
} else if (line.startsWith(PFX_TYPE) && !ignoreDeprecatedTypeData) { | |||||
List lines = new ArrayList(); | List lines = new ArrayList(); | ||||
if ((n = readType(line, b, lines)) < 0) { | if ((n = readType(line, b, lines)) < 0) { | ||||
break; | break; | ||||
// dump instrumentation | // dump instrumentation | ||||
if (verbose) { | if (verbose) { | ||||
System.out.println(); | System.out.println(); | ||||
if (! ignoreDeprecatedTypeData) { | |||||
if (!ignoreDeprecatedTypeData) { | |||||
System.out.println("Read type ranges : " + numTypeRanges); | System.out.println("Read type ranges : " + numTypeRanges); | ||||
} | } | ||||
System.out.println("Read level specs : " + numLevelSpecs); | System.out.println("Read level specs : " + numLevelSpecs); | ||||
System.out.println("Read test specs : " + numTestSpecs); | System.out.println("Read test specs : " + numTestSpecs); | ||||
System.out.println("Read lines : " + lineNumber); | System.out.println("Read lines : " + lineNumber); | ||||
} | } | ||||
if (! ignoreDeprecatedTypeData) { | |||||
if (!ignoreDeprecatedTypeData) { | |||||
td = (int[][]) tdl.toArray(new int [ tdl.size() ] []); | td = (int[][]) tdl.toArray(new int [ tdl.size() ] []); | ||||
} | } | ||||
ld = (int[][]) ldl.toArray(new int [ ldl.size() ] []); | ld = (int[][]) ldl.toArray(new int [ ldl.size() ] []); | ||||
boolean done = false; | boolean done = false; | ||||
int n = 0; | int n = 0; | ||||
lines.add(line); | lines.add(line); | ||||
while (! done) { | |||||
while (!done) { | |||||
switch (testPrefix(b, PFX_LEVELS)) { | switch (testPrefix(b, PFX_LEVELS)) { | ||||
case 0: // within current levels | case 0: // within current levels | ||||
if ((line = b.readLine()) != null) { | if ((line = b.readLine()) != null) { | ||||
n++; | n++; | ||||
if ((line.length() > 0) && ! line.startsWith("#")) { | |||||
if ((line.length() > 0) && !line.startsWith("#")) { | |||||
lines.add(line); | lines.add(line); | ||||
} | } | ||||
} else { | } else { | ||||
CharacterIterator ci = new StringCharacterIterator(charRanges); | CharacterIterator ci = new StringCharacterIterator(charRanges); | ||||
// read initial list delimiter | // read initial list delimiter | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! readStartOfList(ci)) { | |||||
if (!readStartOfList(ci)) { | |||||
badRangeSpec("missing initial list delimiter", charRanges); | badRangeSpec("missing initial list delimiter", charRanges); | ||||
} | } | ||||
// read negation token if present | // read negation token if present | ||||
String s; | String s; | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if ((s = maybeReadSeparator(ci)) != null) { | if ((s = maybeReadSeparator(ci)) != null) { | ||||
if ((s.length() != 0) && ! s.equals("||")) { | |||||
if ((s.length() != 0) && !s.equals("||")) { | |||||
badRangeSpec("invalid item separator \"" + s + "\"", charRanges); | badRangeSpec("invalid item separator \"" + s + "\"", charRanges); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// read terminating list delimiter | // read terminating list delimiter | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! readEndOfList(ci)) { | |||||
if (!readEndOfList(ci)) { | |||||
badRangeSpec("missing terminating list delimiter", charRanges); | badRangeSpec("missing terminating list delimiter", charRanges); | ||||
} | } | ||||
if (! atEnd(ci)) { | |||||
if (!atEnd(ci)) { | |||||
badRangeSpec("extraneous content prior to end of line", ci); | badRangeSpec("extraneous content prior to end of line", ci); | ||||
} | } | ||||
if (negated) { | if (negated) { | ||||
} | } | ||||
private static void skipSpace(CharacterIterator ci) { | private static void skipSpace(CharacterIterator ci) { | ||||
while (! atEnd(ci)) { | |||||
while (!atEnd(ci)) { | |||||
char c = ci.current(); | char c = ci.current(); | ||||
if (! Character.isWhitespace(c)) { | |||||
if (!Character.isWhitespace(c)) { | |||||
break; | break; | ||||
} else { | } else { | ||||
ci.next(); | ci.next(); | ||||
} | } | ||||
private static boolean maybeReadNext(CharacterIterator ci, char next) { | private static boolean maybeReadNext(CharacterIterator ci, char next) { | ||||
while (! atEnd(ci)) { | |||||
while (!atEnd(ci)) { | |||||
char c = ci.current(); | char c = ci.current(); | ||||
if (c == next) { | if (c == next) { | ||||
ci.next(); | ci.next(); | ||||
List ll = new ArrayList(); | List ll = new ArrayList(); | ||||
// read prefix | // read prefix | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! maybeReadToken(ci, PFX_LEVELS)) { | |||||
if (!maybeReadToken(ci, PFX_LEVELS)) { | |||||
badLevelSpec("missing prefix \"" + PFX_LEVELS + "\"", ci); | badLevelSpec("missing prefix \"" + PFX_LEVELS + "\"", ci); | ||||
} | } | ||||
// read level values | // read level values | ||||
} | } | ||||
// read to end of line | // read to end of line | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! atEnd(ci)) { | |||||
if (!atEnd(ci)) { | |||||
badLevelSpec("extraneous content prior to end of line", ci); | badLevelSpec("extraneous content prior to end of line", ci); | ||||
} | } | ||||
if (ll.size() == 0) { | if (ll.size() == 0) { | ||||
List rl = new ArrayList(); | List rl = new ArrayList(); | ||||
// read prefix | // read prefix | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! maybeReadToken(ci, PFX_REORDER)) { | |||||
if (!maybeReadToken(ci, PFX_REORDER)) { | |||||
badReorderSpec("missing prefix \"" + PFX_REORDER + "\"", ci); | badReorderSpec("missing prefix \"" + PFX_REORDER + "\"", ci); | ||||
} | } | ||||
// read reorder values | // read reorder values | ||||
} | } | ||||
// read to end of line | // read to end of line | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! atEnd(ci)) { | |||||
if (!atEnd(ci)) { | |||||
badReorderSpec("extraneous content prior to end of line", ci); | badReorderSpec("extraneous content prior to end of line", ci); | ||||
} | } | ||||
return createReorderArray(rl, levels); | return createReorderArray(rl, levels); | ||||
CharacterIterator ci = new StringCharacterIterator(line); | CharacterIterator ci = new StringCharacterIterator(line); | ||||
List cl = new ArrayList(); | List cl = new ArrayList(); | ||||
// read bidi class identifier sequence | // read bidi class identifier sequence | ||||
while (! atEnd(ci) && ! maybeReadNext(ci, ';')) { | |||||
while (!atEnd(ci) && !maybeReadNext(ci, ';')) { | |||||
skipSpace(ci); | skipSpace(ci); | ||||
int bc; | int bc; | ||||
if ((bc = maybeReadBidiClass(ci)) >= 0) { | if ((bc = maybeReadBidiClass(ci)) >= 0) { | ||||
} | } | ||||
// read to end of line | // read to end of line | ||||
skipSpace(ci); | skipSpace(ci); | ||||
if (! atEnd(ci)) { | |||||
if (!atEnd(ci)) { | |||||
badTestSpec("extraneous content prior to end of line", ci); | badTestSpec("extraneous content prior to end of line", ci); | ||||
} | } | ||||
return createTestArray(cl, bs, levels); | return createTestArray(cl, bs, levels); | ||||
ok = false; | ok = false; | ||||
} | } | ||||
} | } | ||||
if (! ok) { | |||||
if (!ok) { | |||||
System.out.println("Usage: GenerateBidiTestData [-v] [-i] [-d <ucdFile>] [-b <bidiFile>] [-o <outputFile>]"); | System.out.println("Usage: GenerateBidiTestData [-v] [-i] [-d <ucdFile>] [-b <bidiFile>] [-o <outputFile>]"); | ||||
System.out.println(" defaults:"); | System.out.println(" defaults:"); | ||||
if (ignoreDeprecatedTypeData) { | if (ignoreDeprecatedTypeData) { |
import java.util.Arrays; | import java.util.Arrays; | ||||
// CSOFF: WhitespaceAfterCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/* | /* |
import org.apache.fop.area.inline.InlineArea; | import org.apache.fop.area.inline.InlineArea; | ||||
import org.apache.fop.fo.pagination.PageSequence; | import org.apache.fop.fo.pagination.PageSequence; | ||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* <p>A utility class for performing bidirectional resolution processing.</p> | * <p>A utility class for performing bidirectional resolution processing.</p> | ||||
runsNew.addAll(ir.split()); | runsNew.addAll(ir.split()); | ||||
} | } | ||||
} | } | ||||
if (! runsNew.equals(runs)) { | |||||
if (!runsNew.equals(runs)) { | |||||
runs = runsNew; | runs = runsNew; | ||||
} | } | ||||
return runs; | return runs; | ||||
i = e - 1; | i = e - 1; | ||||
} | } | ||||
} | } | ||||
if (! runsNew.equals(runs)) { | |||||
if (!runsNew.equals(runs)) { | |||||
runs = runsNew; | runs = runsNew; | ||||
} | } | ||||
return runs; | return runs; | ||||
Vector rv = new Vector(); | Vector rv = new Vector(); | ||||
for (Iterator it = ranges.iterator(); it.hasNext(); ) { | for (Iterator it = ranges.iterator(); it.hasNext(); ) { | ||||
DelimitedTextRange r = (DelimitedTextRange) it.next(); | DelimitedTextRange r = (DelimitedTextRange) it.next(); | ||||
if (! r.isEmpty()) { | |||||
if (!r.isEmpty()) { | |||||
rv.add(r); | rv.add(r); | ||||
} | } | ||||
} | } |
import org.apache.fop.traits.WritingModeTraitsGetter; | import org.apache.fop.traits.WritingModeTraitsGetter; | ||||
import org.apache.fop.util.CharUtilities; | import org.apache.fop.util.CharUtilities; | ||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* The <code>DelimitedTextRange</code> class implements the "delimited text range" as described | * The <code>DelimitedTextRange</code> class implements the "delimited text range" as described | ||||
TextInterval ti = (TextInterval) it.next(); | 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; | intervals = intervalsNew; | ||||
} | } | ||||
} | } |
import org.apache.fop.area.inline.WordArea; | import org.apache.fop.area.inline.WordArea; | ||||
import org.apache.fop.util.CharUtilities; | import org.apache.fop.util.CharUtilities; | ||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* The <code>InlineRun</code> class is a utility class, the instances of which are used | * The <code>InlineRun</code> class is a utility class, the instances of which are used | ||||
* to capture a sequence of reordering levels associated with an inline area. | * to capture a sequence of reordering levels associated with an inline area. | ||||
if (inline instanceof WordArea) { | if (inline instanceof WordArea) { | ||||
WordArea w = (WordArea) inline; | WordArea w = (WordArea) inline; | ||||
// if not already reversed, then reverse now | // if not already reversed, then reverse now | ||||
if (! w.isReversed()) { | |||||
if (!w.isReversed()) { | |||||
if ((reversals & 1) != 0) { | if ((reversals & 1) != 0) { | ||||
w.reverse(mirror); | w.reverse(mirror); | ||||
} else if (mirror && maybeNeedsMirroring()) { | } else if (mirror && maybeNeedsMirroring()) { | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} else if ((ir.levels == null) && (levels == null)) { | |||||
return true; | |||||
} else { | } else { | ||||
return false; | |||||
return (ir.levels == null) && (levels == null); | |||||
} | } | ||||
} else { | } else { | ||||
return false; | return false; |
import org.apache.fop.fo.flow.Leader; | import org.apache.fop.fo.flow.Leader; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* <p>The <code>TextInterval</code> class is a utility class, the instances of which are used | * <p>The <code>TextInterval</code> class is a utility class, the instances of which are used | ||||
return false; | return false; | ||||
} else if (ti.getStart() != start) { | } else if (ti.getStart() != start) { | ||||
return false; | return false; | ||||
} else if (ti.getEnd() != end) { | |||||
return false; | |||||
} else { | } else { | ||||
return true; | |||||
return ti.getEnd() == end; | |||||
} | } | ||||
} else { | } else { | ||||
return false; | return false; |
import org.apache.fop.area.inline.TextArea; | import org.apache.fop.area.inline.TextArea; | ||||
import org.apache.fop.area.inline.UnresolvedPageNumber; | import org.apache.fop.area.inline.UnresolvedPageNumber; | ||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* <p>The <code>UnflattenProcessor</code> class is used to reconstruct (by unflattening) a line | * <p>The <code>UnflattenProcessor</code> class is used to reconstruct (by unflattening) a line | ||||
private boolean shouldFinishTextContainer(TextArea tc, InlineArea ia) { | private boolean shouldFinishTextContainer(TextArea tc, InlineArea ia) { | ||||
if ((tcOrig != null) && (tc != tcOrig)) { | if ((tcOrig != null) && (tc != tcOrig)) { | ||||
return true; | return true; | ||||
} else if ((iaLevelLast != -1) && (ia.getBidiLevel() != iaLevelLast)) { | |||||
return true; | |||||
} else { | } else { | ||||
return false; | |||||
return (iaLevelLast != -1) && (ia.getBidiLevel() != iaLevelLast); | |||||
} | } | ||||
} | } | ||||
private void finishTextContainer() { | private void finishTextContainer() { | ||||
private void finishTextContainer(TextArea tc, InlineArea ia) { | private void finishTextContainer(TextArea tc, InlineArea ia) { | ||||
if (tcNew != null) { | if (tcNew != null) { | ||||
updateIPD(tcNew); | updateIPD(tcNew); | ||||
if (! icNew.empty()) { | |||||
if (!icNew.empty()) { | |||||
icNew.peek().addChildArea(tcNew); | icNew.peek().addChildArea(tcNew); | ||||
} else { | } else { | ||||
ilNew.add(tcNew); | ilNew.add(tcNew); | ||||
} | } | ||||
private boolean shouldFinishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | private boolean shouldFinishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | ||||
if ((ich == null) || ich.isEmpty()) { | if ((ich == null) || ich.isEmpty()) { | ||||
return ! icOrig.empty(); | |||||
return !icOrig.empty(); | |||||
} else { | } else { | ||||
if (! icOrig.empty()) { | |||||
if (!icOrig.empty()) { | |||||
InlineParent ic = ich.get(0); | InlineParent ic = ich.get(0); | ||||
InlineParent ic0 = icOrig.peek(); | InlineParent ic0 = icOrig.peek(); | ||||
return (ic != ic0) && ! isInlineParentOf(ic, ic0); | |||||
return (ic != ic0) && !isInlineParentOf(ic, ic0); | |||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
finishInlineContainer(null, null, null); | finishInlineContainer(null, null, null); | ||||
} | } | ||||
private void finishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | private void finishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | ||||
if ((ich != null) && ! ich.isEmpty()) { // finish non-matching inner inline container(s) | |||||
if ((ich != null) && !ich.isEmpty()) { // finish non-matching inner inline container(s) | |||||
for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) { | for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) { | ||||
InlineParent ic = it.next(); | InlineParent ic = it.next(); | ||||
InlineParent ic0 = icOrig.empty() ? null : icOrig.peek(); | InlineParent ic0 = icOrig.empty() ? null : icOrig.peek(); | ||||
if (ic0 == null) { | if (ic0 == null) { | ||||
assert icNew.empty(); | assert icNew.empty(); | ||||
} else if (ic != ic0) { | } else if (ic != ic0) { | ||||
assert ! icNew.empty(); | |||||
assert !icNew.empty(); | |||||
InlineParent icO0 = icOrig.pop(); | InlineParent icO0 = icOrig.pop(); | ||||
InlineParent icN0 = icNew.pop(); | InlineParent icN0 = icNew.pop(); | ||||
assert icO0 != null; | assert icO0 != null; | ||||
} else { | } else { | ||||
icNew.peek().addChildArea(icN0); | icNew.peek().addChildArea(icN0); | ||||
} | } | ||||
if (! icOrig.empty() && (icOrig.peek() == ic)) { | |||||
if (!icOrig.empty() && (icOrig.peek() == ic)) { | |||||
break; | break; | ||||
} | } | ||||
} else { | } else { | ||||
} | } | ||||
} | } | ||||
} else { // finish all inline containers | } else { // finish all inline containers | ||||
while (! icNew.empty()) { | |||||
while (!icNew.empty()) { | |||||
InlineParent icO0 = icOrig.pop(); | InlineParent icO0 = icOrig.pop(); | ||||
InlineParent icN0 = icNew.pop(); | InlineParent icN0 = icNew.pop(); | ||||
assert icO0 != null; | assert icO0 != null; | ||||
finishInlineContainer(); | finishInlineContainer(); | ||||
} | } | ||||
private void update(List<InlineParent> ich, TextArea tc, InlineArea ia) { | private void update(List<InlineParent> ich, TextArea tc, InlineArea ia) { | ||||
if (! alreadyUnflattened(ia)) { | |||||
if ((ich != null) && ! ich.isEmpty()) { | |||||
if (!alreadyUnflattened(ia)) { | |||||
if ((ich != null) && !ich.isEmpty()) { | |||||
pushInlineContainers(ich); | pushInlineContainers(ich); | ||||
} | } | ||||
if (tc != null) { | if (tc != null) { | ||||
Area a = ia.getParentArea(); | Area a = ia.getParentArea(); | ||||
while (a != null) { | while (a != null) { | ||||
if (a instanceof InlineArea) { | if (a instanceof InlineArea) { | ||||
if ((a instanceof InlineParent) && ! (a instanceof TextArea)) { | |||||
if ((a instanceof InlineParent) && !(a instanceof TextArea)) { | |||||
ich.add((InlineParent) a); | ich.add((InlineParent) a); | ||||
} | } | ||||
a = ((InlineArea) a) .getParentArea(); | a = ((InlineArea) a) .getParentArea(); |
import org.apache.fop.traits.Direction; | import org.apache.fop.traits.Direction; | ||||
import org.apache.fop.util.CharUtilities; | import org.apache.fop.util.CharUtilities; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
/** | /** | ||||
* <p>The <code>UnicodeBidiAlgorithm</code> class implements functionality prescribed by | * <p>The <code>UnicodeBidiAlgorithm</code> class implements functionality prescribed by | ||||
case RLE: // start right-to-left embedding | case RLE: // start right-to-left embedding | ||||
case LRO: // start left-to-right override | case LRO: // start left-to-right override | ||||
case RLO: // start right-to-left override | case RLO: // start right-to-left override | ||||
{ | |||||
int en; /* new embedding level */ | |||||
if ((bc == RLE) || (bc == RLO)) { | |||||
en = ((ec & ~OVERRIDE) + 1) | 1; | |||||
} else { | |||||
en = ((ec & ~OVERRIDE) + 2) & ~1; | |||||
} | |||||
if (en < (MAX_LEVELS + 1)) { | |||||
es [ ei++ ] = ec; | |||||
if ((bc == LRO) || (bc == RLO)) { | |||||
ec = en | OVERRIDE; | |||||
} else { | |||||
ec = en & ~OVERRIDE; | |||||
} | |||||
int en; /* new embedding level */ | |||||
if ((bc == RLE) || (bc == RLO)) { | |||||
en = ((ec & ~OVERRIDE) + 1) | 1; | |||||
} else { | |||||
en = ((ec & ~OVERRIDE) + 2) & ~1; | |||||
} | |||||
if (en < (MAX_LEVELS + 1)) { | |||||
es [ ei++ ] = ec; | |||||
if ((bc == LRO) || (bc == RLO)) { | |||||
ec = en | OVERRIDE; | |||||
} else { | } else { | ||||
// max levels exceeded, so don't change level or override | |||||
ec = en & ~OVERRIDE; | |||||
} | } | ||||
el = ec; | |||||
break; | |||||
} else { | |||||
// max levels exceeded, so don't change level or override | |||||
} | } | ||||
el = ec; | |||||
break; | |||||
case PDF: // pop directional formatting | case PDF: // pop directional formatting | ||||
{ | |||||
el = ec; | |||||
if (ei > 0) { | |||||
ec = es [ --ei ]; | |||||
} else { | |||||
// ignore isolated PDF | |||||
} | |||||
break; | |||||
el = ec; | |||||
if (ei > 0) { | |||||
ec = es [ --ei ]; | |||||
} else { | |||||
// ignore isolated PDF | |||||
} | } | ||||
break; | |||||
case B: // paragraph separator | case B: // paragraph separator | ||||
{ | |||||
el = ec = defaultLevel; | |||||
ei = 0; | |||||
break; | |||||
} | |||||
el = ec = defaultLevel; | |||||
ei = 0; | |||||
break; | |||||
default: | default: | ||||
{ | |||||
el = ec; | |||||
break; | |||||
} | |||||
el = ec; | |||||
break; | |||||
} | } | ||||
switch (bc) { | switch (bc) { | ||||
case BN: | case BN: | ||||
private static boolean isRetainedFormatting(int[] ca, int s, int e) { | private static boolean isRetainedFormatting(int[] ca, int s, int e) { | ||||
for (int i = s; i < e; i++) { | for (int i = s; i < e; i++) { | ||||
if (! isRetainedFormatting(ca[i])) { | |||||
if (!isRetainedFormatting(ca[i])) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
chOut = chIn; | chOut = chIn; | ||||
} | } | ||||
if (! triggered && triggersBidi(chOut)) { | |||||
if (!triggered && triggersBidi(chOut)) { | |||||
triggered = true; | triggered = true; | ||||
} | } | ||||
if ((chOut & 0xFF0000) == 0) { | if ((chOut & 0xFF0000) == 0) { |
import java.util.List; | import java.util.List; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>Base class implementation of glyph class table.</p> | * <p>Base class implementation of glyph class table.</p> | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (! (o instanceof Integer)) { | |||||
if (!(o instanceof Integer)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (! (o instanceof MappingRange)) { | |||||
if (!(o instanceof MappingRange)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (! (o instanceof GlyphCoverageTable)) { | |||||
if (!(o instanceof GlyphCoverageTable)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
if (it.hasNext()) { | if (it.hasNext()) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
firstGlyph = ((Integer) o) . intValue(); | |||||
firstGlyph = ((Integer) o) .intValue(); | |||||
} else { | } 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); | ||||
} | } | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gc = ((Integer) o) . intValue(); | |||||
int gc = ((Integer) o) .intValue(); | |||||
gca [ i++ ] = gc; | gca [ i++ ] = gc; | ||||
if (gc > gcMax) { | if (gc > gcMax) { | ||||
gcMax = gc; | gcMax = gc; |
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>.Base class implementation of glyph coverage table.</p> | * <p>.Base class implementation of glyph coverage table.</p> | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (! (o instanceof Integer)) { | |||||
if (!(o instanceof Integer)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (! (o instanceof MappingRange)) { | |||||
if (!(o instanceof MappingRange)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gid = ((Integer) o) . intValue(); | |||||
int gid = ((Integer) o) .intValue(); | |||||
if ((gid >= 0) && (gid < 65536)) { | if ((gid >= 0) && (gid < 65536)) { | ||||
if (gid > gidMax) { | if (gid > gidMax) { | ||||
map [ i++ ] = gidMax = gid; | map [ i++ ] = gidMax = gid; |
package org.apache.fop.complexscripts.fonts; | package org.apache.fop.complexscripts.fonts; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: InnerAssignmentCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphDefinitionSubtable</code> implements an abstract base of a glyph definition subtable, | * <p>The <code>GlyphDefinitionSubtable</code> implements an abstract base of a glyph definition subtable, |
import org.apache.fop.complexscripts.scripts.ScriptProcessor; | import org.apache.fop.complexscripts.scripts.ScriptProcessor; | ||||
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** |
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
int mi; | int mi; | ||||
if ((i = Arrays.binarySearch(sa, gid)) >= 0) { | if ((i = Arrays.binarySearch(sa, gid)) >= 0) { | ||||
mi = getMappedIndex(gid, sa [ i ], ma [ i ]); // matches start of (some) range | mi = getMappedIndex(gid, sa [ i ], ma [ i ]); // matches start of (some) range | ||||
} else if ((i = - (i + 1)) == 0) { | |||||
} else if ((i = -(i + 1)) == 0) { | |||||
mi = -1; // precedes first range | mi = -1; // precedes first range | ||||
} else if (gid > ea [ --i ]) { | } else if (gid > ea [ --i ]) { | ||||
mi = -1; // follows preceding (or last) range | mi = -1; // follows preceding (or last) range |
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: ParameterNumberCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphPositioningState</code> implements an state object used during glyph positioning | * <p>The <code>GlyphPositioningState</code> implements an state object used during glyph positioning |
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphPositioningSubtable</code> implements an abstract base of a glyph subtable, | * <p>The <code>GlyphPositioningSubtable</code> implements an abstract base of a glyph subtable, | ||||
boolean appliedOneShot = false; | boolean appliedOneShot = false; | ||||
while (ps.hasNext()) { | while (ps.hasNext()) { | ||||
boolean applied = false; | boolean applied = false; | ||||
if (! appliedOneShot && ps.maybeApplicable()) { | |||||
for (int i = 0, n = sta.length; ! applied && (i < n); i++) { | |||||
if (!appliedOneShot && ps.maybeApplicable()) { | |||||
for (int i = 0, n = sta.length; !applied && (i < n); i++) { | |||||
if (sequenceIndex < 0) { | if (sequenceIndex < 0) { | ||||
applied = ps.apply(sta [ i ]); | applied = ps.apply(sta [ i ]); | ||||
} else if (ps.getPosition() == (sequenceStart + sequenceIndex)) { | } else if (ps.getPosition() == (sequenceStart + sequenceIndex)) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (! applied || ! ps.didConsume()) { | |||||
if (!applied || !ps.didConsume()) { | |||||
ps.applyDefault(); | ps.applyDefault(); | ||||
} | } | ||||
ps.next(); | ps.next(); |
import org.apache.fop.complexscripts.util.GlyphTester; | import org.apache.fop.complexscripts.util.GlyphTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphPositioningTable</code> class is a glyph table that implements | * <p>The <code>GlyphPositioningTable</code> class is a glyph table that implements | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof Value[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, single entry must be a Value[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
Value[] va = (Value[]) o; | Value[] va = (Value[]) o; | ||||
int offsetLast = counts[0] + counts[1]; | int offsetLast = counts[0] + counts[1]; | ||||
// skip any ignored glyphs prior to first non-ignored glyph | // skip any ignored glyphs prior to first non-ignored glyph | ||||
for ( ; offset < offsetLast; ++offset) { | for ( ; offset < offsetLast; ++offset) { | ||||
if (! ps.isIgnoredGlyph(offset)) { | |||||
if (!ps.isIgnoredGlyph(offset)) { | |||||
break; | break; | ||||
} else { | } else { | ||||
ps.consume(1); | ps.consume(1); | ||||
} | } | ||||
// skip any ignored glyphs prior to second non-ignored glyph | // skip any ignored glyphs prior to second non-ignored glyph | ||||
for ( ; offset < offsetLast; ++offset) { | for ( ; offset < offsetLast; ++offset) { | ||||
if (! ps.isIgnoredGlyph(offset)) { | |||||
if (!ps.isIgnoredGlyph(offset)) { | |||||
break; | break; | ||||
} else { | } else { | ||||
ps.consume(1); | ps.consume(1); | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof PairValues[][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first (and only) entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
pvm = (PairValues[][]) o; | pvm = (PairValues[][]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
cdt1 = (GlyphClassTable) o; | cdt1 = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
cdt2 = (GlyphClassTable) o; | cdt2 = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nc1 = ((Integer)(o)).intValue(); | nc1 = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nc2 = ((Integer)(o)).intValue(); | nc2 = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(4)) == null) || ! (o instanceof PairValues[][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
pvm = (PairValues[][]) o; | pvm = (PairValues[][]) o; | ||||
int enw = ps.getWidth(gi2); | int enw = ps.getWidth(gi2); | ||||
if ((exa != null) && (ena != null)) { | if ((exa != null) && (ena != null)) { | ||||
Value v = ena.getAlignmentAdjustment(exa); | Value v = ena.getAlignmentAdjustment(exa); | ||||
v.adjust(- enw, 0, 0, 0); | |||||
v.adjust(-enw, 0, 0, 0); | |||||
if (ps.adjust(v)) { | if (ps.adjust(v)) { | ||||
ps.setAdjusted(true); | ps.setAdjusted(true); | ||||
} | } | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof Anchor[])) { | |||||
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)); | 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 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 { | } else { | ||||
aa = (Anchor[]) o; | aa = (Anchor[]) o; | ||||
} | } | ||||
MarkAnchor ma = getMarkAnchor(ciMark, giMark); | MarkAnchor ma = getMarkAnchor(ciMark, giMark); | ||||
if (ma != null) { | if (ma != null) { | ||||
for (int i = 0, n = ps.getPosition(); i < n; i++) { | for (int i = 0, n = ps.getPosition(); i < n; i++) { | ||||
int gi = ps.getGlyph(- (i + 1)); | |||||
int gi = ps.getGlyph(-(i + 1)); | |||||
if (ps.isMark(gi)) { | if (ps.isMark(gi)) { | ||||
continue; | continue; | ||||
} else { | } else { | ||||
// start experimental fix for END OF AYAH in Lateef/Scheherazade | // start experimental fix for END OF AYAH in Lateef/Scheherazade | ||||
int[] aa = ps.getAdjustment(); | int[] aa = ps.getAdjustment(); | ||||
if (aa[2] == 0) { | if (aa[2] == 0) { | ||||
v.adjust(0, 0, - ps.getWidth(giMark), 0); | |||||
v.adjust(0, 0, -ps.getWidth(giMark), 0); | |||||
} | } | ||||
// end experimental fix for END OF AYAH in Lateef/Scheherazade | // end experimental fix for END OF AYAH in Lateef/Scheherazade | ||||
if (ps.adjust(v)) { | if (ps.adjust(v)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
bct = (GlyphCoverageTable) o; | bct = (GlyphCoverageTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | nmc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof MarkAnchor[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
maa = (MarkAnchor[]) o; | maa = (MarkAnchor[]) o; | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof Anchor[][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be a Anchor[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
bam = (Anchor[][]) o; | bam = (Anchor[][]) o; | ||||
int mxc = getMaxComponentCount(); | int mxc = getMaxComponentCount(); | ||||
if (ma != null) { | if (ma != null) { | ||||
for (int i = 0, n = ps.getPosition(); i < n; i++) { | for (int i = 0, n = ps.getPosition(); i < n; i++) { | ||||
int gi = ps.getGlyph(- (i + 1)); | |||||
int gi = ps.getGlyph(-(i + 1)); | |||||
if (ps.isMark(gi)) { | if (ps.isMark(gi)) { | ||||
continue; | continue; | ||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
lct = (GlyphCoverageTable) o; | lct = (GlyphCoverageTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | nmc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
mxc = ((Integer)(o)).intValue(); | mxc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof MarkAnchor[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
maa = (MarkAnchor[]) o; | maa = (MarkAnchor[]) o; | ||||
} | } | ||||
if (((o = entries.get(4)) == null) || ! (o instanceof Anchor[][][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be a Anchor[][][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
lam = (Anchor[][][]) o; | lam = (Anchor[][][]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 4 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphCoverageTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphCoverageTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
mct2 = (GlyphCoverageTable) o; | mct2 = (GlyphCoverageTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | nmc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof MarkAnchor[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
maa = (MarkAnchor[]) o; | maa = (MarkAnchor[]) o; | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof Anchor[][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be a Anchor[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
mam = (Anchor[][]) o; | mam = (Anchor[][]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
cdt = (GlyphClassTable) o; | cdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | ngc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
icdt = (GlyphClassTable) o; | icdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) != null) && ! (o instanceof GlyphClassTable)) { | |||||
if (((o = entries.get(1)) != null) && !(o instanceof GlyphClassTable)) { | |||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); | ||||
} else { | } else { | ||||
bcdt = (GlyphClassTable) o; | bcdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(2)) != null) && ! (o instanceof GlyphClassTable)) { | |||||
if (((o = entries.get(2)) != null) && !(o instanceof GlyphClassTable)) { | |||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); | ||||
} else { | } else { | ||||
lcdt = (GlyphClassTable) o; | lcdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | ngc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(4)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
boolean first = true; | boolean first = true; | ||||
sb.append("{ "); | sb.append("{ "); | ||||
if (xPlacement != 0) { | if (xPlacement != 0) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("xPlacement = " + xPlacement); | sb.append("xPlacement = " + xPlacement); | ||||
} | } | ||||
if (yPlacement != 0) { | if (yPlacement != 0) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("yPlacement = " + yPlacement); | sb.append("yPlacement = " + yPlacement); | ||||
} | } | ||||
if (xAdvance != 0) { | if (xAdvance != 0) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("xAdvance = " + xAdvance); | sb.append("xAdvance = " + xAdvance); | ||||
} | } | ||||
if (yAdvance != 0) { | if (yAdvance != 0) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("yAdvance = " + yAdvance); | sb.append("yAdvance = " + yAdvance); | ||||
} | } | ||||
if (xPlaDevice != null) { | if (xPlaDevice != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("xPlaDevice = " + xPlaDevice); | sb.append("xPlaDevice = " + xPlaDevice); | ||||
} | } | ||||
if (yPlaDevice != null) { | if (yPlaDevice != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("xPlaDevice = " + yPlaDevice); | sb.append("xPlaDevice = " + yPlaDevice); | ||||
} | } | ||||
if (xAdvDevice != null) { | if (xAdvDevice != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("xAdvDevice = " + xAdvDevice); | sb.append("xAdvDevice = " + xAdvDevice); | ||||
} | } | ||||
if (yAdvDevice != null) { | if (yAdvDevice != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
boolean first = true; | boolean first = true; | ||||
sb.append("{ "); | sb.append("{ "); | ||||
if (glyph != 0) { | if (glyph != 0) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("glyph = " + glyph); | sb.append("glyph = " + glyph); | ||||
} | } | ||||
if (value1 != null) { | if (value1 != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
sb.append("value1 = " + value1); | sb.append("value1 = " + value1); | ||||
} | } | ||||
if (value2 != null) { | if (value2 != null) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(", "); | sb.append(", "); | ||||
} else { | } else { | ||||
first = false; | first = false; |
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphProcessingState</code> implements a common, base state object used during glyph substitution | * <p>The <code>GlyphProcessingState</code> implements a common, base state object used during glyph substitution | ||||
int start = index + offset; | int start = index + offset; | ||||
if (start < 0) { | if (start < 0) { | ||||
throw new IndexOutOfBoundsException("will attempt index at " + start); | throw new IndexOutOfBoundsException("will attempt index at " + start); | ||||
} else if (! reverseOrder && ((start + count) > indexLast)) { | |||||
} else if (!reverseOrder && ((start + count) > indexLast)) { | |||||
throw new IndexOutOfBoundsException("will attempt index at " + (start + count)); | throw new IndexOutOfBoundsException("will attempt index at " + (start + count)); | ||||
} else if (reverseOrder && ((start + 1) < count)) { | } else if (reverseOrder && ((start + 1) < count)) { | ||||
throw new IndexOutOfBoundsException("will attempt index at " + (start - count)); | throw new IndexOutOfBoundsException("will attempt index at " + (start - count)); | ||||
} else if (glyphs.length != 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 + ")"); | throw new IllegalArgumentException("glyphs array is non-null, but its length (" + glyphs.length + "), is not equal to count (" + count + ")"); | ||||
} | } | ||||
if (! reverseOrder) { | |||||
if (!reverseOrder) { | |||||
return getGlyphsForward(start, count, ignoreTester, glyphs, counts); | return getGlyphsForward(start, count, ignoreTester, glyphs, counts); | ||||
} else { | } else { | ||||
return getGlyphsReverse(start, count, ignoreTester, glyphs, counts); | return getGlyphsReverse(start, count, ignoreTester, glyphs, counts); | ||||
if (gi == 65535) { | if (gi == 65535) { | ||||
ignored++; | ignored++; | ||||
} else { | } else { | ||||
if ((ignoreTester == null) || ! ignoreTester.test(gi, getLookupFlags())) { | |||||
if ((ignoreTester == null) || !ignoreTester.test(gi, getLookupFlags())) { | |||||
glyphs [ counted++ ] = gi; | glyphs [ counted++ ] = gi; | ||||
} else { | } else { | ||||
ignored++; | ignored++; | ||||
if (gi == 65535) { | if (gi == 65535) { | ||||
ignored++; | ignored++; | ||||
} else { | } else { | ||||
if ((ignoreTester == null) || ! ignoreTester.test(gi, getLookupFlags())) { | |||||
if ((ignoreTester == null) || !ignoreTester.test(gi, getLookupFlags())) { | |||||
glyphs [ counted++ ] = gi; | glyphs [ counted++ ] = gi; | ||||
} else { | } else { | ||||
ignored++; | ignored++; | ||||
int start = index + offset; | int start = index + offset; | ||||
if ((start < 0) || (start > indexLast)) { | if ((start < 0) || (start > indexLast)) { | ||||
return new int[] { 0, 0 }; | return new int[] { 0, 0 }; | ||||
} else if (! reverseOrder) { | |||||
} else if (!reverseOrder) { | |||||
return getGlyphsAvailableForward(start, ignoreTester); | return getGlyphsAvailableForward(start, ignoreTester); | ||||
} else { | } else { | ||||
return getGlyphsAvailableReverse(start, ignoreTester); | return getGlyphsAvailableReverse(start, ignoreTester); | ||||
int start = index + offset; | int start = index + offset; | ||||
if (start < 0) { | if (start < 0) { | ||||
throw new IndexOutOfBoundsException("will attempt index at " + start); | throw new IndexOutOfBoundsException("will attempt index at " + start); | ||||
} else if (! reverseOrder && ((start + count) > indexLast)) { | |||||
} else if (!reverseOrder && ((start + count) > indexLast)) { | |||||
throw new IndexOutOfBoundsException("will attempt index at " + (start + count)); | throw new IndexOutOfBoundsException("will attempt index at " + (start + count)); | ||||
} else if (reverseOrder && ((start + 1) < count)) { | } else if (reverseOrder && ((start + 1) < count)) { | ||||
throw new IndexOutOfBoundsException("will attempt index at " + (start - count)); | throw new IndexOutOfBoundsException("will attempt index at " + (start - count)); | ||||
} else if (associations.length != 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 + ")"); | throw new IllegalArgumentException("associations array is non-null, but its length (" + associations.length + "), is not equal to count (" + count + ")"); | ||||
} | } | ||||
if (! reverseOrder) { | |||||
if (!reverseOrder) { | |||||
return getAssociationsForward(start, count, ignoreTester, associations, counts); | return getAssociationsForward(start, count, ignoreTester, associations, counts); | ||||
} else { | } else { | ||||
return getAssociationsReverse(start, count, ignoreTester, associations, counts); | return getAssociationsReverse(start, count, ignoreTester, associations, counts); | ||||
if (gi == 65535) { | if (gi == 65535) { | ||||
ignored++; | ignored++; | ||||
} else { | } else { | ||||
if ((ignoreTester == null) || ! ignoreTester.test(gi, getLookupFlags())) { | |||||
if ((ignoreTester == null) || !ignoreTester.test(gi, getLookupFlags())) { | |||||
if (k < count) { | if (k < count) { | ||||
associations [ k++ ] = getAssociation(i - index); | associations [ k++ ] = getAssociation(i - index); | ||||
counted++; | counted++; | ||||
if (gi == 65535) { | if (gi == 65535) { | ||||
ignored++; | ignored++; | ||||
} else { | } else { | ||||
if ((ignoreTester == null) || ! ignoreTester.test(gi, getLookupFlags())) { | |||||
if ((ignoreTester == null) || !ignoreTester.test(gi, getLookupFlags())) { | |||||
if (k < count) { | if (k < count) { | ||||
associations [ k++ ] = getAssociation(i - index); | associations [ k++ ] = getAssociation(i - index); | ||||
counted++; | counted++; | ||||
for (int i = 0, n = ngt; i < n; i++) { | for (int i = 0, n = ngt; i < n; i++) { | ||||
GlyphTester gt = gta [ i ]; | GlyphTester gt = gta [ i ]; | ||||
if (gt != null) { | if (gt != null) { | ||||
if (! gt.test(gi, flags)) { | |||||
if (!gt.test(gi, flags)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } |
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphSubstitutionState</code> implements an state object used during glyph substitution | * <p>The <code>GlyphSubstitutionState</code> implements an state object used during glyph substitution | ||||
* @param predication a predication value to add to association A if predications enabled | * @param predication a predication value to add to association A if predications enabled | ||||
*/ | */ | ||||
public void putGlyph(int glyph, GlyphSequence.CharAssociation a, Object predication) { | public void putGlyph(int glyph, GlyphSequence.CharAssociation a, Object predication) { | ||||
if (! ogb.hasRemaining()) { | |||||
if (!ogb.hasRemaining()) { | |||||
ogb = growBuffer(ogb); | ogb = growBuffer(ogb); | ||||
} | } | ||||
ogb.put(glyph); | ogb.put(glyph); |
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphSubstitutionSubtable</code> implements an abstract base of a glyph substitution subtable, | * <p>The <code>GlyphSubstitutionSubtable</code> implements an abstract base of a glyph substitution subtable, | ||||
boolean appliedOneShot = false; | boolean appliedOneShot = false; | ||||
while (ss.hasNext()) { | while (ss.hasNext()) { | ||||
boolean applied = false; | boolean applied = false; | ||||
if (! appliedOneShot && ss.maybeApplicable()) { | |||||
for (int i = 0, n = sta.length; ! applied && (i < n); i++) { | |||||
if (!appliedOneShot && ss.maybeApplicable()) { | |||||
for (int i = 0, n = sta.length; !applied && (i < n); i++) { | |||||
if (sequenceIndex < 0) { | if (sequenceIndex < 0) { | ||||
applied = ss.apply(sta [ i ]); | applied = ss.apply(sta [ i ]); | ||||
} else if (ss.getPosition() == (sequenceStart + sequenceIndex)) { | } else if (ss.getPosition() == (sequenceStart + sequenceIndex)) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (! applied || ! ss.didConsume()) { | |||||
if (!applied || !ss.didConsume()) { | |||||
ss.applyDefault(); | ss.applyDefault(); | ||||
} | } | ||||
ss.next(); | ss.next(); |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
import org.apache.fop.complexscripts.util.GlyphTester; | import org.apache.fop.complexscripts.util.GlyphTester; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>The <code>GlyphSubstitutionTable</code> class is a glyph table that implements | * <p>The <code>GlyphSubstitutionTable</code> class is a glyph table that implements | ||||
Object o = entries.get(0); | Object o = entries.get(0); | ||||
int delta = 0; | int delta = 0; | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
delta = ((Integer) o) . intValue(); | |||||
delta = ((Integer) o) .intValue(); | |||||
} else { | } 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); | ||||
} | } | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof int[][])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an int[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
gsa = (int[][]) o; | gsa = (int[][]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 3 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
cdt = (GlyphClassTable) o; | cdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | ngc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(2)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 5 entries"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof GlyphClassTable)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an GlyphClassTable, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
icdt = (GlyphClassTable) o; | icdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(1)) != null) && ! (o instanceof GlyphClassTable)) { | |||||
if (((o = entries.get(1)) != null) && !(o instanceof GlyphClassTable)) { | |||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an GlyphClassTable, but is: " + o.getClass()); | ||||
} else { | } else { | ||||
bcdt = (GlyphClassTable) o; | bcdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(2)) != null) && ! (o instanceof GlyphClassTable)) { | |||||
if (((o = entries.get(2)) != null) && !(o instanceof GlyphClassTable)) { | |||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an GlyphClassTable, but is: " + o.getClass()); | ||||
} else { | } else { | ||||
lcdt = (GlyphClassTable) o; | lcdt = (GlyphClassTable) o; | ||||
} | } | ||||
if (((o = entries.get(3)) == null) || ! (o instanceof Integer)) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | ngc = ((Integer)(o)).intValue(); | ||||
} | } | ||||
if (((o = entries.get(4)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | throw new AdvancedTypographicTableFormatException("illegal entries, " + entries.size() + " entries present, but requires 1 entry"); | ||||
} else { | } else { | ||||
Object o; | Object o; | ||||
if (((o = entries.get(0)) == null) || ! (o instanceof RuleSet[])) { | |||||
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)); | throw new AdvancedTypographicTableFormatException("illegal entries, first entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
rsa = (RuleSet[]) o; | rsa = (RuleSet[]) o; |
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* <p>Base class for all advanced typographic glyph tables.</p> | * <p>Base class for all advanced typographic glyph tables.</p> | ||||
* @param lookups map from lookup specs to lookup tables | * @param lookups map from lookup specs to lookup tables | ||||
*/ | */ | ||||
public GlyphTable(GlyphTable gdef, Map/*<LookupSpec,List<String>>*/ lookups) { | public GlyphTable(GlyphTable gdef, Map/*<LookupSpec,List<String>>*/ lookups) { | ||||
if ((gdef != null) && ! (gdef instanceof GlyphDefinitionTable)) { | |||||
if ((gdef != null) && !(gdef instanceof GlyphDefinitionTable)) { | |||||
throw new AdvancedTypographicTableFormatException("bad glyph definition table"); | throw new AdvancedTypographicTableFormatException("bad glyph definition table"); | ||||
} else if (lookups == null) { | } else if (lookups == null) { | ||||
throw new AdvancedTypographicTableFormatException("lookups must be non-null map"); | throw new AdvancedTypographicTableFormatException("lookups must be non-null map"); | ||||
* create resulting cached state. | * create resulting cached state. | ||||
*/ | */ | ||||
protected void freezeSubtables() { | protected void freezeSubtables() { | ||||
if (! frozen) { | |||||
if (!frozen) { | |||||
for (Iterator it = lookupTables.values().iterator(); it.hasNext(); ) { | for (Iterator it = lookupTables.values().iterator(); it.hasNext(); ) { | ||||
LookupTable lt = (LookupTable) it.next(); | LookupTable lt = (LookupTable) it.next(); | ||||
lt.freezeSubtables(lookupTables); | lt.freezeSubtables(lookupTables); | ||||
List/*<LookupSpec>*/ matches = new ArrayList/*<LookupSpec>*/(); | List/*<LookupSpec>*/ matches = new ArrayList/*<LookupSpec>*/(); | ||||
for (Iterator it = keys.iterator(); it.hasNext();) { | for (Iterator it = keys.iterator(); it.hasNext();) { | ||||
LookupSpec ls = (LookupSpec) it.next(); | LookupSpec ls = (LookupSpec) it.next(); | ||||
if (! "*".equals(script)) { | |||||
if (! ls.getScript().equals(script)) { | |||||
if (!"*".equals(script)) { | |||||
if (!ls.getScript().equals(script)) { | |||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
if (! "*".equals(language)) { | |||||
if (! ls.getLanguage().equals(language)) { | |||||
if (!"*".equals(language)) { | |||||
if (!ls.getLanguage().equals(language)) { | |||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
if (! "*".equals(feature)) { | |||||
if (! ls.getFeature().equals(feature)) { | |||||
if (!"*".equals(feature)) { | |||||
if (!ls.getFeature().equals(feature)) { | |||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
* @param permitWildcard if true the permit wildcard 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) { | LookupSpec(String script, String language, String feature, boolean permitEmpty, boolean permitWildcard) { | ||||
if ((script == null) || (! permitEmpty && (script.length() == 0))) { | |||||
if ((script == null) || (!permitEmpty && (script.length() == 0))) { | |||||
throw new AdvancedTypographicTableFormatException("script must be non-empty string"); | throw new AdvancedTypographicTableFormatException("script must be non-empty string"); | ||||
} else if ((language == null) || (! permitEmpty && (language.length() == 0))) { | |||||
} else if ((language == null) || (!permitEmpty && (language.length() == 0))) { | |||||
throw new AdvancedTypographicTableFormatException("language must be non-empty string"); | throw new AdvancedTypographicTableFormatException("language must be non-empty string"); | ||||
} else if ((feature == null) || (! permitEmpty && (feature.length() == 0))) { | |||||
} else if ((feature == null) || (!permitEmpty && (feature.length() == 0))) { | |||||
throw new AdvancedTypographicTableFormatException("feature must be non-empty string"); | throw new AdvancedTypographicTableFormatException("feature must be non-empty string"); | ||||
} else if (! permitWildcard && script.equals("*")) { | |||||
} else if (!permitWildcard && script.equals("*")) { | |||||
throw new AdvancedTypographicTableFormatException("script must not be wildcard"); | throw new AdvancedTypographicTableFormatException("script must not be wildcard"); | ||||
} else if (! permitWildcard && language.equals("*")) { | |||||
} else if (!permitWildcard && language.equals("*")) { | |||||
throw new AdvancedTypographicTableFormatException("language must not be wildcard"); | throw new AdvancedTypographicTableFormatException("language must not be wildcard"); | ||||
} else if (! permitWildcard && feature.equals("*")) { | |||||
} else if (!permitWildcard && feature.equals("*")) { | |||||
throw new AdvancedTypographicTableFormatException("feature must not be wildcard"); | throw new AdvancedTypographicTableFormatException("feature must not be wildcard"); | ||||
} | } | ||||
this.script = script.trim(); | this.script = script.trim(); | ||||
public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
if (o instanceof LookupSpec) { | if (o instanceof LookupSpec) { | ||||
LookupSpec l = (LookupSpec) o; | LookupSpec l = (LookupSpec) o; | ||||
if (! l.script.equals(script)) { | |||||
if (!l.script.equals(script)) { | |||||
return false; | return false; | ||||
} else if (! l.language.equals(language)) { | |||||
return false; | |||||
} else if (! l.feature.equals(feature)) { | |||||
} else if (!l.language.equals(language)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | |||||
return l.feature.equals(feature); | |||||
} | } | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// append at end of list | // append at end of list | ||||
if (! added && (subtable != null)) { | |||||
if (!added && (subtable != null)) { | |||||
subtables.add(subtable); | subtables.add(subtable); | ||||
added = true; | added = true; | ||||
} | } | ||||
} | } | ||||
if (subtables.size() > 0) { | if (subtables.size() > 0) { | ||||
GlyphSubtable st = (GlyphSubtable) subtables.get(0); | GlyphSubtable st = (GlyphSubtable) subtables.get(0); | ||||
if (! st.isCompatible(subtable)) { | |||||
if (!st.isCompatible(subtable)) { | |||||
throw new AdvancedTypographicTableFormatException("subtable " + subtable + " is not compatible with subtable " + st); | throw new AdvancedTypographicTableFormatException("subtable " + subtable + " is not compatible with subtable " + st); | ||||
} | } | ||||
} | } | ||||
* @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables | * @param lookupTables map from lookup table identifers, e.g. "lu4", to lookup tables | ||||
*/ | */ | ||||
public void freezeSubtables(Map/*<String,LookupTable>*/ lookupTables) { | public void freezeSubtables(Map/*<String,LookupTable>*/ lookupTables) { | ||||
if (! frozen) { | |||||
if (!frozen) { | |||||
GlyphSubtable[] sta = getSubtables(); | GlyphSubtable[] sta = getSubtables(); | ||||
resolveLookupReferences(sta, lookupTables); | resolveLookupReferences(sta, lookupTables); | ||||
this.subtablesArray = sta; | this.subtablesArray = sta; | ||||
Class c = r0.getClass(); | 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]; | Rule r = rules[i]; | ||||
if ((r != null) && ! c.isInstance(r)) { | |||||
if ((r != null) && !c.isInstance(r)) { | |||||
throw new AdvancedTypographicTableFormatException("rules[" + i + "] is not an instance of " + c.getName()); | throw new AdvancedTypographicTableFormatException("rules[" + i + "] is not an instance of " + c.getName()); | ||||
} | } | ||||
} | } |
import org.apache.fop.fonts.truetype.OFTableName; | import org.apache.fop.fonts.truetype.OFTableName; | ||||
import org.apache.fop.fonts.truetype.OpenFont; | import org.apache.fop.fonts.truetype.OpenFont; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} else { | } else { | ||||
boolean first = true; | boolean first = true; | ||||
for (int i = 0; i < ia.length; i++) { | for (int i = 0; i < ia.length; i++) { | ||||
if (! first) { | |||||
if (!first) { | |||||
sb.append(' '); | sb.append(' '); | ||||
} else { | } else { | ||||
first = false; | first = false; |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} else { | } else { | ||||
int s = a.getStart(); | int s = a.getStart(); | ||||
int e = a.getEnd(); | int e = a.getEnd(); | ||||
if (! hasFinalPrecedingContext(ca, nc, s, e)) { | |||||
if (!hasFinalPrecedingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else if (forcesFinalThisContext(ca, nc, s, e)) { | } else if (forcesFinalThisContext(ca, nc, s, e)) { | ||||
return true; | return true; | ||||
} else if (! hasFinalFollowingContext(ca, nc, s, e)) { | |||||
} else if (!hasFinalFollowingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
int s = a.getStart(); | int s = a.getStart(); | ||||
int e = a.getEnd(); | int e = a.getEnd(); | ||||
if (! hasInitialPrecedingContext(ca, nc, s, e)) { | |||||
if (!hasInitialPrecedingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else if (! hasInitialFollowingContext(ca, nc, s, e)) { | |||||
} else if (!hasInitialFollowingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
int s = a.getStart(); | int s = a.getStart(); | ||||
int e = a.getEnd(); | int e = a.getEnd(); | ||||
if (! hasLigaturePrecedingContext(ca, nc, s, e)) { | |||||
if (!hasLigaturePrecedingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else if (! hasLigatureFollowingContext(ca, nc, s, e)) { | |||||
} else if (!hasLigatureFollowingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
int s = a.getStart(); | int s = a.getStart(); | ||||
int e = a.getEnd(); | int e = a.getEnd(); | ||||
if (! hasMedialPrecedingContext(ca, nc, s, e)) { | |||||
if (!hasMedialPrecedingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else if (! hasMedialThisContext(ca, nc, s, e)) { | |||||
} else if (!hasMedialThisContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else if (! hasMedialFollowingContext(ca, nc, s, e)) { | |||||
} else if (!hasMedialFollowingContext(ca, nc, s, e)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | return true; |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: WhitespaceAfter | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} | } | ||||
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) . getPredication("half"); | |||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | |||||
return (half != null) ? half.booleanValue() : false; | return (half != null) ? half.booleanValue() : false; | ||||
} | } | ||||
// first candidate target is after first non-half consonant | // first candidate target is after first non-half consonant | ||||
for (int i = 0; i < ng; i++) { | for (int i = 0; i < ng; i++) { | ||||
if ((i != source) && containsConsonant(gs, i)) { | if ((i != source) && containsConsonant(gs, i)) { | ||||
if (! containsHalfConsonant(gs, i)) { | |||||
if (!containsHalfConsonant(gs, i)) { | |||||
c1 = i + 1; | c1 = i + 1; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark | // 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++) { | for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { | ||||
if (containsMatra(gs, i) && ! containsPreBaseMatra(gs, i)) { | |||||
if (containsMatra(gs, i) && !containsPreBaseMatra(gs, i)) { | |||||
c2 = i + 1; | c2 = i + 1; | ||||
} else if (containsOtherMark(gs, i)) { | } else if (containsOtherMark(gs, i)) { | ||||
c2 = i; | c2 = i; | ||||
} | } | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) . getPredication("rphf"); | |||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | |||||
return (rphf != null) ? rphf.booleanValue() : false; | return (rphf != null) ? rphf.booleanValue() : false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static boolean isC(int c) { | static boolean isC(int c) { | ||||
return isType(c,C_C); | |||||
return isType(c, C_C); | |||||
} | } | ||||
static boolean isR(int c) { | static boolean isR(int c) { | ||||
return isType(c,C_C) && hasR(c); | |||||
return isType(c, C_C) && hasR(c); | |||||
} | } | ||||
static boolean isV(int c) { | static boolean isV(int c) { | ||||
return isType(c,C_V); | |||||
return isType(c, C_V); | |||||
} | } | ||||
static boolean isN(int c) { | static boolean isN(int c) { | ||||
return c == 0x093C; | return c == 0x093C; | ||||
return c == 0x094D; | return c == 0x094D; | ||||
} | } | ||||
static boolean isM(int c) { | static boolean isM(int c) { | ||||
return isType(c,C_M); | |||||
return isType(c, C_M); | |||||
} | } | ||||
static boolean isPreM(int c) { | static boolean isPreM(int c) { | ||||
return isType(c,C_M) && hasFlag(c,C_PRE); | |||||
return isType(c, C_M) && hasFlag(c, C_PRE); | |||||
} | } | ||||
static boolean isX(int c) { | static boolean isX(int c) { | ||||
switch (typeOf(c)) { | switch (typeOf(c)) { | ||||
} | } | ||||
} | } | ||||
static boolean hasR(int c) { | static boolean hasR(int c) { | ||||
return hasFlag(c,C_R); | |||||
return hasFlag(c, C_R); | |||||
} | } | ||||
static boolean hasN(int c) { | static boolean hasN(int c) { | ||||
return hasFlag(c,C_N); | |||||
return hasFlag(c, C_N); | |||||
} | } | ||||
} | } |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: WhitespaceAfter | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} | } | ||||
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) . getPredication("half"); | |||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | |||||
return (half != null) ? half.booleanValue() : false; | return (half != null) ? half.booleanValue() : false; | ||||
} | } | ||||
// first candidate target is after first non-half consonant | // first candidate target is after first non-half consonant | ||||
for (int i = 0; i < ng; i++) { | for (int i = 0; i < ng; i++) { | ||||
if ((i != source) && containsConsonant(gs, i)) { | if ((i != source) && containsConsonant(gs, i)) { | ||||
if (! containsHalfConsonant(gs, i)) { | |||||
if (!containsHalfConsonant(gs, i)) { | |||||
c1 = i + 1; | c1 = i + 1; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark | // 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++) { | for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { | ||||
if (containsMatra(gs, i) && ! containsPreBaseMatra(gs, i)) { | |||||
if (containsMatra(gs, i) && !containsPreBaseMatra(gs, i)) { | |||||
c2 = i + 1; | c2 = i + 1; | ||||
} else if (containsOtherMark(gs, i)) { | } else if (containsOtherMark(gs, i)) { | ||||
c2 = i; | c2 = i; | ||||
} | } | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) . getPredication("rphf"); | |||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | |||||
return (rphf != null) ? rphf.booleanValue() : false; | return (rphf != null) ? rphf.booleanValue() : false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static boolean isC(int c) { | static boolean isC(int c) { | ||||
return isType(c,C_C); | |||||
return isType(c, C_C); | |||||
} | } | ||||
static boolean isR(int c) { | static boolean isR(int c) { | ||||
return isType(c,C_C) && hasR(c); | |||||
return isType(c, C_C) && hasR(c); | |||||
} | } | ||||
static boolean isV(int c) { | static boolean isV(int c) { | ||||
return isType(c,C_V); | |||||
return isType(c, C_V); | |||||
} | } | ||||
static boolean isN(int c) { | static boolean isN(int c) { | ||||
return c == 0x0ABC; | return c == 0x0ABC; | ||||
return c == 0x0ACD; | return c == 0x0ACD; | ||||
} | } | ||||
static boolean isM(int c) { | static boolean isM(int c) { | ||||
return isType(c,C_M); | |||||
return isType(c, C_M); | |||||
} | } | ||||
static boolean isPreM(int c) { | static boolean isPreM(int c) { | ||||
return isType(c,C_M) && hasFlag(c,C_PRE); | |||||
return isType(c, C_M) && hasFlag(c, C_PRE); | |||||
} | } | ||||
static boolean isX(int c) { | static boolean isX(int c) { | ||||
switch (typeOf(c)) { | switch (typeOf(c)) { | ||||
} | } | ||||
} | } | ||||
static boolean hasR(int c) { | static boolean hasR(int c) { | ||||
return hasFlag(c,C_R); | |||||
return hasFlag(c, C_R); | |||||
} | } | ||||
static boolean hasN(int c) { | static boolean hasN(int c) { | ||||
return hasFlag(c,C_N); | |||||
return hasFlag(c, C_N); | |||||
} | } | ||||
} | } |
import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; | import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; | ||||
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: WhitespaceAfter | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} | } | ||||
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) . getPredication("half"); | |||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | |||||
return (half != null) ? half.booleanValue() : false; | return (half != null) ? half.booleanValue() : false; | ||||
} | } | ||||
// first candidate target is after first non-half consonant | // first candidate target is after first non-half consonant | ||||
for (int i = 0; i < ng; i++) { | for (int i = 0; i < ng; i++) { | ||||
if ((i != source) && containsConsonant(gs, i)) { | if ((i != source) && containsConsonant(gs, i)) { | ||||
if (! containsHalfConsonant(gs, i)) { | |||||
if (!containsHalfConsonant(gs, i)) { | |||||
c1 = i + 1; | c1 = i + 1; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// second candidate target is after last non-prebase matra after first candidate or before first syllable or vedic mark | // 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++) { | for (int i = (c1 >= 0) ? c1 : 0; i < ng; i++) { | ||||
if (containsMatra(gs, i) && ! containsPreBaseMatra(gs, i)) { | |||||
if (containsMatra(gs, i) && !containsPreBaseMatra(gs, i)) { | |||||
c2 = i + 1; | c2 = i + 1; | ||||
} else if (containsOtherMark(gs, i)) { | } else if (containsOtherMark(gs, i)) { | ||||
c2 = i; | c2 = i; | ||||
} | } | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) . getPredication("rphf"); | |||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | |||||
return (rphf != null) ? rphf.booleanValue() : false; | return (rphf != null) ? rphf.booleanValue() : false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static boolean isC(int c) { | static boolean isC(int c) { | ||||
return isType(c,C_C); | |||||
return isType(c, C_C); | |||||
} | } | ||||
static boolean isR(int c) { | static boolean isR(int c) { | ||||
return isType(c,C_C) && hasR(c); | |||||
return isType(c, C_C) && hasR(c); | |||||
} | } | ||||
static boolean isV(int c) { | static boolean isV(int c) { | ||||
return isType(c,C_V); | |||||
return isType(c, C_V); | |||||
} | } | ||||
static boolean isN(int c) { | static boolean isN(int c) { | ||||
return c == 0x0A3C; | return c == 0x0A3C; | ||||
return c == 0x0A4D; | return c == 0x0A4D; | ||||
} | } | ||||
static boolean isM(int c) { | static boolean isM(int c) { | ||||
return isType(c,C_M); | |||||
return isType(c, C_M); | |||||
} | } | ||||
static boolean isPreM(int c) { | static boolean isPreM(int c) { | ||||
return isType(c,C_M) && hasFlag(c,C_PRE); | |||||
return isType(c, C_M) && hasFlag(c, C_PRE); | |||||
} | } | ||||
static boolean isX(int c) { | static boolean isX(int c) { | ||||
switch (typeOf(c)) { | switch (typeOf(c)) { | ||||
} | } | ||||
} | } | ||||
static boolean hasR(int c) { | static boolean hasR(int c) { | ||||
return hasFlag(c,C_R); | |||||
return hasFlag(c, C_R); | |||||
} | } | ||||
static boolean hasN(int c) { | static boolean hasN(int c) { | ||||
return hasFlag(c,C_N); | |||||
return hasFlag(c, C_N); | |||||
} | } | ||||
@Override | @Override |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: EmptyForIteratorPadCheck | |||||
// CSOFF: WhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** | ||||
} | } | ||||
private GlyphSequence[] syllabize(GlyphSequence gs, String script, String language) { | private GlyphSequence[] syllabize(GlyphSequence gs, String script, String language) { | ||||
return Syllabizer.getSyllabizer(script, language, getSyllabizerClass()) . syllabize(gs); | |||||
return Syllabizer.getSyllabizer(script, language, getSyllabizerClass()) .syllabize(gs); | |||||
} | } | ||||
private GlyphSequence unsyllabize(GlyphSequence gs, GlyphSequence[] sa) { | private GlyphSequence unsyllabize(GlyphSequence gs, GlyphSequence[] sa) { | ||||
public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
if (o instanceof Syllabizer) { | if (o instanceof Syllabizer) { | ||||
Syllabizer s = (Syllabizer) o; | Syllabizer s = (Syllabizer) o; | ||||
if (! s.script.equals(script)) { | |||||
return false; | |||||
} else if (! s.language.equals(language)) { | |||||
if (!s.script.equals(script)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | |||||
return s.language.equals(language); | |||||
} | } | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
return d; | return d; | ||||
} | } | ||||
private static Map<String,Syllabizer> syllabizers = new HashMap<String,Syllabizer>(); | |||||
private static Map<String, Syllabizer> syllabizers = new HashMap<String, Syllabizer>(); | |||||
static Syllabizer getSyllabizer(String script, String language, Class<? extends Syllabizer> syllabizerClass) { | static Syllabizer getSyllabizer(String script, String language, Class<? extends Syllabizer> syllabizerClass) { | ||||
String sid = makeSyllabizerId(script, language); | String sid = makeSyllabizerId(script, language); | ||||
Syllabizer s = syllabizers.get(sid); | Syllabizer s = syllabizers.get(sid); |
import org.apache.fop.complexscripts.util.GlyphSequence; | import org.apache.fop.complexscripts.util.GlyphSequence; | ||||
import org.apache.fop.complexscripts.util.ScriptContextTester; | import org.apache.fop.complexscripts.util.ScriptContextTester; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: ParameterNumberCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
/** | /** | ||||
* <p>Abstract script processor base class for which an implementation of the substitution and positioning methods | * <p>Abstract script processor base class for which an implementation of the substitution and positioning methods | ||||
public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
if (o instanceof AssembledLookupsKey) { | if (o instanceof AssembledLookupsKey) { | ||||
AssembledLookupsKey k = (AssembledLookupsKey) o; | AssembledLookupsKey k = (AssembledLookupsKey) o; | ||||
if (! table.equals(k.table)) { | |||||
if (!table.equals(k.table)) { | |||||
return false; | return false; | ||||
} else if (! Arrays.equals(features, k.features)) { | |||||
return false; | |||||
} else if (! lookups.equals(k.lookups)) { | |||||
} else if (!Arrays.equals(features, k.features)) { | |||||
return false; | return false; | ||||
} else { | } else { | ||||
return true; | |||||
return lookups.equals(k.lookups); | |||||
} | } | ||||
} else { | } else { | ||||
return false; | return false; |
import org.apache.fop.util.CharUtilities; | import org.apache.fop.util.CharUtilities; | ||||
// CSOFF: AvoidNestedBlocksCheck | |||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | |||||
// CSOFF: SimplifyBooleanReturnCheck | |||||
// CSOFF: WhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>Script related utilities.</p> | * <p>Script related utilities.</p> | ||||
* | * | ||||
case SCRIPT_UNCODED: | case SCRIPT_UNCODED: | ||||
break; | break; | ||||
default: | default: | ||||
{ | |||||
Integer v = (Integer) e.getValue(); | |||||
assert v != null; | |||||
int c = v.intValue(); | |||||
if (c > cMax) { | |||||
cMax = c; | |||||
sMax = s; | |||||
} | |||||
break; | |||||
Integer v = (Integer) e.getValue(); | |||||
assert v != null; | |||||
int c = v.intValue(); | |||||
if (c > cMax) { | |||||
cMax = c; | |||||
sMax = s; | |||||
} | } | ||||
break; | |||||
} | } | ||||
} | } | ||||
if (sMax < 0) { | if (sMax < 0) { | ||||
* @return a script tag | * @return a script tag | ||||
*/ | */ | ||||
public static String scriptTagFromCode(int code) { | public static String scriptTagFromCode(int code) { | ||||
Map<Integer,String> m = getScriptTagsMap(); | |||||
Map<Integer, String> m = getScriptTagsMap(); | |||||
if (m != null) { | if (m != null) { | ||||
String tag; | String tag; | ||||
if ((tag = m.get(Integer.valueOf(code))) != null) { | if ((tag = m.get(Integer.valueOf(code))) != null) { | ||||
* @return a script code | * @return a script code | ||||
*/ | */ | ||||
public static int scriptCodeFromTag(String tag) { | public static int scriptCodeFromTag(String tag) { | ||||
Map<String,Integer> m = getScriptCodeMap(); | |||||
Map<String, Integer> m = getScriptCodeMap(); | |||||
if (m != null) { | if (m != null) { | ||||
Integer c; | Integer c; | ||||
if ((c = m.get(tag)) != null) { | if ((c = m.get(tag)) != null) { | ||||
} | } | ||||
} | } | ||||
private static Map<Integer,String> scriptTagsMap = null; | |||||
private static Map<String,Integer> scriptCodeMap = null; | |||||
private static Map<Integer, String> scriptTagsMap = null; | |||||
private static Map<String, Integer> 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 != null; | ||||
} | } | ||||
private static void makeScriptMaps() { | private static void makeScriptMaps() { | ||||
HashMap<Integer,String> tm = new HashMap<Integer,String>(); | |||||
HashMap<String,Integer> cm = new HashMap<String,Integer>(); | |||||
HashMap<Integer, String> tm = new HashMap<Integer, String>(); | |||||
HashMap<String, Integer> cm = new HashMap<String, Integer>(); | |||||
putScriptTag(tm, cm, SCRIPT_HEBREW, "hebr"); | putScriptTag(tm, cm, SCRIPT_HEBREW, "hebr"); | ||||
putScriptTag(tm, cm, SCRIPT_MONGOLIAN, "mong"); | putScriptTag(tm, cm, SCRIPT_MONGOLIAN, "mong"); | ||||
putScriptTag(tm, cm, SCRIPT_ARABIC, "arab"); | putScriptTag(tm, cm, SCRIPT_ARABIC, "arab"); | ||||
scriptCodeMap = cm; | scriptCodeMap = cm; | ||||
} | } | ||||
private static Map<Integer,String> getScriptTagsMap() { | |||||
private static Map<Integer, String> getScriptTagsMap() { | |||||
if (scriptTagsMap == null) { | if (scriptTagsMap == null) { | ||||
makeScriptMaps(); | makeScriptMaps(); | ||||
} | } | ||||
return scriptTagsMap; | return scriptTagsMap; | ||||
} | } | ||||
private static Map<String,Integer> getScriptCodeMap() { | |||||
private static Map<String, Integer> getScriptCodeMap() { | |||||
if (scriptCodeMap == null) { | if (scriptCodeMap == null) { | ||||
makeScriptMaps(); | makeScriptMaps(); | ||||
} | } |
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: WhitespaceAfterCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* <p>A GlyphSequence encapsulates a sequence of character codes, a sequence of glyph codes, | * <p>A GlyphSequence encapsulates a sequence of character codes, a sequence of glyph codes, | ||||
private final int offset; | private final int offset; | ||||
private final int count; | private final int count; | ||||
private final int[] subIntervals; | private final int[] subIntervals; | ||||
private Map<String,Object> predications; | |||||
private Map<String, Object> predications; | |||||
// class state | // class state | ||||
private static volatile Map<String,PredicationMerger> predicationMergers; | |||||
private static volatile Map<String, PredicationMerger> predicationMergers; | |||||
interface PredicationMerger { | interface PredicationMerger { | ||||
Object merge(String key, Object v1, Object v2); | Object merge(String key, Object v1, Object v2); | ||||
public boolean contained(int offset, int count) { | public boolean contained(int offset, int count) { | ||||
int s = offset; | int s = offset; | ||||
int e = offset + count; | int e = offset + count; | ||||
if (! isDisjoint()) { | |||||
if (!isDisjoint()) { | |||||
int s0 = getStart(); | int s0 = getStart(); | ||||
int e0 = getEnd(); | int e0 = getEnd(); | ||||
return (s0 >= s) && (e0 <= e); | return (s0 >= s) && (e0 <= e); | ||||
*/ | */ | ||||
public void setPredication(String key, Object value) { | public void setPredication(String key, Object value) { | ||||
if (predications == null) { | if (predications == null) { | ||||
predications = new HashMap<String,Object>(); | |||||
predications = new HashMap<String, Object>(); | |||||
} | } | ||||
if (predications != null) { | if (predications != null) { | ||||
predications.put(key, value); | predications.put(key, value); | ||||
*/ | */ | ||||
public void mergePredication(String key, Object value) { | public void mergePredication(String key, Object value) { | ||||
if (predications == null) { | if (predications == null) { | ||||
predications = new HashMap<String,Object>(); | |||||
predications = new HashMap<String, Object>(); | |||||
} | } | ||||
if (predications != null) { | if (predications != null) { | ||||
if (predications.containsKey(key)) { | if (predications.containsKey(key)) { | ||||
*/ | */ | ||||
public void mergePredications(CharAssociation ca) { | public void mergePredications(CharAssociation ca) { | ||||
if (ca.predications != null) { | if (ca.predications != null) { | ||||
for (Map.Entry<String,Object> e : ca.predications.entrySet()) { | |||||
for (Map.Entry<String, Object> e : ca.predications.entrySet()) { | |||||
mergePredication(e.getKey(), e.getValue()); | mergePredication(e.getKey(), e.getValue()); | ||||
} | } | ||||
} | } | ||||
try { | try { | ||||
CharAssociation ca = (CharAssociation) super.clone(); | CharAssociation ca = (CharAssociation) super.clone(); | ||||
if (predications != null) { | if (predications != null) { | ||||
ca.predications = new HashMap<String,Object>(predications); | |||||
ca.predications = new HashMap<String, Object>(predications); | |||||
} | } | ||||
return ca; | return ca; | ||||
} catch (CloneNotSupportedException e) { | } catch (CloneNotSupportedException e) { | ||||
*/ | */ | ||||
public static void setPredicationMerger(String key, PredicationMerger pm) { | public static void setPredicationMerger(String key, PredicationMerger pm) { | ||||
if (predicationMergers == null) { | if (predicationMergers == null) { | ||||
predicationMergers = new HashMap<String,PredicationMerger>(); | |||||
predicationMergers = new HashMap<String, PredicationMerger>(); | |||||
} | } | ||||
if (predicationMergers != null) { | if (predicationMergers != null) { | ||||
predicationMergers.put(key, pm); | predicationMergers.put(key, pm); |
import java.util.List; | import java.util.List; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: NoWhitespaceAfterCheck | |||||
// CSOFF: AvoidNestedBlocksCheck | |||||
/** | /** | ||||
* <p>Implementation of Number to String Conversion algorithm specified by | * <p>Implementation of Number to String Conversion algorithm specified by | ||||
separators.add(token.toArray(new Integer [ token.size() ])); | separators.add(token.toArray(new Integer [ token.size() ])); | ||||
} | } | ||||
} | } | ||||
if (! separators.isEmpty()) { | |||||
if (!separators.isEmpty()) { | |||||
this.prefix = separators.remove(0); | this.prefix = separators.remove(0); | ||||
} | } | ||||
if (! separators.isEmpty()) { | |||||
if (!separators.isEmpty()) { | |||||
this.suffix = separators.remove(separators.size() - 1); | this.suffix = separators.remove(separators.size() - 1); | ||||
} | } | ||||
this.separators = separators.toArray(new Integer [ separators.size() ] []); | this.separators = separators.toArray(new Integer [ separators.size() ] []); | ||||
int s = token[0].intValue(); | int s = token[0].intValue(); | ||||
switch (s) { | switch (s) { | ||||
case (int) '1': | case (int) '1': | ||||
{ | |||||
fn = formatNumberAsDecimal(number, (int) '1', 1); | |||||
break; | |||||
} | |||||
fn = formatNumberAsDecimal(number, (int) '1', 1); | |||||
break; | |||||
case (int) 'W': | case (int) 'W': | ||||
case (int) 'w': | case (int) 'w': | ||||
{ | |||||
fn = formatNumberAsWord(number, (s == (int) 'W') ? Character.UPPERCASE_LETTER : Character.LOWERCASE_LETTER); | |||||
break; | |||||
} | |||||
fn = formatNumberAsWord(number, (s == (int) 'W') ? Character.UPPERCASE_LETTER : Character.LOWERCASE_LETTER); | |||||
break; | |||||
case (int) 'A': // handled as numeric sequence | case (int) 'A': // handled as numeric sequence | ||||
case (int) 'a': // handled as numeric sequence | case (int) 'a': // handled as numeric sequence | ||||
case (int) 'I': // handled as numeric special | case (int) 'I': // handled as numeric special | ||||
case (int) 'i': // handled as numeric special | case (int) 'i': // handled as numeric special | ||||
default: | 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); | |||||
} else { | |||||
fn = null; | |||||
} | |||||
break; | |||||
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')) { | } else if ((token.length == 2) && (token[0] == (int) 'W') && (token[1] == (int) 'w')) { | ||||
fn = formatNumberAsWord(number, Character.TITLECASE_LETTER); | fn = formatNumberAsWord(number, Character.TITLECASE_LETTER); |
import org.apache.fop.util.CharUtilities; | import org.apache.fop.util.CharUtilities; | ||||
// CSOFF: InnerAssignmentCheck | |||||
/** | /** | ||||
* <p>UTF32 related utilities.</p> | * <p>UTF32 related utilities.</p> |
import org.apache.fop.fonts.truetype.OFFontLoader; | import org.apache.fop.fonts.truetype.OFFontLoader; | ||||
import org.apache.fop.fonts.truetype.TTFFile; | import org.apache.fop.fonts.truetype.TTFFile; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** | /** |
* - commit BOTH changed files | * - commit BOTH changed files | ||||
*/ | */ | ||||
// CSOFF: WhitespaceAfterCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
/** Line breaking utilities. */ | /** Line breaking utilities. */ | ||||
"CP", "CR", "EX", "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP", | "CP", "CR", "EX", "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP", | ||||
"PO", "PR", "QU", "SA", "SG", "SP", "SY", "WJ", "XX", "ZW"}; | "PO", "PR", "QU", "SA", "SG", "SP", "SY", "WJ", "XX", "ZW"}; | ||||
private static String[] lineBreakPropertyLongNames = {"Ambiguous","Alphabetic","Break_Both","Break_After","Break_Before", | |||||
"Mandatory_Break","Contingent_Break","Close_Punctuation","Combining_Mark","Close_Parenthesis","Carriage_Return", | |||||
"Exclamation","Glue","H2","H3","Hyphen","Ideographic","Inseparable","Infix_Numeric","JL","JT","JV","Line_Feed", | |||||
"Next_Line","Nonstarter","Numeric","Open_Punctuation","Postfix_Numeric","Prefix_Numeric","Quotation","Complex_Context", | |||||
"Surrogate","Space","Break_Symbols","Word_Joiner","Unknown","ZWSpace"}; | |||||
private static String[] lineBreakPropertyLongNames = {"Ambiguous", "Alphabetic", "Break_Both", "Break_After", "Break_Before", | |||||
"Mandatory_Break", "Contingent_Break", "Close_Punctuation", "Combining_Mark", "Close_Parenthesis", "Carriage_Return", | |||||
"Exclamation", "Glue", "H2", "H3", "Hyphen", "Ideographic", "Inseparable", "Infix_Numeric", "JL", "JT", "JV", "Line_Feed", | |||||
"Next_Line", "Nonstarter", "Numeric", "Open_Punctuation", "Postfix_Numeric", "Prefix_Numeric", "Quotation", "Complex_Context", | |||||
"Surrogate", "Space", "Break_Symbols", "Word_Joiner", "Unknown", "ZWSpace"}; | |||||
/** | /** | ||||
* Return the short name for the linebreak property corresponding | * Return the short name for the linebreak property corresponding |
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.ObjectInputStream; | import java.io.ObjectInputStream; | ||||
// CSOFF: WhitespaceAfterCheck | |||||
/* | /* | ||||
* !!! THIS IS A GENERATED FILE !!! | * !!! THIS IS A GENERATED FILE !!! |
import org.xml.sax.helpers.DefaultHandler; | import org.xml.sax.helpers.DefaultHandler; | ||||
// CSOFF: InnerAssignmentCheck | |||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
// CSOFF: NoWhitespaceAfterCheck | |||||
/** | /** | ||||
* This class supports a subset of the <code>TTX</code> file as produced by the Adobe FLEX | * This class supports a subset of the <code>TTX</code> file as produced by the Adobe FLEX |