In the core of the comparison a float is cast to an int:
for(int i=0;i<layout.getLineCount();i++)
if(maxWidth<layout.getLineWidth(i))
maxWidth=(int)layout.getLineWidth(i);
textRect.right=maxWidth;
This cast underestimates the width of the line and so may allow a font size to pass as small enough. The correct solution would be to round up the float I think. What do you think?