[Windows] Some icon fonts not working in unpacked apps
GuidoNeele opened this issue ยท 11 comments
Description
Some icon fonts are not working in unpacked apps when using them with FontImageSource. They do work when they are used with labels.
The icon fonts I tested:
- Font awesome (doesn't work)
- ionicons (works)
- MaterialIcons (doesn't work)
<Button x:Name="CounterBtn"
Clicked="OnCounterClicked"
FontFamily="OpenSansSemibold"
HorizontalOptions="Fill"
ImageSource="{FontImage ,
FontFamily=FontAwesome,
Color=White}"
SemanticProperties.Hint="Counts the number of times you click"
Text="Click me" />
<Button Clicked="OnCounterClicked"
FontFamily="OpenSansSemibold"
HorizontalOptions="Fill"
ImageSource="{FontImage ,
FontFamily=ionicons,
Size=44}"
SemanticProperties.Hint="Counts the number of times you click"
Text="Click me" />
<Button Clicked="OnCounterClicked"
FontFamily="OpenSansSemibold"
HorizontalOptions="Fill"
ImageSource="{FontImage Glyph=,
FontFamily=MaterialIcons,
Size=44}"
SemanticProperties.Hint="Counts the number of times you click"
Text="Click me" />
Steps to Reproduce
- Download attached reproduction repository
- Open solution
- Build SharedLib as Release
- Build MauiIconTest as Release
- Go to <repository_path>\MauiIconTest\bin\Release\net8.0-windows10.0.19041.0\win10-x64\
- Start MauiIconTest.exe
OR
- Start a new MAUI project
- Add FontAwesome font to Resources/Fonts directory
- Add font to MauiProgram.cs
.ConfigureFonts(fonts =>
{
fonts.AddFont("FontAwesome.ttf", "FontAwesome");
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
- Add the following lines to csproj
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>
- Add button to MainPage
<Button Clicked="OnCounterClicked"
HorizontalOptions="Fill"
ImageSource="{FontImage ,
FontFamily=FontAwesome,
Size=44}"
SemanticProperties.Hint="Counts the number of times you click"
Text="FontAwesome" />
- Build application and run it.
Link to public reproduction project repository
https://github.com/GuidoNeele/MauiIconTest
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
No, this is something new, Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
net8.0-windows10.0.19041.0
Did you find any workaround?
No didn't find a workaround.
A workaround could be to use a different icon font than FontAwesome because ionicons does work.
Relevant log output
No response
Can repro this issue at Windows platform on the latest 17.10 Preview 4(8.0.20)
I see material icons is a .otf
file, so that may not be supported - but I need to confirm. Was there anything in the logs?
I wonder if I have an issue in my targets file that is preventing something - I will have a look.
No it's not a problem with the targets file. If you move all fonts over to the Maui app, you'll get the same result. I just wanted to try out your targets file ๐
OK, I managed to repro this, I have no idea why it is failing as there are no errors in the logs:
I will; have a look and try debug.
@rmarinho I think I recall you saying that you had an issue with FontAwesome in your app?
There are no errors in maui, so for some reason Win2D just does not draw the right thing. I'll log an issue with that team.
I'm fairly sure this is essentially the same issue that #21333 was except the title is more accurate in this issue here. I've had the same issue with materialdesignicons-webfont.ttf
and I had hoped #21144 would fix the issue for me but it didn't. I tried converting the font into a few different font file formats but nothing worked. After PR #21144 I don't get any errors any more when running the app and wasn't able to find any useful logs to hint what might be going wrong.
/similarissues
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Open similar issues:
- FontImage not working as an IconImageSource for ToolbarItem on Windows. Regular image format works. (#19695), similarity score: 0.80
- [iOS] TabBar Icons not showing when using FontIconSource for Tab.Icon (#10350), similarity score: 0.79
Closed similar issues:
- [WinUI] Image with FontImageSource is not displayed properly when using a custom font in an unpackaged app (#19608), similarity score: 0.82
- FontFamily is Not Recognized in UnPackaged WinUI App (#19457), similarity score: 0.79
- In RC1, FontImageSource does not work on Image.Source (#5859), similarity score: 0.79
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
I figured out the issue. The font name had spaces and the Uri was encoding things.
Just tried the nightly and fix #22646 indeed solved this issue.
Thanks @mattleibow!
8.0.60 this appears to be fixed for me with material design icons. Thank you :)