how to restrict the width of bitmap font using bmf library?

I am using bitmap font to show the score in my app. Now the score has to fit into a certain width. But as the score increases the width increases. I am trying to get around it by lowering the scale accordingly. I came up with the following code but it’s incomplete and the width is either too small or too large.

uielements.scorestext\_left = bmf.newString(fontsfamily.ui\_Score\_Moves\_font, score\_elements.PlayerScore, 72, 18) uielements.scorestext\_left.align = "center" uielements.scorestext\_left.x = uielements.ui\_left.x uielements.scorestext\_left.y = uielements.ui\_left.y-65 if uielements.scorestext\_left.width\>220 then uielements.scorestext\_left.xScale = uielements.scorestext\_left.xScale - 0.01\*uielements.scorestext\_left.xScale end

It sounds like it should be easy to do but I just can’t get it to work. Please help.