diff --git a/src/UglyToad.PdfPig.Fonts/Polyfills/StreamExtensions.cs b/src/UglyToad.PdfPig.Fonts/Polyfills/StreamExtensions.cs new file mode 100644 index 00000000..2451eea8 --- /dev/null +++ b/src/UglyToad.PdfPig.Fonts/Polyfills/StreamExtensions.cs @@ -0,0 +1,26 @@ +#if NETFRAMEWORK || NETSTANDARD2_0 + +namespace System.IO; + +using System.Buffers; + +internal static class StreamExtensions +{ + public static void Write(this Stream stream, ReadOnlySpan buffer) + { + var tempBuffer = ArrayPool.Shared.Rent(buffer.Length); + + buffer.CopyTo(tempBuffer); + + try + { + stream.Write(tempBuffer, 0, buffer.Length); + } + finally + { + ArrayPool.Shared.Return(tempBuffer); + } + } +} + +#endif \ No newline at end of file