Skip to content

Commit

Permalink
Fix ByteEncodingCMapTable.CharacterCodeToGlyphIndex() to account for …
Browse files Browse the repository at this point in the history
…glyph mapping length, add test and fix #881
  • Loading branch information
BobLd committed Sep 29, 2024
1 parent ad78532 commit 8ce6bcc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static ByteEncodingCMapTable Load(TrueTypeDataBytes data, TrueTypeCMapPla

public int CharacterCodeToGlyphIndex(int characterCode)
{
if (characterCode < 0 || characterCode >= GlyphMappingLength)
if (characterCode < 0 || characterCode >= glyphMapping.Length)
{
return 0;
}
Expand Down
Binary file not shown.
24 changes: 24 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/TrueTypeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System.Linq;

public class TrueTypeTests
{
[Fact]
public void Issue881()
{
var file = IntegrationHelpers.GetDocumentPath("issue_881.pdf");

using (var document = PdfDocument.Open(file))
{
var page = document.GetPage(1);
var words = page.GetWords().ToArray();
Assert.Equal(4, words.Length);
Assert.Equal("IDNR:", words[0].Text);
Assert.Equal("4174", words[1].Text);
Assert.Equal("/", words[2].Text);
Assert.Equal("06.08.2018", words[3].Text);
}
}
}
}

0 comments on commit 8ce6bcc

Please sign in to comment.