diff options
author | Jeremias Maerki <jeremias@apache.org> | 2011-07-27 12:37:29 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2011-07-27 12:37:29 +0000 |
commit | 24158d577f1512d4c765c73829c96197154d1e2a (patch) | |
tree | ddfadb8d09ed4d6ba96dbd19d48456d37cfd3ac6 /src/java | |
parent | 61bbd77c1e09ad8248d23241b91eb9674fa223a9 (diff) | |
download | xmlgraphics-fop-24158d577f1512d4c765c73829c96197154d1e2a.tar.gz xmlgraphics-fop-24158d577f1512d4c765c73829c96197154d1e2a.zip |
Attempt at making the remapComposite "more readable".
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1151447 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java index 9fcfe72cc..f0c4da408 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java @@ -528,11 +528,16 @@ public class TTFSubSetFile extends TTFFile { } TTFMtxEntry mtxEntry = mtxTab[glyphIdx.intValue()]; long offset = glyphOffset + mtxEntry.getOffset() + 10; - if (remappedComposites.contains(offset)) { - return; + + //Avoid duplicate remapping (see javadoc for remappedComposites above) + if (!remappedComposites.contains(offset)) { + remappedComposites.add(offset); + innerRemapComposite(in, glyphs, offset); } - remappedComposites.add(offset); + } + private void innerRemapComposite(FontFileReader in, Map<Integer, Integer> glyphs, long offset) + throws IOException { Integer compositeIdx = null; int flags = 0; boolean moreComposites = true; @@ -806,15 +811,15 @@ public class TTFSubSetFile extends TTFFile { * Read a unsigned short value at given position */ private int readUShort(int pos) { - int ret = (int)output[pos]; + int ret = output[pos]; if (ret < 0) { ret += 256; } ret = ret << 8; - if ((int)output[pos + 1] < 0) { - ret |= (int)output[pos + 1] + 256; + if (output[pos + 1] < 0) { + ret |= output[pos + 1] + 256; } else { - ret |= (int)output[pos + 1]; + ret |= output[pos + 1]; } return ret; @@ -837,7 +842,7 @@ public class TTFSubSetFile extends TTFFile { */ private int maxPow2(int max) { int i = 0; - while (Math.pow(2, (double)i) < max) { + while (Math.pow(2, i) < max) { i++; } @@ -845,7 +850,7 @@ public class TTFSubSetFile extends TTFFile { } private int log2(int num) { - return (int)(Math.log((double)num) / Math.log(2)); + return (int)(Math.log(num) / Math.log(2)); } @@ -864,10 +869,10 @@ public class TTFSubSetFile extends TTFFile { long sum = 0; for (int i = 0; i < size; i += 4) { - int l = (int)(output[start + i] << 24); - l += (int)(output[start + i + 1] << 16); - l += (int)(output[start + i + 2] << 16); - l += (int)(output[start + i + 3] << 16); + int l = (output[start + i] << 24); + l += (output[start + i + 1] << 16); + l += (output[start + i + 2] << 16); + l += (output[start + i + 3] << 16); sum += l; if (sum > 0xffffffff) { sum = sum - 0xffffffff; |