0

i have a custom Xamarin.Forms.Label and set the FontSize to 18. As a understand correct, the unit is DiP (Device Independent Pixels).
In my ios custom renderer, this custom label is a UILabel with a UIFont. This uifont has a PointSize, which has also a value of 18. In my custom renderer i resize the label and the PointSize could become a different value. 15 for example.
Now i need the new value (15) of UIFont.PointSize in my shared project.
The question is: Is the UIFont.PointSize unit different than the Label.FontSize unit? So i need a conversion? In my test it looks like the units are the same, but i', not sure.
Thanks

Saftpresse99
  • 849
  • 7
  • 16
  • iOS uses points. In retina devices, 1 point equals four pixels. In non-retina devices, 1 points equals 1 pixel. Check https://developer.apple.com/library/archive/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW7 – Lucas Zhang Oct 28 '20 at 13:56
  • Thank you. I know that, but i don't understand why Label.FontSize (DiP) and UIFont.PointSize (Points) are the same values. 18 in my example. – Saftpresse99 Oct 29 '20 at 07:19

1 Answers1

0

Yes, they are different units

pt

Points - 1/72 of an inch based on the physical size of the screen.

dp or dip

Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

There are more information here