start creating interface structure for cid fonts to be used elsewhere. port most encoding classes from pdfbox

This commit is contained in:
Eliot Jones
2017-12-26 14:02:47 +00:00
parent cab46f1ecf
commit a97bac2c69
13 changed files with 1398 additions and 0 deletions

View File

@@ -34,5 +34,7 @@
CharacterIdentifierSystemInfo SystemInfo { get; } CharacterIdentifierSystemInfo SystemInfo { get; }
CidFontType CidFontType { get; } CidFontType CidFontType { get; }
FontDescriptor Descriptor { get; }
} }
} }

View File

@@ -0,0 +1,10 @@
namespace UglyToad.Pdf.Fonts.CidFonts
{
/// <summary>
/// Represents either an Adobe Type 1 or TrueType font program for a CIDFont.
/// </summary>
internal interface ICidFontProgram
{
}
}

View File

@@ -14,5 +14,6 @@
public CosName BaseFont { get; } public CosName BaseFont { get; }
public CharacterIdentifierSystemInfo SystemInfo { get; } public CharacterIdentifierSystemInfo SystemInfo { get; }
public CidFontType CidFontType => CidFontType.Type0; public CidFontType CidFontType => CidFontType.Type0;
public FontDescriptor Descriptor { get; }
} }
} }

View File

@@ -1,6 +1,7 @@
namespace UglyToad.Pdf.Fonts.CidFonts namespace UglyToad.Pdf.Fonts.CidFonts
{ {
using Cos; using Cos;
using TrueType.Parser;
/// <inheritdoc /> /// <inheritdoc />
/// <summary> /// <summary>
@@ -9,10 +10,22 @@
/// </summary> /// </summary>
internal class Type2CidFont : ICidFont internal class Type2CidFont : ICidFont
{ {
private readonly TrueTypeFont fontProgram;
public CosName Type { get; } public CosName Type { get; }
public CosName SubType { get; } public CosName SubType { get; }
public CosName BaseFont { get; } public CosName BaseFont { get; }
public CharacterIdentifierSystemInfo SystemInfo { get; } public CharacterIdentifierSystemInfo SystemInfo { get; }
public CidFontType CidFontType => CidFontType.Type2; public CidFontType CidFontType => CidFontType.Type2;
public FontDescriptor Descriptor { get; }
public Type2CidFont(CosName type, CosName subType, CosName baseFont, CharacterIdentifierSystemInfo systemInfo, FontDescriptor descriptor, TrueTypeFont fontProgram)
{
Type = type;
SubType = subType;
BaseFont = baseFont;
SystemInfo = systemInfo;
Descriptor = descriptor;
this.fontProgram = fontProgram;
}
} }
} }

View File

@@ -0,0 +1,17 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
using System.Collections.Generic;
internal class BuiltInEncoding : Encoding
{
public override string EncodingName => "built-in (TTF)";
public BuiltInEncoding(IReadOnlyDictionary<int, string> codeToName)
{
foreach (var keyValuePair in codeToName)
{
Add(keyValuePair.Key, keyValuePair.Value);
}
}
}
}

View File

@@ -0,0 +1,59 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
using System;
using System.Collections.Generic;
/// <summary>
/// Maps character codes to glyph names from a PostScript encoding.
/// </summary>
internal abstract class Encoding
{
protected readonly Dictionary<int, string> CodeToName = new Dictionary<int, string>(250);
public IReadOnlyDictionary<int, string> CodeToNameMap => CodeToName;
protected readonly Dictionary<string, int> NameToCode = new Dictionary<string, int>(250);
public IReadOnlyDictionary<string, int> NameToCodeMap => NameToCode;
public abstract string EncodingName { get; }
public bool ContainsName(string name)
{
foreach (var keyValuePair in CodeToNameMap)
{
if (string.Equals(keyValuePair.Value, name, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
return false;
}
public bool ContainsCode(int code)
{
return CodeToName.ContainsKey(code);
}
public string GetName(int code)
{
if (!CodeToName.TryGetValue(code, out var name))
{
return ".notdef";
}
return name;
}
protected void Add(int code, string name)
{
CodeToName[code] = name;
if (!NameToCode.ContainsKey(name))
{
NameToCode[name] = code;
}
}
}
}

View File

@@ -0,0 +1,189 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class MacExpertEncoding : Encoding
{
/// <summary>
/// Table of octal character codes and their corresponding names.
/// </summary>
private static readonly (int, string)[] EncodingTable =
{
(0276, "AEsmall"),
(0207, "Aacutesmall"),
(0211, "Acircumflexsmall"),
(047, "Acutesmall"),
(0212, "Adieresissmall"),
(0210, "Agravesmall"),
(0214, "Aringsmall"),
(0141, "Asmall"),
(0213, "Atildesmall"),
(0363, "Brevesmall"),
(0142, "Bsmall"),
(0256, "Caronsmall"),
(0215, "Ccedillasmall"),
(0311, "Cedillasmall"),
(0136, "Circumflexsmall"),
(0143, "Csmall"),
(0254, "Dieresissmall"),
(0372, "Dotaccentsmall"),
(0144, "Dsmall"),
(0216, "Eacutesmall"),
(0220, "Ecircumflexsmall"),
(0221, "Edieresissmall"),
(0217, "Egravesmall"),
(0145, "Esmall"),
(0104, "Ethsmall"),
(0146, "Fsmall"),
(0140, "Gravesmall"),
(0147, "Gsmall"),
(0150, "Hsmall"),
(042, "Hungarumlautsmall"),
(0222, "Iacutesmall"),
(0224, "Icircumflexsmall"),
(0225, "Idieresissmall"),
(0223, "Igravesmall"),
(0151, "Ismall"),
(0152, "Jsmall"),
(0153, "Ksmall"),
(0302, "Lslashsmall"),
(0154, "Lsmall"),
(0364, "Macronsmall"),
(0155, "Msmall"),
(0156, "Nsmall"),
(0226, "Ntildesmall"),
(0317, "OEsmall"),
(0227, "Oacutesmall"),
(0231, "Ocircumflexsmall"),
(0232, "Odieresissmall"),
(0362, "Ogoneksmall"),
(0230, "Ogravesmall"),
(0277, "Oslashsmall"),
(0157, "Osmall"),
(0233, "Otildesmall"),
(0160, "Psmall"),
(0161, "Qsmall"),
(0373, "Ringsmall"),
(0162, "Rsmall"),
(0247, "Scaronsmall"),
(0163, "Ssmall"),
(0271, "Thornsmall"),
(0176, "Tildesmall"),
(0164, "Tsmall"),
(0234, "Uacutesmall"),
(0236, "Ucircumflexsmall"),
(0237, "Udieresissmall"),
(0235, "Ugravesmall"),
(0165, "Usmall"),
(0166, "Vsmall"),
(0167, "Wsmall"),
(0170, "Xsmall"),
(0264, "Yacutesmall"),
(0330, "Ydieresissmall"),
(0171, "Ysmall"),
(0275, "Zcaronsmall"),
(0172, "Zsmall"),
(046, "ampersandsmall"),
(0201, "asuperior"),
(0365, "bsuperior"),
(0251, "centinferior"),
(043, "centoldstyle"),
(0202, "centsuperior"),
(072, "colon"),
(0173, "colonmonetary"),
(054, "comma"),
(0262, "commainferior"),
(0370, "commasuperior"),
(0266, "dollarinferior"),
(044, "dollaroldstyle"),
(045, "dollarsuperior"),
(0353, "dsuperior"),
(0245, "eightinferior"),
(070, "eightoldstyle"),
(0241, "eightsuperior"),
(0344, "esuperior"),
(0326, "exclamdownsmall"),
(041, "exclamsmall"),
(0126, "ff"),
(0131, "ffi"),
(0132, "ffl"),
(0127, "fi"),
(0320, "figuredash"),
(0114, "fiveeighths"),
(0260, "fiveinferior"),
(065, "fiveoldstyle"),
(0336, "fivesuperior"),
(0130, "fl"),
(0242, "fourinferior"),
(064, "fouroldstyle"),
(0335, "foursuperior"),
(057, "fraction"),
(055, "hyphen"),
(0137, "hypheninferior"),
(0321, "hyphensuperior"),
(0351, "isuperior"),
(0361, "lsuperior"),
(0367, "msuperior"),
(0273, "nineinferior"),
(071, "nineoldstyle"),
(0341, "ninesuperior"),
(0366, "nsuperior"),
(053, "onedotenleader"),
(0112, "oneeighth"),
(0174, "onefitted"),
(0110, "onehalf"),
(0301, "oneinferior"),
(061, "oneoldstyle"),
(0107, "onequarter"),
(0332, "onesuperior"),
(0116, "onethird"),
(0257, "osuperior"),
(0133, "parenleftinferior"),
(050, "parenleftsuperior"),
(0135, "parenrightinferior"),
(051, "parenrightsuperior"),
(056, "period"),
(0263, "periodinferior"),
(0371, "periodsuperior"),
(0300, "questiondownsmall"),
(077, "questionsmall"),
(0345, "rsuperior"),
(0175, "rupiah"),
(073, "semicolon"),
(0115, "seveneighths"),
(0246, "seveninferior"),
(067, "sevenoldstyle"),
(0340, "sevensuperior"),
(0244, "sixinferior"),
(066, "sixoldstyle"),
(0337, "sixsuperior"),
(040, "space"),
(0352, "ssuperior"),
(0113, "threeeighths"),
(0243, "threeinferior"),
(063, "threeoldstyle"),
(0111, "threequarters"),
(075, "threequartersemdash"),
(0334, "threesuperior"),
(0346, "tsuperior"),
(052, "twodotenleader"),
(0252, "twoinferior"),
(062, "twooldstyle"),
(0333, "twosuperior"),
(0117, "twothirds"),
(0274, "zeroinferior"),
(060, "zerooldstyle"),
(0342, "zerosuperior")
};
public static MacExpertEncoding Instance { get; } = new MacExpertEncoding();
public override string EncodingName => "MacExpertEncoding";
private MacExpertEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}

View File

@@ -0,0 +1,38 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
/// <summary>
/// Similar to the <see cref="MacRomanEncoding"/> with 15 additional entries.
/// </summary>
internal class MacOsRomanEncoding : MacRomanEncoding
{
private static readonly (int, string)[] EncodingTable =
{
(255, "notequal"),
(260, "infinity"),
(262, "lessequal"),
(263, "greaterequal"),
(266, "partialdiff"),
(267, "summation"),
(270, "product"),
(271, "pi"),
(272, "integral"),
(275, "Omega"),
(303, "radical"),
(305, "approxequal"),
(306, "Delta"),
(327, "lozenge"),
(333, "Euro"),
(360, "apple")
};
public new static MacOsRomanEncoding Instance { get; } = new MacOsRomanEncoding();
private MacOsRomanEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}

View File

@@ -0,0 +1,233 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class MacRomanEncoding : Encoding
{
/// <summary>
/// Table of octal character codes and their corresponding names.
/// </summary>
private static readonly (int, string)[] EncodingTable =
{
(0101, "A"),
(0256, "AE"),
(0347, "Aacute"),
(0345, "Acircumflex"),
(0200, "Adieresis"),
(0313, "Agrave"),
(0201, "Aring"),
(0314, "Atilde"),
(0102, "B"),
(0103, "C"),
(0202, "Ccedilla"),
(0104, "D"),
(0105, "E"),
(0203, "Eacute"),
(0346, "Ecircumflex"),
(0350, "Edieresis"),
(0351, "Egrave"),
(0106, "F"),
(0107, "G"),
(0110, "H"),
(0111, "I"),
(0352, "Iacute"),
(0353, "Icircumflex"),
(0354, "Idieresis"),
(0355, "Igrave"),
(0112, "J"),
(0113, "K"),
(0114, "L"),
(0115, "M"),
(0116, "N"),
(0204, "Ntilde"),
(0117, "O"),
(0316, "OE"),
(0356, "Oacute"),
(0357, "Ocircumflex"),
(0205, "Odieresis"),
(0361, "Ograve"),
(0257, "Oslash"),
(0315, "Otilde"),
(0120, "P"),
(0121, "Q"),
(0122, "R"),
(0123, "S"),
(0124, "T"),
(0125, "U"),
(0362, "Uacute"),
(0363, "Ucircumflex"),
(0206, "Udieresis"),
(0364, "Ugrave"),
(0126, "V"),
(0127, "W"),
(0130, "X"),
(0131, "Y"),
(0331, "Ydieresis"),
(0132, "Z"),
(0141, "a"),
(0207, "aacute"),
(0211, "acircumflex"),
(0253, "acute"),
(0212, "adieresis"),
(0276, "ae"),
(0210, "agrave"),
(046, "ampersand"),
(0214, "aring"),
(0136, "asciicircum"),
(0176, "asciitilde"),
(052, "asterisk"),
(0100, "at"),
(0213, "atilde"),
(0142, "b"),
(0134, "backslash"),
(0174, "bar"),
(0173, "braceleft"),
(0175, "braceright"),
(0133, "bracketleft"),
(0135, "bracketright"),
(0371, "breve"),
(0245, "bullet"),
(0143, "c"),
(0377, "caron"),
(0215, "ccedilla"),
(0374, "cedilla"),
(0242, "cent"),
(0366, "circumflex"),
(072, "colon"),
(054, "comma"),
(0251, "copyright"),
(0333, "currency"),
(0144, "d"),
(0240, "dagger"),
(0340, "daggerdbl"),
(0241, "degree"),
(0254, "dieresis"),
(0326, "divide"),
(044, "dollar"),
(0372, "dotaccent"),
(0365, "dotlessi"),
(0145, "e"),
(0216, "eacute"),
(0220, "ecircumflex"),
(0221, "edieresis"),
(0217, "egrave"),
(070, "eight"),
(0311, "ellipsis"),
(0321, "emdash"),
(0320, "endash"),
(075, "equal"),
(041, "exclam"),
(0301, "exclamdown"),
(0146, "f"),
(0336, "fi"),
(065, "five"),
(0337, "fl"),
(0304, "florin"),
(064, "four"),
(0332, "fraction"),
(0147, "g"),
(0247, "germandbls"),
(0140, "grave"),
(076, "greater"),
(0307, "guillemotleft"),
(0310, "guillemotright"),
(0334, "guilsinglleft"),
(0335, "guilsinglright"),
(0150, "h"),
(0375, "hungarumlaut"),
(055, "hyphen"),
(0151, "i"),
(0222, "iacute"),
(0224, "icircumflex"),
(0225, "idieresis"),
(0223, "igrave"),
(0152, "j"),
(0153, "k"),
(0154, "l"),
(074, "less"),
(0302, "logicalnot"),
(0155, "m"),
(0370, "macron"),
(0265, "mu"),
(0156, "n"),
(071, "nine"),
(0226, "ntilde"),
(043, "numbersign"),
(0157, "o"),
(0227, "oacute"),
(0231, "ocircumflex"),
(0232, "odieresis"),
(0317, "oe"),
(0376, "ogonek"),
(0230, "ograve"),
(061, "one"),
(0273, "ordfeminine"),
(0274, "ordmasculine"),
(0277, "oslash"),
(0233, "otilde"),
(0160, "p"),
(0246, "paragraph"),
(050, "parenleft"),
(051, "parenright"),
(045, "percent"),
(056, "period"),
(0341, "periodcentered"),
(0344, "perthousand"),
(053, "plus"),
(0261, "plusminus"),
(0161, "q"),
(077, "question"),
(0300, "questiondown"),
(042, "quotedbl"),
(0343, "quotedblbase"),
(0322, "quotedblleft"),
(0323, "quotedblright"),
(0324, "quoteleft"),
(0325, "quoteright"),
(0342, "quotesinglbase"),
(047, "quotesingle"),
(0162, "r"),
(0250, "registered"),
(0373, "ring"),
(0163, "s"),
(0244, "section"),
(073, "semicolon"),
(067, "seven"),
(066, "six"),
(057, "slash"),
(040, "space"),
(0243, "sterling"),
(0164, "t"),
(063, "three"),
(0367, "tilde"),
(0252, "trademark"),
(062, "two"),
(0165, "u"),
(0234, "uacute"),
(0236, "ucircumflex"),
(0237, "udieresis"),
(0235, "ugrave"),
(0137, "underscore"),
(0166, "v"),
(0167, "w"),
(0170, "x"),
(0171, "y"),
(0330, "ydieresis"),
(0264, "yen"),
(0172, "z"),
(060, "zero"),
// adding an additional mapping as defined in Appendix D of the pdf spec
(0312, "space")
};
public static MacRomanEncoding Instance { get; } = new MacRomanEncoding();
public override string EncodingName => "MacRomanEncoding";
protected MacRomanEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}

View File

@@ -0,0 +1,170 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class StandardEncoding : Encoding
{
private static readonly (int, string)[] EncodingTable =
{
(0101, "A"),
(0341, "AE"),
(0102, "B"),
(0103, "C"),
(0104, "D"),
(0105, "E"),
(0106, "F"),
(0107, "G"),
(0110, "H"),
(0111, "I"),
(0112, "J"),
(0113, "K"),
(0114, "L"),
(0350, "Lslash"),
(0115, "M"),
(0116, "N"),
(0117, "O"),
(0352, "OE"),
(0351, "Oslash"),
(0120, "P"),
(0121, "Q"),
(0122, "R"),
(0123, "S"),
(0124, "T"),
(0125, "U"),
(0126, "V"),
(0127, "W"),
(0130, "X"),
(0131, "Y"),
(0132, "Z"),
(0141, "a"),
(0302, "acute"),
(0361, "ae"),
(0046, "ampersand"),
(0136, "asciicircum"),
(0176, "asciitilde"),
(0052, "asterisk"),
(0100, "at"),
(0142, "b"),
(0134, "backslash"),
(0174, "bar"),
(0173, "braceleft"),
(0175, "braceright"),
(0133, "bracketleft"),
(0135, "bracketright"),
(0306, "breve"),
(0267, "bullet"),
(0143, "c"),
(0317, "caron"),
(0313, "cedilla"),
(0242, "cent"),
(0303, "circumflex"),
(0072, "colon"),
(0054, "comma"),
(0250, "currency"),
(0144, "d"),
(0262, "dagger"),
(0263, "daggerdbl"),
(0310, "dieresis"),
(0044, "dollar"),
(0307, "dotaccent"),
(0365, "dotlessi"),
(0145, "e"),
(0070, "eight"),
(0274, "ellipsis"),
(0320, "emdash"),
(0261, "endash"),
(0075, "equal"),
(0041, "exclam"),
(0241, "exclamdown"),
(0146, "f"),
(0256, "fi"),
(0065, "five"),
(0257, "fl"),
(0246, "florin"),
(0064, "four"),
(0244, "fraction"),
(0147, "g"),
(0373, "germandbls"),
(0301, "grave"),
(0076, "greater"),
(0253, "guillemotleft"),
(0273, "guillemotright"),
(0254, "guilsinglleft"),
(0255, "guilsinglright"),
(0150, "h"),
(0315, "hungarumlaut"),
(0055, "hyphen"),
(0151, "i"),
(0152, "j"),
(0153, "k"),
(0154, "l"),
(0074, "less"),
(0370, "lslash"),
(0155, "m"),
(0305, "macron"),
(0156, "n"),
(0071, "nine"),
(0043, "numbersign"),
(0157, "o"),
(0372, "oe"),
(0316, "ogonek"),
(0061, "one"),
(0343, "ordfeminine"),
(0353, "ordmasculine"),
(0371, "oslash"),
(0160, "p"),
(0266, "paragraph"),
(0050, "parenleft"),
(0051, "parenright"),
(0045, "percent"),
(0056, "period"),
(0264, "periodcentered"),
(0275, "perthousand"),
(0053, "plus"),
(0161, "q"),
(0077, "question"),
(0277, "questiondown"),
(0042, "quotedbl"),
(0271, "quotedblbase"),
(0252, "quotedblleft"),
(0272, "quotedblright"),
(0140, "quoteleft"),
(0047, "quoteright"),
(0270, "quotesinglbase"),
(0251, "quotesingle"),
(0162, "r"),
(0312, "ring"),
(0163, "s"),
(0247, "section"),
(0073, "semicolon"),
(0067, "seven"),
(0066, "six"),
(0057, "slash"),
(0040, "space"),
(0243, "sterling"),
(0164, "t"),
(0063, "three"),
(0304, "tilde"),
(0062, "two"),
(0165, "u"),
(0137, "underscore"),
(0166, "v"),
(0167, "w"),
(0170, "x"),
(0171, "y"),
(0245, "yen"),
(0172, "z"),
(0060, "zero")
};
public static StandardEncoding Instance { get; } = new StandardEncoding();
public override string EncodingName => "StandardEncoding";
private StandardEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}

View File

@@ -0,0 +1,209 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class SymbolEncoding : Encoding
{
private static readonly (int, string)[] EncodingTable = {
(0101, "Alpha"),
(0102, "Beta"),
(0103, "Chi"),
(0104, "Delta"),
(0105, "Epsilon"),
(0110, "Eta"),
(0240, "Euro"),
(0107, "Gamma"),
(0301, "Ifraktur"),
(0111, "Iota"),
(0113, "Kappa"),
(0114, "Lambda"),
(0115, "Mu"),
(0116, "Nu"),
(0127, "Omega"),
(0117, "Omicron"),
(0106, "Phi"),
(0120, "Pi"),
(0131, "Psi"),
(0302, "Rfraktur"),
(0122, "Rho"),
(0123, "Sigma"),
(0124, "Tau"),
(0121, "Theta"),
(0125, "Upsilon"),
(0241, "Upsilon1"),
(0130, "Xi"),
(0132, "Zeta"),
(0300, "aleph"),
(0141, "alpha"),
(0046, "ampersand"),
(0320, "angle"),
(0341, "angleleft"),
(0361, "angleright"),
(0273, "approxequal"),
(0253, "arrowboth"),
(0333, "arrowdblboth"),
(0337, "arrowdbldown"),
(0334, "arrowdblleft"),
(0336, "arrowdblright"),
(0335, "arrowdblup"),
(0257, "arrowdown"),
(0276, "arrowhorizex"),
(0254, "arrowleft"),
(0256, "arrowright"),
(0255, "arrowup"),
(0275, "arrowvertex"),
(0052, "asteriskmath"),
(0174, "bar"),
(0142, "beta"),
(0173, "braceleft"),
(0175, "braceright"),
(0354, "bracelefttp"),
(0355, "braceleftmid"),
(0356, "braceleftbt"),
(0374, "bracerighttp"),
(0375, "bracerightmid"),
(0376, "bracerightbt"),
(0357, "braceex"),
(0133, "bracketleft"),
(0135, "bracketright"),
(0351, "bracketlefttp"),
(0352, "bracketleftex"),
(0353, "bracketleftbt"),
(0371, "bracketrighttp"),
(0372, "bracketrightex"),
(0373, "bracketrightbt"),
(0267, "bullet"),
(0277, "carriagereturn"),
(0143, "chi"),
(0304, "circlemultiply"),
(0305, "circleplus"),
(0247, "club"),
(0072, "colon"),
(0054, "comma"),
(0100, "congruent"),
(0343, "copyrightsans"),
(0323, "copyrightserif"),
(0260, "degree"),
(0144, "delta"),
(0250, "diamond"),
(0270, "divide"),
(0327, "dotmath"),
(0070, "eight"),
(0316, "element"),
(0274, "ellipsis"),
(0306, "emptyset"),
(0145, "epsilon"),
(0075, "equal"),
(0272, "equivalence"),
(0150, "eta"),
(0041, "exclam"),
(0044, "existential"),
(0065, "five"),
(0246, "florin"),
(0064, "four"),
(0244, "fraction"),
(0147, "gamma"),
(0321, "gradient"),
(0076, "greater"),
(0263, "greaterequal"),
(0251, "heart"),
(0245, "infinity"),
(0362, "integral"),
(0363, "integraltp"),
(0364, "integralex"),
(0365, "integralbt"),
(0307, "intersection"),
(0151, "iota"),
(0153, "kappa"),
(0154, "lambda"),
(0074, "less"),
(0243, "lessequal"),
(0331, "logicaland"),
(0330, "logicalnot"),
(0332, "logicalor"),
(0340, "lozenge"),
(0055, "minus"),
(0242, "minute"),
(0155, "mu"),
(0264, "multiply"),
(0071, "nine"),
(0317, "notelement"),
(0271, "notequal"),
(0313, "notsubset"),
(0156, "nu"),
(0043, "numbersign"),
(0167, "omega"),
(0166, "omega1"),
(0157, "omicron"),
(0061, "one"),
(0050, "parenleft"),
(0051, "parenright"),
(0346, "parenlefttp"),
(0347, "parenleftex"),
(0350, "parenleftbt"),
(0366, "parenrighttp"),
(0367, "parenrightex"),
(0370, "parenrightbt"),
(0266, "partialdiff"),
(0045, "percent"),
(0056, "period"),
(0136, "perpendicular"),
(0146, "phi"),
(0152, "phi1"),
(0160, "pi"),
(0053, "plus"),
(0261, "plusminus"),
(0325, "product"),
(0314, "propersubset"),
(0311, "propersuperset"),
(0265, "proportional"),
(0171, "psi"),
(0077, "question"),
(0326, "radical"),
(0140, "radicalex"),
(0315, "reflexsubset"),
(0312, "reflexsuperset"),
(0342, "registersans"),
(0322, "registerserif"),
(0162, "rho"),
(0262, "second"),
(0073, "semicolon"),
(0067, "seven"),
(0163, "sigma"),
(0126, "sigma1"),
(0176, "similar"),
(0066, "six"),
(0057, "slash"),
(0040, "space"),
(0252, "spade"),
(0047, "suchthat"),
(0345, "summation"),
(0164, "tau"),
(0134, "therefore"),
(0161, "theta"),
(0112, "theta1"),
(0063, "three"),
(0344, "trademarksans"),
(0324, "trademarkserif"),
(0062, "two"),
(0137, "underscore"),
(0310, "union"),
(0042, "universal"),
(0165, "upsilon"),
(0303, "weierstrass"),
(0170, "xi"),
(0060, "zero"),
(0172, "zeta")
};
public static SymbolEncoding Instance { get; } = new SymbolEncoding();
public override string EncodingName => "SymbolEncoding";
private SymbolEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}

View File

@@ -0,0 +1,249 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class WinAnsiEncoding : Encoding
{
private static readonly (int, string)[] EncodingTable =
{
(0101, "A"),
(0306, "AE"),
(0301, "Aacute"),
(0302, "Acircumflex"),
(0304, "Adieresis"),
(0300, "Agrave"),
(0305, "Aring"),
(0303, "Atilde"),
(0102, "B"),
(0103, "C"),
(0307, "Ccedilla"),
(0104, "D"),
(0105, "E"),
(0311, "Eacute"),
(0312, "Ecircumflex"),
(0313, "Edieresis"),
(0310, "Egrave"),
(0320, "Eth"),
(0200, "Euro"),
(0106, "F"),
(0107, "G"),
(0110, "H"),
(0111, "I"),
(0315, "Iacute"),
(0316, "Icircumflex"),
(0317, "Idieresis"),
(0314, "Igrave"),
(0112, "J"),
(0113, "K"),
(0114, "L"),
(0115, "M"),
(0116, "N"),
(0321, "Ntilde"),
(0117, "O"),
(0214, "OE"),
(0323, "Oacute"),
(0324, "Ocircumflex"),
(0326, "Odieresis"),
(0322, "Ograve"),
(0330, "Oslash"),
(0325, "Otilde"),
(0120, "P"),
(0121, "Q"),
(0122, "R"),
(0123, "S"),
(0212, "Scaron"),
(0124, "T"),
(0336, "Thorn"),
(0125, "U"),
(0332, "Uacute"),
(0333, "Ucircumflex"),
(0334, "Udieresis"),
(0331, "Ugrave"),
(0126, "V"),
(0127, "W"),
(0130, "X"),
(0131, "Y"),
(0335, "Yacute"),
(0237, "Ydieresis"),
(0132, "Z"),
(0216, "Zcaron"),
(0141, "a"),
(0341, "aacute"),
(0342, "acircumflex"),
(0264, "acute"),
(0344, "adieresis"),
(0346, "ae"),
(0340, "agrave"),
(046, "ampersand"),
(0345, "aring"),
(0136, "asciicircum"),
(0176, "asciitilde"),
(052, "asterisk"),
(0100, "at"),
(0343, "atilde"),
(0142, "b"),
(0134, "backslash"),
(0174, "bar"),
(0173, "braceleft"),
(0175, "braceright"),
(0133, "bracketleft"),
(0135, "bracketright"),
(0246, "brokenbar"),
(0225, "bullet"),
(0143, "c"),
(0347, "ccedilla"),
(0270, "cedilla"),
(0242, "cent"),
(0210, "circumflex"),
(072, "colon"),
(054, "comma"),
(0251, "copyright"),
(0244, "currency"),
(0144, "d"),
(0206, "dagger"),
(0207, "daggerdbl"),
(0260, "degree"),
(0250, "dieresis"),
(0367, "divide"),
(044, "dollar"),
(0145, "e"),
(0351, "eacute"),
(0352, "ecircumflex"),
(0353, "edieresis"),
(0350, "egrave"),
(070, "eight"),
(0205, "ellipsis"),
(0227, "emdash"),
(0226, "endash"),
(075, "equal"),
(0360, "eth"),
(041, "exclam"),
(0241, "exclamdown"),
(0146, "f"),
(065, "five"),
(0203, "florin"),
(064, "four"),
(0147, "g"),
(0337, "germandbls"),
(0140, "grave"),
(076, "greater"),
(0253, "guillemotleft"),
(0273, "guillemotright"),
(0213, "guilsinglleft"),
(0233, "guilsinglright"),
(0150, "h"),
(055, "hyphen"),
(0151, "i"),
(0355, "iacute"),
(0356, "icircumflex"),
(0357, "idieresis"),
(0354, "igrave"),
(0152, "j"),
(0153, "k"),
(0154, "l"),
(074, "less"),
(0254, "logicalnot"),
(0155, "m"),
(0257, "macron"),
(0265, "mu"),
(0327, "multiply"),
(0156, "n"),
(071, "nine"),
(0361, "ntilde"),
(043, "numbersign"),
(0157, "o"),
(0363, "oacute"),
(0364, "ocircumflex"),
(0366, "odieresis"),
(0234, "oe"),
(0362, "ograve"),
(061, "one"),
(0275, "onehalf"),
(0274, "onequarter"),
(0271, "onesuperior"),
(0252, "ordfeminine"),
(0272, "ordmasculine"),
(0370, "oslash"),
(0365, "otilde"),
(0160, "p"),
(0266, "paragraph"),
(050, "parenleft"),
(051, "parenright"),
(045, "percent"),
(056, "period"),
(0267, "periodcentered"),
(0211, "perthousand"),
(053, "plus"),
(0261, "plusminus"),
(0161, "q"),
(077, "question"),
(0277, "questiondown"),
(042, "quotedbl"),
(0204, "quotedblbase"),
(0223, "quotedblleft"),
(0224, "quotedblright"),
(0221, "quoteleft"),
(0222, "quoteright"),
(0202, "quotesinglbase"),
(047, "quotesingle"),
(0162, "r"),
(0256, "registered"),
(0163, "s"),
(0232, "scaron"),
(0247, "section"),
(073, "semicolon"),
(067, "seven"),
(066, "six"),
(057, "slash"),
(040, "space"),
(0243, "sterling"),
(0164, "t"),
(0376, "thorn"),
(063, "three"),
(0276, "threequarters"),
(0263, "threesuperior"),
(0230, "tilde"),
(0231, "trademark"),
(062, "two"),
(0262, "twosuperior"),
(0165, "u"),
(0372, "uacute"),
(0373, "ucircumflex"),
(0374, "udieresis"),
(0371, "ugrave"),
(0137, "underscore"),
(0166, "v"),
(0167, "w"),
(0170, "x"),
(0171, "y"),
(0375, "yacute"),
(0377, "ydieresis"),
(0245, "yen"),
(0172, "z"),
(0236, "zcaron"),
(060, "zero"),
// adding some additional mappings as defined in Appendix D of the pdf spec
(0240, "space"),
(0255, "hyphen")
};
public static WinAnsiEncoding Instance { get; } = new WinAnsiEncoding();
public override string EncodingName => "WinAnsiEncoding";
private WinAnsiEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
// In WinAnsiEncoding, all unused codes greater than 40 map to the bullet character.
for (var i = 041; i <= 255; i++)
{
if (!CodeToName.ContainsKey(i))
{
Add(i, "bullet");
}
}
}
}
}

View File

@@ -0,0 +1,208 @@
namespace UglyToad.Pdf.Fonts.Encodings
{
internal class ZapfDingbatsEncoding : Encoding
{
private static readonly (int, string)[] EncodingTable = {
(040, "space"),
(041, "a1"),
(042, "a2"),
(043, "a202"),
(044, "a3"),
(045, "a4"),
(046, "a5"),
(047, "a119"),
(050, "a118"),
(051, "a117"),
(052, "a11"),
(053, "a12"),
(054, "a13"),
(055, "a14"),
(056, "a15"),
(057, "a16"),
(060, "a105"),
(061, "a17"),
(062, "a18"),
(063, "a19"),
(064, "a20"),
(065, "a21"),
(066, "a22"),
(067, "a23"),
(070, "a24"),
(071, "a25"),
(072, "a26"),
(073, "a27"),
(074, "a28"),
(075, "a6"),
(076, "a7"),
(077, "a8"),
(0100, "a9"),
(0101, "a10"),
(0102, "a29"),
(0103, "a30"),
(0104, "a31"),
(0105, "a32"),
(0106, "a33"),
(0107, "a34"),
(0110, "a35"),
(0111, "a36"),
(0112, "a37"),
(0113, "a38"),
(0114, "a39"),
(0115, "a40"),
(0116, "a41"),
(0117, "a42"),
(0120, "a43"),
(0121, "a44"),
(0122, "a45"),
(0123, "a46"),
(0124, "a47"),
(0125, "a48"),
(0126, "a49"),
(0127, "a50"),
(0130, "a51"),
(0131, "a52"),
(0132, "a53"),
(0133, "a54"),
(0134, "a55"),
(0135, "a56"),
(0136, "a57"),
(0137, "a58"),
(0140, "a59"),
(0141, "a60"),
(0142, "a61"),
(0143, "a62"),
(0144, "a63"),
(0145, "a64"),
(0146, "a65"),
(0147, "a66"),
(0150, "a67"),
(0151, "a68"),
(0152, "a69"),
(0153, "a70"),
(0154, "a71"),
(0155, "a72"),
(0156, "a73"),
(0157, "a74"),
(0160, "a203"),
(0161, "a75"),
(0162, "a204"),
(0163, "a76"),
(0164, "a77"),
(0165, "a78"),
(0166, "a79"),
(0167, "a81"),
(0170, "a82"),
(0171, "a83"),
(0172, "a84"),
(0173, "a97"),
(0174, "a98"),
(0175, "a99"),
(0176, "a100"),
(0241, "a101"),
(0242, "a102"),
(0243, "a103"),
(0244, "a104"),
(0245, "a106"),
(0246, "a107"),
(0247, "a108"),
(0250, "a112"),
(0251, "a111"),
(0252, "a110"),
(0253, "a109"),
(0254, "a120"),
(0255, "a121"),
(0256, "a122"),
(0257, "a123"),
(0260, "a124"),
(0261, "a125"),
(0262, "a126"),
(0263, "a127"),
(0264, "a128"),
(0265, "a129"),
(0266, "a130"),
(0267, "a131"),
(0270, "a132"),
(0271, "a133"),
(0272, "a134"),
(0273, "a135"),
(0274, "a136"),
(0275, "a137"),
(0276, "a138"),
(0277, "a139"),
(0300, "a140"),
(0301, "a141"),
(0302, "a142"),
(0303, "a143"),
(0304, "a144"),
(0305, "a145"),
(0306, "a146"),
(0307, "a147"),
(0310, "a148"),
(0311, "a149"),
(0312, "a150"),
(0313, "a151"),
(0314, "a152"),
(0315, "a153"),
(0316, "a154"),
(0317, "a155"),
(0320, "a156"),
(0321, "a157"),
(0322, "a158"),
(0323, "a159"),
(0324, "a160"),
(0325, "a161"),
(0326, "a163"),
(0327, "a164"),
(0330, "a196"),
(0331, "a165"),
(0332, "a192"),
(0333, "a166"),
(0334, "a167"),
(0335, "a168"),
(0336, "a169"),
(0337, "a170"),
(0340, "a171"),
(0341, "a172"),
(0342, "a173"),
(0343, "a162"),
(0344, "a174"),
(0345, "a175"),
(0346, "a176"),
(0347, "a177"),
(0350, "a178"),
(0351, "a179"),
(0352, "a193"),
(0353, "a180"),
(0354, "a199"),
(0355, "a181"),
(0356, "a200"),
(0357, "a182"),
(0361, "a201"),
(0362, "a183"),
(0363, "a184"),
(0364, "a197"),
(0365, "a185"),
(0366, "a194"),
(0367, "a198"),
(0370, "a186"),
(0371, "a195"),
(0372, "a187"),
(0373, "a188"),
(0374, "a189"),
(0375, "a190"),
(0376, "a191")
};
public static ZapfDingbatsEncoding Instance { get; } = new ZapfDingbatsEncoding();
public override string EncodingName => "ZapfDingbatsEncoding";
private ZapfDingbatsEncoding()
{
foreach (var valueTuple in EncodingTable)
{
Add(valueTuple.Item1, valueTuple.Item2);
}
}
}
}