---
title: "Read variable font axes and ranges in C#"
url: https://recursiveai.org/onefont/cookbook/list-variable-font-axes/
description: "List the OpenType axes in a variable font file in C#. Get each axis tag, name, and minimum, default, and maximum values from OneFont."
version: "1.5.1"
---

# Read variable font axes and ranges 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/list-variable-font-axes/list-variable-font-axes.zip)

Read the ranges for controls like weight. 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`.

```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"));
foreach (var axis in face.Axes)
{
    var label = axis.Name ?? axis.Tag;
    Console.WriteLine($"{axis.Tag}: {label}");
    Console.WriteLine(
        $"  Min: {axis.Minimum} " +
        $"Default: {axis.Default} " +
        $"Max: {axis.Maximum}");
}
```

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/list-variable-font-axes/list-variable-font-axes.zip) and `dotnet run`.

Prints the tag, name, and minimum, default, and maximum for each axis.

```text
wght: Weight
  Min: 200 Default: 400 Max: 800
opsz: Optical Size
  Min: 6 Default: 18 Max: 72
```

If the file has no usable variation axes, `Axes` is empty and the loop prints nothing. The zip includes the sample’s SIL Open Font License.

## Variations

### List the axes to offer in a picker

Append this to skip axes the font marks as hidden:

```csharp
foreach (var axis in face.Axes)
    if (!axis.IsHidden)
        Console.WriteLine(axis.Tag);
```

```text
wght
opsz
```

## Related recipes

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

[Load a variable font named instance](https://recursiveai.org/onefont/cookbook/select-variable-font-named-instance/)

[Read normalized variation coordinates](https://recursiveai.org/onefont/cookbook/read-variable-font-normalized-coordinates/)

---

## The short answer

Load the font file with `FontFace.Load` and enumerate `face.Axes`. For each axis, use `Tag` as its identifier, `Name` as its display label when present, and `Minimum`, `Default`, and `Maximum` as the bounds and initial value for a control. These are values in the font’s own axis units, not percentages of the range or normalized coordinates. The sample outputs `wght` and `opsz` in the order they were declared in the file.

## How can you tell if a font is variable?

Check `face.IsVariable`. The `.ttf` or `.otf` extension isn’t enough to tell a static font from a variable one. OneFont looks for a usable OpenType `fvar` table, which defines the axes and ranges. [The `Axes` API](https://github.com/recursive-ai-oss/onefont-csharp/blob/8c71b3fc22254ad7ff2561eb3abd171f1abdea0c/src/OneFont/FontFace.cs#L33-L43) documents the list as “empty for a font that is not variable.” If a font is meant to be variable but the property is false, verify that you opened the variable file rather than a static export. A damaged `fvar` table can also leave the face looking static to OneFont. Use an actual font file; OneFont doesn’t read WOFF or WOFF2.

## How do variable font axes and ranges work?

An axis describes a setting the font author lets you change. OpenType has registered tags such as `wght` for weight and `opsz` for optical size. Fonts can also define custom axes. Read what the file has rather than assuming a particular set of tags. The [OpenType `fvar` specification](https://learn.microsoft.com/en-us/typography/opentype/spec/fvar) defines the minimum, default, and maximum for each axis. The default isn’t necessarily the midpoint: in this example the optical-size range is 6–72, but the default is 18. In an editor, initialize a slider at the declared default and use that same value when the user resets the control.

A friendly axis name is optional. OneFont’s [`FontAxis`](https://github.com/recursive-ai-oss/onefont-csharp/blob/8c71b3fc22254ad7ff2561eb3abd171f1abdea0c/src/OneFont/FontVariation.cs#L58-L74) returns `null` when it can’t supply a name, so the tag is a useful fallback. Keep the tag for saved settings even when the UI shows a label. A hidden axis can still appear in the metadata; the flag means the font asks the UI not to offer it, not that the axis has been removed.
