Skip to main content

Exceptions

Namespace: PinataLabs.Typography.

Exception
├── FontException
│ ├── FontFamilyNotFoundException
│ └── GlyphMissingException
└── InvalidFontFileException
├── InvalidFontTableException
└── MissingFontTableException
ExceptionThrown whenExtra members
FontExceptionA general font error, for example when you use a default FontFamily. The base class of the two below.
FontFamilyNotFoundExceptionGet or CreateFont cannot find a family by name.FontFamily: the name that was not found. SearchDirectories: the folders that were searched, for system fonts.
GlyphMissingExceptionNot thrown by the library at present. A missing glyph gives the font's missing-glyph box instead.
InvalidFontFileExceptionThe data is not a font that the library can read.
InvalidFontTableExceptionA table in the font has data that is not valid.Table: the tag of the table.
MissingFontTableExceptionThe font has no table that the library needs, such as cmap or head.Table: the tag of the table.

The library also throws the standard .NET exceptions: ArgumentNullException for a null argument, ArgumentOutOfRangeException for a negative Dpi, ArgumentException for a LineSpacing of 0, and FileNotFoundException and other I/O exceptions when it reads a file.

To load fonts that a user supplies, catch InvalidFontFileException (which also catches the two table exceptions) and show a message:

try
{
fonts.Add(path);
}
catch (InvalidFontFileException ex)
{
Console.WriteLine($"{Path.GetFileName(path)} is not a usable font: {ex.Message}");
}