In my application I'm using a variety of Fonts by setting FontFamily variable, but I need the FontPointSize to change to fit into the dimensions of the image the text is written on. I tried calculating the FontPointSize using the code below but it doesn't really do the job.

Can anyone here show me what code I could use to get the right FontPointSize based on the FontFamily used and image size?

Resolution ties together the two systems of measuring length: pixels and inches (or centimetres). For example: 72 dpi (dots per inch).

One point is 1/72 inches, more or less. So a font size of 36 points will give a text height of 0.5 inches. But your image might be 72 dpi, so the text height is 36 pixels. Or it might be 720 dpi, so the text height is 360 pixels.

Here is the test image where you can see the text does not size properly inside the rounded corner image on the top and bottom. The code I wrote is below.

Yes. Here is the sample code below that produces the image above. Please tell me how I can resize the text within the bounds of the rounded corner image on top and bottom. Any help is much appreciated.

Setting the Width makes sure that the text is scaled to fit inside the specified Width. You probably want to set both the Width and the Height in your case. This will make sure it fits inside that area. And with the `TextGravity` you can determine where the text is positioned. It looks like you want to center the text so you should probably use Gravity.Center there.