SixLabors.Fonts
[](https://github.com/SixLabors/Fonts/actions)
[](https://codecov.io/gh/SixLabors/Fonts)
[](https://github.com/SixLabors/Fonts/blob/main/LICENSE)
**SixLabors.Fonts** is a cross-platform library for loading, measuring, and laying out fonts and text. It supports TrueType and OpenType fonts (including CFF1 and CFF2 outlines), WOFF/WOFF2 web fonts, variable fonts, color fonts (COLR v0/v1 and SVG), and TrueType hinting. The library provides a full OpenType layout engine with GSUB/GPOS support, advanced text shaping for complex scripts, and bidirectional text rendering.
Fonts also exposes high-level text layout primitives for applications that need more than a single bounding box. Callers can measure advance, ink bounds, renderable bounds, lines, words, graphemes, and glyphs; reuse prepared text across multiple wrapping widths; inspect the resolved font used to shape and render fallback glyphs; and use built-in hit testing, caret placement, and selection geometry.
## License
- Fonts is licensed under the [Six Labors Split License, Version 1.0](https://github.com/SixLabors/Fonts/blob/main/LICENSE)
## Support Six Labors
Support the efforts of the development of the Six Labors projects.
- [Purchase a Commercial License :heart:](https://sixlabors.com/pricing/)
- [Become a sponsor via GitHub Sponsors :heart:]( https://github.com/sponsors/SixLabors)
- [Become a sponsor via Open Collective :heart:](https://opencollective.com/sixlabors)
## Documentation
- [Detailed documentation](https://sixlabors.github.io/docs/) for the Fonts API is available. This includes additional conceptual documentation to help you get started.
- Our [Samples Repository](https://github.com/SixLabors/Samples/tree/main/ImageSharp) is also available containing buildable code samples demonstrating common activities.
## Questions
- Do you have questions? We are happy to help! Please [join our Discussions Forum](https://github.com/SixLabors/Fonts/discussions/category_choices).
- Please read our [Contribution Guide](https://github.com/SixLabors/Fonts/blob/main/.github/CONTRIBUTING.md) before opening issues or pull requests!
## Code of Conduct
This project has adopted the code of conduct defined by the [Contributor Covenant](https://contributor-covenant.org/) to clarify expected behavior in our community.
## Installation
Install stable releases via Nuget; development releases are available via Feedz.io.
| Package Name | Release (NuGet) | Nightly (Feedz.io) |
|--------------------------------|-----------------|-----------------|
| `SixLabors.Fonts` | [](https://www.nuget.org/packages/SixLabors.Fonts/) | [](https://f.feedz.io/sixlabors/sixlabors/nuget/index.json) |
## Manual build
If you prefer, you can compile Fonts yourself (please do and help!)
- Using [Visual Studio 2022](https://visualstudio.microsoft.com/vs/)
- Make sure you have the latest version installed
- Make sure you have [the .NET 8 SDK](https://www.microsoft.com/net/core#windows) installed
Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**:
- [Visual Studio Code](https://code.visualstudio.com/) with [C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
- [.NET Core](https://www.microsoft.com/net/core#linuxubuntu)
To clone Fonts locally, click the "Clone in [YOUR_OS]" button above or run the following git commands:
```bash
git clone https://github.com/SixLabors/Fonts
```
If working with Windows please ensure that you have enabled log file paths in git (run as Administrator).
```bash
git config --system core.longpaths true
```
### Submodules
This repository contains [git submodules](https://blog.github.com/2016-02-01-working-with-submodules/). To add the submodules to the project, navigate to the repository root and type:
``` bash
git submodule update --init --recursive
```
### LFS
This repository uses LFS Large File Storage. To configure it for the project, navigate to the repository root and type:
``` bash
git lfs install
```
``` bash
git lfs pull
```
### Features
- Reading font description (name, family, subname etc plus other string metadata).
- Loading TrueType fonts and OpenType fonts with CFF1 and CFF2 outlines.
- Loading [WOFF](https://www.w3.org/Submission/WOFF/) and [WOFF2](https://www.w3.org/TR/WOFF2) web fonts.
- Loading all compatible fonts from the local machine store.
- Support for [variable fonts](https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview) (fvar, gvar, cvar, CFF2 variations).
- Support for color fonts ([COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr) v0/v1 and [SVG](https://learn.microsoft.com/en-us/typography/opentype/spec/svg)).
- TrueType hinting (FreeType v40-compatible interpreter).
- Support for advanced OpenType layout via glyph substitution ([GSUB](https://learn.microsoft.com/en-us/typography/opentype/spec/gsub)) and glyph positioning ([GPOS](https://learn.microsoft.com/en-us/typography/opentype/spec/gpos)).
- Advanced text shaping for complex scripts (Indic, Myanmar, Universal Shaping Engine).
- Support for ligatures and kerning.
- Support for rendering left to right, right to left, and bidirectional text.
- Support for line breaking based on [UAX 14](https://www.unicode.org/reports/tr14/).
- Support for reusable prepared text layout via `TextBlock`.
- Text measurement APIs for advance bounds, ink bounds, renderable bounds, line metrics, word metrics, grapheme metrics, and glyph metrics.
- Glyph and grapheme metrics expose the resolved font used to shape and render each entry, including fallback fonts.
- Text interaction helpers for hit testing, caret positioning, caret movement, and selection bounds.
- Support for wrapping, trimming, ellipsis, hyphenation, tab width, tracking, line height, and horizontal and vertical layout modes.
## API Examples
### Read font description
```c#
FontDescription description = null;
using(var fs = File.OpenRead("Font.ttf")){
description = FontDescription.Load(fs); // once it has loaded the data the stream is no longer required and can be disposed of
}
string name = description.FontName(CultureInfo.InvariantCulture);
```
### Populating a font collection
```c#
FontCollection fonts = new FontCollection();
FontFamily font1 = fonts.Add("./path/to/font1.ttf");
FontFamily font2 = fonts.Add("./path/to/font2.woff");
```
### How can you help?
Please... Spread the word, contribute algorithms, submit performance improvements, unit tests.
### Projects using SixLabors.Fonts
* [SixLabors.ImageSharp.Drawing](https://github.com/SixLabors/ImageSharp.Drawing) - cross platform, fully managed, image drawing library.
### The SixLabors.Fonts Team
- [Scott Williams](https://github.com/tocsoft)
- [Dirk Lemstra](https://github.com/dlemstra)
- [Anton Firsov](https://github.com/antonfirsov)
- [James Jackson-South](https://github.com/jimbobsquarepants)
- [Brian Popow](https://github.com/brianpopow)