Fixed BitmapText width calculation

BitmapText width calculation was broken, this is how you fix it:

Not sure how to do pull requests with single commits… but this needs to get into the main jME3 branch.

Thanks for the fix… but even before it turns into a pull request it needs some fixing. For one, a pull request should only have the files that actually need changing and not a couple jars and the nb properties file.

Second, it’s important that the sizing methods here match up exactly with the sizing methods elsewhere. I think the BitmapText suite of classes calculates text width in like three different places (ugh). It would smooth the patching process if we knew that these had also been looked at and the calculation confirmed to be the same. (Notably, BitmapFont has a width calculation, BitmapText has a width calculation, and I think there are two other places in the various classes that x position is calculated and must match those… fixing kerning was incredibly painful because all of these places do the calculation completely differently.)

BitmapText is one of the most fragile set of classes in all of JME. To date, no single person (other than myself) has been able to patch it without breaking one or two other things. (And even my own track record is not great but I’ve been through this code 100s of times by now.) So at this point, I don’t receive any BitmapText patch without automatically assuming it’s going to take me 2 hours to apply it. And every time, I reweigh the time sink that would be required to rewrite the whole thing…

2 Likes