MIR.DirectWriteFontsForAvalonia 12.1.0

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

MIR.Direct2D1ForAvalonia

Independent derivative of the deprecated Avalonia Direct2D1 backend, updated for Avalonia 12.1.0.

This project is not affiliated with or endorsed by AvaloniaUI OÜ.

UseDirect2D1() is separated from text shaping:

  • Rendering backend: Direct2D1
  • Font backend: shared DirectWrite-backed font/typeface provider
  • Text shaping: choose explicitly with UseHarfBuzz() or UseDirectWrite()

Package choice is explicit:

  • DirectWrite shaping: reference MIR.DirectWriteForAvalonia and call UseDirectWrite().
  • HarfBuzz shaping: reference Avalonia.HarfBuzz and call UseHarfBuzz().

MIR.DirectWriteFontsForAvalonia is a narrow shared dependency package. Applications normally get it transitively through MIR.Direct2D1ForAvalonia or MIR.DirectWriteForAvalonia; it supplies the Windows font backend that both shapers consume through Avalonia's IPlatformTypeface APIs.

Example:

using MIR.Direct2D1ForAvalonia;
using MIR.DirectWriteForAvalonia;

AppBuilder.Configure<App>()
    .UseWin32()
    .UseDirect2D1()
    .UseDirectWrite();

To keep Avalonia's HarfBuzz shaping instead, reference Avalonia.HarfBuzz in your app and call UseHarfBuzz():

using MIR.Direct2D1ForAvalonia;

AppBuilder.Configure<App>()
    .UseWin32()
    .UseDirect2D1()
    .UseHarfBuzz();

Known limitations

  • Windows only. Direct2D1/DirectWrite are not available on other platforms.
  • Window surfaces. UseDirect2D1() renders windows when Avalonia supplies an IDirect3D11TexturePlatformSurface, or when the host supplies an external Direct2D render target (IExternalDirect2DRenderTargetSurface). Bare-HWND swap chains and the software framebuffer fallback are not supported and will throw NotSupportedException at render-target creation.
  • RenderTargetBitmap. Created on the GPU (D3D11 texture + D2D device context) when Direct2D is initialised, matching Avalonia.Skia's DIP scaling (useScaledDrawing: true). Save / CopyPixels / Lock perform a staging readback lazily. Falls back to WIC only if no D2D device exists.
  • High DPI. Drawing coordinates for RenderTargetBitmap are device-independent pixels (DIPs), same as Skia: at 192 DPI a logical Rect(0,0,96,64) fills a 192×128 pixel bitmap.
  • Bitmap formats. Bitmap.Save accepts .png, .jpg/.jpeg, .bmp, .tif/.tiff, .gif, and .webp via the file extension. The optional quality parameter is applied to JPEG output through WIC's ImageQuality encoder option.
  • Path segmenting. Geometry.TryGetSegment is supported through a Direct2D length-sampled polyline approximation. It preserves path trimming behavior, but returned curve segments are flattened rather than retaining their original Bezier/arc commands.
  • Text parity. DirectWrite shaping is validated against Avalonia's Skia/HarfBuzz path, but a small set of engine/font-metric divergences is tracked as known rather than bit-for-bit identical.
  • 3D transforms. Only the 2D Transform (Matrix) is honored. There is no per-context 4x4/perspective transform.
  • Thread affinity. The Direct2D device context is thread-affine. The standard single-render-thread Avalonia model is fine; the EnsureCurrent() hook does not currently marshal or assert thread ownership.

Licensing:

  • This repository is distributed under the MIT license. See LICENSE.
  • Avalonia-derived source lineage and notices are documented in THIRD_PARTY_NOTICES.md.

Packaging:

  • Packages target Avalonia 12.1.0; NuGet package versions come from the <Version> values in the package projects.
  • Pack with dotnet pack src/DirectWriteFontsForAvalonia/MIR.DirectWriteFontsForAvalonia.csproj -c Release
  • Pack with dotnet pack src/Direct2D1ForAvalonia/MIR.Direct2D1ForAvalonia.csproj -c Release
  • Pack with dotnet pack src/DirectWriteForAvalonia/MIR.DirectWriteForAvalonia.csproj -c Release
  • Packages embed README.md, LICENSE, and THIRD_PARTY_NOTICES.md.

Validation:

  • Fast local check: pwsh scripts/validate.ps1 builds the solution, runs the TextParity, AotSmoke, and HarfBuzz smoke test projects, and runs the TextParity CLI report.
  • Include Skia/D2D render parity scenes: pwsh scripts/validate.ps1 -RunRenderParity (via ParityTools render)
  • Include real window screenshot smoke: pwsh scripts/validate.ps1 -RunWindowSmoke
  • Include benchmark smoke: pwsh scripts/validate.ps1 -RunBenchmarks
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 was computed.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MIR.DirectWriteFontsForAvalonia:

Package Downloads
MIR.Direct2D1ForAvalonia

Direct2D1 rendering backend for Avalonia 12 on Windows, maintained as an independent derivative.

MIR.DirectWriteForAvalonia

DirectWrite text shaping backend for Avalonia 12 on Windows, maintained as an independent derivative.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
12.1.0 41 7/10/2026
12.0.0 127 7/5/2026