From eff766ea5a5b4e1e12b5c39a8aa4505e4b88e872 Mon Sep 17 00:00:00 2001 From: IgorSapijaszko Date: Mon, 6 Apr 2026 16:54:48 +0200 Subject: [PATCH] fix: removed incorrect signed cast in Fixed1616 fraction part parsing Previously, the fractional part was cast to a signed short, which caused incorrect interpretation of values when the highest bit of the fraction was set. This resulted in subtle coordinate drift when reconstructing glyph outlines from Type2 charstrings. The fix removes the unnecessary signed cast and treats the fractional part as an unsigned 16-bit value, aligning with the Fixed1616 specification. This resolves cumulative errors visible across contour segments. --- Typography.OpenFont/Tables.CFF/Type2CharStringParser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Typography.OpenFont/Tables.CFF/Type2CharStringParser.cs b/Typography.OpenFont/Tables.CFF/Type2CharStringParser.cs index 00aa179d..0956d5f3 100644 --- a/Typography.OpenFont/Tables.CFF/Type2CharStringParser.cs +++ b/Typography.OpenFont/Tables.CFF/Type2CharStringParser.cs @@ -57,7 +57,7 @@ public float ReadValueAsFixed1616() ///This number is interpreted as a Fixed; that is, a signed number with 16 bits of fraction float int_part = (short)((b0 << 8) | b1); - float fraction_part = (short)((b2 << 8) | b3) / (float)(1 << 16); + float fraction_part = ((b2 << 8) | b3) / (float)(1 << 16); return int_part + fraction_part; } @@ -1298,4 +1298,4 @@ static int ReadIntegerNumber(ref SimpleBinaryReader _reader, byte b0) } -} \ No newline at end of file +}