MemoryFontSource constructor

MemoryFontSource(font_data)

Ctor.

def __init__(self, font_data: bytes):
    ...
ParameterTypeDescription
font_databytesBinary font data.

MemoryFontSource(font_data, priority)

Ctor.

def __init__(self, font_data: bytes, priority: int):
    ...
ParameterTypeDescription
font_databytesBinary font data.
priorityintFont source priority. See the FontSourceBase.priority property description for more information.

MemoryFontSource(font_data, priority, cache_key)

Ctor.

def __init__(self, font_data: bytes, priority: int, cache_key: str):
    ...
ParameterTypeDescription
font_databytesBinary font data.
priorityintFont source priority. See the FontSourceBase.priority property description for more information.
cache_keystrThe key of this source in the cache. See MemoryFontSource.cache_key property description for more information.

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