mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-20 03:17:57 +08:00

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.
52 lines
1.5 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|