MartinTopfstedt/FontAwesome6

WPF Icons do not display unless fonts are in temp/. Fonts being in temp/6.1.2/ does not work.

Closed this issue · 4 comments

Fresh install - ensure there are NO font awesome fonts in your %temp% folder.

image

Run a project with a simple UI as above that uses some icons. The icons do not display:
image

Now copy the fonts from %temp%/6.1.2/ into %temp% (main temp folder). Re run the application and it works:
image

I tried to fix this myself, I though this was due to this change: 3d2d307

But I cannot seem to fix it. I changed the code so that the base URI for the font families is %temp%/6.1.2/ rather than just %temp%, but it still only works when the font files are in %temp%. Not sure from where those files are being loaded.

Any help appreciated.

Hi, you are right, this is a bug, i fixed it and will provide v2.4.1 with a fix.

Hmm, before I opened this issue I tried to fix the issue myself. I cloned the source and I made those exact changes in your commit, but it still didn't work for me. It only loaded the fonts when they were in the temp folder. I have no idea why that was happening.

Did you test this and confirm the fix worked? If so that's great but I just couldn't get it working locally for me :(

I can confirm this still does not fix the issue. The font family constructor gets passed a uri: %temp%/6.1.2. It appears that because there is not trailing /, it treats 6.1.2 as a file, not a folder in which to find the fonts. As such, it uses the parent directory (%temp%) as the base uri for the fonts - which it then cannot find.

Changing LoadAllStyles(path); to LoadAllStyles(path + Path.DirectorySeparatorChar); fixes the issue for me. Or alternatively var path = Path.Combine(Path.GetTempPath(), FontAwesomeInfo.Version) + Path.DirectorySeparatorChar;

This was not an issue before because Path.GetTempPath() returns a path to a directory - i.e. it has the trailing slash. See https://learn.microsoft.com/en-us/dotnet/api/system.io.path.gettemppath?view=net-7.0&tabs=windows#returns

The path to the temporary folder, ending with a DirectorySeparatorChar.

Hi, you are completely right. I added your fix and will release a new bug fix. Sorry for not testing it earlier.