I have a custom font String (Font-Awesome Icon) and I want to draw it into a FloatingActionButton. For this reason I must convert the String to a Drawable like this. The problem is that the icon is never centered, even if I try something like this:
public override void Draw(global::Android.Graphics.Canvas canvas)
{
Rect bounds = new Rect();
paint.GetTextBounds(text, 0, text.Length, bounds);
float x = (canvas.Width / 2f) - (bounds.Width() / 2f)
float y = (canvas.Height / 2f) - (bounds.Height() / 2f);
canvas.DrawText(text, x, y, paint);
}
The result will be something like this:
I can't figure out the problem.
Thanks in advance.
Edit: If I do GetBounds, this is the result: