Use canvas.DrawString and set canvas.Font , It work well on ios but not display right on android and windows.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp2.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Label x:Name="labFont" HorizontalOptions="Center"/>
<GraphicsView x:Name="graFont" HeightRequest="100" WidthRequest="100"/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
labFont.FontFamily = "zSign004";
labFont.FontSize = 50;
labFont.Text = "\u0049";
graFont.Drawable = new FontDrawable();
}
}
internal class FontDrawable : IDrawable
{
public void Draw(ICanvas canvas, RectF dirtyRect)
{
canvas.FontColor = Colors.Black;
canvas.FontSize = 50;
canvas.Font = new Microsoft.Maui.Graphics.Font("zSign004");
canvas.DrawString("\u0049", 0, 0, dirtyRect.Width, dirtyRect.Height, HorizontalAlignment.Center, VerticalAlignment.Center);
}
}
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("zSign004.ttf", "zSign004");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
If you set font OpenSans-Semibold and canvas.drawstring some string ,it will display nobold on android and windows, ios is ok.