__init__ constructor

On this page

init

Initializes a new instance of FolderFontSource.

def __init__(self, folder_path, search_option):
    ...
Parameter Type Description
folder_path str Path to the folder that contains TrueType fonts.
search_option SearchOption Specifies whether to search the current folder only or the current folder and all sub‑folders.
Raises Description
ValueError If folder_path is None.
FileNotFoundError If the path specified in folder_path cannot be located.

Example

from groupdocs.viewer.fonts import FolderFontSource, SearchOption, FontSettings

src1 = FolderFontSource("C:/fonts/primary", SearchOption.ALL_FOLDERS)
src2 = FolderFontSource("C:/fonts/backup", SearchOption.TOP_FOLDER_ONLY)

# Register the font sources for rendering
FontSettings.set_font_sources(src1, src2)

# When done, reset to avoid leaking sources
FontSettings.reset_font_sources()

See Also

On this page