FontSourceBase class

FontSourceBase class

This is an abstract base class for the classes that allow the user to specify various font sources. To learn more, visit the Working with Fonts documentation article.

Properties

NameDescription
priorityReturns the font source priority.
typeReturns the type of the font source.
warning_callbackCalled during processing of font source when an issue is detected that might result in formatting fidelity loss.

Methods

NameDescription
as_file_font_source()Cast FontSourceBase object to FileFontSource.
as_folder_font_source()Cast FontSourceBase object to FolderFontSource.
as_memory_font_source()Cast FontSourceBase object to MemoryFontSource.
as_stream_font_source()Cast FontSourceBase object to StreamFontSource.
as_system_font_source()Cast FontSourceBase object to SystemFontSource.
get_available_fonts()Returns list of fonts available via this source.

Examples

Shows how to use a font file in the local file system as a font source.

file_font_source = aw.fonts.FileFontSource(file_path=MY_DIR + 'Alte DIN 1451 Mittelschrift.ttf', priority=0)
doc = aw.Document()
doc.font_settings = aw.fonts.FontSettings()
doc.font_settings.set_fonts_sources(sources=[file_font_source])
self.assertEqual(MY_DIR + 'Alte DIN 1451 Mittelschrift.ttf', file_font_source.file_path)
self.assertEqual(aw.fonts.FontSourceType.FONT_FILE, file_font_source.type)
self.assertEqual(0, file_font_source.priority)

See Also