• R/O
  • SSH
  • HTTPS

copper: Commit


Commit MetaInfo

Revision1581 (tree)
Time2018-12-25 13:55:24
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/PdfEmbeddedFont.java (revision 1580)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/PdfEmbeddedFont.java (revision 1581)
@@ -17,6 +17,8 @@
1717
1818 public Shape getShape(int i);
1919
20+ public byte[] getCharString(int i);
21+
2022 public int getGlyphCount();
2123
2224 public int getCharCount();
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/embedded/OpenTypeEmbeddedCIDFont.java (revision 1580)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/embedded/OpenTypeEmbeddedCIDFont.java (revision 1581)
@@ -86,7 +86,7 @@
8686 }
8787
8888 public Shape getShapeByGID(int gid) {
89- Glyph glyph = source.getOpenTypeFont().getGlyph(this.toSourceGID(gid));
89+ Glyph glyph = this.source.getOpenTypeFont().getGlyph(this.toSourceGID(gid));
9090 if (glyph == null) {
9191 return null;
9292 }
@@ -157,6 +157,16 @@
157157 return this.getShapeByGID(gid);
158158 }
159159
160+ public byte[] getCharString(int gid) {
161+ return null;
162+// Glyph glyph = this.source.getOpenTypeFont().getGlyph(this.toSourceGID(gid));
163+// if (glyph == null) {
164+// return null;
165+// }
166+// return glyph.getCharString();
167+ }
168+
169+
160170 public int getSupplement() {
161171 return CIDUtils.SUPPLEMENT;
162172 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/embedded/SystemEmbeddedCIDFont.java (revision 1580)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/embedded/SystemEmbeddedCIDFont.java (revision 1581)
@@ -117,6 +117,10 @@
117117 return (Shape) this.shapes.get(gid);
118118 }
119119
120+ public byte[] getCharString(int i) {
121+ return null;
122+ }
123+
120124 public Shape getShapeByGID(int gid) {
121125 return this.getShape(gid);
122126 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/missing/MissingCIDFont.java (revision 1580)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/cid/missing/MissingCIDFont.java (revision 1581)
@@ -162,6 +162,10 @@
162162 return (Shape) this.shapes.get(gid);
163163 }
164164
165+ public byte[] getCharString(int i) {
166+ return null;
167+ }
168+
165169 public int getSupplement() {
166170 return CIDUtils.SUPPLEMENT;
167171 }
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/type2/CffGenerator.java (revision 1580)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/font/type2/CffGenerator.java (revision 1581)
@@ -16,6 +16,8 @@
1616
1717 protected PdfEmbeddedFont font;
1818
19+ private static final boolean DEBUG = false;
20+
1921 public void setSubsetName(String subsetName) {
2022 this.subsetName = subsetName;
2123 }
@@ -101,10 +103,26 @@
101103 // CharStrings INDEX
102104 padding1 += 5 - cout2.writeInteger(offset + cout1.getOffset());
103105 cout2.writeOperator(CffOutputStream.CHAR_STRINGS);
104- // System.out.println(Runtime.getRuntime().totalMemory()+"/"+Runtime.getRuntime().freeMemory()+"/"+Runtime.getRuntime().maxMemory());
105106
106107 final List<byte[]> fonts = new ArrayList<byte[]>();
107108 for (int i = 0; i < this.font.getGlyphCount(); ++i) {
109+ short width = this.font.getWidth(i);
110+ {
111+ final byte[] charString = this.font.getCharString(i);
112+ if (charString != null) {
113+ if (defaultWidth != width) {
114+ final ByteArrayOutputStream bout3 = new ByteArrayOutputStream();
115+ final Type2OutputStream tout3 = new Type2OutputStream(bout3);
116+ tout3.writeShort((short) (width - defaultWidth));
117+ tout3.write(charString);
118+ tout3.close();
119+ fonts.add(bout3.toByteArray());
120+ } else {
121+ fonts.add(charString);
122+ }
123+ continue;
124+ }
125+ }
108126 final Shape shape = this.font.getShape(i);
109127 if (shape == null) {
110128 fonts.add(Type2OutputStream.ENDCHAR);
@@ -112,8 +130,6 @@
112130 }
113131 try (final ByteArrayOutputStream bout3 = new ByteArrayOutputStream();
114132 final Type2OutputStream tout3 = new Type2OutputStream(bout3)) {
115-
116- short width = this.font.getWidth(i);
117133 if (defaultWidth != width) {
118134 tout3.writeShort((short) (width - defaultWidth));
119135 }
@@ -133,15 +149,24 @@
133149 if (dx == 0) {
134150 tout3.writeShort(dy);
135151 tout3.writeOperator(Type2OutputStream.VMOVETO);
152+ if (DEBUG) {
153+ System.err.println("vmoveto " + dy);
154+ }
136155 cy += dy;
137156 } else if (dy == 0) {
138157 tout3.writeShort(dx);
139158 tout3.writeOperator(Type2OutputStream.HMOVETO);
159+ if (DEBUG) {
160+ System.err.println("hmoveto " + dx);
161+ }
140162 cx += dx;
141163 } else {
142164 tout3.writeShort(dx);
143165 tout3.writeShort(dy);
144166 tout3.writeOperator(Type2OutputStream.RMOVETO);
167+ if (DEBUG) {
168+ System.err.println("rmoveto " + dx + " " + dy);
169+ }
145170 cx += dx;
146171 cy += dy;
147172 }
@@ -153,6 +178,9 @@
153178 if (closed) {
154179 tout3.writeShort((short) 0);
155180 tout3.writeOperator(Type2OutputStream.HMOVETO);
181+ if (DEBUG) {
182+ System.err.println("hmoveto " + 0);
183+ }
156184 closed = false;
157185 }
158186 double x = cord[0];
@@ -162,15 +190,24 @@
162190 if (dx == 0) {
163191 tout3.writeShort(dy);
164192 tout3.writeOperator(Type2OutputStream.VLINETO);
193+ if (DEBUG) {
194+ System.err.println("vlineto " + dy);
195+ }
165196 cy += dy;
166197 } else if (dy == 0) {
167198 tout3.writeShort(dx);
168199 tout3.writeOperator(Type2OutputStream.HLINETO);
200+ if (DEBUG) {
201+ System.err.println("hlineto " + dx);
202+ }
169203 cx += dx;
170204 } else {
171205 tout3.writeShort(dx);
172206 tout3.writeShort(dy);
173207 tout3.writeOperator(Type2OutputStream.RLINETO);
208+ if (DEBUG) {
209+ System.err.println("rlineto " + dx + " " + dy);
210+ }
174211 cx += dx;
175212 cy += dy;
176213 }
@@ -181,6 +218,9 @@
181218 if (closed) {
182219 tout3.writeShort((short) 0);
183220 tout3.writeOperator(Type2OutputStream.HMOVETO);
221+ if (DEBUG) {
222+ System.err.println("hmoveto " + 0);
223+ }
184224 closed = false;
185225 }
186226 double x1 = cord[0];
@@ -212,6 +252,10 @@
212252 tout3.writeShort(dxc);
213253 tout3.writeShort(dyc);
214254 tout3.writeOperator(Type2OutputStream.RRCURVETO);
255+ if (DEBUG) {
256+ System.err.println("rrcurveto " + dxa + " " + dya + " " + dxb + " " + dyb + " "
257+ + dxc + " " + dyc);
258+ }
215259 }
216260 break;
217261
@@ -219,6 +263,9 @@
219263 if (closed) {
220264 tout3.writeShort((short) 0);
221265 tout3.writeOperator(Type2OutputStream.HMOVETO);
266+ if (DEBUG) {
267+ System.err.println("hmoveto " + 0);
268+ }
222269 closed = false;
223270 }
224271 double xa = cord[0];
@@ -246,6 +293,10 @@
246293 tout3.writeShort(dxc);
247294 tout3.writeShort(dyc);
248295 tout3.writeOperator(Type2OutputStream.RRCURVETO);
296+ if (DEBUG) {
297+ System.err.println("rrcurveto " + dxa + " " + dya + " " + dxb + " " + dyb + " "
298+ + dxc + " " + dyc);
299+ }
249300 cx = xc;
250301 cy = yc;
251302 }
@@ -262,7 +313,8 @@
262313 j.next();
263314 }
264315 tout3.writeOperator(Type2OutputStream.ENDCHAR);
265- fonts.add(bout3.toByteArray());
316+ byte[] charString = bout3.toByteArray();
317+ fonts.add(charString);
266318 }
267319 }
268320 cout1.writeIndex((byte[][]) fonts.toArray(new byte[fonts.size()][]), (byte) 4);
Show on old repository browser