mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
* Make AdobeFontMetricsLigature a struct * Make AdobeFontMetricsCharacterSize a struct * Eliminate allocation in CompactFontFormatData * Pass TransformationMatrix by reference * Seal Encoding classes * Make SubTableHeaderEntry a readonly struct * Introduce StringSplitter and eliminate various allocations in GlyphListFactory * Eliminate a few substring allocations * Use char overload on StringBuilder * Eliminate virtual calls on stringIndex * Optimize ReadHelper ReadLong and ReadInt methods * Add additional readonly annotations to PdfRectangle * Optimize NameTokenizer * Eliminate allocation in TrueTypeGlyphTableSubsetter * Use empty arrays * Eliminate allocations in OperationWriteHelper.WriteHex * Use simplified DecryptCbc method on .NET 6+ * Fix windows-1252 encoding not working on net6.0 and 8.0 * Update int buffers to exact unsigned max length and eliminate additional byte allocation * Fix typo * Remove unused constant
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
namespace UglyToad.PdfPig.Fonts.Encodings
|
|
{
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// Similar to the <see cref="T:UglyToad.PdfPig.Fonts.Encodings.MacRomanEncoding" /> with 15 additional entries.
|
|
/// </summary>
|
|
public sealed class MacOsRomanEncoding : MacRomanEncoding
|
|
{
|
|
private static readonly (int, string)[] EncodingTable =
|
|
{
|
|
(0255, "notequal"),
|
|
(0260, "infinity"),
|
|
(0262, "lessequal"),
|
|
(0263, "greaterequal"),
|
|
(0266, "partialdiff"),
|
|
(0267, "summation"),
|
|
(0270, "product"),
|
|
(0271, "pi"),
|
|
(0272, "integral"),
|
|
(0275, "Omega"),
|
|
(0303, "radical"),
|
|
(0305, "approxequal"),
|
|
(0306, "Delta"),
|
|
(0327, "lozenge"),
|
|
(0333, "Euro"),
|
|
(0360, "apple")
|
|
};
|
|
|
|
/// <summary>
|
|
/// The single instance of this encoding.
|
|
/// </summary>
|
|
public new static MacOsRomanEncoding Instance { get; } = new MacOsRomanEncoding();
|
|
|
|
private MacOsRomanEncoding()
|
|
{
|
|
foreach ((var codeToBeConverted, var name) in EncodingTable)
|
|
{
|
|
// In source code an int literal with a leading zero ('0')
|
|
// in other languages ('C' and 'Java') would be interpreted
|
|
// as octal (base 8) and converted but C# does not support and
|
|
// so arrives here as a different value parsed as base10.
|
|
// Convert 'codeToBeConverted' to intended value as if it was an octal literal before using.
|
|
// For example 040 converts to string "40" then convert string to int again but using base 8 (octal) so result is 32 (base 10).
|
|
var code = System.Convert.ToInt32($"{codeToBeConverted}", 8); // alternative is OctalHelpers.FromOctalInt()
|
|
Add(code, name);
|
|
}
|
|
}
|
|
}
|
|
} |