|
30 | 30 | public class Type2CharStringParser |
31 | 31 | { |
32 | 32 | // 1-byte commands |
33 | | - private static final int CALLSUBR = 10; |
34 | | - private static final int CALLGSUBR = 29; |
| 33 | + private static final int CALLSUBR = CharStringCommand.CALLSUBR.getValue(); |
| 34 | + private static final int CALLGSUBR = CharStringCommand.CALLGSUBR.getValue(); |
| 35 | + |
| 36 | + // not yet supported commands |
| 37 | + private static final int HINTMASK = CharStringCommand.HINTMASK.getValue(); |
| 38 | + private static final int CNTRMASK = CharStringCommand.CNTRMASK.getValue(); |
35 | 39 |
|
36 | 40 | private final String fontName; |
37 | 41 |
|
@@ -79,7 +83,17 @@ else if (b0 == CALLGSUBR) |
79 | 83 | { |
80 | 84 | processCallGSubr(globalSubrIndex, localSubrIndex, glyphData); |
81 | 85 | } |
82 | | - else if ((b0 >= 0 && b0 <= 27) || (b0 >= 29 && b0 <= 31)) |
| 86 | + else if (b0 == HINTMASK || b0 == CNTRMASK) |
| 87 | + { |
| 88 | + int maskLength = getMaskLength(glyphData.hstemCount, glyphData.vstemCount); |
| 89 | + // drop the following bytes representing the mask as long as we don't support HINTMASK and CNTRMASK |
| 90 | + for (int i = 0; i < maskLength; i++) |
| 91 | + { |
| 92 | + input.readUnsignedByte(); |
| 93 | + } |
| 94 | + glyphData.sequence.add(CharStringCommand.getInstance(b0)); |
| 95 | + } |
| 96 | + else if ((b0 >= 0 && b0 <= 18) || (b0 >= 21 && b0 <= 27) || (b0 >= 29 && b0 <= 31)) |
83 | 97 | { |
84 | 98 | glyphData.sequence.add(readCommand(b0, input, glyphData)); |
85 | 99 | } |
@@ -163,18 +177,6 @@ private CharStringCommand readCommand(int b0, DataInput input, GlyphData glyphDa |
163 | 177 | return CharStringCommand.getInstance(b0); |
164 | 178 | case 12: |
165 | 179 | return CharStringCommand.getInstance(b0, input.readUnsignedByte()); |
166 | | - case 19: |
167 | | - case 20: |
168 | | - glyphData.vstemCount += countNumbers(glyphData.sequence) / 2; |
169 | | - int[] value = new int[1 + getMaskLength(glyphData.hstemCount, glyphData.vstemCount)]; |
170 | | - value[0] = b0; |
171 | | - |
172 | | - for (int i = 1; i < value.length; i++) |
173 | | - { |
174 | | - value[i] = input.readUnsignedByte(); |
175 | | - } |
176 | | - |
177 | | - return CharStringCommand.getInstance(value); |
178 | 180 | default: |
179 | 181 | return CharStringCommand.getInstance(b0); |
180 | 182 | } |
|
0 commit comments