'Paint measureText returns wrong value when monospace font applied in that string: Android

Im using measureText to get width of particular string. it is working fine when spannable string has no Typeface. but when spannable string has Typeface Monospace applied, it returns wrong width. i can apply typeface to paint but the problem is i applied monospace(Typeface) for particular length of spannable string only. please help me to find width of monospace applied string. Note: I have tried staticlayout and rect bounds too, it all returns same value.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source