Forum Xamarin.Forms

How to translate NamedSize for a font into an actual value?

JohnHardmanJohnHardman GBUniversity admin
edited May 2015 in Xamarin.Forms

[Edited: Answered my own question... the answer to the following is to use Device.GetNamedSize]

My user panel have concluded that text that I display in a particular scenario wants to be larger than NamedSize.Small, but smaller than NamedSize.Medium . Is there any way that I can get the actual values used at run-time (post any accessibility transformations) for NamedSize.Small and NamedSize.Medium?

I had hoped something along the lines of the following would work:

                var v1 = Font.OfSize("Droid Sans Mono", NamedSize.Medium);
                var v2 = Font.OfSize("Droid Sans Mono", NamedSize.Small);
                double sizeToUse = (v1.FontSize + v2.FontSize) / 2.0;

However, that generates the value 0, as v1 and v2 both have UseNamedSize set to true, with FontSize set to 0.

Many thanks,

John H.

Sign In or Register to comment.