Fix ByteEncodingCMapTable.CharacterCodeToGlyphIndex() to account for glyph mapping length, add test and fix #881

This commit is contained in:
BobLd 2024-08-25 11:59:19 +01:00
parent ad785328e1
commit 8ce6bcc2a7
3 changed files with 25 additions and 1 deletions

View File

@ -46,7 +46,7 @@
public int CharacterCodeToGlyphIndex(int characterCode)
{
if (characterCode < 0 || characterCode >= GlyphMappingLength)
if (characterCode < 0 || characterCode >= glyphMapping.Length)
{
return 0;
}

View File

@ -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);
}
}
}
}