---
title: "Read a font family name from a TTF file in C#"
url: https://recursiveai.org/onefont/cookbook/read-font-family-name/
description: "Read the font family name from a TTF file in C# without installing the font. Get the family, style, full name, and PostScript name from the file’s metadata."
version: "1.4.0"
---

# Read a font family name from a TTF file 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/read-font-family-name/read-font-family-name.zip)

Read the name stored inside the font, without installing it. The zip includes `NotoSans-Regular.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(
    "NotoSans-Regular.ttf"));
Console.WriteLine(face.FamilyName);
```

Unzip [the example](https://recursiveai.org/onefont/cookbook/read-font-family-name/read-font-family-name.zip), then `dotnet run`.

Prints:

```text
Noto Sans
```

## The full program

The zip includes [Noto Sans Regular](https://github.com/notofonts/notofonts.github.io/blob/ac9cdcd317b3c34c7578f609189c963c7eeff3c5/fonts/NotoSans/hinted/ttf/NotoSans-Regular.ttf) under the [SIL Open Font License](https://github.com/notofonts/notofonts.github.io/blob/ac9cdcd317b3c34c7578f609189c963c7eeff3c5/fonts/LICENSE). Run `dotnet run -- "path/to/font.ttf"` to inspect another file.

```csharp
using OneFont;

string path = args.Length == 0 ? "NotoSans-Regular.ttf" : args[0];
var face = FontFace.Load(File.ReadAllBytes(path));
Console.WriteLine($"Family: {face.FamilyName}");
Console.WriteLine($"Style: {face.SubfamilyName}");
Console.WriteLine($"Full name: {face.FullName ?? "(not set)"}");
Console.WriteLine($"PostScript: {face.PostScriptName ?? "(not set)"}");
```

```text
Family: Noto Sans
Style: Regular
Full name: Noto Sans Regular
PostScript: NotoSans-Regular
```

A missing file throws `FileNotFoundException`; malformed or unsupported font data can throw `FontFormatException`.

## Variations

### Read the style instead of the family

```csharp
using OneFont;
var face = FontFace.Load(File.ReadAllBytes(
    "NotoSans-Regular.ttf"));
Console.WriteLine(face.SubfamilyName);
```

```text
Regular
```

## Related recipes

- [Read a TTF or OTF font file in C#](https://recursiveai.org/onefont/cookbook/read-font-file/)
- [Check if a font supports a character](https://recursiveai.org/onefont/cookbook/font-supports-character/)

---

## The short answer

Pass the `.ttf` file’s bytes to `FontFace.Load` and read `FamilyName`. The bundled file prints `Noto Sans`. Nothing is added to the operating system’s font list, and the file name isn’t used to decide the family.

## How do I find the font family name?

A TrueType font includes a [name table](https://learn.microsoft.com/en-us/typography/opentype/spec/name) with separate records for the family, style, full name, and PostScript name. The family is the label you’d use to group faces; the style tells you which face in that family you opened. For the example, those are `Noto Sans` and `Regular`. The full name is its own record (`Noto Sans Regular`), not a string you need to build by joining the two properties. The PostScript name is a separate identifier (`NotoSans-Regular`).

In [onefont 1.4.0](https://github.com/recursive-ai-oss/onefont-csharp/blob/7db48bc21a7eec46272aa73f4e76acf07645db03/src/OneFont/Fonts/FontFace.cs#L124-L130), `FamilyName` first tries the typographic family, then the legacy family record. The legacy grouping can put related styles in separate families; the [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-ids) describes why the typographic record exists. If neither family record is readable, onefont tries the full name and then the PostScript name before returning `Unknown`. `FullName` and `PostScriptName` themselves can be `null`. If you’re listing a folder of fonts, keep the file path alongside the display label: the name is not a unique file identifier.

## How do I read a TTF file without installing it?

Use the path to the actual file, not a family name like `Noto Sans`. A relative path such as the one in the snippet is resolved from the program’s working directory. `FontFace.Load` keeps a reference to the bytes, so leave that array unchanged while using the face. The program reads the name but doesn’t modify the font.

The same call accepts supported OpenType `.otf` files; for a TrueType Collection (`.ttc`), it opens face index zero by default. Use `FontFace.GetFaceCount` and pass the zero-based `faceIndex` to `Load` if you need to inspect the other faces. WOFF, WOFF2 and CFF2 aren’t supported by this loader. See the [pinned `FontFace` API](https://github.com/recursive-ai-oss/onefont-csharp/blob/7db48bc21a7eec46272aa73f4e76acf07645db03/src/OneFont/FontFace.cs#L9-L52) for the accepted inputs and errors.
