move classes to new projects

to make the project more useful and expose more usable classes we're rearchitecting in the following way. code used to read fonts from external file formats like truetype, adobe font metrics (afm) and adobe type 1 fonts are moving to a new project which doesn't reference most of the pdf logic. the shared logic is moving to a new flat-structured project called core. this is a sort-of onion type architecture, with core being the... core, fonts being the next layer of the onion, pdfpig itself the next. this will then support additional libraries/projects as outer layers of the onion as well as releasing standalone version of the font library as pdfbox does with fontbox.
This commit is contained in:
Eliot Jones
2020-01-04 16:38:18 +00:00
parent cf1b8651d6
commit 7c0ef111ea
348 changed files with 2278 additions and 1335 deletions

View File

@@ -0,0 +1,66 @@
namespace UglyToad.PdfPig.Core
{
using System.IO;
/// <summary>
/// Handles writing specified data types to an output stream in a valid PDF compliant format.
/// </summary>
public static class WritingExtensions
{
/// <summary>
/// Write the <see langword="long"/> to the stream as a <see langword="uint"/>.
/// </summary>
public static void WriteUInt(this Stream stream, long value) => WriteUInt(stream, (uint)value);
/// <summary>
/// Write the <see langword="uint"/> to the stream as a <see langword="uint"/>.
/// </summary>
public static void WriteUInt(this Stream stream, uint value)
{
var buffer = new[]
{
(byte) (value >> 24),
(byte) (value >> 16),
(byte) (value >> 8),
(byte) value
};
stream.Write(buffer, 0, 4);
}
/// <summary>
/// Write the <see langword="int"/> to the stream as a <see langword="ushort"/>.
/// </summary>
public static void WriteUShort(this Stream stream, int value) => WriteUShort(stream, (ushort)value);
/// <summary>
/// Write the <see langword="ushort"/> to the stream as a <see langword="ushort"/>.
/// </summary>
public static void WriteUShort(this Stream stream, ushort value)
{
var buffer = new[]
{
(byte) (value >> 8),
(byte) value
};
stream.Write(buffer, 0, 2);
}
/// <summary>
/// Write the <see langword="ushort"/> to the stream as a <see langword="short"/>.
/// </summary>
public static void WriteShort(this Stream stream, ushort value) => WriteShort(stream, (short)value);
/// <summary>
/// Write the <see langword="short"/> to the stream as a <see langword="short"/>.
/// </summary>
public static void WriteShort(this Stream stream, short value)
{
var buffer = new[]
{
(byte) (value >> 8),
(byte) value
};
stream.Write(buffer, 0, 2);
}
}
}