Issue #198 Fixed DefineFont2Tag on zero numGlyphs

This commit is contained in:
Jindra Pet��k
2013-07-04 20:22:28 +02:00
parent a19d6ce95c
commit 8db15debbd
@@ -120,19 +120,21 @@ public class DefineFont2Tag extends CharacterTag implements FontTag {
}
byte ba3[] = baos3.toByteArray();
sos.write(ba2);
long offset = ba2.length + ba3.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset + 4);
} else {
sos.writeUI16((int) (offset + 2));
}
sos.write(ba3);
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
if (numGlyphs > 0) {
long offset = ba2.length + ba3.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset + 4);
} else {
sos.writeUI8(codeTable.get(i));
sos.writeUI16((int) (offset + 2));
}
sos.write(ba3);
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
} else {
sos.writeUI8(codeTable.get(i));
}
}
}
if (fontFlagsHasLayout) {
@@ -187,11 +189,13 @@ public class DefineFont2Tag extends CharacterTag implements FontTag {
offsetTable[i] = sis.readUI16();
}
}
long codeTableOffset;
if (fontFlagsWideOffsets) {
codeTableOffset = sis.readUI32();
} else {
codeTableOffset = sis.readUI16();
long codeTableOffset = 0;
if (numGlyphs > 0) {
if (fontFlagsWideOffsets) {
codeTableOffset = sis.readUI32();
} else {
codeTableOffset = sis.readUI16();
}
}
glyphShapeTable = new SHAPE[numGlyphs];