Lokad.Svg
0.4.0
Prefix Reserved
dotnet add package Lokad.Svg --version 0.4.0
NuGet\Install-Package Lokad.Svg -Version 0.4.0
<PackageReference Include="Lokad.Svg" Version="0.4.0" />
<PackageVersion Include="Lokad.Svg" Version="0.4.0" />
<PackageReference Include="Lokad.Svg" />
paket add Lokad.Svg --version 0.4.0
#r "nuget: Lokad.Svg, 0.4.0"
#:package Lokad.Svg@0.4.0
#addin nuget:?package=Lokad.Svg&version=0.4.0
#tool nuget:?package=Lokad.Svg&version=0.4.0
Lokad.Svg
Lokad.Svg converts static SVG to PNG on .NET 10 and .NET 11, on Windows and Linux, without runtime package dependencies. The .NET 11 asset currently targets the RC runtime pinned by the repository. The renderer implements a bounded SVG subset; it does not claim full browser conformance.
using System;
using System.IO;
using System.Threading;
using Lokad.Svg;
ReadOnlyMemory<byte> png = SvgConverter.ConvertToPng(
File.ReadAllBytes("input.svg"),
SvgRenderOptions.Default,
CancellationToken.None);
File.WriteAllBytes("output.png", png.ToArray());
The subset includes affine geometry, local instances, gradients/patterns,
clips/masks, embedded base64 PNGs, static CSS, markers, selected filters and
supplied-font text. Unsupported visible features report SvgException.
Event attributes and character-data script elements are inert during static
conversion; script URLs are not fetched. Animation remains unsupported.
Hover/active/focus CSS states remain inactive, and float has no image-layout effect.
Rendering applies size/structural limits, optional host memory admission and cancellation.
Outputs support owned memory, caller memory and writable streams, synchronously
or asynchronously. Text needs an explicit font catalog and font-program provider.
SvgPreparedDocument.CreateAsync prepares a document for one conversion; the host
supplies font sources or configures the HTTP resolver below.
The opt-in SvgHttpFontPackResolver uses a caller-owned HttpClient and
IMemoryBudget for shared acquisition/cache admission. Prepare through its
document overload and use ConvertToOwnedPng/ConvertToOwnedPngAsync; dispose the
returned SvgPngResult after its readers/writes finish to release the PNG charge.
Cache and operation owners share one root allowance. Keep the operation parent
alive through every result reader, including awaited asynchronous writes:
using var document = await SvgPreparedDocument.CreateAsync(
svg, resolver, renderOptions.WithMemoryBudget(operationBudget), cancellationToken);
using SvgPngResult result = await document.ConvertToOwnedPngAsync(cancellationToken);
await destination.WriteAsync(result.Memory, cancellationToken);
Caller-memory and asynchronous stream conversion avoid transferring an owned PNG; each prepared document permits one conversion. Resolver shutdown waits for its I/O and leaves existing prepared borrowers usable; their font charges remain until they finish. Caller-owned clients, destinations and parent budgets remain borrowed.
This package includes CHANGELOG.md, LICENSE.txt and THIRD_PARTY_NOTICES.txt. The repository contains the detailed support matrix, contributor documentation and test evidence.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- No dependencies.
-
net11.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Targets .NET 10 and .NET 11; adds HTTP font packs, shared memory admission and rendering improvements. Includes breaking limits API changes; see CHANGELOG.md in this package for migration details.