I have a Maui app where I am successfully using custom fonts. However, in the Maui Toolkit Snackbar, setting the font is done with a font object, not the string for font family.
How can I load up a Font object from my custom font?
var snackbarOptions = new SnackbarOptions
{
// this is how you set the font according to samples
Font = Microsoft.Maui.Font.SystemFontOfSize(14),
// FontFamily is not valid. Custom fonts are usually set like this
FontFamily = "MyCustomFont"
};
I have a Maui app where I am successfully using custom fonts. However, in the Maui Toolkit Snackbar, setting the font is done with a font object, not the string for font family.
How can I load up a Font object from my custom font?
var snackbarOptions = new SnackbarOptions
{
// this is how you set the font according to samples
Font = Microsoft.Maui.Font.SystemFontOfSize(14),
// FontFamily is not valid. Custom fonts are usually set like this
FontFamily = "MyCustomFont"
};
Share
Improve this question
edited Mar 11 at 7:34
DarkBee
15.5k8 gold badges72 silver badges118 bronze badges
asked Mar 8 at 17:11
Mr WMr W
6761 gold badge9 silver badges25 bronze badges
2
- What platform did you target? – Liyun Zhang - MSFT Commented Mar 10 at 5:02
- iOS but that doesn't matter. this is a coding issue, not including the actual font resource – Mr W Commented Mar 10 at 15:54
2 Answers
Reset to default 0As you see:
// this is how you set the font according to samples Font = Microsoft.Maui.Font.SystemFontOfSize(14)
And I have check the source code about the Microsoft.Maui.Font, the font family is read-only. So you can set it as a custom font.
In addition, I also checked the source code about the ios platform snackbar. There is no override method can custom it.
You can open a feature request on the CommunityToolkit/Maui repo.
Found the solution:
Font = Font.OfSize("MyCustomFontName", 14),
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744890432a4599377.html
评论列表(0条)