This commit is contained in:
BobLd 2024-03-23 19:25:40 +00:00 committed by GitHub
parent 69e2b7bb08
commit e789691100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 47 additions and 11 deletions

View File

@ -0,0 +1,24 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System.Linq;
public class Type1FontSimpleTests
{
[Fact]
public void Issue807()
{
var file = IntegrationHelpers.GetDocumentPath("Diacritics_export.pdf");
using (var document = PdfDocument.Open(file))
{
var page = document.GetPage(1);
var words = page.GetWords().ToArray();
Assert.Equal(3, words.Length);
Assert.Equal("Espinosa", words[0].Text);
Assert.Equal("Spínola", words[1].Text);
Assert.Equal("Moraña,", words[2].Text);
}
}
}
}

View File

@ -90,14 +90,13 @@
public bool TryGetUnicode(int characterCode, [NotNullWhen(true)] out string? value)
{
if (toUnicodeCMap.CanMapToUnicode)
value = null;
if (toUnicodeCMap.CanMapToUnicode && toUnicodeCMap.TryGet(characterCode, out value))
{
return toUnicodeCMap.TryGet(characterCode, out value);
return true;
}
value = null;
if (encoding == null)
if (encoding is null)
{
try
{
@ -132,7 +131,7 @@
return false;
}
return true;
return value is not null;
}
public CharacterBoundingBox GetBoundingBox(int characterCode)

View File

@ -52,16 +52,29 @@
public bool TryGetUnicode(int characterCode, [NotNullWhen(true)] out string? value)
{
if (toUnicodeCMap.CanMapToUnicode)
value = null;
if (toUnicodeCMap.CanMapToUnicode && toUnicodeCMap.TryGet(characterCode, out value))
{
return toUnicodeCMap.TryGet(characterCode, out value);
return true;
}
var name = encoding.GetName(characterCode);
if (encoding is null)
{
return false;
}
value = GlyphList.AdobeGlyphList.NameToUnicode(name);
try
{
var name = encoding.GetName(characterCode);
value = GlyphList.AdobeGlyphList.NameToUnicode(name);
}
catch
{
return false;
}
return true;
return value is not null;
}
public CharacterBoundingBox GetBoundingBox(int characterCode)