AddFallbackFont

Description

Adds a fallback font.

The fallback font will not take effect if no main font is specified via the SetFont function or font property. See Usage below for more details.

Applies to

PDFTableOfContents object

PDFTableOfContentsItem object

PDFText object

PDFTextBlock object

PDFMultiLineText object

Syntax

AddFallbackFont (string fontName)

Argument

Description

fontName

The name of the font you want to add.


Return value

None.

Usage

PDF Builder supports two types of fonts: the main font and the fallback font. The main font is specified through the SetFont function or font property, while the fallback font is added through the AddFallbackFont function.

The fallback font is used to address the issue of displaying multiple languages in a text where the main font may not be sufficient. In such cases, certain language characters may disappear or be displayed as unrecognizable symbols in the generated PDF file. By setting a fallback font, the PDF generation process can automatically select the fallback font to render the text that cannot be displayed using the main font, thus resolving the issue of text rendering. However, it is possible that the text display may still not fully meet the requirement even with a fallback font. In such cases, adjustments can be made by changing the order of font addition or replacing the main font.

Additionally, PDF Builder supports automatically matching and using system fonts for multilingual text rendering. If no main font is specified (where all fallback fonts will be ignored), the automatic font matching feature will be enabled, and PDF Builder will retrieve all fonts installed on the system and determine the best-matching one(s) to use for text rendering.

Examples

This example adds the Microsoft YaHei font for displaying the Chinese characters.

lpdf_toc.addfallbackfont( "Microsoft YaHei")

See also

AddFallbackFont

GetFallbackFontCount

GetFallbackFont

RemoveFallbackFont

RemoveAllFallbackFont

GetFont

SetFont