xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

setting FontSize of Label produces wrong size on Android when system font size is set to large #15713

Open tbambuch opened 1 year ago

tbambuch commented 1 year ago

Description

If you change the Label.FontSize by a tiny coeficient (eg you multiply it by 0.99d), the very different font size is actually produced on Android when the system is set to use large font size. This is because:

Seems that the issue is in ToScaledPixel() when it returns the FontSize, because FontSize is not supposed to be a scaled pixel, it is a device - independent size, and thus it gets scaled twice

Steps to Reproduce

  1. Set Android to use the largest font possible
  2. Create a Label, do not specify font size
  3. Create a second Label, with FontSize *= 0.99d

Expected Behavior

the label size to be the same (or, to be precise, differ by 0.01dp)

Actual Behavior

the Label size is different

Basic Information

Environment

Show/Hide Visual Studio info ``` ```

Build Logs

Screenshots

image

Reproduction Link

Workaround

FontSizeTest.zip

tbambuch commented 1 year ago

this seems to be related to https://github.com/xamarin/Xamarin.Forms/issues/2168, which is still present in XF5