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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lokad.Svg" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lokad.Svg" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Lokad.Svg" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lokad.Svg --version 0.4.0
                    
#r "nuget: Lokad.Svg, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lokad.Svg@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lokad.Svg&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Lokad.Svg&version=0.4.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
0.4.0 69 11/8/2026
0.3.0 123 10/28/2026
0.2.0 104 10/18/2026
0.1.0 125 10/17/2026

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.