diff --git a/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java b/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java index 5f5651ba98b..2726833f1ee 100644 --- a/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java +++ b/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java @@ -152,11 +152,6 @@ public static CharStringCommand getInstance(int b0, int b1) */ public static CharStringCommand getInstance(int[] values) { - if (values[0] == 19 || values[0] == 20) - { - //TODO store the rest (hintmask and cntrmask) if we ever process these. - return getInstance(values[0]); - } switch (values.length) { case 1: diff --git a/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java b/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java index b47d8fed245..84c8215d708 100644 --- a/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java +++ b/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java @@ -30,8 +30,12 @@ public class Type2CharStringParser { // 1-byte commands - private static final int CALLSUBR = 10; - private static final int CALLGSUBR = 29; + private static final int CALLSUBR = CharStringCommand.CALLSUBR.getValue(); + private static final int CALLGSUBR = CharStringCommand.CALLGSUBR.getValue(); + + // not yet supported commands + private static final int HINTMASK = CharStringCommand.HINTMASK.getValue(); + private static final int CNTRMASK = CharStringCommand.CNTRMASK.getValue(); private final String fontName; @@ -79,7 +83,17 @@ else if (b0 == CALLGSUBR) { processCallGSubr(globalSubrIndex, localSubrIndex, glyphData); } - else if ((b0 >= 0 && b0 <= 27) || (b0 >= 29 && b0 <= 31)) + else if (b0 == HINTMASK || b0 == CNTRMASK) + { + int maskLength = getMaskLength(glyphData.hstemCount, glyphData.vstemCount); + // drop the following bytes representing the mask as long as we don't support HINTMASK and CNTRMASK + for (int i = 0; i < maskLength; i++) + { + input.readUnsignedByte(); + } + glyphData.sequence.add(CharStringCommand.getInstance(b0)); + } + else if ((b0 >= 0 && b0 <= 18) || (b0 >= 21 && b0 <= 27) || (b0 >= 29 && b0 <= 31)) { glyphData.sequence.add(readCommand(b0, input, glyphData)); } @@ -163,18 +177,6 @@ private CharStringCommand readCommand(int b0, DataInput input, GlyphData glyphDa return CharStringCommand.getInstance(b0); case 12: return CharStringCommand.getInstance(b0, input.readUnsignedByte()); - case 19: - case 20: - glyphData.vstemCount += countNumbers(glyphData.sequence) / 2; - int[] value = new int[1 + getMaskLength(glyphData.hstemCount, glyphData.vstemCount)]; - value[0] = b0; - - for (int i = 1; i < value.length; i++) - { - value[i] = input.readUnsignedByte(); - } - - return CharStringCommand.getInstance(value); default: return CharStringCommand.getInstance(b0); }