MIR.DirectWriteFontsForAvalonia
12.1.0
dotnet add package MIR.DirectWriteFontsForAvalonia --version 12.1.0
NuGet\Install-Package MIR.DirectWriteFontsForAvalonia -Version 12.1.0
<PackageReference Include="MIR.DirectWriteFontsForAvalonia" Version="12.1.0" />
<PackageVersion Include="MIR.DirectWriteFontsForAvalonia" Version="12.1.0" />
<PackageReference Include="MIR.DirectWriteFontsForAvalonia" />
paket add MIR.DirectWriteFontsForAvalonia --version 12.1.0
#r "nuget: MIR.DirectWriteFontsForAvalonia, 12.1.0"
#:package MIR.DirectWriteFontsForAvalonia@12.1.0
#addin nuget:?package=MIR.DirectWriteFontsForAvalonia&version=12.1.0
#tool nuget:?package=MIR.DirectWriteFontsForAvalonia&version=12.1.0
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()orUseDirectWrite()
Package choice is explicit:
- DirectWrite shaping: reference
MIR.DirectWriteForAvaloniaand callUseDirectWrite(). - HarfBuzz shaping: reference
Avalonia.HarfBuzzand callUseHarfBuzz().
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 anIDirect3D11TexturePlatformSurface, 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 throwNotSupportedExceptionat 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/Lockperform a staging readback lazily. Falls back to WIC only if no D2D device exists. - High DPI. Drawing coordinates for
RenderTargetBitmapare device-independent pixels (DIPs), same as Skia: at 192 DPI a logicalRect(0,0,96,64)fills a192×128pixel bitmap. - Bitmap formats.
Bitmap.Saveaccepts.png,.jpg/.jpeg,.bmp,.tif/.tiff,.gif, and.webpvia the file extension. The optionalqualityparameter is applied to JPEG output through WIC'sImageQualityencoder option. - Path segmenting.
Geometry.TryGetSegmentis 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, andTHIRD_PARTY_NOTICES.md.
Validation:
- Fast local check:
pwsh scripts/validate.ps1builds 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(viaParityTools render) - Include real window screenshot smoke:
pwsh scripts/validate.ps1 -RunWindowSmoke - Include benchmark smoke:
pwsh scripts/validate.ps1 -RunBenchmarks
| Product | Versions 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. |
-
net8.0
- Avalonia (>= 12.1.0)
- Vortice.Direct2D1 (>= 3.8.3)
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.