move compact font format fonts to fonts project

This commit is contained in:
Eliot Jones
2020-01-05 12:08:01 +00:00
parent bbde38f656
commit b29354e3e6
119 changed files with 5409 additions and 423 deletions

View File

@@ -1,10 +1,9 @@
namespace UglyToad.PdfPig.Geometry
namespace UglyToad.PdfPig.Core
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
/// <summary>
/// A path in a PDF document, used by glyphs and page content. Can contain multiple sub-paths.
@@ -157,13 +156,19 @@
return simplifiedPath;
}
internal void MoveTo(double x, double y)
/// <summary>
/// Add a <see cref="Move"/> command to the path.
/// </summary>
public void MoveTo(double x, double y)
{
currentPosition = new PdfPoint(x, y);
commands.Add(new Move(currentPosition.Value));
}
internal void LineTo(double x, double y)
/// <summary>
/// Add a <see cref="Line"/> command to the path.
/// </summary>
public void LineTo(double x, double y)
{
if (currentPosition.HasValue)
{
@@ -179,10 +184,26 @@
MoveTo(x, y);
}
}
/// <summary>
/// Adds 4 <see cref="Line"/>s forming a rectangle to the path.
/// </summary>
public void Rectangle(double x, double y, double width, double height)
{
currentPosition = new PdfPoint(x, y);
LineTo(x + width, y);
LineTo(x + width, y + height);
LineTo(x, y + height);
LineTo(x, y);
IsDrawnAsRectangle = true;
}
internal void QuadraticCurveTo(double x1, double y1, double x2, double y2) { }
internal void BezierCurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
/// <summary>
/// Add a <see cref="BezierCurve"/> to the path.
/// </summary>
public void BezierCurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
{
if (currentPosition.HasValue)
{
@@ -202,7 +223,10 @@
internal void SetWindingRuleMode(int windingRule) { }
internal void ClosePath()
/// <summary>
/// Close the path.
/// </summary>
public void ClosePath()
{
if (currentPosition.HasValue)
{
@@ -274,56 +298,6 @@
return new PdfRectangle(minX, minY, maxX, maxY);
}
internal string ToSvg()
{
var builder = new StringBuilder();
foreach (var pathCommand in commands)
{
pathCommand.WriteSvg(builder);
}
if (builder.Length == 0)
{
return string.Empty;
}
if (builder[builder.Length - 1] == ' ')
{
builder.Remove(builder.Length - 1, 1);
}
return builder.ToString();
}
internal string ToFullSvg()
{
string BboxToRect(PdfRectangle box, string stroke)
{
var overallBbox = $"<rect x='{box.Left}' y='{box.Bottom}' width='{box.Width}' height='{box.Height}' stroke-width='2' fill='none' stroke='{stroke}'></rect>";
return overallBbox;
}
var glyph = ToSvg();
var bbox = GetBoundingRectangle();
var bboxes = new List<PdfRectangle>();
foreach (var command in commands)
{
var segBbox = command.GetBoundingRectangle();
if (segBbox.HasValue)
{
bboxes.Add(segBbox.Value);
}
}
var path = $"<path d='{glyph}' stroke='cyan' stroke-width='3'></path>";
var bboxRect = bbox.HasValue ? BboxToRect(bbox.Value, "yellow") : string.Empty;
var others = string.Join(" ", bboxes.Select(x => BboxToRect(x, "gray")));
var result = $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";
return result;
}
/// <summary>
/// A command in a <see cref="PdfPath"/>.
/// </summary>
@@ -642,7 +616,10 @@
return true;
}
internal static double ValueWithT(double p1, double p2, double p3, double p4, double t)
/// <summary>
/// Calculate the value of the Bezier curve at t.
/// </summary>
public static double ValueWithT(double p1, double p2, double p3, double p4, double t)
{
// P = (1t)^3*P_1 + 3(1t)^2*t*P_2 + 3(1t)*t^2*P_3 + t^3*P_4
var oneMinusT = 1 - t;
@@ -700,16 +677,6 @@
}
}
internal void Rectangle(double x, double y, double width, double height)
{
currentPosition = new PdfPoint(x, y);
LineTo(x + width, y);
LineTo(x + width, y + height);
LineTo(x, y + height);
LineTo(x, y);
IsDrawnAsRectangle = true;
}
/// <summary>
/// Compares two <see cref="PdfPath"/>s for equality. Paths will only be considered equal if the commands which construct the paths are in the same order.
/// </summary>

View File

@@ -7,6 +7,7 @@
using System.Xml.Serialization;
using Alto;
using Content;
using Core;
using DocumentLayoutAnalysis;
using Geometry;
using Util;

View File

@@ -1,12 +1,20 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics
{
using System;
using Fonts.AdobeFontMetrics;
using Encodings;
internal class AdobeFontMetricsEncoding : Encoding
/// <inheritdoc />
/// <summary>
/// An <see cref="T:UglyToad.PdfPig.Fonts.Encodings.Encoding" /> from an Adobe Font Metrics file.
/// </summary>
public class AdobeFontMetricsEncoding : Encoding
{
/// <inheritdoc />
public override string EncodingName { get; } = "AFM";
/// <summary>
/// Create a new <see cref="AdobeFontMetricsEncoding"/>.
/// </summary>
public AdobeFontMetricsEncoding(AdobeFontMetrics metrics)
{
if (metrics == null)

View File

@@ -1,15 +1,13 @@
namespace UglyToad.PdfPig.PdfFonts
namespace UglyToad.PdfPig.Fonts
{
using System;
using System.Collections.Generic;
using Core;
using Util;
using Util.JetBrains.Annotations;
/// <summary>
/// Holds common properties between Type 1 and Compact Font Format private dictionaries.
/// Holds common properties between Adobe Type 1 and Compact Font Format private dictionaries.
/// </summary>
internal abstract class AdobeStylePrivateDictionary
public abstract class AdobeStylePrivateDictionary
{
/// <summary>
/// Default value of <see cref="BlueScale"/>.
@@ -41,14 +39,12 @@
/// The first pair is the baseline overshoot position and the baseline.
/// All following pairs describe top-zones.
/// </summary>
[NotNull]
public IReadOnlyList<int> BlueValues { get; }
/// <summary>
/// Optional: Pairs of integers similar to <see cref="BlueValues"/>.
/// These only describe bottom zones.
/// </summary>
[NotNull]
public IReadOnlyList<int> OtherBlues { get; }
/// <summary>
@@ -56,7 +52,6 @@
/// are used to enforce consistency across a font family when there are small differences (&lt;1px) in
/// font alignment.
/// </summary>
[NotNull]
public IReadOnlyList<int> FamilyBlues { get; }
/// <summary>
@@ -64,7 +59,6 @@
/// are used to enforce consistency across a font family with small differences
/// in alignment similarly to <see cref="FamilyBlues"/>.
/// </summary>
[NotNull]
public IReadOnlyList<int> FamilyOtherBlues { get; }
/// <summary>
@@ -113,13 +107,11 @@
/// <summary>
/// Optional: Up to 12 numbers with the most common widths for horizontal stems vertically in character space units.
/// </summary>
[NotNull]
public IReadOnlyList<decimal> StemSnapHorizontalWidths { get; }
/// <summary>
/// Optional: Up to 12 numbers with the most common widths for vertical stems horizontally in character space units.
/// </summary>
[NotNull]
public IReadOnlyList<decimal> StemSnapVerticalWidths { get; }
/// <summary>
@@ -145,7 +137,7 @@
/// Creates a new <see cref="AdobeStylePrivateDictionary"/>.
/// </summary>
/// <param name="builder">The builder used to gather property values.</param>
protected AdobeStylePrivateDictionary([NotNull] BaseBuilder builder)
protected AdobeStylePrivateDictionary(BaseBuilder builder)
{
if (builder == null)
{

View File

@@ -0,0 +1,89 @@
namespace UglyToad.PdfPig.Fonts
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
/// <summary>
/// The stack of numeric operands currently active in a CharString.
/// </summary>
internal class CharStringStack
{
private readonly List<double> stack = new List<double>();
/// <summary>
/// The current size of the stack.
/// </summary>
public int Length => stack.Count;
/// <summary>
/// Whether it's possible to pop a value from either end of the stack.
/// </summary>
public bool CanPop => stack.Count > 0;
/// <summary>
/// Remove and return the value from the top of the stack.
/// </summary>
/// <returns>The value from the top of the stack.</returns>
public double PopTop()
{
if (stack.Count == 0)
{
throw new InvalidOperationException("Cannot pop from the top of an empty stack, invalid charstring parsed.");
}
var result = stack[stack.Count - 1];
stack.RemoveAt(stack.Count - 1);
return result;
}
/// <summary>
/// Remove and return the value from the bottom of the stack.
/// </summary>
/// <returns>The value from the bottom of the stack.</returns>
public double PopBottom()
{
if (stack.Count == 0)
{
throw new InvalidOperationException("Cannot pop from the bottom of an empty stack, invalid charstring parsed.");
}
var result = stack[0];
stack.RemoveAt(0);
return result;
}
/// <summary>
/// Adds the value to the top of the stack.
/// </summary>
/// <param name="value">The value to add.</param>
public void Push(double value)
{
stack.Add(value);
}
public double CopyElementAt(int index)
{
if (index < 0)
{
return stack[stack.Count - 1];
}
return stack[index];
}
/// <summary>
/// Removes all values from the stack.
/// </summary>
public void Clear()
{
stack.Clear();
}
public override string ToString()
{
return string.Join(" ", stack.Select(x => x.ToString(CultureInfo.InvariantCulture)));
}
}
}

View File

@@ -1,21 +1,18 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.CharStrings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.CharStrings
{
using System;
using System.Diagnostics;
using Util.JetBrains.Annotations;
/// <summary>
/// Represents the deferred execution of a Type 2 charstring command.
/// </summary>
internal class LazyType2Command
{
[NotNull]
private readonly Action<Type2BuildCharContext> runCommand;
/// <summary>
/// The name of the command to run. See the Type 2 charstring specification for the possible command names.
/// </summary>
[NotNull]
public string Name { get; }
/// <summary>
@@ -23,7 +20,7 @@
/// </summary>
/// <param name="name">The name of the command.</param>
/// <param name="runCommand">The action to execute when evaluating the command. This modifies the <see cref="Type2BuildCharContext"/>.</param>
public LazyType2Command([NotNull] string name, [NotNull] Action<Type2BuildCharContext> runCommand)
public LazyType2Command(string name, Action<Type2BuildCharContext> runCommand)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
this.runCommand = runCommand ?? throw new ArgumentNullException(nameof(runCommand));
@@ -34,7 +31,7 @@
/// </summary>
/// <param name="context">The current <see cref="Type2BuildCharContext"/>.</param>
[DebuggerStepThrough]
public void Run([NotNull] Type2BuildCharContext context)
public void Run(Type2BuildCharContext context)
{
if (context == null)
{

View File

@@ -1,8 +1,7 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.CharStrings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.CharStrings
{
using System.Collections.Generic;
using Core;
using Geometry;
/// <summary>
/// The context used and updated when interpreting the commands for a charstring.

View File

@@ -1,12 +1,11 @@
// ReSharper disable CompareOfFloatsByEqualityOperator
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.CharStrings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.CharStrings
{
using System;
using System.Collections.Generic;
using System.Linq;
using Charsets;
using Core;
using Util.JetBrains.Annotations;
/// <summary>
/// Decodes the commands and numbers making up a Type 2 CharString. A Type 2 CharString extends on the Type 1 CharString format.
@@ -700,7 +699,7 @@ namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.CharStrings
return SingleByteCommandStore[identifier.CommandId];
}
public static Type2CharStrings Parse([NotNull] IReadOnlyList<IReadOnlyList<byte>> charStringBytes,
public static Type2CharStrings Parse(IReadOnlyList<IReadOnlyList<byte>> charStringBytes,
CompactFontFormatSubroutinesSelector subroutinesSelector, ICompactFontFormatCharset charset)
{
if (charStringBytes == null)

View File

@@ -1,10 +1,9 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.CharStrings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.CharStrings
{
using System;
using System.Collections.Generic;
using System.Text;
using Geometry;
using Util.JetBrains.Annotations;
using Core;
/// <summary>
/// Stores the decoded command sequences for Type 2 CharStrings from a Compact Font Format font as well
@@ -221,7 +220,6 @@
/// <summary>
/// The path of the glyph.
/// </summary>
[NotNull]
public PdfPath Path { get; }
/// <summary>

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Charsets
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{
internal interface ICompactFontFormatCharset
{

View File

@@ -1,7 +1,7 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;
using CompactFontFormat;
using Encodings;
internal abstract class CompactFontFormatBaseEncoding : Encoding
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;
@@ -9,20 +9,32 @@
/// <summary>
/// Provides access to the raw bytes of this Compact Font Format file with utility methods for reading data types from it.
/// </summary>
internal class CompactFontFormatData
public class CompactFontFormatData
{
private readonly IReadOnlyList<byte> dataBytes;
/// <summary>
/// The current position in the data.
/// </summary>
public int Position { get; private set; } = -1;
/// <summary>
/// The length of the data.
/// </summary>
public int Length => dataBytes.Count;
/// <summary>
/// Create a new <see cref="CompactFontFormatData"/>.
/// </summary>
[DebuggerStepThrough]
public CompactFontFormatData(IReadOnlyList<byte> dataBytes)
{
this.dataBytes = dataBytes;
}
/// <summary>
/// Read a string of the specified length.
/// </summary>
public string ReadString(int length, Encoding encoding)
{
var bytes = new byte[length];
@@ -35,21 +47,33 @@
return encoding.GetString(bytes);
}
/// <summary>
/// Read Card8 format.
/// </summary>
public byte ReadCard8()
{
return ReadByte();
}
/// <summary>
/// Read Card16 format.
/// </summary>
public ushort ReadCard16()
{
return (ushort)(ReadByte() << 8 | ReadByte());
}
/// <summary>
/// Read Offsize.
/// </summary>
public byte ReadOffsize()
{
return ReadByte();
}
/// <summary>
/// Read Offset.
/// </summary>
public int ReadOffset(int offsetSize)
{
var value = 0;
@@ -62,6 +86,9 @@
return value;
}
/// <summary>
/// Read byte.
/// </summary>
public byte ReadByte()
{
Position++;
@@ -74,31 +101,49 @@
return dataBytes[Position];
}
/// <summary>
/// Peek the next byte without advancing the data.
/// </summary>
public byte Peek()
{
return dataBytes[Position + 1];
}
/// <summary>
/// Whether there's more data to read in the input.
/// </summary>
public bool CanRead()
{
return Position < dataBytes.Count - 1;
}
/// <summary>
/// Move to the given offset from the beginning.
/// </summary>
public void Seek(int offset)
{
Position = offset - 1;
}
/// <summary>
/// Read long.
/// </summary>
public long ReadLong()
{
return (ReadCard16() << 16) | ReadCard16();
}
/// <summary>
/// Read sid.
/// </summary>
public int ReadSid()
{
return ReadByte() << 8 | ReadByte();
}
/// <summary>
/// Read byte array of given length.
/// </summary>
public byte[] ReadBytes(int length)
{
var result = new byte[length];
@@ -111,6 +156,9 @@
return result;
}
/// <summary>
/// Create a new <see cref="CompactFontFormatData"/> from this data with a snapshot at the position and length.
/// </summary>
public CompactFontFormatData SnapshotPortion(int startLocation, int length)
{
if (length == 0)

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;
@@ -9,15 +9,27 @@
using Encodings;
using Type1.CharStrings;
internal class CompactFontFormatFont
/// <summary>
/// A Compact Font Format (CFF) font.
/// </summary>
public class CompactFontFormatFont
{
public CompactFontFormatTopLevelDictionary TopDictionary { get; }
public CompactFontFormatPrivateDictionary PrivateDictionary { get; }
public ICompactFontFormatCharset Charset { get; }
public Union<Type1CharStrings, Type2CharStrings> CharStrings { get; }
internal CompactFontFormatTopLevelDictionary TopDictionary { get; }
internal CompactFontFormatPrivateDictionary PrivateDictionary { get; }
internal ICompactFontFormatCharset Charset { get; }
internal Union<Type1CharStrings, Type2CharStrings> CharStrings { get; }
/// <summary>
/// The encoding for this font.
/// </summary>
public Encoding Encoding { get; }
public CompactFontFormatFont(CompactFontFormatTopLevelDictionary topDictionary, CompactFontFormatPrivateDictionary privateDictionary,
/// <summary>
/// The font matrix for this font.
/// </summary>
public TransformationMatrix FontMatrix => TopDictionary.FontMatrix;
internal CompactFontFormatFont(CompactFontFormatTopLevelDictionary topDictionary, CompactFontFormatPrivateDictionary privateDictionary,
ICompactFontFormatCharset charset,
Union<Type1CharStrings, Type2CharStrings> charStrings, Encoding fontEncoding)
{
@@ -28,6 +40,9 @@
Encoding = fontEncoding;
}
/// <summary>
/// Get the bounding box for the character with the given name.
/// </summary>
public PdfRectangle? GetCharacterBoundingBox(string characterName)
{
var defaultWidthX = GetDefaultWidthX(characterName);
@@ -50,11 +65,17 @@
return result;
}
/// <summary>
/// Get the default width of x for the character.
/// </summary>
protected virtual decimal GetDefaultWidthX(string characterName)
{
return PrivateDictionary.DefaultWidthX;
}
/// <summary>
/// Get the nominal width of x for the character.
/// </summary>
protected virtual decimal GetNominalWidthX(string characterName)
{
return PrivateDictionary.NominalWidthX;

View File

@@ -0,0 +1,56 @@
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;
using System.Linq;
using Core;
/// <summary>
/// A Compact Font Format (CFF) font program as described in The Compact Font Format specification (Adobe Technical Note #5176).
/// A CFF font may contain multiple fonts and achieves compression by sharing details between fonts in the set.
/// </summary>
public class CompactFontFormatFontCollection
{
/// <summary>
/// The decoded header table for this font.
/// </summary>
public CompactFontFormatHeader Header { get; }
/// <summary>
/// The individual fonts contained in this font keyed by name.
/// </summary>
public IReadOnlyDictionary<string, CompactFontFormatFont> Fonts { get; }
/// <summary>
/// Create a new <see cref="CompactFontFormatFontCollection"/>.
/// </summary>
/// <param name="header">The header table for the font.</param>
/// <param name="fontSet">The fonts in this font program.</param>
public CompactFontFormatFontCollection(CompactFontFormatHeader header, IReadOnlyDictionary<string, CompactFontFormatFont> fontSet)
{
Header = header;
Fonts = fontSet ?? throw new ArgumentNullException(nameof(fontSet));
}
/// <summary>
/// Get the first font matrix in the font collection.
/// </summary>
public TransformationMatrix GetFirstTransformationMatrix()
{
foreach (var font in Fonts)
{
return font.Value.FontMatrix;
}
return TransformationMatrix.Identity;
}
/// <summary>
/// Get the bounding box for a character if the font contains a corresponding glyph.
/// </summary>
public PdfRectangle? GetCharacterBoundingBox(string characterName)
{
return Fonts.First().Value.GetCharacterBoundingBox(characterName);
}
}
}

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,9 +1,9 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
/// <summary>
/// The header table for the binary data of a Compact Font Format file.
/// </summary>
internal struct CompactFontFormatHeader
public struct CompactFontFormatHeader
{
/// <summary>
/// The major version of this font format. Starting at 1.
@@ -41,6 +41,7 @@
OffsetSize = offsetSize;
}
/// <inheritdoc />
public override string ToString()
{
return $"Major: {MajorVersion}, Minor: {MinorVersion}, Header Size: {SizeInBytes}, Offset: {OffsetSize}";

View File

@@ -1,13 +1,11 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections;
using System.Collections.Generic;
using Core;
using Util.JetBrains.Annotations;
internal class CompactFontFormatIndex : IReadOnlyList<IReadOnlyList<byte>>
{
[CanBeNull]
private readonly IReadOnlyList<IReadOnlyList<byte>> bytes;
public int Count => bytes.Count;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;

View File

@@ -1,23 +1,26 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System;
using System.Collections.Generic;
using Core;
using Dictionaries;
internal class CompactFontFormatParser
/// <summary>
/// Parse the Compact Font Format (CFF).
/// </summary>
public static class CompactFontFormatParser
{
private const string TagOtto = "OTTO";
private const string TagTtcf = "ttcf";
private const string TagTtfonly = "\u0000\u0001\u0000\u0000";
private readonly CompactFontFormatIndividualFontParser individualFontParser;
public CompactFontFormatParser(CompactFontFormatIndividualFontParser individualFontParser)
{
this.individualFontParser = individualFontParser;
}
public CompactFontFormatFontProgram Parse(CompactFontFormatData data)
private static readonly CompactFontFormatIndividualFontParser IndividualFontParser = new CompactFontFormatIndividualFontParser(
new CompactFontFormatTopLevelDictionaryReader(), new CompactFontFormatPrivateDictionaryReader());
/// <summary>
/// Read the Compact Font Format font from the input data.
/// </summary>
public static CompactFontFormatFontCollection Parse(CompactFontFormatData data)
{
var tag = ReadTag(data);
@@ -51,10 +54,10 @@
{
var fontName = fontNames[i];
fonts[fontName] = individualFontParser.Parse(data, fontName, topLevelDictionaryIndex[i], stringIndex, globalSubroutineIndex);
fonts[fontName] = IndividualFontParser.Parse(data, fontName, topLevelDictionaryIndex[i], stringIndex, globalSubroutineIndex);
}
return new CompactFontFormatFontProgram(header, fonts);
return new CompactFontFormatFontCollection(header, fonts);
}
private static string ReadTag(CompactFontFormatData data)

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
internal static class CompactFontFormatStandardStrings
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat
namespace UglyToad.PdfPig.Fonts.CompactFontFormat
{
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Dictionaries
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Dictionaries
{
using System;
using System.Collections.Generic;

View File

@@ -1,5 +1,7 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Dictionaries
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Dictionaries
{
using Fonts;
internal class CompactFontFormatPrivateDictionary : AdobeStylePrivateDictionary
{
/// <summary>

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Dictionaries
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Dictionaries
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Dictionaries
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Dictionaries
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.CompactFontFormat.Dictionaries
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Dictionaries
{
using System;
using System.Collections.Generic;

View File

@@ -1,11 +1,19 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using System.Collections.Generic;
internal class BuiltInEncoding : Encoding
/// <inheritdoc />
/// <summary>
/// An encoding built in to a TrueType font.
/// </summary>
public class BuiltInEncoding : Encoding
{
/// <inheritdoc />
public override string EncodingName => "built-in (TTF)";
/// <summary>
/// Create a new <see cref="BuiltInEncoding"/>.
/// </summary>
public BuiltInEncoding(IReadOnlyDictionary<int, string> codeToName)
{
foreach (var keyValuePair in codeToName)

View File

@@ -1,16 +1,21 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using System;
using System.Collections.Generic;
using System.Linq;
/// <inheritdoc />
/// <summary>
/// Created by combining a base encoding with the differences.
/// </summary>
internal class DifferenceBasedEncoding : Encoding
public class DifferenceBasedEncoding : Encoding
{
/// <inheritdoc />
public override string EncodingName { get; } = "Difference Encoding";
/// <summary>
/// Create a new <see cref="DifferenceBasedEncoding"/>.
/// </summary>
public DifferenceBasedEncoding(Encoding baseEncoding, IReadOnlyList<(int, string)> differences)
{
if (baseEncoding == null)

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using System.Collections.Generic;
using Tokens;
@@ -6,28 +6,52 @@
/// <summary>
/// Maps character codes to glyph names from a PostScript encoding.
/// </summary>
internal abstract class Encoding
public abstract class Encoding
{
/// <summary>
/// Mutable code to name map.
/// </summary>
protected readonly Dictionary<int, string> CodeToName = new Dictionary<int, string>(250);
/// <summary>
/// Maps from character codes to names.
/// </summary>
public IReadOnlyDictionary<int, string> CodeToNameMap => CodeToName;
/// <summary>
/// Mutable name to code map.
/// </summary>
protected readonly Dictionary<string, int> NameToCode = new Dictionary<string, int>(250);
/// <summary>
/// Maps from names to character cocdes.
/// </summary>
public IReadOnlyDictionary<string, int> NameToCodeMap => NameToCode;
/// <summary>
/// The name of this encoding.
/// </summary>
public abstract string EncodingName { get; }
/// <summary>
/// Whether this encoding contains a code for the name.
/// </summary>
public bool ContainsName(string name)
{
return NameToCode.ContainsKey(name);
}
/// <summary>
/// Whether this encoding contains a name for the code.
/// </summary>
public bool ContainsCode(int code)
{
return CodeToName.ContainsKey(code);
}
/// <summary>
/// Get the character name corresponding to the given code.
/// </summary>
public virtual string GetName(int code)
{
if (!CodeToName.TryGetValue(code, out var name))
@@ -38,6 +62,9 @@
return name;
}
/// <summary>
/// Add a character code and name pair.
/// </summary>
protected void Add(int code, string name)
{
CodeToName[code] = name;
@@ -48,6 +75,9 @@
}
}
/// <summary>
/// Get a known encoding instance with the given name.
/// </summary>
public static bool TryGetNamedEncoding(NameToken name, out Encoding encoding)
{
encoding = null;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using Core;

View File

@@ -1,11 +1,12 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using Core;
/// <inheritdoc />
/// <summary>
/// Similar to the <see cref="MacRomanEncoding"/> with 15 additional entries.
/// Similar to the <see cref="T:UglyToad.PdfPig.Fonts.Encodings.MacRomanEncoding" /> with 15 additional entries.
/// </summary>
internal class MacOsRomanEncoding : MacRomanEncoding
public class MacOsRomanEncoding : MacRomanEncoding
{
private static readonly (int, string)[] EncodingTable =
{
@@ -27,6 +28,9 @@
(360, "apple")
};
/// <summary>
/// The single instance of this encoding.
/// </summary>
public new static MacOsRomanEncoding Instance { get; } = new MacOsRomanEncoding();
private MacOsRomanEncoding()

View File

@@ -1,8 +1,11 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using Core;
internal class MacRomanEncoding : Encoding
/// <summary>
/// The Mac Roman encoding.
/// </summary>
public class MacRomanEncoding : Encoding
{
/// <summary>
/// Table of octal character codes and their corresponding names.
@@ -220,10 +223,17 @@
(0312, "space")
};
/// <summary>
/// The single instance of this encoding.
/// </summary>
public static MacRomanEncoding Instance { get; } = new MacRomanEncoding();
/// <inheritdoc />
public override string EncodingName => "MacRomanEncoding";
/// <summary>
/// Create a new <see cref="MacRomanEncoding"/>
/// </summary>
protected MacRomanEncoding()
{
foreach (var valueTuple in EncodingTable)

View File

@@ -1,8 +1,11 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using Core;
internal class StandardEncoding : Encoding
/// <summary>
/// The standard PDF encoding.
/// </summary>
public class StandardEncoding : Encoding
{
private static readonly (int, string)[] EncodingTable =
{
@@ -157,8 +160,12 @@
(0060, "zero")
};
/// <summary>
/// The single instance of the standard encoding.
/// </summary>
public static StandardEncoding Instance { get; } = new StandardEncoding();
/// <inheritdoc />
public override string EncodingName => "StandardEncoding";
private StandardEncoding()

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
internal class SymbolEncoding : Encoding
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts.Encodings
{
internal class ZapfDingbatsEncoding : Encoding
{

View File

@@ -1,12 +1,15 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Fonts;
using Encodings;
internal class GlyphList
/// <summary>
/// A list which maps PostScript glyph names to unicode values.
/// </summary>
public class GlyphList
{
private const string NotDefined = ".notdef";
@@ -16,15 +19,27 @@
private readonly Dictionary<string, string> oddNameToUnicodeCache = new Dictionary<string, string>();
private static readonly Lazy<GlyphList> LazyAdobeGlyphList = new Lazy<GlyphList>(() => GlyphListFactory.Get("glyphlist"));
/// <summary>
/// The Adobe Glyph List.
/// </summary>
public static GlyphList AdobeGlyphList => LazyAdobeGlyphList.Value;
private static readonly Lazy<GlyphList> LazyAdditionalGlyphList = new Lazy<GlyphList>(() => GlyphListFactory.Get("additional"));
/// <summary>
/// An extension to the Adobe Glyph List.
/// </summary>
public static GlyphList AdditionalGlyphList => LazyAdditionalGlyphList.Value;
private static readonly Lazy<GlyphList> LazyZapfDingbatsGlyphList = new Lazy<GlyphList>(() => GlyphListFactory.Get("zapfdingbats"));
/// <summary>
/// Zapf Dingbats.
/// </summary>
public static GlyphList ZapfDingbats => LazyZapfDingbatsGlyphList.Value;
public GlyphList(IReadOnlyDictionary<string, string> namesToUnicode)
internal GlyphList(IReadOnlyDictionary<string, string> namesToUnicode)
{
nameToUnicode = namesToUnicode;
@@ -48,6 +63,9 @@
unicodeToName = unicodeToNameTemp;
}
/// <summary>
/// Get the name for the unicode code point value.
/// </summary>
public string UnicodeCodePointToName(int unicodeValue)
{
var value = char.ConvertFromUtf32(unicodeValue);
@@ -60,6 +78,9 @@
return NotDefined;
}
/// <summary>
/// Get the unicode value for the glyph name.
/// </summary>
public string NameToUnicode(string name)
{
if (name == null)

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Encodings
namespace UglyToad.PdfPig.Fonts
{
using System;
using System.Collections.Generic;
@@ -11,7 +11,7 @@
{
using (var resource =
typeof(GlyphListFactory).Assembly.GetManifestResourceStream(
$"UglyToad.PdfPig.Resources.GlyphList.{listName}"))
$"UglyToad.PdfPig.Fonts.Resources.GlyphList.{listName}"))
{
if (resource == null)
{

View File

@@ -0,0 +1,147 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Format: Semicolon-delimited fields:
# (1) glyph name
# (2) Unicode scalar value
#
# These mappings are missing in glyphlist.txt
#
angbracketleft;3008
angbracketright;3009
circlecopyrt;00A9
controlNULL;0000
#
# TeX-related mappings using named values
#
angbracketleftbig;2329
angbracketleftBig;2329
angbracketleftbigg;2329
angbracketleftBigg;2329
angbracketrightBig;232A
angbracketrightbig;232A
angbracketrightBigg;232A
angbracketrightbigg;232A
arrowhookleft;21AA
arrowhookright;21A9
arrowlefttophalf;21BC
arrowleftbothalf;21BD
arrownortheast;2197
arrownorthwest;2196
arrowrighttophalf;21C0
arrowrightbothalf;21C1
arrowsoutheast;2198
arrowsouthwest;2199
backslashbig;2216
backslashBig;2216
backslashBigg;2216
backslashbigg;2216
bardbl;2016
bracehtipdownleft;FE37
bracehtipdownright;FE37
bracehtipupleft;FE38
bracehtipupright;FE38
braceleftBig;007B
braceleftbig;007B
braceleftbigg;007B
braceleftBigg;007B
bracerightBig;007D
bracerightbig;007D
bracerightbigg;007D
bracerightBigg;007D
bracketleftbig;005B
bracketleftBig;005B
bracketleftbigg;005B
bracketleftBigg;005B
bracketrightBig;005D
bracketrightbig;005D
bracketrightbigg;005D
bracketrightBigg;005D
ceilingleftbig;2308
ceilingleftBig;2308
ceilingleftBigg;2308
ceilingleftbigg;2308
ceilingrightbig;2309
ceilingrightBig;2309
ceilingrightbigg;2309
ceilingrightBigg;2309
circledotdisplay;2299
circledottext;2299
circlemultiplydisplay;2297
circlemultiplytext;2297
circleplusdisplay;2295
circleplustext;2295
contintegraldisplay;222E
contintegraltext;222E
coproductdisplay;2210
coproducttext;2210
floorleftBig;230A
floorleftbig;230A
floorleftbigg;230A
floorleftBigg;230A
floorrightbig;230B
floorrightBig;230B
floorrightBigg;230B
floorrightbigg;230B
hatwide;0302
hatwider;0302
hatwidest;0302
intercal;1D40
integraldisplay;222B
integraltext;222B
intersectiondisplay;22C2
intersectiontext;22C2
logicalanddisplay;2227
logicalandtext;2227
logicalordisplay;2228
logicalortext;2228
nonmarkingreturn;000D
parenleftBig;0028
parenleftbig;0028
parenleftBigg;0028
parenleftbigg;0028
parenrightBig;0029
parenrightbig;0029
parenrightBigg;0029
parenrightbigg;0029
prime;2032
productdisplay;220F
producttext;220F
radicalbig;221A
radicalBig;221A
radicalBigg;221A
radicalbigg;221A
radicalbt;221A
radicaltp;221A
radicalvertex;221A
slashbig;002F
slashBig;002F
slashBigg;002F
slashbigg;002F
summationdisplay;2211
summationtext;2211
tildewide;02DC
tildewider;02DC
tildewidest;02DC
uniondisplay;22C3
unionmultidisplay;228E
unionmultitext;228E
unionsqdisplay;2294
unionsqtext;2294
uniontext;22C3
vextenddouble;2225
vextendsingle;2223
#END

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,248 @@
# -----------------------------------------------------------
# Copyright 2002, 2010 Adobe Systems Incorporated.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of Adobe Systems Incorporated nor the names
# of its contributors may be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------
# Name: ITC Zapf Dingbats Glyph List
# Table version: 2.0
# Date: September 20, 2002
# URL: http://sourceforge.net/adobe/aglfn/
#
# Format: two semicolon-delimited fields:
# (1) glyph name--upper/lowercase letters and digits
# (2) Unicode scalar value--four uppercase hexadecimal digits
#
a100;275E
a101;2761
a102;2762
a103;2763
a104;2764
a105;2710
a106;2765
a107;2766
a108;2767
a109;2660
a10;2721
a110;2665
a111;2666
a112;2663
a117;2709
a118;2708
a119;2707
a11;261B
a120;2460
a121;2461
a122;2462
a123;2463
a124;2464
a125;2465
a126;2466
a127;2467
a128;2468
a129;2469
a12;261E
a130;2776
a131;2777
a132;2778
a133;2779
a134;277A
a135;277B
a136;277C
a137;277D
a138;277E
a139;277F
a13;270C
a140;2780
a141;2781
a142;2782
a143;2783
a144;2784
a145;2785
a146;2786
a147;2787
a148;2788
a149;2789
a14;270D
a150;278A
a151;278B
a152;278C
a153;278D
a154;278E
a155;278F
a156;2790
a157;2791
a158;2792
a159;2793
a15;270E
a160;2794
a161;2192
a162;27A3
a163;2194
a164;2195
a165;2799
a166;279B
a167;279C
a168;279D
a169;279E
a16;270F
a170;279F
a171;27A0
a172;27A1
a173;27A2
a174;27A4
a175;27A5
a176;27A6
a177;27A7
a178;27A8
a179;27A9
a17;2711
a180;27AB
a181;27AD
a182;27AF
a183;27B2
a184;27B3
a185;27B5
a186;27B8
a187;27BA
a188;27BB
a189;27BC
a18;2712
a190;27BD
a191;27BE
a192;279A
a193;27AA
a194;27B6
a195;27B9
a196;2798
a197;27B4
a198;27B7
a199;27AC
a19;2713
a1;2701
a200;27AE
a201;27B1
a202;2703
a203;2750
a204;2752
a205;276E
a206;2770
a20;2714
a21;2715
a22;2716
a23;2717
a24;2718
a25;2719
a26;271A
a27;271B
a28;271C
a29;2722
a2;2702
a30;2723
a31;2724
a32;2725
a33;2726
a34;2727
a35;2605
a36;2729
a37;272A
a38;272B
a39;272C
a3;2704
a40;272D
a41;272E
a42;272F
a43;2730
a44;2731
a45;2732
a46;2733
a47;2734
a48;2735
a49;2736
a4;260E
a50;2737
a51;2738
a52;2739
a53;273A
a54;273B
a55;273C
a56;273D
a57;273E
a58;273F
a59;2740
a5;2706
a60;2741
a61;2742
a62;2743
a63;2744
a64;2745
a65;2746
a66;2747
a67;2748
a68;2749
a69;274A
a6;271D
a70;274B
a71;25CF
a72;274D
a73;25A0
a74;274F
a75;2751
a76;25B2
a77;25BC
a78;25C6
a79;2756
a7;271E
a81;25D7
a82;2758
a83;2759
a84;275A
a85;276F
a86;2771
a87;2772
a88;2773
a89;2768
a8;271F
a90;2769
a91;276C
a92;276D
a93;276A
a94;276B
a95;2774
a96;2775
a97;275B
a98;275C
a99;275D
a9;2720
space;0020
#END

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
/// <summary>
/// Calls a subroutine with index from the subroutines array in the Private dictionary.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
/// <summary>
/// This operator returns the result of dividing num1 by num2. The result is always a real.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
/// <summary>
/// Pops a number from the top of the PostScript interpreter operand stack and pushes that number onto the operand stack.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
/// <summary>
/// Returns from a charstring subroutine and continues execution in the calling charstring.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Arithmetic
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Arithmetic
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Hint
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Hint
{
/// <summary>
/// Brackets an outline section for the dots in letters such as "i", "j" and "!".

View File

@@ -1,5 +1,5 @@
// ReSharper disable UnusedVariable
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Hint
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Hint
{
/// <summary>
/// Declares the vertical ranges of three horizontal stem zones:

View File

@@ -1,5 +1,5 @@
// ReSharper disable UnusedVariable
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Hint
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Hint
{
/// <summary>
/// Declares the vertical range of a horizontal stem zone between the y coordinates y and y+dy,

View File

@@ -1,5 +1,5 @@
// ReSharper disable UnusedVariable
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Hint
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Hint
{
/// <summary>
/// Declares the horizontal ranges of three vertical stem zones.

View File

@@ -1,5 +1,5 @@
// ReSharper disable UnusedVariable
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.Hint
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.Hint
{
/// <summary>
/// Declares the horizontal range of a vertical stem zone between the x coordinates x and x+dx,

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands
{
using System;
using System.Diagnostics;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
/// <summary>
/// Closes a sub-path. This command does not reposition the current point.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.PathConstruction
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.PathConstruction
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.StartFinishOutline
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.StartFinishOutline
{
/// <summary>
/// Finishes a charstring outline definition and must be the last command in a character's outline

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.StartFinishOutline
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.StartFinishOutline
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.StartFinishOutline
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.StartFinishOutline
{
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands.StartFinishOutline
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands.StartFinishOutline
{
using Encodings;

View File

@@ -1,10 +1,8 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings.Commands
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings.Commands
{
using System;
using System.Collections.Generic;
using Core;
using Geometry;
using Util.JetBrains.Annotations;
internal class Type1BuildCharContext
{
@@ -22,7 +20,6 @@
public bool IsFlexing { get; set; }
[NotNull]
public PdfPath Path { get; private set; } = new PdfPath();
public PdfPoint CurrentPosition { get; set; }

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings
{
using System;
using System.Collections.Generic;

View File

@@ -1,11 +1,10 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.CharStrings
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings
{
using System;
using System.Collections.Generic;
using System.Linq;
using Commands;
using Core;
using Geometry;
internal class Type1CharStrings
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.CharStrings
{
using System;
using System.Collections.Generic;

View File

@@ -1,10 +1,10 @@
namespace UglyToad.PdfPig.PdfFonts.Type1
namespace UglyToad.PdfPig.Fonts.Type1
{
/// <summary>
/// Represents the <see cref="Type1PrivateDictionary"/> MinFeature entry which is required for compatibility
/// and must have the value 16, 16.
/// and is required by the specification to have the value 16, 16.
/// </summary>
internal class MinFeature
public class MinFeature
{
/// <summary>
/// The first value.
@@ -32,6 +32,7 @@
Second = second;
}
/// <inheritdoc />
public override string ToString()
{
return $"{{{First} {Second}}}";

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.Fonts.Type1
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System;
using System.Collections.Generic;

View File

@@ -1,28 +1,25 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System;
using System.Collections.Generic;
using Core;
using Encodings;
using Fonts;
using Fonts.Type1;
using Tokenization;
using Type1;
using Tokenization.Scanner;
using Tokens;
internal class Type1FontParser
/// <summary>
/// Parse Adobe Type 1 font format.
/// </summary>
public static class Type1FontParser
{
private const string ClearToMark = "cleartomark";
private const int PfbFileIndicator = 0x80;
private readonly Type1EncryptedPortionParser encryptedPortionParser;
public Type1FontParser(Type1EncryptedPortionParser encryptedPortionParser)
{
this.encryptedPortionParser = encryptedPortionParser;
}
private static readonly Type1EncryptedPortionParser EncryptedPortionParser = new Type1EncryptedPortionParser();
/// <summary>
/// Parses an embedded Adobe Type 1 font file.
/// </summary>
@@ -30,7 +27,7 @@
/// <param name="length1">The length in bytes of the clear text portion of the font program.</param>
/// <param name="length2">The length in bytes of the encrypted portion of the font program.</param>
/// <returns>The parsed type 1 font.</returns>
public Type1FontProgram Parse(IInputBytes inputBytes, int length1, int length2)
public static Type1Font Parse(IInputBytes inputBytes, int length1, int length2)
{
// Sometimes the entire PFB file including the header bytes can be included which prevents parsing in the normal way.
var isEntirePfbFile = inputBytes.Peek() == PfbFileIndicator;
@@ -147,9 +144,9 @@
var matrix = GetFontMatrix(dictionaries);
var boundingBox = GetBoundingBox(dictionaries);
var (privateDictionary, charStrings) = encryptedPortionParser.Parse(eexecPortion, false);
var (privateDictionary, charStrings) = EncryptedPortionParser.Parse(eexecPortion, false);
return new Type1FontProgram(name, encoding, matrix, boundingBox ?? new PdfRectangle(), privateDictionary, charStrings);
return new Type1Font(name, encoding, matrix, boundingBox ?? new PdfRectangle(), privateDictionary, charStrings);
}
/// <summary>

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.Fonts.Type1
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System.Text;
using Core;

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
internal static class Type1Symbols
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System;
using System.Collections.Generic;

View File

@@ -1,11 +1,10 @@
namespace UglyToad.PdfPig.PdfFonts.Type1.Parser
namespace UglyToad.PdfPig.Fonts.Type1.Parser
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Core;
using PdfPig.Parser.Parts;
internal class Type1Tokenizer
{

View File

@@ -1,16 +1,15 @@
namespace UglyToad.PdfPig.PdfFonts.Type1
namespace UglyToad.PdfPig.Fonts.Type1
{
using System;
using System.Collections.Generic;
using CharStrings;
using Core;
using Tokens;
using Util.JetBrains.Annotations;
/// <summary>
/// The information from the Type 1 font file.
/// An Adobe Type 1 font.
/// </summary>
internal class Type1FontProgram
public class Type1Font
{
/// <summary>
/// The name of the font.
@@ -22,8 +21,10 @@
/// </summary>
public IReadOnlyDictionary<int, string> Encoding { get; }
[CanBeNull]
public ArrayToken FontMatrix { get; }
/// <summary>
/// The font matrix.
/// </summary>
public TransformationMatrix FontMatrix { get; }
/// <summary>
/// A rectangle in glyph coordinates specifying the font bounding box.
@@ -31,33 +32,34 @@
/// </summary>
public PdfRectangle BoundingBox { get; }
[NotNull]
/// <summary>
/// The private dictionary for this font.
/// </summary>
public Type1PrivateDictionary PrivateDictionary { get; }
[NotNull]
public Type1CharStrings CharStrings { get; }
/// <summary>
/// The charstrings in this font.
/// </summary>
internal Type1CharStrings CharStrings { get; }
/// <summary>
/// Create a new <see cref="Type1FontProgram"/> from the information retrieved from the PDF document.
/// Create a new <see cref="Type1Font"/>.
/// </summary>
/// <param name="name">The name of the font.</param>
/// <param name="encoding"></param>
/// <param name="fontMatrix"></param>
/// <param name="boundingBox"></param>
/// <param name="privateDictionary"></param>
/// <param name="charStrings"></param>
public Type1FontProgram(string name, IReadOnlyDictionary<int, string> encoding, ArrayToken fontMatrix, PdfRectangle boundingBox,
internal Type1Font(string name, IReadOnlyDictionary<int, string> encoding, ArrayToken fontMatrix, PdfRectangle boundingBox,
Type1PrivateDictionary privateDictionary,
Type1CharStrings charStrings)
{
Name = name;
Encoding = encoding;
FontMatrix = fontMatrix;
FontMatrix = GetFontTransformationMatrix(fontMatrix);
BoundingBox = boundingBox;
PrivateDictionary = privateDictionary ?? throw new ArgumentNullException(nameof(privateDictionary));
CharStrings = charStrings ?? throw new ArgumentNullException(nameof(charStrings));
}
/// <summary>
/// Get the bounding box for the character with the given name.
/// </summary>
public PdfRectangle? GetCharacterBoundingBox(string characterName)
{
if (!CharStrings.TryGenerate(characterName, out var glyph))
@@ -70,24 +72,27 @@
return bbox;
}
/// <summary>
/// Whether the font contains a character with the given name.
/// </summary>
public bool ContainsNamedCharacter(string name)
{
return CharStrings.CharStrings.ContainsKey(name);
}
public TransformationMatrix GetFontTransformationMatrix()
private static TransformationMatrix GetFontTransformationMatrix(ArrayToken array)
{
if (FontMatrix == null || FontMatrix.Data.Count != 6)
if (array == null || array.Data.Count != 6)
{
return TransformationMatrix.FromValues(0.001, 0, 0, 0.001, 0, 0);
}
var a = ((NumericToken) FontMatrix.Data[0]).Double;
var b = ((NumericToken) FontMatrix.Data[1]).Double;
var c = ((NumericToken) FontMatrix.Data[2]).Double;
var d = ((NumericToken) FontMatrix.Data[3]).Double;
var e = ((NumericToken) FontMatrix.Data[4]).Double;
var f = ((NumericToken) FontMatrix.Data[5]).Double;
var a = ((NumericToken)array.Data[0]).Double;
var b = ((NumericToken)array.Data[1]).Double;
var c = ((NumericToken)array.Data[2]).Double;
var d = ((NumericToken)array.Data[3]).Double;
var e = ((NumericToken)array.Data[4]).Double;
var f = ((NumericToken)array.Data[5]).Double;
return TransformationMatrix.FromValues(a, b, c, d, e, f);
}

View File

@@ -1,9 +1,8 @@
namespace UglyToad.PdfPig.PdfFonts.Type1
namespace UglyToad.PdfPig.Fonts.Type1
{
using System;
using System.Collections.Generic;
using Parser;
using Util.JetBrains.Annotations;
using CharStrings;
/// <summary>
/// The Private dictionary for a Type 1 font contains hints that apply across all characters in the font. These hints
@@ -11,9 +10,9 @@
/// These hints help ensure that the shape is as close as possible to the original design even where the character
/// must be represented in few pixels.
/// Note that subroutines are also defined in the private dictionary however for the purposes of this API they are
/// stored on the parent <see cref="Type1FontProgram"/>.
/// stored on the parent <see cref="Type1Font"/>.
/// </summary>
internal class Type1PrivateDictionary : AdobeStylePrivateDictionary
public class Type1PrivateDictionary : AdobeStylePrivateDictionary
{
/// <summary>
/// Optional: Uniquely identifies this font.
@@ -41,7 +40,6 @@
/// Required: Backwards compatibility.
/// Default: {16 16}
/// </summary>
[NotNull]
public MinFeature MinFeature { get; } = new MinFeature(16, 16);
/// <inheritdoc />
@@ -49,7 +47,7 @@
/// Creates a new <see cref="T:UglyToad.PdfPig.Fonts.Type1.Type1PrivateDictionary" />.
/// </summary>
/// <param name="builder">The builder used to gather property values.</param>
public Type1PrivateDictionary([NotNull] Builder builder) : base(builder)
internal Type1PrivateDictionary(Builder builder) : base(builder)
{
if (builder == null)
{
@@ -69,7 +67,7 @@
/// <summary>
/// A mutable builder which can set any property of the private dictionary and performs no validation.
/// </summary>
public class Builder : BaseBuilder
internal class Builder : BaseBuilder
{
/// <summary>
/// Temporary storage for the Rd procedure tokens.
@@ -125,7 +123,6 @@
/// Generate a <see cref="Type1PrivateDictionary"/> from the values in this builder.
/// </summary>
/// <returns>The generated <see cref="Type1PrivateDictionary"/>.</returns>
[NotNull]
public Type1PrivateDictionary Build()
{
return new Type1PrivateDictionary(this);

View File

@@ -13,6 +13,7 @@
<ItemGroup>
<None Remove="Resources\AdobeFontMetrics\*" />
<None Remove="Resources\GlyphList\*" />
</ItemGroup>
<ItemGroup>
@@ -24,6 +25,10 @@
<ItemGroup>
<EmbeddedResource Include="Resources\AdobeFontMetrics\*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\GlyphList\*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UglyToad.PdfPig.Core\UglyToad.PdfPig.Core.csproj" />

View File

@@ -3,21 +3,17 @@
using System;
using System.IO;
using System.Linq;
using PdfFonts.CompactFontFormat;
using PdfFonts.CompactFontFormat.Dictionaries;
using PdfPig.Fonts.CompactFontFormat;
using Xunit;
public class CompactFontFormatParserTests
{
private readonly CompactFontFormatParser parser = new CompactFontFormatParser(
new CompactFontFormatIndividualFontParser(new CompactFontFormatTopLevelDictionaryReader(), new CompactFontFormatPrivateDictionaryReader()));
[Fact]
public void CanReadMinionPro()
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
Assert.Equal(1, font.Header.MajorVersion);
Assert.Equal(1, font.Fonts.Count);
@@ -29,7 +25,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
// Calls a global subroutine
var box = font.GetCharacterBoundingBox("percent");
@@ -42,7 +38,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
// Calls a local subroutine
var box = font.GetCharacterBoundingBox("numbersign");
@@ -55,7 +51,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
// Calls a local subroutine which adds to the hints
var box = font.GetCharacterBoundingBox("perthousand");
@@ -68,7 +64,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
// Calls a global subroutine which adds to the hints
var box = font.GetCharacterBoundingBox("Atildesmall");
@@ -81,7 +77,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var font = parser.Parse(new CompactFontFormatData(fileBytes));
var font = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
// Calls hugely nested subroutines
var box = font.GetCharacterBoundingBox("uniF687");
@@ -94,7 +90,7 @@
{
var fileBytes = GetFileBytes("MinionPro.bin");
var fontSet = parser.Parse(new CompactFontFormatData(fileBytes));
var fontSet = CompactFontFormatParser.Parse(new CompactFontFormatData(fileBytes));
var font = fontSet.Fonts["MinionPro-It"];

View File

@@ -2,7 +2,7 @@
{
using System;
using System.IO;
using PdfFonts.Encodings;
using PdfPig.Fonts;
using Xunit;
public class GlyphListFactoryTests

View File

@@ -1,7 +1,7 @@
namespace UglyToad.PdfPig.Tests.Fonts.Encodings
{
using System.Collections.Generic;
using PdfFonts.Encodings;
using PdfPig.Fonts;
using Xunit;
public class GlyphListTests

View File

@@ -4,20 +4,19 @@
using System.IO;
using System.Linq;
using System.Text;
using PdfFonts.Type1.Parser;
using PdfPig.Core;
using PdfPig.Fonts.Type1.Parser;
using PdfPig.Geometry;
using Xunit;
public class Type1FontParserTests
{
private readonly Type1FontParser parser = new Type1FontParser(new Type1EncryptedPortionParser());
[Fact]
public void CanReadHexEncryptedPortion()
{
var bytes = GetFileBytes("AdobeUtopia.pfa");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
[Fact]
@@ -26,7 +25,7 @@
// TODO: support reading in these pfb files
var bytes = GetFileBytes("Raleway-Black.pfb");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
[Fact]
@@ -34,7 +33,7 @@
{
var bytes = GetFileBytes("CMBX10.pfa");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
[Fact]
@@ -42,7 +41,7 @@
{
var bytes = GetFileBytes("CMCSC10");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
[Fact]
@@ -50,7 +49,7 @@
{
var bytes = GetFileBytes("CMBX12");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
[Fact]
@@ -58,7 +57,7 @@
{
var bytes = GetFileBytes("CMBX10");
var result = parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
var result = Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
var builder = new StringBuilder("<!DOCTYPE html><html><head></head><body>");
foreach (var charString in result.CharStrings.CharStrings)
@@ -77,7 +76,7 @@
{
var bytes = GetFileBytes("CMR10");
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
Type1FontParser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}
private static byte[] GetFileBytes(string name)

Some files were not shown because too many files have changed in this diff Show More