On iOS named fontsizes are calculated incorrectly usually resulting in 1 point less than expected.
var result = new FontSizeConverter().ConvertFromInvariantString(nameof(NamedSize.Micro));
NamedSize.Micro should return 12 with default settings
Returns 11
I think the issue lies in https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Forms.cs
The font scaling factor is calculated on line 188 like this.
_fontScalingFactor = (double)UIFont.PreferredBody.PointSize / 18f;
I think it should be :
_fontScalingFactor = (double)UIFont.PreferredBody.PointSize / 17f;
Why?
The default UIFont.PreferredBody.PointSize is 17 on my emulator iPhone 7 iOS 12.2.
Also on the Apple guidelines https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography/
It states that the default body Size in points is 17.
And on line 224 in the source it is also stated that
// iOS docs say default button font size is 15, default label font size is 17 so we use those as the defaults.
@RobWos Can you please attach a small project that demonstrates this issue? Thanks!
IncorrectFontSize.zip
Just checked the last known good Xamarin.Forms version is 4.0.0.709238, the first version with the bug is 4.1.0.555618.
Instructions :
Run the app on iOS note down the font sizes.
Update Xamarin.Forms to version 4.1.0.555618.
Run the app on iOS note down the font sizes.
Compare the results
This regression was introduced when we added the scaling #5985
@Clancey opinions ?
https://github.com/xamarin/Xamarin.Forms/blame/master/Xamarin.Forms.Platform.iOS/Forms.cs#L188
Any news on this?
We need to upgrade Xamarin.Forms to version 4.3 (from 3.6) in our product
because of the relative source binding in 4.3. However, we use named font sizes a lot
and are not happy with the smaller fonts on iOS. We need to solve this somehow
but the best thing would be if it was solved in Xamarin.Forms.
I Agree with Blomman1. We have the same problem.
We have the same problem as Blomman1. This might delay our next release!
We are also troubled by this. We can't upgrade Xamarin Forms version.
We solved this by disabling the font scaling feature for now.
Xamarin.Forms.Application.Current.On<iOS>().SetEnableAccessibilityScalingForNamedFontSizes(false);
closed by #9821
Most helpful comment
Any news on this?
We need to upgrade Xamarin.Forms to version 4.3 (from 3.6) in our product
because of the relative source binding in 4.3. However, we use named font sizes a lot
and are not happy with the smaller fonts on iOS. We need to solve this somehow
but the best thing would be if it was solved in Xamarin.Forms.