Skip to content

Commit 97ac0ab

Browse files
committed
PDFBOX-6085: add exception; revert bugfix; new bugfix that counts the initial skip
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929287 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3a4fea4 commit 97ac0ab

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@ private void addCompoundReferences() throws IOException
527527
LOG.debug("Tried skipping {} bytes but skipped only {} bytes",
528528
offset - lastOff, isResult);
529529
}
530-
if (invisibleGlyphIds.contains(gid))
531-
{
532-
continue;
533-
}
534530
byte[] buf = new byte[(int) length];
535531
isResult = is.read(buf);
536532

@@ -638,6 +634,7 @@ private byte[] buildGlyfTable(long[] newOffsets) throws IOException
638634
// corresponding 'loca' table entry with length = 0
639635
if (invisibleGlyphIds.contains(gid))
640636
{
637+
lastOff = offset;
641638
continue;
642639
}
643640

@@ -663,6 +660,11 @@ private byte[] buildGlyfTable(long[] newOffsets) throws IOException
663660

664661
// glyphIndex
665662
int componentGid = (buf[off] & 0xff) << 8 | buf[off + 1] & 0xff;
663+
if (!glyphIds.contains(componentGid))
664+
{
665+
// PDFBOX-6085
666+
throw new IOException("Internal error: componentGid " + componentGid + " not in glyphIds set");
667+
}
666668
int newComponentGid = getNewGlyphId(componentGid);
667669
buf[off] = (byte)(newComponentGid >>> 8);
668670
buf[off + 1] = (byte)newComponentGid;

0 commit comments

Comments
 (0)