set_font_sources method

set_font_sources

Sets the sources to look for TrueType fonts when rendering documents.

The method accepts any combination of individual IFontSource objects, lists of them, or a mixture of both; all inputs are flattened into a single list before being applied. String paths are passed through as‑is and are not split into characters.

def set_font_sources(cls, font_sources):
    ...
Parameter Type Description
font_sources list[IFontSource] The font sources.
Raises Description
ValueError When font_sources is None.

Example

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

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

# varargs
FontSettings.set_font_sources(src1, src2)
# single list
FontSettings.set_font_sources([src1, src2])
# multiple lists (flattened)
FontSettings.set_font_sources([src1], [src2])
# mixed — also flattened
FontSettings.set_font_sources([src1, src2], src2)

See Also