mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-20 03:17:57 +08:00
#141 fix two's complement in adobe type 2 charstring
the byte value of 28 indicates the next 2 bytes are a 16 bit two's complement number rather than just a short. this changes the calculation to generate the two's complement value correctly.
This commit is contained in:
@@ -767,7 +767,11 @@ namespace UglyToad.PdfPig.Fonts.CompactFontFormat.CharStrings
|
|||||||
{
|
{
|
||||||
if (b == 28)
|
if (b == 28)
|
||||||
{
|
{
|
||||||
return bytes[++i] << 8 | bytes[++i];
|
var num = bytes[++i] << 8 | bytes[++i];
|
||||||
|
// Next 2 bytes are a 16-bit two's complement number.
|
||||||
|
// The twos complement of a number N in a B-bit system is 2^B - N. For 16 bits the result is 2^16 - num.
|
||||||
|
// A shortcut is to invert the bits of the number and add 1.
|
||||||
|
return (short) (~(num) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b >= 32 && b <= 246)
|
if (b >= 32 && b <= 246)
|
||||||
|
Reference in New Issue
Block a user