Summary
I have text that I draw on a SkiaSharp canvas which does not automatically adjust to the Larger Accessibilty Sizes setting in iOS. I would like to scale the font when I draw it according to the user's setting, but I do not know how to convert UIContentSizeCategory to a numerical value. Is there a way to convert UIContentSizeCategory value to a numerical value?
Details
The user is able to change the font scale on their iPhone as shown by going to Settings -> Display & Text Size -> Larger Text -> enabling Larger Accessibility Sizes and dragging the slider to the right.
The value matching this slider can be obtained as follows (in Xamarin C#)
string sizeCategoryAsString =
UIKit.UIApplication.SharedApplication.PreferredContentSizeCategory;
var sizeCategoryAsEnum =
UIContentSizeCategoryExtensions.GetValue(UIApplication.SharedApplication.PreferredContentSizeCategory);
Unfortunately I do not see a way to convert this enumeration value to a scale value such as 1.5
.
I would like a numerical value to multiply my text rendering in a separate rendering system (SkiaSharp in this case, but it could be anything else like a game). I also need to adjust my layout in SkiaSharp to accommodate for the larger font.
I know that this is possible on Xamarin Android using the following code:
var globalFontScale = Resources.Configuration.FontScale;
Is there an equivalent value in Xamarin iOS?
I found a similar question posted here:
https://social.msdn.microsoft.com/Forums/en-US/5a95e5d6-1263-4ed4-bc03-dd6f54d7df04/accessibility-font-size
Unfortunately the code listed there stops at
ExtraExtraExtraLarge
(a value of 7), but larger "Accessibility" values are available if the user checks the Larger Accessibility Sizes option. Therefore, I did my own measurements and got these values. Note that these differ slightly from the values in the link above.