Skip to content

Commit 5a851a1

Browse files
authored
Fix font width array parsing when entries are indirect object references (#1307)
* Improve error handling in FontDictionaryAccessHelper Refactor error handling for non-numeric tokens in width array. * Improve error message in InvalidFontFormatException
1 parent 217b776 commit 5a851a1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/UglyToad.PdfPig/PdfFonts/Parser/FontDictionaryAccessHelper.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ public static double[] GetWidths(IPdfTokenScanner pdfScanner, DictionaryToken di
4848

4949
if (!(arrayToken is NumericToken number))
5050
{
51-
throw new InvalidFontFormatException($"Token which was not a number found in the widths array: {arrayToken}.");
51+
if (DirectObjectFinder.TryGet<NumericToken>(arrayToken, pdfScanner, out var resolved))
52+
{
53+
number = resolved;
54+
}
55+
else
56+
{
57+
throw new InvalidFontFormatException($"Token which was not a number found in the widths array: {arrayToken}.");
58+
}
5259
}
5360

5461
result[i] = number.Double;

0 commit comments

Comments
 (0)