dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.71k forks source link

Variable font support #16604

Open hansmbakker opened 1 year ago

hansmbakker commented 1 year ago

Description

I would like to consume variable fonts in .NET MAUI.

Public API Changes

It would be nice to have an overload of the current font loading API that takes a dictionary of variation settings to define labeled combinations.

var variationSettingsA = new Dictionary<string, double>()
{
    { "wght", 700d},
    { "ital", 0d }
};

var variationSettingsB = new Dictionary<string, double>()
{
    { "wght", 300d},
    { "ital", 1d }
};

builder.ConfigureFonts(
            fonts =>
            {
                fonts.AddFont(filename: "myVariableFont.otf", label: "FontVariationA", variationSettings: variationSettingsA);
                fonts.AddFont(filename: "myVariableFont.otf", label: "FontVariationB", variationSettings: variationSettingsB);
            });

Intended Use-Case

One of the things this is needed for, is to use the Material Symbols, which are shipped as variable fonts. Besides these Material Symbols, supporting variable fonts allows app developers to have more flexibility with their typography in general.

⚠️ Note: the fixed fonts elsewhere in the linked repo are the legacy Material Icons, not the newer Material Symbols I want to use

hansmbakker commented 1 year ago

The manual workaround for this now seems to be using the mutator tool from fontTools.

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.