Read the name stored inside the font, without installing it. The zip includes NotoSans-Regular.ttf.
dotnet add package RecursiveAI.OneFontRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneFont; var face = FontFace.Load(File.ReadAllBytes( "NotoSans-Regular.ttf")); Console.WriteLine(face.FamilyName);
Unzip the example, then dotnet run.
Prints:
Noto SansThe full program
The zip includes Noto Sans Regular under the SIL Open Font License. Run dotnet run -- "path/to/font.ttf" to inspect another file.
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)"}");
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
using OneFont; var face = FontFace.Load(File.ReadAllBytes( "NotoSans-Regular.ttf")); Console.WriteLine(face.SubfamilyName);
RegularRelated recipes
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 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, FamilyName first tries the typographic family, then the legacy family record. The legacy grouping can put related styles in separate families; the OpenType specification 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 for the accepted inputs and errors.