Table of Contents

Class PdfTrueTypeFont

Namespace
MiPdf.Fonts
Assembly
MiPdf.dll

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

double

CapHeight

Cap height in 1/1000 em.

public override double CapHeight { get; }

Property Value

double

Descent

Descent in 1/1000 em (negative).

public override double Descent { get; }

Property Value

double

FamilyName

The font family name from the font's name table, e.g. "Arial".

public string FamilyName { get; }

Property Value

string

HasKerning

True if the font contains pair kerning data (loaded on first access).

public override bool HasKerning { get; }

Property Value

bool

IsBold

True if the font is flagged bold (macStyle) or its weight class is 600 or higher.

public bool IsBold { get; }

Property Value

bool

IsItalic

True if the font is flagged italic (macStyle) or has a non-zero italic angle.

public bool IsItalic { get; }

Property Value

bool

LineGap

Additional line gap in 1/1000 em.

public override double LineGap { get; }

Property Value

double

Name

The PostScript name of the font.

public override string Name { get; }

Property Value

string

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

double

UnderlineThickness

Thickness of the underline in 1/1000 em, from the font's post table.

public override double UnderlineThickness { get; }

Property Value

double

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

codePoint int

Returns

bool

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

data byte[]

Content of a .ttf, .otf or .ttc file.

collectionIndex int

Index of the font inside a TrueType collection (.ttc).

ignoreLicenseRestrictions bool

Embed even if the font's license flags forbid it.

Returns

PdfTrueTypeFont

Exceptions

PdfException

The font's license does not permit embedding and ignoreLicenseRestrictions is 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

path string

Path of the font file.

collectionIndex int

Index of the font inside a TrueType collection (.ttc).

ignoreLicenseRestrictions bool

Embed even if the font's license flags forbid it.

Returns

PdfTrueTypeFont

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

stream Stream

Stream with the content of a .ttf, .otf or .ttc file.

collectionIndex int

Index of the font inside a TrueType collection (.ttc).

ignoreLicenseRestrictions bool

Embed even if the font's license flags forbid it.

Returns

PdfTrueTypeFont

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

codePoint int

Returns

double

GetKerning(int, int)

Kerning between two characters in 1/1000 em (negative = closer), 0 if none.

public override double GetKerning(int left, int right)

Parameters

left int
right int

Returns

double