Discussion on the implementation of `NamedSize` fonts in Core
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 297
Description
Based on the discussions here:
- https://github.com/dotnet/maui/issues/831
And the work here:
- https://github.com/dotnet/maui/pull/5088
- https://github.com/dotnet/maui/pull/1774
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":
```xaml
```
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.