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

PR: Return original font directory when font user installation load fails #273

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion qtawesome/iconic_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,28 @@ def _install_fonts(self, fonts_directory, system_wide=False):
# Possible permission error when trying to remove
# a font which potentially is already in use
# See spyder-ide/qtawesome#236
continue
pass
# Regardless whether the font file is actually removed,
# we need to return here where the font file is
# originally located since the load failed. With that,
# a `FontError` can be eventually raised with useful
# information (i.e not being able to load bundled
# fonts, saying that the fonts are located in the
# QtAwesome `fonts` directory and manual configuration
# is needed to allow them). Also, if we don't detected
# that the font being available from the system fonts
# directory, a warning with a more specific suggestion
# (i.e. to install the font manually) is shown.
# See spyder-ide/qtawesome#264
if not os.path.isfile(os.path.join(system_fonts_dir, filename)):
warnings.warn(
"Font at '{0}' could not be loaded. If "
"possible, install it system wide to make it "
"available to QtAwesome. The source file to "
"be manually installed can be found at "
"'{1}'".format(dst_path, src_path)
)
return fonts_directory

# Store the fontname/filename in the registry
fontname = os.path.splitext(filename)[0]
Expand Down
Loading