mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-23 20:53:39 +08:00
fix encoding to work with acrobat reader
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
using Geometry;
|
using Geometry;
|
||||||
using Logging;
|
using Logging;
|
||||||
using Tokens;
|
using Tokens;
|
||||||
using Util;
|
|
||||||
|
|
||||||
internal class TrueTypeWritingFont : IWritingFont
|
internal class TrueTypeWritingFont : IWritingFont
|
||||||
{
|
{
|
||||||
@@ -156,7 +155,8 @@
|
|||||||
|
|
||||||
public FontDictionaryMetrics GetMetrics(decimal scaling)
|
public FontDictionaryMetrics GetMetrics(decimal scaling)
|
||||||
{
|
{
|
||||||
var encoding = ReadFontEncoding();
|
// TODO: differences array
|
||||||
|
var encoding = WinAnsiEncoding.Instance;
|
||||||
var firstCharacter = encoding.CodeToNameMap.Keys.Min();
|
var firstCharacter = encoding.CodeToNameMap.Keys.Min();
|
||||||
var lastCharacter = encoding.CodeToNameMap.Keys.Max();
|
var lastCharacter = encoding.CodeToNameMap.Keys.Max();
|
||||||
|
|
||||||
@@ -199,14 +199,21 @@
|
|||||||
{
|
{
|
||||||
var codeToName = new Dictionary<int, string>();
|
var codeToName = new Dictionary<int, string>();
|
||||||
var postscript = font.TableRegister.PostScriptTable;
|
var postscript = font.TableRegister.PostScriptTable;
|
||||||
for (int i = 0; i <= 256; i++)
|
for (var i = 0; i <= 256; i++)
|
||||||
{
|
{
|
||||||
if (!font.TableRegister.CMapTable.TryGetGlyphIndex(i, out var glyphIndex))
|
if (!font.TableRegister.CMapTable.TryGetGlyphIndex(i, out var glyphIndex))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
codeToName[i] = postscript.GlyphNames[glyphIndex];
|
var name = postscript.GlyphNames[glyphIndex];
|
||||||
|
|
||||||
|
if (GlyphList.AdobeGlyphList.NameToUnicode(name) == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
codeToName[i] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BuiltInEncoding(codeToName);
|
return new BuiltInEncoding(codeToName);
|
||||||
|
Reference in New Issue
Block a user