From 43afac8f5d1db8995c819b17cfce8aaff857c0c2 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Wed, 26 Feb 2020 12:39:12 +0000 Subject: [PATCH] default to zero width characters in truetype for '.notdef' when the character is not defined and the corresponding '.notdef' glyph isn't included in a truetype font we now default to a zero width character. it might be that we should use the default/missing width instead but this will work ok for most use-cases. --- .../PdfFonts/Simple/TrueTypeStandard14FallbackSimpleFont.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/UglyToad.PdfPig/PdfFonts/Simple/TrueTypeStandard14FallbackSimpleFont.cs b/src/UglyToad.PdfPig/PdfFonts/Simple/TrueTypeStandard14FallbackSimpleFont.cs index 17346d87..f649f567 100644 --- a/src/UglyToad.PdfPig/PdfFonts/Simple/TrueTypeStandard14FallbackSimpleFont.cs +++ b/src/UglyToad.PdfPig/PdfFonts/Simple/TrueTypeStandard14FallbackSimpleFont.cs @@ -87,7 +87,10 @@ } var name = encoding.GetName(characterCode); - var metrics = fontMetrics.CharacterMetrics[name]; + if (!fontMetrics.CharacterMetrics.TryGetValue(name, out var metrics)) + { + return new CharacterBoundingBox(new PdfRectangle(), 0); + } if (overrides?.TryGetWidth(characterCode, out width) != true) {