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

NameTypeAccessDescription
BaseFontstringReadGets the base font.
FontNamestringReadGets the font name.
DecodedFontNamestringReadGets the decoded font name.
IsEmbeddedboolRead/WriteGets or sets the is embedded.
IsSubsetboolRead/WriteGets or sets the is subset.
IsAccessibleboolReadGets the is accessible.
FontOptionsIFontOptionsReadGets the font options.
iPdfFontPdfFontViewReadLower-level PDF-font view of this Font.
DefaultHelveticaFontReadDefault Helvetica font for detached text fragments.
ResourceNamestringReadResource name in the page’s font dictionary (e.g., “F1”).
UniqueIdstringReadUnique identifier combining resource name and base font.
SubtypestringReadFont subtype (Type1, TrueType, Type0, Type3, etc.).
Encodingstring?ReadEncoding name (WinAnsiEncoding, Identity-H, etc.).
IsItalicboolReadWhether the font is italic.
IsBoldboolReadWhether the font is bold.
IsCidboolReadWhether the font is a CID (Type0) font — used for Arabic, CJK, etc.

Methods

SignatureDescription
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.

See Also