Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected corruption check when qta.load_font() with same ttf_filename as bundled #196

Closed
kumattau opened this issue Dec 18, 2021 · 0 comments · Fixed by #197
Closed

Unexpected corruption check when qta.load_font() with same ttf_filename as bundled #196

kumattau opened this issue Dec 18, 2021 · 0 comments · Fixed by #197
Assignees
Labels
Milestone

Comments

@kumattau
Copy link
Contributor

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'
@kumattau kumattau changed the title Unexpected corruption check when qta.load() with same ttf_filename as bundled Unexpected corruption check when qta.load_font() with same ttf_filename as bundled Dec 19, 2021
@dalthviz dalthviz added this to the v1.2.0 milestone Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants