• R/O
  • SSH
  • HTTPS

copper: Commit


Commit MetaInfo

Revision1605 (tree)
Time2020-10-01 11:10:53
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ArrayIntMapIterator.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ArrayIntMapIterator.java (revision 1605)
@@ -0,0 +1,29 @@
1+package jp.cssj.sakae.util;
2+
3+public class ArrayIntMapIterator implements IntMapIterator {
4+ private final int[] array;
5+ private int i = 0;
6+
7+ public ArrayIntMapIterator(int[] array) {
8+ this.array = array;
9+ }
10+
11+ public boolean next() {
12+ if (this.i >= this.array.length) {
13+ return false;
14+ }
15+ this.i++;
16+ return true;
17+ }
18+
19+ @Override
20+ public int key() {
21+ return this.i - 1;
22+ }
23+
24+ @Override
25+ public int value() {
26+ return this.array[this.i - 1];
27+ }
28+
29+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ArrayShortMapIterator.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ArrayShortMapIterator.java (revision 1605)
@@ -0,0 +1,29 @@
1+package jp.cssj.sakae.util;
2+
3+public class ArrayShortMapIterator implements ShortMapIterator {
4+ private final short[] array;
5+ private int i = 0;
6+
7+ public ArrayShortMapIterator(short[] array) {
8+ this.array = array;
9+ }
10+
11+ public boolean next() {
12+ if (this.i >= this.array.length) {
13+ return false;
14+ }
15+ this.i++;
16+ return true;
17+ }
18+
19+ @Override
20+ public int key() {
21+ return this.i - 1;
22+ }
23+
24+ @Override
25+ public short value() {
26+ return this.array[this.i - 1];
27+ }
28+
29+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntList.java (revision 1604)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntList.java (revision 1605)
@@ -8,7 +8,7 @@
88 * @author MIYABE Tatsuhiko
99 * @version $Id$
1010 */
11-public class IntList implements Serializable {
11+public class IntList implements Serializable, IntMap {
1212 private static final long serialVersionUID = 0;
1313
1414 private static final int[] ZERO = new int[0];
@@ -57,7 +57,12 @@
5757 }
5858 return this.array[i];
5959 }
60+
61+ public boolean contains(int key) {
62+ return this.get(key) != this.defaultValue;
63+ }
6064
65+
6166 public int size() {
6267 return this.length;
6368 }
@@ -73,4 +78,9 @@
7378 public boolean isEmpty() {
7479 return this.length == 0;
7580 }
81+
82+ public IntMapIterator getIterator() {
83+ this.pack();
84+ return new ArrayIntMapIterator(this.array);
85+ }
7686 }
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntMap.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntMap.java (revision 1605)
@@ -0,0 +1,8 @@
1+package jp.cssj.sakae.util;
2+
3+public interface IntMap {
4+ public void set(int key, int value);
5+ public int get(int key);
6+ public boolean contains(int key);
7+ public IntMapIterator getIterator();
8+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntMapIterator.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/IntMapIterator.java (revision 1605)
@@ -0,0 +1,7 @@
1+package jp.cssj.sakae.util;
2+
3+public interface IntMapIterator {
4+ public boolean next();
5+ public int key();
6+ public int value();
7+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/MapIntMap.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/MapIntMap.java (revision 1605)
@@ -0,0 +1,47 @@
1+package jp.cssj.sakae.util;
2+
3+import java.util.Iterator;
4+import java.util.Map;
5+import java.util.Map.Entry;
6+import java.util.TreeMap;
7+
8+public class MapIntMap implements IntMap {
9+ protected Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
10+
11+ public void set(int key, int value) {
12+ this.map.put(key, value);
13+ }
14+
15+ public int get(int key) {
16+ return this.map.get(key);
17+ }
18+
19+ public boolean contains(int key) {
20+ return this.map.containsKey(key);
21+ }
22+
23+ public IntMapIterator getIterator() {
24+ final Iterator<Entry<Integer, Integer>> i = this.map.entrySet().iterator();
25+ return new IntMapIterator() {
26+ private Entry<Integer, Integer> e;
27+ @Override
28+ public boolean next() {
29+ if (!i.hasNext()) {
30+ return false;
31+ }
32+ this.e = i.next();
33+ return true;
34+ }
35+
36+ @Override
37+ public int key() {
38+ return e.getKey();
39+ }
40+
41+ @Override
42+ public int value() {
43+ return e.getValue();
44+ }
45+ };
46+ }
47+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ShortMapIterator.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/util/ShortMapIterator.java (revision 1605)
@@ -0,0 +1,7 @@
1+package jp.cssj.sakae.util;
2+
3+public interface ShortMapIterator {
4+ public boolean next();
5+ public int key();
6+ public short value();
7+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDFont.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDFont.java (revision 1605)
@@ -27,11 +27,11 @@
2727 return this.name;
2828 }
2929
30- public short getKerning(int gid, int cid) {
30+ public short getKerning(int gid, int c) {
3131 return 0;
3232 }
3333
34- public int getLigature(int gid, int cid) {
34+ public int getLigature(int gid, int c) {
3535 return -1;
3636 }
3737
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDTable.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDTable.java (revision 1605)
@@ -11,6 +11,9 @@
1111
1212 import jp.cssj.resolver.Source;
1313 import jp.cssj.sakae.util.IntList;
14+import jp.cssj.sakae.util.IntMap;
15+import jp.cssj.sakae.util.IntMapIterator;
16+import jp.cssj.sakae.util.MapIntMap;
1417
1518 /**
1619 * CIDフォントのキャラクタマッピング情報です。
@@ -29,7 +32,7 @@
2932
3033 protected final String javaEncoding;
3134
32- transient protected WeakReference<int[]> toCID = null;
35+ transient protected WeakReference<IntMap> toCID = null;
3336
3437 transient protected int missingCID = 0;
3538
@@ -40,10 +43,10 @@
4043 this.javaEncoding = javaEncoding;
4144 }
4245
43- private int[] getToCid() {
44- int[] toCid = null;
46+ private IntMap getToCid() {
47+ IntMap toCid = null;
4548 if (this.toCID != null) {
46- toCid = (int[]) this.toCID.get();
49+ toCid = this.toCID.get();
4750 if (toCid != null) {
4851 return toCid;
4952 }
@@ -54,32 +57,38 @@
5457
5558 CIDTableParser parser = new CIDTableParser();
5659 try {
57- toCid = parser.parse(this.cmapSource);
5860 Charset charset = this.getCharset();
5961 // UTF-16BEの場合は、Javaの内部コードと一致する
60- if (!charset.name().equalsIgnoreCase("UTF-16BE")) {
62+ if (charset.name().equalsIgnoreCase("UTF-16BE")) {
63+ toCid = new MapIntMap();
64+ parser.parse(this.cmapSource, toCid);
65+ } else {
66+ toCid = new IntList();
67+ parser.parse(this.cmapSource, toCid);
6168 IntList intList = new IntList();
6269 CharsetDecoder decoder = charset.newDecoder();
6370 ByteBuffer in = ByteBuffer.allocate(4);
6471 CharBuffer out = CharBuffer.allocate(1);
65- for (int i = 0; i < toCid.length; ++i) {
66- int cid = toCid[i];
72+ IntMapIterator i = toCid.getIterator();
73+ while (i.next()) {
74+ int cid = i.value();
75+ int c = i.key();
6776 if (cid != 0) {
6877 in.clear();
69- if (i < 0xFF) {
70- in.put((byte) (i & 0xFF));
71- } else if (i <= 0xFFFF) {
72- in.put((byte) ((i >> 8) & 0xFF));
73- in.put((byte) (i & 0xFF));
74- } else if (i <= 0xFFFFFF) {
75- in.put((byte) ((i >> 16) & 0xFF));
76- in.put((byte) ((i >> 8) & 0xFF));
77- in.put((byte) (i & 0xFF));
78+ if (c < 0xFF) {
79+ in.put((byte) (c & 0xFF));
80+ } else if (c <= 0xFFFF) {
81+ in.put((byte) ((c >> 8) & 0xFF));
82+ in.put((byte) (c & 0xFF));
83+ } else if (c <= 0xFFFFFF) {
84+ in.put((byte) ((c >> 16) & 0xFF));
85+ in.put((byte) ((c >> 8) & 0xFF));
86+ in.put((byte) (c & 0xFF));
7887 } else {
79- in.put((byte) ((i >> 24) & 0xFF));
80- in.put((byte) ((i >> 16) & 0xFF));
81- in.put((byte) ((i >> 8) & 0xFF));
82- in.put((byte) (i & 0xFF));
88+ in.put((byte) ((c >> 24) & 0xFF));
89+ in.put((byte) ((c >> 16) & 0xFF));
90+ in.put((byte) ((c >> 8) & 0xFF));
91+ in.put((byte) (c & 0xFF));
8392 }
8493 in.flip();
8594 out.clear();
@@ -89,17 +98,15 @@
8998 intList.set(out.get(0), cid);
9099 }
91100 }
92- toCid = intList.toArray();
101+ toCid = intList;
93102 }
94- for (int i = 0; i < toCid.length; ++i) {
95- if (toCid[i] == 0) {
96- toCid[i] = -1;
97- }
103+ if (!toCid.contains(MISSING_CHAR)) {
104+ System.err.println("missing missing char");
98105 }
99106 } catch (Exception e) {
100107 throw new RuntimeException(e);
101108 }
102- this.toCID = new WeakReference<int[]>(toCid);
109+ this.toCID = new WeakReference<IntMap>(toCid);
103110 return toCid;
104111 }
105112
@@ -130,20 +137,15 @@
130137 /**
131138 * 文字をCIDに変換します。
132139 *
133- * @param c
134- * 文字
140+ * @param c 文字
135141 * @return cid
136142 */
137143 public int toCID(int c) {
138- int[] toCid = this.getToCid();
139- if (c < 0 || c >= toCid.length) {
144+ IntMap toCid = this.getToCid();
145+ if (!toCid.contains(c)) {
140146 return this.getMissingCID();
141147 }
142- int cid = toCid[c];
143- if (cid == -1) {
144- return this.getMissingCID();
145- }
146- return cid;
148+ return toCid.get(c);
147149 }
148150
149151 /**
@@ -153,19 +155,12 @@
153155 * @return
154156 */
155157 public boolean containsChar(int c) {
156- int[] toCid = this.getToCid();
157- if (c < 0 || c >= toCid.length) {
158- return false;
159- }
160- int cid = toCid[c];
161- if (cid == -1) {
162- return false;
163- }
164- return true;
158+ IntMap toCid = this.getToCid();
159+ return toCid.contains(c);
165160 }
166161
167- public int getLength() {
168- int[] toCid = this.getToCid();
169- return toCid.length;
162+ public IntMapIterator getIterator() {
163+ IntMap toCid = this.getToCid();
164+ return toCid.getIterator();
170165 }
171166 }
\ No newline at end of file
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDTableParser.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDTableParser.java (revision 1605)
@@ -12,7 +12,7 @@
1212 import jp.cssj.resolver.composite.CompositeSourceResolver;
1313 import jp.cssj.resolver.helpers.URIHelper;
1414 import jp.cssj.sakae.pdf.util.PdfUtils;
15-import jp.cssj.sakae.util.IntList;
15+import jp.cssj.sakae.util.IntMap;
1616
1717 /**
1818 * CMapファイルのCIDテーブルを解析します。
@@ -28,13 +28,7 @@
2828
2929 private SourceResolver resolver;
3030
31- public int[] parse(Source source) throws IOException, CMapException {
32- IntList toCID = new IntList();
33- this.parse(source, toCID);
34- return toCID.toArray();
35- }
36-
37- private void parse(Source source, IntList toCID) throws IOException, CMapException {
31+ public void parse(Source source, IntMap toCID) throws IOException, CMapException {
3832 this.in = new InputStreamReader(new BufferedInputStream(source.getInputStream()), "ISO-8859-1");
3933 try {
4034 try {
@@ -73,8 +67,22 @@
7367 this.in.close();
7468 }
7569 }
70+
71+ private static int parseCode(String a) {
72+ int code;
73+ if (a.length() <= 4) {
74+ code = Integer.parseInt(a, 16);
75+ }
76+ else {
77+ // サロゲートペア
78+ int h = Integer.parseInt(a.substring(0, 4), 16);
79+ int l = Integer.parseInt(a.substring(4, 8), 16);
80+ code = 0x10000 + (h - 0xD800) * 0x400 + (l - 0xDC00);
81+ }
82+ return code;
83+ }
7684
77- private void parseCidChars(IntList toCID) throws IOException, CMapException {
85+ private void parseCidChars(IntMap toCID) throws IOException, CMapException {
7886 for (;;) {
7987 String a = this.nextToken();
8088 if (a.equals("endcidchar")) {
@@ -83,7 +91,7 @@
8391 String b = this.nextToken();
8492 a = a.substring(1, a.length() - 1).trim();
8593 try {
86- int code = Integer.parseInt(a, 16);
94+ int code = parseCode(a);
8795 int offset = Integer.parseInt(b);
8896 toCID.set(code, offset);
8997 } catch (NumberFormatException e) {
@@ -92,7 +100,7 @@
92100 }
93101 }
94102
95- private void parseCidRanges(IntList toCID) throws IOException, CMapException {
103+ private void parseCidRanges(IntMap toCID) throws IOException, CMapException {
96104 for (;;) {
97105 String a = this.nextToken();
98106 if (a.equals("endcidrange")) {
@@ -104,8 +112,8 @@
104112 a = a.substring(1, a.length() - 1).trim();
105113 b = b.substring(1, b.length() - 1).trim();
106114 try {
107- int start = Integer.parseInt(a, 16);
108- int end = Integer.parseInt(b, 16);
115+ int start = parseCode(a);
116+ int end = parseCode(b);
109117 if (a.length() != b.length() || a.length() % 2 != 0) {
110118 throw new CMapException("開始位置と終了位置のキャラクターコードのバイト数が一致しないか、偶数桁の116進数になっていません");
111119 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDUtils.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/CIDUtils.java (revision 1605)
@@ -12,6 +12,7 @@
1212 import jp.cssj.sakae.pdf.font.PdfEmbeddedFont;
1313 import jp.cssj.sakae.pdf.font.cid.ToUnicode.Unicode;
1414 import jp.cssj.sakae.pdf.font.type2.CffGenerator;
15+import jp.cssj.sakae.util.ArrayShortMapIterator;
1516
1617 public final class CIDUtils {
1718 public static final String ENCODING_H = "Identity-H";
@@ -279,11 +280,11 @@
279280
280281 // WArray
281282 {
282- WArray warray = WArray.buildFromWidths(w);
283+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(w));
283284 CIDUtils.writeWArray(out, warray);
284285 }
285286 if (w2 != null && w2.length > 0) {
286- WArray warray = WArray.buildFromWidths(w2);
287+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(w2));
287288 CIDUtils.writeWArray2(out, warray);
288289 }
289290
@@ -444,8 +445,7 @@
444445 * @param fontRef
445446 * @param w
446447 * @param w2
447- * @param unicodeArray
448- * CIDからユニコードへのマッピング
448+ * @param unicodeArray CIDからユニコードへのマッピング
449449 * @throws IOException
450450 */
451451 public static void writeEmbeddedFont(PdfFragmentOutput out, XRef xref, CIDFontSource source, PdfEmbeddedFont font,
@@ -525,11 +525,11 @@
525525
526526 // WArray
527527 {
528- WArray warray = WArray.buildFromWidths(w);
528+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(w));
529529 CIDUtils.writeWArray(out, warray);
530530 }
531531 if (w2 != null && w2.length > 0) {
532- WArray warray = WArray.buildFromWidths(w2);
532+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(w2));
533533 CIDUtils.writeWArray2(out, warray);
534534 }
535535
@@ -610,7 +610,7 @@
610610 out.writeName("CIDFontType0C");
611611 out.lineBreak();
612612
613- try (OutputStream cout = out.startStreamFromHash(PdfFragmentOutput.STREAM_BINARY)) {
613+ try (OutputStream cout = out.startStreamFromHash(PdfFragmentOutput.STREAM_BINARY)) {
614614 // InputStream in = new InflaterInputStream(new FileInputStream("/home/miyabe/workspaces/copper/CopperPDF.dev/files/misc/fontfile.bin"));
615615 // IOUtils.copy(in, cout);
616616 CffGenerator cff = new CffGenerator();
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/WArray.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/WArray.java (revision 1605)
@@ -5,6 +5,7 @@
55 import java.util.List;
66
77 import jp.cssj.sakae.util.IntList;
8+import jp.cssj.sakae.util.ShortMapIterator;
89
910 /**
1011 * フォントのDW,W属性です。
@@ -77,7 +78,7 @@
7778 * @param widths
7879 * @return
7980 */
80- public static WArray buildFromWidths(short[] widths) {
81+ public static WArray buildFromWidths(ShortMapIterator widths) {
8182 final List<Width> list = new ArrayList<Width>();
8283 final IntList widthCounts = new IntList();// 最も多い幅をデフォルトとする
8384 final short[] runWidths = new short[255];
@@ -85,8 +86,9 @@
8586 int position = 0;
8687 int startCid = -1;
8788 boolean run = false;
88- for (int cid = 0; cid < widths.length; ++cid) {
89- short advance = widths[cid];
89+ int cid = widths.key();
90+ while (widths.next()) {
91+ short advance = widths.value();
9092 // Short.MIN_VALUEはデフォルトの幅とする
9193 if (advance == Short.MIN_VALUE) {
9294 if (position == 0) {
@@ -127,7 +129,7 @@
127129 if (startCid != -1) {
128130 short[] temp = new short[position];
129131 System.arraycopy(runWidths, 0, temp, 0, position);
130- list.add(new Width(startCid, widths.length - 1, temp));
132+ list.add(new Width(startCid, cid, temp));
131133 }
132134 short defaultWidth = 0;
133135 if (!widthCounts.isEmpty()) {
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/CIDKeyedFont.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/CIDKeyedFont.java (revision 1605)
@@ -15,7 +15,6 @@
1515 import jp.cssj.sakae.pdf.PdfGraphicsOutput;
1616 import jp.cssj.sakae.pdf.XRef;
1717 import jp.cssj.sakae.pdf.font.cid.CIDFont;
18-import jp.cssj.sakae.pdf.font.cid.CIDTable;
1918 import jp.cssj.sakae.pdf.font.cid.CIDUtils;
2019 import jp.cssj.sakae.pdf.font.cid.CMap;
2120 import jp.cssj.sakae.pdf.font.cid.WArray;
@@ -104,10 +103,6 @@
104103 char c = ch[i + off];
105104 // \A0は空白に変換
106105 c = (c == '\u00A0') ? '\u0020' : c;
107- // 不明な文字
108- if (!this.cmap.getCIDTable().containsChar(c)) {
109- c = CIDTable.MISSING_CHAR;
110- }
111106 this.cbuff.put(c);
112107 }
113108 len -= llen;
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/OpenTypeCIDKeyedFontSource.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/OpenTypeCIDKeyedFontSource.java (revision 1605)
@@ -8,6 +8,8 @@
88 import jp.cssj.sakae.pdf.font.cid.CMap;
99 import jp.cssj.sakae.pdf.font.cid.WArray;
1010 import jp.cssj.sakae.pdf.font.cid.identity.OpenTypeCIDIdentityFontSource;
11+import jp.cssj.sakae.util.ArrayShortMapIterator;
12+import jp.cssj.sakae.util.IntMapIterator;
1113 import jp.cssj.sakae.util.ShortList;
1214 import net.zamasoft.font.OpenTypeFont;
1315 import net.zamasoft.font.table.Table;
@@ -65,12 +67,10 @@
6567
6668 ShortList cidToAdvance = new ShortList(Short.MIN_VALUE);
6769 CIDTable ct = cmap.getCIDTable();
68- for (int i = 0; i < ct.getLength(); ++i) {
69- if (!ct.containsChar(i)) {
70- continue;
71- }
72- int cid = ct.toCID(i);
73- int gid = fs.getCmapFormat().mapCharCode(i);
70+ IntMapIterator i = ct.getIterator();
71+ while (i.next()) {
72+ int cid = i.value();
73+ int gid = fs.getCmapFormat().mapCharCode(i.key());
7474 short advance = (short) (hmtx.getAdvanceWidth(gid) * FontSource.DEFAULT_UNITS_PER_EM / upm);
7575 // CIDは重複することがあるので、広い方の幅を採用する
7676 if (advance > cidToAdvance.get(cid)) {
@@ -77,7 +77,8 @@
7777 cidToAdvance.set(cid, advance);
7878 }
7979 }
80- WArray warray = WArray.buildFromWidths(cidToAdvance.toArray());
80+ short[] widths = cidToAdvance.toArray();
81+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(widths));
8182 return warray;
8283 }
8384 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/SystemCIDKeyedFontSource.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/keyed/SystemCIDKeyedFontSource.java (revision 1605)
@@ -6,6 +6,8 @@
66 import jp.cssj.sakae.pdf.font.cid.CMap;
77 import jp.cssj.sakae.pdf.font.cid.WArray;
88 import jp.cssj.sakae.pdf.font.cid.identity.SystemCIDIdentityFontSource;
9+import jp.cssj.sakae.util.ArrayShortMapIterator;
10+import jp.cssj.sakae.util.IntMapIterator;
911 import jp.cssj.sakae.util.ShortList;
1012
1113 /**
@@ -49,16 +51,15 @@
4951 private static WArray systemWArray(SystemCIDIdentityFontSource fs, CMap cmap) {
5052 ShortList cidToAdvance = new ShortList(Short.MIN_VALUE);
5153 CIDTable ct = cmap.getCIDTable();
52- for (int i = 0; i < ct.getLength(); ++i) {
53- if (!ct.containsChar(i)) {
54- continue;
55- }
56- int cid = ct.toCID(i);
57- int gid = fs.toGID(i);
54+ IntMapIterator i = ct.getIterator();
55+ while (i.next()) {
56+ int cid = i.value();
57+ int gid = fs.toGID(i.key());
5858 short advance = (short) fs.getWidth(gid);
5959 cidToAdvance.set(cid, advance);
6060 }
61- WArray warray = WArray.buildFromWidths(cidToAdvance.toArray());
61+ short[] widths = cidToAdvance.toArray();
62+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(widths));
6263 return warray;
6364 }
6465 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/tools/WArrayTool.java (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/tools/WArrayTool.java (revision 1605)
@@ -11,6 +11,8 @@
1111 import jp.cssj.sakae.pdf.font.cid.WArray;
1212 import jp.cssj.sakae.pdf.font.cid.identity.OpenTypeCIDIdentityFontSource;
1313 import jp.cssj.sakae.pdf.font.cid.identity.SystemCIDIdentityFontSource;
14+import jp.cssj.sakae.util.ArrayShortMapIterator;
15+import jp.cssj.sakae.util.IntMapIterator;
1416 import jp.cssj.sakae.util.ShortList;
1517 import net.zamasoft.font.OpenTypeFont;
1618 import net.zamasoft.font.table.Os2Table;
@@ -84,19 +86,17 @@
8486
8587 ShortList cidToAdvance = new ShortList(Short.MIN_VALUE);
8688 CIDTable ct = cmap.getCIDTable();
87- for (int i = 0; i < ct.getLength(); ++i) {
88- if (!ct.containsChar(i)) {
89- continue;
90- }
91- int gid = fs.getCmapFormat().mapCharCode(i);
89+ IntMapIterator i = ct.getIterator();
90+ while (i.next()) {
91+ int gid = fs.getCmapFormat().mapCharCode(i.key());
9292 if (gid != 0) {
93- int cid = ct.toCID(i);
93+ int cid = i.value();
9494 short advance = (short) (hmtx.getAdvanceWidth(gid) * FontSource.DEFAULT_UNITS_PER_EM / upm);
9595 cidToAdvance.set(cid, advance);
9696 }
9797 }
9898 short[] widths = cidToAdvance.toArray();
99- WArray warray = WArray.buildFromWidths(widths);
99+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(widths));
100100 return warray;
101101 }
102102
@@ -103,17 +103,15 @@
103103 private static WArray systemWArray(SystemCIDIdentityFontSource fs, CMap cmap) {
104104 ShortList cidToAdvance = new ShortList(Short.MIN_VALUE);
105105 CIDTable ct = cmap.getCIDTable();
106- for (int i = 0; i < ct.getLength(); ++i) {
107- if (!ct.containsChar(i)) {
108- continue;
109- }
110- int cid = ct.toCID(i);
111- int gid = fs.toGID(i);
106+ IntMapIterator i = ct.getIterator();
107+ while (i.next()) {
108+ int cid = i.value();
109+ int gid = fs.toGID(i.key());
112110 short advance = (short) fs.getWidth(gid);
113111 cidToAdvance.set(cid, advance);
114112 }
115113 short[] widths = cidToAdvance.toArray();
116- WArray warray = WArray.buildFromWidths(widths);
114+ WArray warray = WArray.buildFromWidths(new ArrayShortMapIterator(widths));
117115 return warray;
118116 }
119117 }
--- copper/trunk/sakae/sakae-pdf/src/main/resources/jp/cssj/sakae/pdf/font/builtin/fonts.xml (revision 1604)
+++ copper/trunk/sakae/sakae-pdf/src/main/resources/jp/cssj/sakae/pdf/font/builtin/fonts.xml (revision 1605)
@@ -81,16 +81,16 @@
8181 <cid-fonts>
8282 <!-- CID-Keydフォント name: フォント名 italic: 斜体ならtrue weight: 太さ(100-900) panose:
8383 PANOSEコード cmap: 横書きcmapエンコーディング名 vcmap: 縦書きcmapエンコーディング名 warray: フォントメトリックス -->
84- <!-- Adobe Japan 1 4 -->
85- <cid-keyed-font name="AJ14UniJIS-Mincho" panose="1 5 2 2 6 9 4 2 5 8 3 4"
86- cmap="UniJIS-UCS2-HW-H" vcmap="UniJIS-UCS2-HW-V" warray="warrays/monospace_jis.txt">
84+ <!-- Adobe Japan 1 7 -->
85+ <cid-keyed-font name="AJ17UniJIS-Mincho" panose="1 5 2 2 6 9 4 2 5 8 3 4"
86+ cmap="UniJIS-UTF16-H" vcmap="UniJIS-UTF16-V" warray="warrays/monospace_jis.txt">
8787 <alias name="Mincho" />
8888 <alias name="小塚明朝 Pr6N R" />
8989 <alias name="KozMinPr6N" />
9090 <alias name="Serif" />
9191 </cid-keyed-font>
92- <cid-keyed-font name="AJ14UniJIS-Gothic" panose="8 1 2 11 6 9 7 2 5 8 2 4"
93- cmap="UniJIS-UCS2-HW-H" vcmap="UniJIS-UCS2-HW-V" warray="warrays/monospace_jis.txt">
92+ <cid-keyed-font name="AJ17UniJIS-Gothic" panose="8 1 2 11 6 9 7 2 5 8 2 4"
93+ cmap="UniJIS-UTF16-H" vcmap="UniJIS-UTF16-V" warray="warrays/monospace_jis.txt">
9494 <alias name="Gothic" />
9595 <alias name="小塚ゴシック Pr6N M" />
9696 <alias name="KozGoPr6N" />
@@ -112,11 +112,11 @@
112112 <cid-keyed-font name="EUC-Gothic" panose="8 1 2 11 6 9 7 2 5 8 2 4"
113113 cmap="EUC-H" vcmap="EUC-V" warray="warrays/monospace_jis.txt" />
114114
115- <!-- Adobe Japan 1 7 -->
116- <cid-keyed-font name="AJ17UniJIS-Mincho" panose="1 5 2 2 6 9 4 2 5 8 3 4"
117- cmap="UniJIS-UTF16-H" vcmap="UniJIS-UTF16-V" warray="warrays/monospace_jis.txt" />
118- <cid-keyed-font name="AJ17UniJIS-Gothic" panose="8 1 2 11 6 9 7 2 5 8 2 4"
119- cmap="UniJIS-UTF16-H" vcmap="UniJIS-UTF16-V" warray="warrays/monospace_jis.txt" />
115+ <!-- Adobe Japan 1 4 -->
116+ <cid-keyed-font name="AJ14UniJIS-Mincho" panose="1 5 2 2 6 9 4 2 5 8 3 4"
117+ cmap="UniJIS-UCS2-HW-H" vcmap="UniJIS-UCS2-HW-V" warray="warrays/monospace_jis.txt" />
118+ <cid-keyed-font name="AJ14UniJIS-Gothic" panose="8 1 2 11 6 9 7 2 5 8 2 4"
119+ cmap="UniJIS-UCS2-HW-H" vcmap="UniJIS-UCS2-HW-V" warray="warrays/monospace_jis.txt" />
120120
121121 <!-- JIS 2004 -->
122122 <cid-keyed-font name="UniJIS2004-Mincho" panose="1 5 2 2 6 9 4 2 5 8 3 4"
Show on old repository browser