Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion on the implementation of NamedSize fonts in Core #3938

Open
hartez opened this issue Jan 4, 2022 · 4 comments
Open

Discussion on the implementation of NamedSize fonts in Core #3938

hartez opened this issue Jan 4, 2022 · 4 comments
Labels
area-fonts Custom fonts and Font related API's Task neither bug nor feature but something that needs to be done in support of either
Milestone

Comments

@hartez
Copy link
Contributor

hartez commented Jan 4, 2022

Based on the discussions here:

And the work here:

We now in a place that both needs and does not need NamedSize...

The original design offered 2 features: font scaling and a special meaning to the OS

Font Scaling

Status: improved and complete

The NamedSize concept used to be the only way to get scaled font sizes, but now it is built into the Core Font using the AutoScalingEnabled property or WithAutoScaling method. This is exposed at the Controls layer with a bunch of FontAutoScalingEnabled bindable properties on many of the controls that display text.

The default value of FontAutoScalingEnabled is true which means that the font is scaled when a11y values are changed. So if the UI scaling is 2x and the font size is 12, then the actual rendered size is 24.

This can be disabled by setting FontAutoScalingEnabled to `false":

<Label Text="Hello Scaled World!"
       FontSize="12"
       FontAutoScalingEnabled="false" />

Special Meaning

Status: under discussion

The other value that the NamedSize values offered was for special OS meanings. However, this was often deceiving because it was a first-run thing and then fell apart. At XAML parse time, they are translated into a double with no idea that they were special values. Thus, they never did respond to OS changes. Once set, they are just a number and nothing special.

If we want to actually expose those values to the user, we can maybe use a "stringly-typed enum" to allow for supporting the other values on the system. For example, we only had Title1, but there is also a Title2 and Title3.

@Eilon Eilon added the area-fonts Custom fonts and Font related API's label Feb 10, 2022
@mattleibow mattleibow added this to the .NET 7 milestone Apr 26, 2022
@mattleibow mattleibow changed the title Do we want to keep the concept of NamedSize Fonts at the MAUI Core level? If so, do we want to make any design changes (allowing custom values, etc.) Discussion on the implementation of NamedSize fonts in Core Apr 26, 2022
@mattleibow
Copy link
Member

There was a discussion sort of starting here by @GalaxiaGuy: #831 (comment)

There are few extra features around this I would like support for (some of these are Forms-y and some Essentials-y but I guess they all go here now?):

  • Text that isn't scaled, regardless of device setting.
  • Scale an arbitrary size in the same way as font size.

(Of the two, I've used the second more often - think something like sizing the image of a custom radio button).

  • Query the current accessible font scaling details.
  • A notification when it changes.

For the points:

  1. "Text that isn't scaled"
    This is now implemented via the FontAutoScalingEnabled property.
  2. "Scale an arbitrary size"
    Not quite sure what this means. Are you expecting to set a FontSize of 12 and then also have a FontScaling be a 3 and thus result in a true font size of 36? This might actually be better set using a converter? @StephaneDelcroix do we support some dynamic resource as a converter parameter? That could be used as a way to set a size and then bind to some scaling - or the reverse.
  3. "Query the current accessible font scaling"
    @PureWeen @rachelkang do we have some feature like this already? Somehow feels familiar yet distant...
  4. "A notification when it changes"
    This probably goes after the implementation of the previous point. I wonder if the Microsoft.Maui.Devices.DisplayInfo.MainDisplayInfoChanged event fires if scaling changed... That might be useful with the scaling value, however it is actually related to monitor scaling more. This needs more investigation if we implement the previous point.

@rachelkang
Copy link
Member

To my knowledge, we don't currently have anything beyond FontAutoScalingEnabled to query for font scaling!

@GalaxiaGuy
Copy link
Contributor

Regarding point 2:

I mean the inverse of point 1. The ability to set something that is sized in the same way the font scales. i.e. using sp on Android for something that isn't a font. The places I've use this are for things that need to be sized relative to font size.

At the moment in Forms I'm using custom markup extension to do it.

@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@samhouts samhouts added the Task neither bug nor feature but something that needs to be done in support of either label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-fonts Custom fonts and Font related API's Task neither bug nor feature but something that needs to be done in support of either
Projects
None yet
Development

No branches or pull requests

7 participants