Skip to content

PdfFont class

View as Markdown

Namespace: PdfNetStack.Fonts
Assembly: PdfNetStack.dll
Package: PdfNetStack

A font for drawing text. Font size is given when drawing, so one instance serves every size. Vertical metrics are fractions of the font size: multiply by the size in points to get points.

public abstract class PdfFont

Inheritance

object ← PdfFont

Derived

PdfOpenTypeFont, PdfStandardFont

Use PdfStandardFont for the 14 fonts every PDF viewer has. A font is written into a document the first time text is drawn with it, once per document, and is safe to share between documents and threads.

Height above the baseline used for line spacing.

public double Ascent { get; }

double

Height of flat capital letters such as H.

public double CapHeight { get; }

double

Depth below the baseline used for line spacing, as a positive number.

public double Descent { get; }

double

Family name, such as “Helvetica”.

public abstract string FamilyName { get; }

string

True for bold and heavier weights.

public abstract bool IsBold { get; }

bool

True for italic and oblique styles.

public abstract bool IsItalic { get; }

bool

Slant in degrees, counterclockwise from vertical; negative for fonts leaning right.

public double ItalicAngle { get; }

double

Extra space the font designer recommends between lines.

public double LineGap { get; }

double

PostScript name, as written to /BaseFont.

public abstract string Name { get; }

string

Height of the middle of a strikethrough line above the baseline.

public double StrikeoutPosition { get; }

double

Strikethrough stroke thickness.

public double StrikeoutThickness { get; }

double

Distance from the baseline down to the middle of an underline.

public double UnderlinePosition { get; }

double

Underline stroke thickness.

public double UnderlineThickness { get; }

double

Height of flat lowercase letters such as x.

public double XHeight { get; }

double

True when every character of text can be drawn: the font has a glyph for it (directly, or for OpenType fonts after Unicode normalization: decomposed, composed with the marks before it, or a space drawn with the font’s space), or it is an invisible control or format character, which drawing skips.

public bool CanRender(string text)

text string

bool

Default line height for size: ascent, descent and line gap, in points.

public double GetLineHeight(double size)

size double

double

True when the font has a glyph for the Unicode code point.

public bool HasGlyph(int codePoint)

codePoint int

bool

Width of text drawn on one line at size, in points.

public double MeasureString(string text, double size)

text string

size double

double

ArgumentException

The font has no glyph for a character of the text.

Returns a string that represents the current object.

public override string ToString()

string

A string that represents the current object.