qta.load_font() checks corruption using ttf_filename as a key.
So, when users execute qta.load_font() with same ttf_filename as bundled,
the ttf binary is checked unexpectedly and raise exception if the ttf binary is different from the bundled.
This makes the use of newer font than bundled by users difficult.
# -*- coding: utf-8 -*-
import sys
from qtpy import QtWidgets, QtCore
import qtawesome as qta
class AwesomeExample(QtWidgets.QDialog):
def __init__(self):
super().__init__()
# same ttf_filename as bundled
qta.load_font("new_msc", "codicon.ttf", "codicon-charmap.json", directory="./fonts/")
icon = qta.icon("new_msc.verified-filled")
button = QtWidgets.QPushButton(icon, "New Codicon Icon")
grid = QtWidgets.QGridLayout()
grid.addWidget(button, 0, 0)
self.setLayout(grid)
self.setWindowTitle('Awesome')
self.show()
def main():
app = QtWidgets.QApplication(sys.argv)
QtCore.QTimer.singleShot(10000, app.exit)
_ = AwesomeExample()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
$ python test.py
Traceback (most recent call last):
File "test.py", line 29, in <module>
main()
File "test.py", line 25, in main
_ = AwesomeExample()
File "test.py", line 11, in __init__
qta.load_font("new_msc", "codicon.ttf", "codicon-charmap.json", directory="./fonts/")
File "/home/.local/lib/python3.8/site-packages/qtawesome/__init__.py", line 216, in load_font
return _instance().load_font(prefix, ttf_filename, charmap_filename, directory)
File "/home/.local/lib/python3.8/site-packages/qtawesome/iconic_font.py", line 317, in load_font
raise FontError(u"Font is corrupt at: '{0}'".format(
qtawesome.iconic_font.FontError: Font is corrupt at: './fonts/codicon.ttf'
qta.load_font() checks corruption using ttf_filename as a key. So, when users execute qta.load_font() with same ttf_filename as bundled, the ttf binary is checked unexpectedly and raise exception if the ttf binary is different from the bundled. This makes the use of newer font than bundled by users difficult.