Files
PdfPig/src/UglyToad.PdfPig/Graphics/Operations/OperationWriteHelper.cs
Eliot Jones 74774995d6 complete move of truetype, afm and standard14 fonts
the 3 font types mentioned are moved to the new fonts project, any referenced types are moved to the core project. most truetype classes are made public #8.
2020-01-04 22:39:13 +00:00

52 lines
1.5 KiB
C#

namespace UglyToad.PdfPig.Graphics.Operations
{
using System;
using System.IO;
using PdfPig.Core;
internal static class OperationWriteHelper
{
private static readonly byte WhiteSpace = OtherEncodings.StringAsLatin1Bytes(" ")[0];
private static readonly byte NewLine = OtherEncodings.StringAsLatin1Bytes("\n")[0];
public static void WriteText(this Stream stream, string text, bool appendWhitespace = false)
{
var bytes = OtherEncodings.StringAsLatin1Bytes(text);
stream.Write(bytes, 0, bytes.Length);
if (appendWhitespace)
{
stream.WriteWhiteSpace();
}
}
public static void WriteHex(this Stream stream, byte[] bytes)
{
var text = BitConverter.ToString(bytes).Replace("-", string.Empty);
stream.WriteText($"<{text}>");
}
public static void WriteWhiteSpace(this Stream stream)
{
stream.WriteByte(WhiteSpace);
}
public static void WriteNewLine(this Stream stream)
{
stream.WriteByte(NewLine);
}
public static void WriteDecimal(this Stream stream, decimal value)
{
stream.WriteText(value.ToString("G"));
}
public static void WriteNumberText(this Stream stream, decimal number, string text)
{
stream.WriteDecimal(number);
stream.WriteWhiteSpace();
stream.WriteText(text);
stream.WriteNewLine();
}
}
}