MemoryFontSource class

MemoryFontSource class

Represents the single TrueType font file stored in memory. To learn more, visit the Working with Fonts documentation article.

Inheritance: MemoryFontSourceFontSourceBase

Constructors

NameDescription
MemoryFontSource(font_data)Ctor.
MemoryFontSource(font_data, priority)Ctor.
MemoryFontSource(font_data, priority, cache_key)Ctor.

Properties

NameDescription
cache_keyThe key of this source in the cache.
font_dataBinary font data.
priorityReturns the font source priority.
(Inherited from FontSourceBase)
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.
(Inherited from FontSourceBase)

Methods

NameDescription
get_available_fonts()Returns list of fonts available via this source.
(Inherited from FontSourceBase)

Examples

Shows how to use a byte array with data from a font file as a font source.

with open(MY_DIR + "Alte DIN 1451 Mittelschrift.ttf", "rb") as file:
    font_bytes = file.read()

memory_font_source = aw.fonts.MemoryFontSource(font_bytes, 0)

doc = aw.Document()
doc.font_settings = aw.fonts.FontSettings()
doc.font_settings.set_fonts_sources([memory_font_source])

self.assertEqual(aw.fonts.FontSourceType.MEMORY_FONT, memory_font_source.type)
self.assertEqual(0, memory_font_source.priority)

See Also