Font Class Documentation

class Font : SystemIDisposable

Namespace:Datalogics::PDFL

Inherits from:
SystemIDisposable

Detailed Description

Represents a font. Defines the typeface, size, style (bold, italic), Unicode values, and other details.

The Font class represents a font installed on the system.

Constructor & Destructor Documentation

Font

Font(string fontName)

Parameters

fontName: string

the name of the font to find and create

Find a font with the specified name, and construct a Font object from it.

Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.

When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.

PDFL enforces the following requirements on fonts:

• TrueTypes used as CID fonts must be embedded.

• All CID fonts that are embedded must be subsetted.

• CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).

Exceptions

BadInput
—

A font with the specified name could not be found.

Font

Font(string fontName, FontCreateFlags createFlags)

Parameters

fontName: string

the name of the font to create

createFlags: FontCreateFlags

flags specifying embedding and other options for the use of a font in the document

Find a font with the specified name, and construct a Font object from it.

Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.

When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.

PDFL enforces the following requirements on fonts:

• TrueTypes used as CID fonts must be embedded.

• All CID fonts that are embedded must be subsetted.

• CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).

Exceptions

BadInput
—

A font with the specified name could not be found.

Font

Font(string fontName, FontCreateFlags createFlags, WritingMode wrMode)

Parameters

fontName: string

the name of the font to create

createFlags: FontCreateFlags

flags specifying embedding and other options for the use of a font in the document

wrMode: WritingMode

determines whether text will be printed horizontally or vertically

Find a font with the specified name, and construct a Font object from it.

Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.

When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H or Identity-V encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.

PDFL enforces the following requirements on fonts:

• TrueTypes used as CID fonts must be embedded.

• All CID fonts that are embedded must be subsetted.

• CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).

Exceptions

BadInput
—

A font with the specified name could not be found.

Property Documentation

Ascent

double Ascent[get]

the Ascent value from the font descriptor. This is the maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.

AvgWidth

double AvgWidth[get]

the AvgWidth value from the font descriptor. This is the average width of glyphs in the font, or 0 if the value is not defined in the font descriptor.

BBox

Rect BBox[get]

The Bounding Box rectangle of the font.

CapHeight

double CapHeight[get]

the CapHeight value from the font descriptor. This is the vertical coordinate of the top of flat capital letters, measured from the baseline, or 0 if the value is not defined in the font descriptor.

CidFontType

string CidFontType[get]

Get the CID font type of the font.

Descent

double Descent[get]

the Descent value from the font descriptor. This is the maximum depth below the baseline reached by glyphs in this font. The value is a negative number.

Embedded

bool Embedded[get]

Tests whether the font is embedded in the document it was created for.

Encoding

string Encoding[get]

Return the encoding of the font.

For a font created from a system font by name, this is the encoding PDFL gives the font when it is written to a document: WinAnsiEncoding on Windows and Linux, MacRomanEncoding on macOS, or Identity-H/V for a Type0 font. Symbolic fonts (Symbol, ZapfDingbats, Wingdings) use their own built-in encoding and return an empty string.

EncodingInfo

EncodingInfo EncodingInfo[get]

Get the populated CEncodingInfo object.

Flags

FontFlags Flags[get]

Get the font flags for a font.

FontList

static System.Collections.Generic.IList< Font > FontList[get]

FullName

string FullName[get]

Get the Full Name of the font.

GlyphWidths

System.Collections.Generic.IList< System.Double > GlyphWidths[get]

Retrieve the glyph width table for the font's single-byte encoding.

Returns the 256-entry glyph advance table in character-space units (1000 units per em). For the user-space width of character code c at font sizes:widths[c] * s / 1000.0.

The returned vector always has 256 entries; positions outside the font's defined encoding are filled with whatever advance the font reports for unmapped codes (typically zero or the missing-glyph advance). This API is therefore only meaningful for simple single-byte fonts — Type 1, TrueType with a simple encoding, etc. CID / Type 0 fonts need per-glyph measurement via MeasureTextWidth instead.

ItalicAngle

double ItalicAngle[get]

the ItalicAngle value from the font descriptor. This is the angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font, defined in the font descriptor.

Leading

double Leading[get]

the Leading value from the font descriptor. This is the spacing between baselines of consecutive lines of text, or 0 if the value is not defined in the font descriptor.

MaxWidth

double MaxWidth[get]

the MaxWidth value from the font descriptor. This is the maximum glyph width present in the font, or 0 if the value is not defined in the font descriptor.

MissingWidth

double MissingWidth[get]

the MissingWidth value from the font descriptor. This is the width given to characters that do not have corresponding glyphs defined in the font, or 0 if the value is not defined in the font descriptor.

Name

string Name[get]

Get the name of the font.

PDFDict

PDFDict PDFDict[get]

Retrieve the PDFDict representation of this font.

StemH

double StemH[get]

the StemH value from the font descriptor. This is the vertical thickness of the dominant horizontal stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.

StemV

double StemV[get]

the StemV value from the font descriptor. This is the horizontal thickness of the dominant vertical stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.

Type

string Type[get]

Get the type of the font.

WritingMode

WritingMode WritingMode[get]

Get the writing mode of the font. The writing mode of the fontwhether it will place glyphs horizontally or vertically. Text written with this font will run in the direction of the writing mode

.

XHeight

double XHeight[get]

the XHeight value from the font descriptor. This is the vertical coordinate of the top of flat nonascending lowercase letters in fonts that have Latin characters, as measured from the baseline, or 0 if the value is not defined in the font descriptor.

Member Function Documentation

Dispose

void Dispose()

Returns:

void

EmbedNow

void EmbedNow(Document doc)

Parameters

doc: Document

the Document the Font is embedded into

Returns:

void

Embeds the Font.

FindIndexOfFirstUnrepresentableChar

uint FindIndexOfFirstUnrepresentableChar(string text)

Parameters

text: string

the text to check

Returns:

uint

The index of the first character that cannot be represented in this font.

Find the index of the first character that cannot be represented in this font. This will return the index of the first character in the string for which the font has no glyph. If all characters can be represented (i.e. if IsTextRepresentable() would return true), this will return the length of the string.

IsFromDoc

bool IsFromDoc()

Returns:

bool

true if the font was loaded from a document, false if it was created from a system font.

Determine whether this font was obtained from an existing document rather than the system.

IsTextRepresentable

bool IsTextRepresentable(string text)

Parameters

text: string

the text to check

Returns:

bool

true if all characters in the text have corresponding glyphs in this font.

Is this text representable in this font?

MeasureTextWidth

double MeasureTextWidth(string text, double fontSize)

Parameters

text: string

the Text to be measured

fontSize: double

the Font size to be used

Returns:

double

The width of the text in points.

Measures the width of the specified text in points, using the Font at the specified size.