Read the PostScript name stored in the font, not its filename. Use a .ttf or supported .otf file. NotoSans-Regular.ttf is in the download.
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")); var name = face.PostScriptName; Console.WriteLine(name ?? "No PostScript name");
Unzip the example, then dotnet run.
Prints:
NotoSans-RegularThe full program
using OneFont; string path = args.Length == 0 ? "NotoSans-Regular.ttf" : args[0]; var face = FontFace.Load(File.ReadAllBytes(path)); Console.WriteLine(face.PostScriptName ?? "No PostScript name");
With the included font, dotnet run prints NotoSans-Regular.
The download contains the unchanged Noto Sans Regular font and its SIL Open Font License. To inspect your own font, run dotnet run -- "path/to/font.ttf".
If the font has no PostScript name, you get null. If FontFace.Load can’t read the font data because it’s malformed or unsupported, it throws FontFormatException.
Variations
To show a display name too, append this line to the snippet at the top:
Console.WriteLine(face.FamilyName);The extra line prints Noto Sans.
Related recipes
The short answer
Read FontFace.PostScriptName for the stored PostScript identifier. If the result is null, report the name as missing; stripping spaces from FamilyName or dropping the extension from the filename won’t retrieve the stored value.
What’s the difference between a PostScript name and a font family name?
A family name groups related faces in a font menu. With the bundled font, that label is Noto Sans, while the PostScript name identifies the regular face as NotoSans-Regular. FullName is another human-readable field; it includes the style here (Noto Sans Regular). Use the family name to group faces and the PostScript name when an input or output field specifically asks for it.
The OpenType naming table specification defines those as separate records: name ID 6 is the PostScript name, ID 4 is the full name, and IDs 16 and 1 are the typographic and legacy family names. It limits the PostScript name to 63 characters in a restricted printable ASCII range that excludes spaces. That explains why it often looks different from the menu label. It doesn’t give you a recipe to turn one into the other.
How do I find the PostScript name inside a font file?
The extension tells you the kind of file, not the name stored in it. OneFont reads name ID 6 from the face’s name table; it doesn’t get this identifier from the post table or from a system font menu. The font doesn’t have to be installed. Renaming the file doesn’t change the ID 6 record, even though the example’s filename happens to match the name it prints.
A .ttc font collection can contain multiple faces. FontFace.Load defaults to the first face, index 0. Its faceIndex parameter selects a different face from the same file; choose the index for the style you need rather than treating the collection as a single face. The pinned load API documents the accepted formats and the zero-based index. WOFF, WOFF2 and CFF2 aren’t supported at this release.