Skip to content

Commit c61e2b1

Browse files
committed
PDFBOX-5915: hintmask and cntrmask should handled separately, by Andreas Lehmkühler
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922254 13f79535-47bb-0310-9956-ffa450edef68
1 parent f2b94f9 commit c61e2b1

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ public static CharStringCommand getInstance(int b0, int b1)
152152
*/
153153
public static CharStringCommand getInstance(int[] values)
154154
{
155-
if (values[0] == 19 || values[0] == 20)
156-
{
157-
//TODO store the rest (hintmask and cntrmask) if we ever process these.
158-
return getInstance(values[0]);
159-
}
160155
switch (values.length)
161156
{
162157
case 1:

fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@
3030
public class Type2CharStringParser
3131
{
3232
// 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();
3539

3640
private final String fontName;
3741

@@ -79,7 +83,17 @@ else if (b0 == CALLGSUBR)
7983
{
8084
processCallGSubr(globalSubrIndex, localSubrIndex, glyphData);
8185
}
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))
8397
{
8498
glyphData.sequence.add(readCommand(b0, input, glyphData));
8599
}
@@ -163,18 +177,6 @@ private CharStringCommand readCommand(int b0, DataInput input, GlyphData glyphDa
163177
return CharStringCommand.getInstance(b0);
164178
case 12:
165179
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);
178180
default:
179181
return CharStringCommand.getInstance(b0);
180182
}

0 commit comments

Comments
 (0)