qtawesome.load_font

qtawesome.load_font(prefix, ttf_filename, charmap_filename, directory=None)[source]

Loads a font file and the associated charmap.

If directory is passed, the files will be looked for in the qtawesome fonts directory.

Parameters:
  • prefix (str) – Prefix string to be used when accessing a given font set

  • ttf_filename (str) – Ttf font filename

  • charmap_filename (str) – Character map filename

  • directory (str or None, optional) – Directory path for font and charmap files

Example

If you want to load a font myicon.tff with a myicon-charmap.json charmap added to the qtawesome fonts directory (usually located at </path/to/lib/python>/site-packages/qtawesome/fonts/) you can use:

qta.load_font(
    'myicon',
    'myicon.ttf',
    'myicon-charmap.json'
)

However, if you want to load a font myicon.tff with a myicon-charmap.json charmap located in a specific path outside the qtawesome font directory like for example /path/to/myproject/fonts you can use:

qta.load_font(
    'myicon',
    'myicon.ttf',
    'myicon-charmap.json',
    directory='/path/to/myproject/fonts'
)