Martin Mirchev created PDFBOX-6344:
--------------------------------------

             Summary: Type2 charstring 16.16 fixed point operands are decoded 
with a 1/65535 fraction
                 Key: PDFBOX-6344
                 URL: https://issues.apache.org/jira/browse/PDFBOX-6344
             Project: PDFBox
          Issue Type: Bug
          Components: FontBox
    Affects Versions: 4.0.0, 3.0.8 PDFBox
            Reporter: Martin Mirchev
         Attachments: type2-fixed-16-16.patch

{{Type2CharStringParser.readNumber}} decodes an operand that starts with byte 
255 as {{value + input.readUnsignedShort() / 65535d}}. The Type 2 charstring 
format defines this operand as a 16.16 fixed point number, so the fraction is 
in units of 1/65536: {{00 01 80 00}} is 1.5, but PDFBox gives 1.5000076. The 
error is small, but every fixed-point coordinate and width in a CFF font is 
affected.

The attached patch divides by 65536 and adds a test to 
{{Type2CharStringParserTest}} for 1.5 and -1.5. The test fails without the 
change, and the fontbox tests pass with it.

This issue was found by an LLM-assisted tool and verified manually.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to