Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args):
"""IconicFont Constructor.
Parameters
----------
``*args``: tuples
Each positional argument is a tuple of 3 or 4 values:
- The prefix string to be used when accessing a given font set,
- The ttf font filename,
- The json charmap filename,
- Optionally, the directory containing these files. When not
provided, the files will be looked for in ``./fonts/``.
"""
super(IconicFont, self).__init__()
self.painter = CharIconPainter()
self.painters = {}
self.fontname = {}
self.charmap = {}
self.icon_cache = {}
for fargs in args:
self.load_font(*fargs)
def _instance():
"""
Return the singleton instance of IconicFont.
Functions ``icon``, ``load_font``, ``charmap``, ``font`` and
``set_defaults`` all rebind to methods of the singleton instance of IconicFont.
"""
if _resource['iconic'] is None:
_resource['iconic'] = IconicFont(
('fa',
'fontawesome4.7-webfont.ttf',
'fontawesome4.7-webfont-charmap.json'),
('fa5',
'fontawesome5-regular-webfont.ttf',
'fontawesome5-regular-webfont-charmap.json'),
('fa5s',
'fontawesome5-solid-webfont.ttf',
'fontawesome5-solid-webfont-charmap.json'),
('fa5b',
'fontawesome5-brands-webfont.ttf',
'fontawesome5-brands-webfont-charmap.json'),
('ei', 'elusiveicons-webfont.ttf', 'elusiveicons-webfont-charmap.json'),
('mdi', 'materialdesignicons-webfont.ttf',
'materialdesignicons-webfont-charmap.json')
)
def __init__(self, *args):
"""IconicFont Constructor.
Parameters
----------
``*args``: tuples
Each positional argument is a tuple of 3 or 4 values:
- The prefix string to be used when accessing a given font set,
- The ttf font filename,
- The json charmap filename,
- Optionally, the directory containing these files. When not
provided, the files will be looked for in ``./fonts/``.
"""
super(IconicFont, self).__init__()
self.painter = CharIconPainter()
self.painters = {}
self.fontname = {}
self.charmap = {}
self.icon_cache = {}
for fargs in args:
self.load_font(*fargs)