Skip to content

Commit 8c23281

Browse files
committed
Fix issues with autoport in io.font.
1 parent 859fe49 commit 8c23281

19 files changed

+486
-521
lines changed

io/src/main/java/com/itextpdf/io/font/AdobeGlyphList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static Integer nameToUnicode(String name) {
7676
Integer v = names2unicode.get(name);
7777
if (v == null && name.length() == 7 && name.toLowerCase().startsWith("uni")) {
7878
try {
79-
return Integer.parseInt(name.substring(3), 16);
79+
return Integer.valueOf(name.substring(3), 16);
8080
} catch (Exception ignored) {
8181
}
8282
}

io/src/main/java/com/itextpdf/io/font/CFFFont.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,45 +226,45 @@ protected void getDictItem() {
226226
char b0 = getCard8();
227227
if (b0 == 29) {
228228
int item = getInt();
229-
args[arg_count] = Integer.valueOf(item);
229+
args[arg_count] = item;
230230
arg_count++;
231231
//System.err.println(item+" ");
232232
continue;
233233
}
234234
if (b0 == 28) {
235235
short item = getShort();
236-
args[arg_count] = Integer.valueOf(item);
236+
args[arg_count] = (int) item;
237237
arg_count++;
238238
//System.err.println(item+" ");
239239
continue;
240240
}
241241
if (b0 >= 32 && b0 <= 246) {
242242
byte item = (byte) (b0-139);
243-
args[arg_count] = Integer.valueOf(item);
243+
args[arg_count] = (int) item;
244244
arg_count++;
245245
//System.err.println(item+" ");
246246
continue;
247247
}
248248
if (b0 >= 247 && b0 <= 250) {
249249
char b1 = getCard8();
250250
short item = (short) ((b0-247)*256+b1+108);
251-
args[arg_count] = Integer.valueOf(item);
251+
args[arg_count] = (int) item;
252252
arg_count++;
253253
//System.err.println(item+" ");
254254
continue;
255255
}
256256
if (b0 >= 251 && b0 <= 254) {
257257
char b1 = getCard8();
258258
short item = (short) (-(b0-251)*256-b1-108);
259-
args[arg_count] = Integer.valueOf(item);
259+
args[arg_count] = (int) item;
260260
arg_count++;
261261
//System.err.println(item+" ");
262262
continue;
263263
}
264264
if (b0 == 30) {
265265
StringBuilder item = new StringBuilder("");
266266
boolean done = false;
267-
char buffer = 0;
267+
char buffer = (char) 0;
268268
byte avail = 0;
269269
int nibble = 0;
270270
while (!done) {
@@ -280,7 +280,7 @@ protected void getDictItem() {
280280
case 0xf: done=true ; break;
281281
default:
282282
if (nibble >= 0 && nibble <= 9)
283-
item.append(String.valueOf(nibble));
283+
item.append(nibble);
284284
else {
285285
item.append("<NIBBLE ERROR: ").append(nibble).append('>');
286286
done = true;
@@ -494,7 +494,7 @@ public void emit(byte[] buffer) {
494494

495495
static protected final class UInt16Item extends Item {
496496
public char value;
497-
public UInt16Item(char value) {this.value=value;}
497+
public UInt16Item(char value) {this.value = value;}
498498

499499
@Override
500500
public void increment(int[] currentOffset) {
@@ -504,8 +504,11 @@ public void increment(int[] currentOffset) {
504504
// this is incomplete!
505505
@Override
506506
public void emit(byte[] buffer) {
507-
buffer[myOffset+0] = (byte) (value >>> 8 & 0xff);
508-
buffer[myOffset+1] = (byte) (value >>> 0 & 0xff);
507+
// Simplify from: there is no sense in >>> for unsigned char.
508+
// buffer[myOffset+0] = (byte) (value >>> 8 & 0xff);
509+
// buffer[myOffset+1] = (byte) (value >>> 0 & 0xff);
510+
buffer[myOffset+0] = (byte) (value >> 8 & 0xff);
511+
buffer[myOffset+1] = (byte) (value >> 0 & 0xff);
509512
}
510513
}
511514

@@ -524,7 +527,8 @@ public void increment(int[] currentOffset) {
524527
// this is incomplete!
525528
@Override
526529
public void emit(byte[] buffer) {
527-
buffer[myOffset+0] = (byte) (value >>> 0 & 0xff);
530+
//buffer[myOffset+0] = (byte) (value >>> 0 & 0xff);
531+
buffer[myOffset+0] = (byte) (value & 0xff);
528532
}
529533
}
530534

@@ -718,16 +722,16 @@ public byte[] getCID(String fontName)
718722
int p1 = getPosition();
719723
getDictItem();
720724
int p2 = getPosition();
721-
if (key=="Encoding"
722-
|| key=="Private"
723-
|| key=="FDSelect"
724-
|| key=="FDArray"
725-
|| key=="charset"
726-
|| key=="CharStrings"
725+
if ("Encoding".equals(key)
726+
|| "Private".equals(key)
727+
|| "FDSelect".equals(key)
728+
|| "FDArray".equals(key)
729+
|| "charset".equals(key)
730+
|| "CharStrings".equals(key)
727731
) {
728732
// just drop them
729733
} else {
730-
l.add(new RangeItem(buf,p1,p2-p1));
734+
l.addLast(new RangeItem(buf,p1,p2-p1));
731735
}
732736
}
733737

0 commit comments

Comments
 (0)