MsdfAtlasGen 1.1.0

dotnet add package MsdfAtlasGen --version 1.1.0
                    
NuGet\Install-Package MsdfAtlasGen -Version 1.1.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="MsdfAtlasGen" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MsdfAtlasGen" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MsdfAtlasGen" />
                    
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 MsdfAtlasGen --version 1.1.0
                    
#r "nuget: MsdfAtlasGen, 1.1.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 MsdfAtlasGen@1.1.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=MsdfAtlasGen&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MsdfAtlasGen&version=1.1.0
                    
Install as a Cake Tool

MsdfAtlasGen

In-process MSDF/MTSDF font-atlas generation for .NET, powered by msdf-atlas-gen and msdfgen.

The upstream C++ libraries are compiled from source into a small native library (msdf_atlas_c) with a stable C API, and wrapped by an AOT- and trim-compatible managed API. You get the atlas pixels, glyph layout, font metrics and kerning as .NET objects, with no process to spawn and no temporary files.

For the standalone msdf-atlas-gen command-line executable, use the sibling package MsdfAtlasGen.Native.

Install

<PackageReference Include="MsdfAtlasGen" Version="X.Y.Z" />

Use

using MsdfAtlasGen;

var atlas = MsdfAtlas.Generate(File.ReadAllBytes("MyFont.ttf"), new AtlasOptions
{
    ImageType = ImageType.Mtsdf,
    Glyphs = GlyphSelection.Ascii,
    EmSize = 48,
    DistanceRange = DistanceRange.Pixels(6),
    YOrigin = YOrigin.Top,
});

ReadOnlyMemory<byte> rgba = atlas.Pixels;          // atlas.Width × atlas.Height × atlas.Channels
foreach (var glyph in atlas.Glyphs)
{
    // glyph.Codepoint, glyph.Advance, glyph.PlaneBounds (ems), glyph.AtlasBounds (pixels)
}

File.WriteAllBytes("atlas.png", atlas.EncodePng());
atlas.ExportJson("atlas.json");                     // same layout as msdf-atlas-gen -json

MsdfAtlas.Generate is safe to call concurrently. It throws MsdfAtlasException with a Status when generation fails, for example PackDidNotFit when fixed atlas dimensions are too small.

Differences from the msdf-atlas-gen CLI

  • The default image type is Mtsdf (CLI: msdf).
  • The default glyph size is a fixed 32 pixels per em (CLI: a minimum of 32 that the packer may grow). Set EmSize = 0 and MinEmSize to get the CLI behaviour.
  • Glyphs are selected with GlyphSelection (ASCII, codepoints, a string, glyph indices, or all glyphs) rather than charset files.
  • Kerning is loaded whenever Kerning is true; the CLI only loads it when a JSON output is requested.
  • Only tight packing of a single font is supported. Grid packing, font variants, variable-font axes and image formats other than PNG are not exposed.

Packaged runtime identifiers

RID Native asset
win-x64 runtimes/win-x64/native/msdf_atlas_c.dll (static CRT)
linux-x64 runtimes/linux-x64/native/libmsdf_atlas_c.so (glibc 2.35+)
osx-x64 runtimes/osx-x64/native/libmsdf_atlas_c.dylib (macOS 11+)
osx-arm64 runtimes/osx-arm64/native/libmsdf_atlas_c.dylib (macOS 11+)

The .NET host resolves the library from runtimes/<rid>/native/ automatically, for both portable and RID-specific builds and publishes. FreeType, libpng and zlib are linked statically, and the library exports only its C API.

License

MIT. Redistributed native code retains its upstream licenses; see THIRD-PARTY-NOTICES.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.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
1.1.0 203 10/2/2026