Fonts
High-performance font loading, shaping, layout, measurement, inspection, and custom text rendering for modern .NET.
Fonts lets .NET applications load fonts, shape multilingual text, measure layout, inspect font data, and render glyphs into custom pipelines, whether you are measuring UI text, generating assets, inspecting font files, or building your own text renderer.
Built for real-world text
Fonts handles the full path from loading families to creating concrete font instances, measuring text, shaping complex scripts, inspecting font data, and rendering or exporting glyph geometry.
With no native dependencies to ship, it runs anywhere that supports .NET 8+, making it a strong fit for web apps, services, desktop applications, graphics pipelines, and custom rendering systems.
dotnet add package SixLabors.Fonts
Measure, layout, and shape with confidence
Fonts gives you the layout controls and shaping behavior needed for multilingual text, mixed scripts, emoji, fallback families, and production UI strings.
Use one consistent API to control wrapping, alignment, direction, fallback families, OpenType features, FreeType v40-compatible TrueType hinting, tracking, color-font support, and variable-font settings while keeping measurement and rendering aligned.
Capture a full layout once with TextMetrics, or reuse a prepared TextBlock across redraws when the same string is measured, wrapped, hit-tested, selected, or rendered repeatedly.
using SixLabors.Fonts;
FontCollection collection = new();
FontFamily textFamily = collection.Add("fonts/NotoSans-Regular.ttf");
FontFamily arabicFamily = collection.Add("fonts/NotoSansArabic-Regular.ttf");
FontFamily emojiFamily = collection.Add("fonts/NotoColorEmoji-Regular.ttf");
TextOptions options = new(textFamily.CreateFont(18))
{
WrappingLength = 320,
TextDirection = TextDirection.Auto,
HintingMode = HintingMode.Standard,
FallbackFontFamilies = new[] { arabicFamily, emojiFamily },
ColorFontSupport = ColorFontSupport.ColrV1 | ColorFontSupport.ColrV0 | ColorFontSupport.Svg
};
TextMetrics metrics = TextMeasurer.Measure(
"Status: ready 😀 Ù…Ø±ØØ¨Ø§",
options);
FontRectangle advance = metrics.Advance;
FontRectangle ink = metrics.Bounds;
FontRectangle renderable = metrics.RenderableBounds;
Prepared text and editor behavior
When shaped text becomes application state, TextBlock prepares the wrapping-independent work once and lets you measure, render, inspect, and interact with the same text repeatedly.
That makes Fonts useful for editors, design tools, layout panels, report generators, and any surface where measurement, rendering, hit testing, caret movement, and selection geometry must agree.
- Measure with different wrapping lengths without reshaping the string from scratch each time.
- Inspect line, word, grapheme, and glyph metrics for layout and diagnostics.
- Use line-local layout APIs when another system places text into columns, frames, paths, or virtualized rows.
- Paint selection rectangles returned by the API, including mixed bidirectional text and blank-line behavior.
using SixLabors.Fonts;
Font font = SystemFonts.CreateFont("Segoe UI", 18);
TextOptions options = new(font)
{
TextDirection = TextDirection.Auto,
TextInteractionMode = TextInteractionMode.Editor
};
TextBlock block = new("Status: ready for layout", options);
TextMetrics narrow = block.Measure(240);
TextMetrics wide = block.Measure(480);
// TextBlock keeps measurement and interaction on the same shaped text.
ReadOnlyMemory<LineLayout> lines = block.GetLineLayouts(320);
ReadOnlyMemory<FontRectangle> selection =
wide.GetSelectionBounds(start: 0, length: 6);
Advanced typography workflows
Fonts gives .NET teams the tools they need when text quality matters, whether the destination is ImageSharp.Drawing, a custom renderer, or another output system entirely.
- Load TrueType, OpenType, CFF and CFF2 outlines, WOFF, WOFF2, COLR v0 and v1 paint-graph color fonts, SVG color fonts, and variable fonts.
- Handle bidirectional text, Arabic, Hebrew, Indic, Myanmar, Thai, and Lao shaping, fallback families, and multilingual content correctly.
- Work with Unicode code points, graphemes, line metrics, hit testing, caret movement, and selection geometry for editor-grade text behavior.
- Request OpenType features such as ligatures, fractions, tabular figures, and stylistic sets.
- Drive layout decisions with logical advance, glyph ink bounds, renderable bounds, and per-line metrics from a single measurement pass.
- Inspect font metadata, metrics, glyph coverage, and variation axes for tooling and diagnostics.
- Render through ImageSharp.Drawing or drive your own pipeline with custom glyph rendering, including layered paint and gradient color glyphs.
using SixLabors.Fonts;
using SixLabors.Fonts.Tables.AdvancedTypographic;
FontCollection collection = new();
FontFamily family = collection.Add("fonts/RobotoFlex.ttf");
Font font = family.CreateFont(
16,
new FontVariation(KnownVariationAxes.Weight, 700),
new FontVariation(KnownVariationAxes.Width, 85),
new FontVariation(KnownVariationAxes.OpticalSize, 16));
TextOptions options = new(font)
{
FeatureTags = new Tag[]
{
KnownFeatureTags.Ligatures,
KnownFeatureTags.TabularFigures
}
};