## Setting font size of Label to exactly 12 (WinRT) or 15 (UWP) results in much larger font

_Submitted by a community member on 2016-07-13 13:26 UTC_

In Xamarin.Forms Windows PCL project, if I set FontSize of Label to exactly 12 (WinRT) or 15 (UWP), which is what  Device.GetNamedSize(NamedSize.Default, typeof(Label)) returns, the rendered font size is much larger, even larger than of label with font size +1.

Looking into Xamarin.Forms code on git (<https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.WinRT/LabelRenderer.cs> and <https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.WinRT/FontExtensions.cs>) it seems the font is recognized as default, but than font size of medium is used, which is much larger.
On iOS and Android default font size is the same as medium.

Example code:

var stack = new StackLayout()
{
```
    Orientation = StackOrientation.Vertical
```

};

for (var i = -4; i \< 4; i++) { stack.Children.Add(new Label() { Text = "font size " + (Device.GetNamedSize(NamedSize.Default, typeof(Label)) + i), FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)) + i }); };

* * *

_Xamarin Bugzilla comment 1 by a community member on 2016-07-13 13:26 UTC_

Created attachment 16647
font size on UWP

* * *

_Xamarin Bugzilla comment 2 by Samantha Houts [MSFT] [MSFT] on 2016-07-13 22:07 UTC_


I don't see the same behavior when I try this locally. I've used my local machine and the mobile emulators to test it, and it seems to be the correct size for both UWP and WinRT. Have the default font sizes on your device been changed?

* * *

_Xamarin Bugzilla comment 3 by a community member on 2016-07-14 07:51 UTC_

You are right, we set different font size in platform page xaml:
FontSize="{StaticResource TextStyleLargeFontSize}" 
Sorry I haven't mentioned it before.

Even thought I think this behavior is not correct.

* * *

_Xamarin Bugzilla comment 4 by Samantha Houts [MSFT] [MSFT] on 2016-07-19 16:56 UTC_

Thank you for the clarification!

* * *

_Xamarin Bugzilla comment 5 by a community member on 2017-02-17 23:02 UTC_

Is there a fix/workaround to ensure that a font size of 15 does not appear larger than a font size of 16?

It appears that a font size of 15 actually renders the same as size 23 in a UWP Windows desktop app.  This is an even bigger discrepancy than is visible with the mobile app, where it looks like 15 is more like 18, according to Tom's attachment 16657.

I created a dynamic font sizer that determines the appropriate font size to fit in an area and when it hits 15, my layout can break since the font is larger than my calculations expect.

* * *

_Xamarin Bugzilla comment 6 by a community member on 2017-02-17 23:16 UTC_

It appears that a font size of 15 actually renders the same as size 23 in a UWP Windows desktop app.  This is an even bigger discrepancy than is visible with the mobile app, where it looks like 15 is more like 18, according to Tom's attachment 16657.

I created a dynamic font sizer that determines the appropriate font size to fit in an area and when it hits 15, my layout can break since the font is larger than my calculations expect.

Luckily, I found an easy workaround for this.  Don't use integer values.  As long as it's not exactly 12 or exactly 15, the "font bloating" won't happen.  For instance, use 12.01 or 15.01 instead.

* * *

_Xamarin Bugzilla comment 7 by a community member on 2017-02-17 23:18 UTC_

Sorry for the double post!  I misunderstood the comment conflict resolution options.  I would delete my earlier post (Comment 5) if I could (and if someone else can, feel free to delete that one and this one, too.)

* * *

<br />

_Reference: <https://bugzilla.xamarin.com/show_bug.cgi?id=42517>_