Class PdfTrueTypeFont
An embedded TrueType or OpenType font with full Unicode support. The font is embedded as composite font (Type0, Identity-H). TrueType outlines are subset to the used glyphs; CFF-based OpenType fonts are embedded completely. A ToUnicode map is always written so text remains extractable/searchable.
public sealed class PdfTrueTypeFont : PdfFont
- Inheritance
-
PdfTrueTypeFont
- Inherited Members
Remarks
Pair kerning (kern table) is applied by the layout engine (Paragraph). Complex script shaping (Arabic, Indic) and ligatures are not applied.
Properties
Ascent
Ascent in 1/1000 em (positive).
public override double Ascent { get; }
Property Value
CapHeight
Cap height in 1/1000 em.
public override double CapHeight { get; }
Property Value
Descent
Descent in 1/1000 em (negative).
public override double Descent { get; }
Property Value
FamilyName
The font family name from the font's name table, e.g. "Arial".
public string FamilyName { get; }
Property Value
HasKerning
True if the font contains pair kerning data (loaded on first access).
public override bool HasKerning { get; }
Property Value
IsBold
True if the font is flagged bold (macStyle) or its weight class is 600 or higher.
public bool IsBold { get; }
Property Value
IsItalic
True if the font is flagged italic (macStyle) or has a non-zero italic angle.
public bool IsItalic { get; }
Property Value
LineGap
Additional line gap in 1/1000 em.
public override double LineGap { get; }
Property Value
Name
The PostScript name of the font.
public override string Name { get; }
Property Value
UnderlinePosition
Position of the underline relative to the baseline in 1/1000 em (negative = below), from the font's post table.
public override double UnderlinePosition { get; }
Property Value
UnderlineThickness
Thickness of the underline in 1/1000 em, from the font's post table.
public override double UnderlineThickness { get; }
Property Value
Methods
CanDisplay(int)
True if the font's character map maps the character to a glyph other than .notdef.
public override bool CanDisplay(int codePoint)
Parameters
codePointint
Returns
FromBytes(byte[], int, bool)
Loads a TrueType/OpenType font or TrueType collection from its file content.
public static PdfTrueTypeFont FromBytes(byte[] data, int collectionIndex = 0, bool ignoreLicenseRestrictions = false)
Parameters
databyte[]Content of a .ttf, .otf or .ttc file.
collectionIndexintIndex of the font inside a TrueType collection (.ttc).
ignoreLicenseRestrictionsboolEmbed even if the font's license flags forbid it.
Returns
Exceptions
- PdfException
The font's license does not permit embedding and
ignoreLicenseRestrictionsis false.
FromFile(string, int, bool)
Loads a .ttf, .otf or .ttc file.
public static PdfTrueTypeFont FromFile(string path, int collectionIndex = 0, bool ignoreLicenseRestrictions = false)
Parameters
pathstringPath of the font file.
collectionIndexintIndex of the font inside a TrueType collection (.ttc).
ignoreLicenseRestrictionsboolEmbed even if the font's license flags forbid it.
Returns
FromStream(Stream, int, bool)
Loads a TrueType/OpenType font or TrueType collection from a stream (read to the end, not closed).
public static PdfTrueTypeFont FromStream(Stream stream, int collectionIndex = 0, bool ignoreLicenseRestrictions = false)
Parameters
streamStreamStream with the content of a .ttf, .otf or .ttc file.
collectionIndexintIndex of the font inside a TrueType collection (.ttc).
ignoreLicenseRestrictionsboolEmbed even if the font's license flags forbid it.
Returns
GetCharWidth(int)
Advance width of a character in 1/1000 em; characters without a glyph return the width of the .notdef glyph.
public override double GetCharWidth(int codePoint)
Parameters
codePointint
Returns
GetKerning(int, int)
Kerning between two characters in 1/1000 em (negative = closer), 0 if none.
public override double GetKerning(int left, int right)