SharpAstro.Fonts
0.2.91
dotnet add package SharpAstro.Fonts --version 0.2.91
NuGet\Install-Package SharpAstro.Fonts -Version 0.2.91
<PackageReference Include="SharpAstro.Fonts" Version="0.2.91" />
<PackageVersion Include="SharpAstro.Fonts" Version="0.2.91" />
<PackageReference Include="SharpAstro.Fonts" />
paket add SharpAstro.Fonts --version 0.2.91
#r "nuget: SharpAstro.Fonts, 0.2.91"
#:package SharpAstro.Fonts@0.2.91
#addin nuget:?package=SharpAstro.Fonts&version=0.2.91
#tool nuget:?package=SharpAstro.Fonts&version=0.2.91
SharpAstro.Fonts
A pure-managed, MIT-licensed C# library for loading and rendering OpenType / TrueType fonts.
Status
All phases complete. TrueType hinting, CFF outlines, COLR v0/v1 color glyphs, bitmap emoji, variable fonts, PostScript Type 1, WOFF/WOFF2, and CJK variation selectors. 155 tests passing across outline, rasterizer, color, hinting, variation, and CJK baseline suites.
Goals
- 100% managed C#, AOT-compatible, no native dependencies.
- Cross-platform — targets
net10.0, runs on x64 (Windows, Linux, macOS) and ARM64 (Windows on ARM, Apple Silicon, Linux ARM64). SIMD hot paths useVector<T>to auto-scale across SSE2 / AVX2 / AVX-512 / AdvSIMD. - Thread-safe by construction (immutable font records, per-call rasterizer state, lock-free hinting snapshot cache).
- MIT-licensed end to end. No code is copied from FreeType, SixLabors.Fonts, HarfBuzz, or other non-MIT sources.
- Feature parity with the FreeType subset needed for PDF rendering and UI text.
Supported formats
Container formats
| Format | Notes |
|---|---|
OpenType / TrueType (.otf, .ttf) |
SFNT versions 0x00010000, OTTO, true, typ1 |
TrueType Collection (.ttc) |
Per-face offset loading |
| WOFF1 | Zlib-compressed SFNT |
| WOFF2 | Brotli + glyf/loca transform reconstruction |
PostScript Type 1 (.pfb) |
PFB binary container, eexec decryption |
OpenType tables
Core
| Tag | Coverage |
|---|---|
head |
Full |
maxp |
v0.5 (CFF) and v1.0 (TrueType) |
hhea / hmtx |
Full horizontal metrics |
vhea / vmtx |
Full vertical metrics |
Character mapping (cmap)
| Format | Description |
|---|---|
| 0 | Byte encoding (256-entry) |
| 4 | Segmented BMP (most common) |
| 6 | Trimmed table |
| 12 | Segmented full UCS-4 |
| 14 | Unicode Variation Sequences (IVS / emoji VS) |
Not implemented: formats 2 (high-byte CJK legacy), 8 (mixed 16/32), 13 (last-resort).
Outlines
| Tag | Coverage |
|---|---|
loca |
Short and long offset formats |
glyf |
Simple glyphs (full flag/coordinate decoding), composite glyphs (all transform variants, scaled/unscaled component offsets, composite instructions) |
CFF |
CFF1: Type 2 charstring interpreter, CID-keyed fonts (FDSelect format 0 + 3), global + local subroutines |
Not implemented: CFF2 (blend operator, uint32 INDEX counts).
TrueType hinting
| Tag | Coverage |
|---|---|
cvt |
Full CVT array, scaled per ppem |
fpgm |
Executed once at face load |
prep |
Executed per size change |
Full v40 grayscale interpreter: ~150 opcodes including DELTAP1/2/3, DELTAC1/2/3,
ISECT, engine compensation, IUP, SHP/SHC/SHZ, all round modes, function defs,
projection/freedom/dual vector setters. Per-(face, ppem) HintingSnapshot cache
with thread-safe per-call clone.
Color
| Tag | Coverage |
|---|---|
COLR |
v0: base glyph + layer records. v1: all 32 paint formats including Var* variants, full Porter-Duff composite modes (HSL non-separable modes fall back to SrcOver), ColorLine with Pad/Repeat/Reflect extend, VarIndexMap + embedded ItemVariationStore |
CPAL |
v0 and v1 headers, multiple palettes, BGRA→RGBA conversion |
CBLC |
Index formats 1, 2, 3. Formats 4/5 (sparse) parse but return empty |
CBDT |
Image formats 17, 18 (metrics + PNG), 19 (PNG-only with shared metrics) |
Not implemented: sbix (Apple bitmap strikes), non-PNG CBDT image formats.
Variable fonts
| Tag | Coverage |
|---|---|
fvar |
Axis definitions, named instances, normalization |
avar |
v1 segment maps (piecewise-linear remap) |
gvar |
Full tuple variation: shared/private point numbers, packed deltas, composite component-offset deltas, phantom points |
HVAR |
Advance-width variation via ItemVariationStore + DeltaSetIndexMap |
VVAR |
Advance-height variation (mirrors HVAR) |
MVAR |
Font-wide metric variation (all tags) |
cvar |
CVT hint-program variation (packed tuples targeting CVT indices) |
Not implemented: avar v2 (non-linear ItemVariationStore remapping).
Kerning / positioning
| Tag | Coverage |
|---|---|
kern |
Microsoft v0, format 0 (ordered pairs with binary search) |
GPOS |
LookupType 2 PairAdjustment: format 1 (per-glyph pair sets) and format 2 (class-based pair matrix), Coverage format 1+2, ClassDef format 1+2 |
Not implemented: Apple kern v1, kern format 2, GPOS lookup types 1/3–9.
Shared variation infrastructure
| Component | Coverage |
|---|---|
| ItemVariationStore | Format 1, LONG_WORDS flag, piecewise-linear region scalars. Shared by HVAR, VVAR, MVAR, COLR v1 |
| DeltaSetIndexMap | Format 0 (uint16) and format 1 (uint32), variable entry sizes |
Rasterizer
| Feature | Notes |
|---|---|
| Anti-aliased (smooth) | Analytic coverage rasterizer |
| Mono fallback | Binary threshold |
| SDF (signed distance field) | For GPU text rendering |
| COLR v0/v1 renderer | Full paint-tree walker into RGBA surface |
PostScript Type 1
| Feature | Notes |
|---|---|
.pfb binary container |
Segment markers, eexec decryption |
| Type 1 charstrings | Full interpreter including seac accented composites |
| Encoding array + FontMatrix | Standard encoding, custom encoding |
Not implemented: .pfa ASCII format, standalone CID Type 0 (CID-keyed CFF is
supported via the CFF1 parser).
License
MIT — see LICENSE.
Specifications used as reference
All public, freely-implementable specs:
- OpenType (Microsoft)
- CFF / Type 2 charstrings (Adobe)
- TrueType instruction set (Microsoft / Apple)
- WOFF / WOFF2 (W3C)
- COLR (Microsoft / Google)
- Unicode UAX (Unicode Consortium)
Layout
src/SharpAstro.Fonts/ pure library
tests/SharpAstro.Fonts.Tests/ xUnit v3 tests + font fixtures
benchmarks/SharpAstro.Fonts.Benchmarks/ BenchmarkDotNet perf suite
Development history
Developed in 12 phases, each validated against golden output:
- SFNT skeleton + cmap
- TrueType outlines (glyf/loca, composite glyphs)
- Smooth rasterizer (analytic coverage)
- CFF1 (Type 2 charstring interpreter, CID-keyed fonts)
- COLR v0/v1 + CPAL (paint tree, gradients, composite modes)
- CBDT bitmap glyphs (PNG emoji)
- Variable fonts (fvar/avar/gvar/cvar/HVAR/VVAR/MVAR)
- TrueType bytecode hinting (v40 grayscale, ~150 opcodes)
- PostScript Type 1 (.pfb)
- SDF rasterizer, kern/GPOS kerning, stroker, vertical metrics
- WOFF / WOFF2
- DIR.Lib integration (replaced FreeType native bindings)
| 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. |
-
net10.0
- StbImageSharp (>= 2.30.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpAstro.Fonts:
| Package | Downloads |
|---|---|
|
DIR.Lib
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.