Font
Overview
Font is a class in Aspose.PDF FOSS for .NET.
Inherits from: FontInfo.
Type alias for FontInfo, matching the Font class name.
This class provides 5 methods for working with Font objects in .NET programs.
Available methods include: FromFontData, GetGlyphWidth, GetLastFontEmbeddingError, MeasureString, Save.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: BaseFont, DecodedFontName, DefaultHelvetica, Encoding, FontName, FontOptions, and 10 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
BaseFont | string | Read | Gets the base font. |
FontName | string | Read | Gets the font name. |
DecodedFontName | string | Read | Gets the decoded font name. |
IsEmbedded | bool | Read/Write | Gets or sets the is embedded. |
IsSubset | bool | Read/Write | Gets or sets the is subset. |
IsAccessible | bool | Read | Gets the is accessible. |
FontOptions | IFontOptions | Read | Gets the font options. |
iPdfFont | PdfFontView | Read | Lower-level PDF-font view of this Font. |
DefaultHelvetica | Font | Read | Default Helvetica font for detached text fragments. |
ResourceName | string | Read | Resource name in the page’s font dictionary (e.g., “F1”). |
UniqueId | string | Read | Unique identifier combining resource name and base font. |
Subtype | string | Read | Font subtype (Type1, TrueType, Type0, Type3, etc.). |
Encoding | string? | Read | Encoding name (WinAnsiEncoding, Identity-H, etc.). |
IsItalic | bool | Read | Whether the font is italic. |
IsBold | bool | Read | Whether the font is bold. |
IsCid | bool | Read | Whether the font is a CID (Type0) font — used for Arabic, CJK, etc. |
Methods
| Signature | Description |
|---|---|
GetLastFontEmbeddingError() | Last error encountered embedding this font in a PDF; empty when none. |
MeasureString(str: string, fontSize: float) | Measure the rendered width of a string at the given size, in points. |
Save(stream: System.IO.Stream) | Write the raw font file data to a stream. |
FromFontData(fontData: FontData) | Create a FontInfo from a FontData (system font found via FontRepository.FindFont). |
GetGlyphWidth(charCode: int) | Get the width of a character code in 1/1000 text space units. |