Introduction
What is Fonts?
Fonts is the high-performance part of the Six Labors stack that handles font loading, text measurement, layout, shaping, and custom text rendering.
If you are new to the library, the easiest way to think about it is in layers: load families, create concrete Font instances, then measure or render text with TextOptions. The rest of this section is organized around that path so you can start simple and move into shaping, Unicode, fallback, and custom rendering only when you need them.
It supports TrueType and OpenType fonts, including CFF1 and CFF2 outlines, WOFF and WOFF2 web fonts, variable fonts, color fonts, advanced OpenType layout, complex script shaping, and bidirectional text rendering.
Fonts is often used underneath ImageSharp.Drawing, but it is not limited to image rendering. You can also use it for font inspection, text measurement, shaping, and custom rendering pipelines.
The main thing to learn early is the difference between font assets, font instances, and text layout. A font collection tells you what families are available, a Font chooses a family/style/size, and TextOptions describes how a specific piece of text should be shaped, wrapped, aligned, measured, or rendered. TextBlock builds on that by preparing layout once so you can inspect lines, hit-test, move carets, or draw the same shaped text consistently.
The Unicode pages are part of the practical API story, not a side topic. Most real text is not one UTF-16 code unit per visible character, and indexes used for rich text, placeholders, selection, and hit testing need to be understood in terms of graphemes and shaped layout rather than raw char positions.
License
Fonts is licensed under the terms of the Six Labors Split License, Version 1.0. See https://sixlabors.com/pricing for commercial licensing details.
Important
Starting with Fonts 3.0.0, projects that directly depend on SixLabors.Fonts require a valid Six Labors license at build time. This enforcement applies to direct dependencies only. See License Enforcement Changes and a New Subscription Tier for details.
Installation
Fonts is installed via NuGet with nightly builds available on Feedz.
PM > Install-Package SixLabors.Fonts -Version VERSION_NUMBER
Warning
Prerelease versions installed via the Visual Studio NuGet Package Manager require the "include prerelease" checkbox to be checked.
How to use the license file
By default, the build searches from each project directory for sixlabors.lic. Place the supplied file in the directory that contains the project file, or in a subdirectory below it. Use the file as supplied; it already contains the complete license string required by the build.
If you want to keep the file somewhere else, including a repository root that sits above the project directory, set SixLaborsLicenseFile in your project file or a shared props file:
<PropertyGroup>
<SixLaborsLicenseFile>path/to/sixlabors.lic</SixLaborsLicenseFile>
</PropertyGroup>
If you do not want to store the license on disk, pass the license string directly from an environment variable or secret store. When extracting the value from sixlabors.lic, use the full file contents, not only the Key field:
<PropertyGroup>
<SixLaborsLicenseKey>$(SIXLABORS_LICENSE_KEY)</SixLaborsLicenseKey>
</PropertyGroup>
You can also pass the key to common .NET CLI commands.
PowerShell:
dotnet build -p:SixLaborsLicenseKey="$env:SIXLABORS_LICENSE_KEY"
dotnet publish -p:SixLaborsLicenseKey="$env:SIXLABORS_LICENSE_KEY"
Bash and other shells that expand environment variables with $NAME:
dotnet build -p:SixLaborsLicenseKey="$SIXLABORS_LICENSE_KEY"
dotnet publish -p:SixLaborsLicenseKey="$SIXLABORS_LICENSE_KEY"
Build as normal after the file or property is configured. If the license is missing or invalid, the build fails with a clear error. You do not need to reference the licensing package directly; it is carried by Six Labors libraries.
Start Here
If you are new to Fonts, start with Loading Fonts and Collections and then use the pages below to branch into the topics your application needs.
- System Fonts
- Font Metadata and Inspection
- Font Metrics
- Measuring Text
- Prepared Text with TextBlock
- Hit Testing and Caret Movement
- Selection and Bidi Drag
- Text Layout and Options
- OpenType Features
- Text Shaping
- TrueType Hinting
- Color Fonts
- Unicode, Code Points, and Graphemes
- Fallback Fonts and Multilingual Text
- Variable Fonts
- Custom Rendering
- Recipes
- Troubleshooting
How to Use These Docs
- Start with font loading and measurement before moving into shaping, fallback, and rendering.
- Use the Unicode pages whenever text ranges, caret movement, styling, or placeholders are involved.
- Use
TextBlockpages when layout must be measured, inspected, interacted with, and rendered consistently. - Use custom rendering only after the layout model is clear.