-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
FileNotFoundError on fonts due to Windows Font Blocking policy #264
Comments
Update... The virtual environment doesn't matter. The same error occurs with PySide6 and QtAwesome installed in the base Python's site-packages and the venv deactivated. |
Hey @wedgef5, thanks for reporting. Do you have permissions to write to this directory?
|
@ccordoba12 Yes. It is within my home directory. I also tried doing the entire install from an elevated CMD window, and it made no difference. None of the machines that I have installed on (including all of those that are working correctly) have the fonts in that path. |
One other factor worth noting: the machine where I'm having this problem is my work computer, and it is controlled by group policy from above. That said, I typically have great freedom within my own home directory and I do have admin access on the local machine. I have checked the "trusted fonts" setting as noted in #167 but that is not enabled on my machine. I do not know of any other setting that would cause the fonts to not be read from site-packages\qtawesome\fonts. |
I have determined that this issue is being caused by the Windows "untrusted font blocking" policy. In my case, however, it appears to be slightly different than what was addressed in #167. The Group Policy on my machine seems to not allow ANY fonts to be installed at all. I have some administrator access on my local machine, and I still can't do it. Even after copying the ttf files to %SystemRoot%\Fonts (which is supposed to be the location to put "trusted" fonts), the Install button in File Explorer is grayed out. If I try to right-click, Install, I get a message about the file not being a "valid" font file. My Windows Event Viewer is full of messages about the font installation being blocked. I think the reason I was getting the FileNotFoundException is due to this section of iconic_font.py in IconicFont._install_fonts()
When gdi32.AddFontResourceW() fails (due to the blocking policy), it returns zero. That causes the file to be removed from the user Font directory, then load_font() tries to open it. Should a separate issue be opened to more gracefully handle this case of font-blocking or perhaps just rename this issue? |
Thank you for the extra info @wedgef5 ! I think renaming this issue should be enough 👍 Also, do you have any suggestion regarding how we could improve the font-blocking case? Let us know! |
I have edited the subject of the bug to be a bit more descriptive. There are two possibilities I can think of to try and address this. In my case, I believe the font installation failed silently, so I had no idea what was going on, and I spent a lot of time trying to diagnose why I was getting the FileNotFoundError. Is there some way that a simple test could be added to the installation process such that the user would be alerted to this possibility? In my case, I can see no easy way to use the TTF files. I have started working on migrating the font usage in my application to use SVG files instead. Is there any appetite for including SVG versions of the fonts as a fallback? |
I have a PySide6 application using QtAwesome which has worked fine on every machine I have installed it on up until now. On this new machine, the application fails to start with a FileNotFoundError on fontawesome4-webfont-4.7.ttf. I have created a small test application, which exhibits the same problem...
The error I get is this...
I'm using a venv, which works on every other machine I've installed on. The fontawesome4-webfont-4.7.ttf file is not present on any of the machines in the AppData path in the traceback. It IS in .venv\Lib\site-packages\qtawesome\fonts on every machine, including the one on which the error is occurring.
This is on Windows 11 and Python 3.12.5 installed from the python.org installer.
The text was updated successfully, but these errors were encountered: