Skip to content

Commit

Permalink
PDFBOX-5915: hintmask and cntrmask should handled separately, by Andr…
Browse files Browse the repository at this point in the history
…eas Lehmkühler

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922254 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Dec 2, 2024
1 parent f2b94f9 commit c61e2b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c61e2b1

Please sign in to comment.