---
title: "Load a variable font named instance in C#"
url: https://recursiveai.org/onefont/cookbook/select-variable-font-named-instance/
description: "Load an OpenType variable font preset such as Bold in C#. Use OneFont to select a named instance and print the axis values stored for it in the font."
version: "1.5.1"
---

# Load a variable font named instance in C#

**onefont** is a free, open-source font and text-shaping library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneFont) · [GitHub](https://github.com/recursive-ai-oss/onefont-csharp) · [Docs](https://recursiveai.org/onefont/docs/) · [Download example (.zip)](https://recursiveai.org/onefont/cookbook/select-variable-font-named-instance/select-variable-font-named-instance.zip)

A named instance is a preset, like Bold, stored in the variable font. The program reads `Newsreader.ttf` from the working directory (the file comes in the zip); you can replace it with the path to any variable `.ttf` that declares the preset.

```shell
dotnet add package RecursiveAI.OneFont
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneFont;
var face = FontFace.Load(
    File.ReadAllBytes("Newsreader.ttf"));
var bold = face.WithNamedInstance("Bold");
foreach (var axis in bold.Variations)
    Console.WriteLine(
        $"{axis.Tag}: {axis.Value}");
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/onefont/cookbook/select-variable-font-named-instance/select-variable-font-named-instance.zip) and `dotnet run`.

Selects the font’s Bold preset and prints its active weight and optical size.

```text
wght: 700
opsz: 18
```

`WithNamedInstance` throws `ArgumentException` if that name isn’t declared in the file; check `NamedInstances` for the available names. The zip includes the sample’s SIL Open Font License.

## Variations

### List the presets before choosing one

Append this to print the names a style picker can offer:

```csharp
foreach (var preset in face.NamedInstances)
    Console.WriteLine(preset.Name);
```

```text
ExtraLight
Light
Regular
Medium
SemiBold
Bold
ExtraBold
```

## Related recipes

[Read variable font axes and ranges](https://recursiveai.org/onefont/cookbook/list-variable-font-axes/)

[Set variable font weight and optical size](https://recursiveai.org/onefont/cookbook/set-variable-font-axis/)

---

## The short answer

Load the variable font once and call `face.WithNamedInstance("Bold")` to get a face at the coordinates of its Bold preset. Use the returned face for shaping or reading outlines and metrics; the original stays at its existing settings. To see what the preset selected, read `bold.Variations`. The sample’s Bold preset sets `wght` to 700 and leaves `opsz` at 18. Those values come from this font, not from a rule in the API about what “Bold” means.

## What is a named instance of a variable font?

An instance is a point in the range the variable file describes. A named instance gives one such point a label: in a font with several axes, it can set weight, width, and optical size together. The [OpenType `fvar` table](https://learn.microsoft.com/en-us/typography/opentype/spec/fvar) holds these presets as records with a name reference and one user-space coordinate per axis. A preset is not a separate font file. For example, the Newsreader subset declares Regular and Bold inside the same `.ttf`, but an unlisted combination such as a weight of 450 and an optical size of 16 can still be selected by passing axis values directly.

## How do you find the named instances in a font?

Read `face.NamedInstances` rather than guessing names from the filename or offering a fixed list like Regular, Italic, and Bold. Each entry exposes its `Name`, its `Coordinates`, and its `PostScriptName` when the font supplies one. The `Name` is the subfamily label used for selection, not the PostScript name. The [OneFont API](https://github.com/recursive-ai-oss/onefont-csharp/blob/8c71b3fc22254ad7ff2561eb3abd171f1abdea0c/src/OneFont/FontFace.cs#L154-L171) compares names “ignoring case; the first match wins”. If you show the entries in a picker, you can use the selected entry’s zero-based index with `WithNamedInstance(index)` to identify the exact record even if labels repeat. An index belongs to that font file’s list; don’t assume the same index means the same style in another file.

An empty list means there are no declared presets to offer, not necessarily that there are no axes to adjust. If the task is to use a font’s intended presets, list its names. If it’s to choose a combination in between those presets, use its axis ranges instead. OneFont selects a face over the existing bytes; it doesn’t export the preset as a static font.
