// just for this micro-demo.
BitmapFont font = new BitmapFont();
font.setCharSet(new BitmapCharacterSet());
font.setPages(new Material[0]);
// in game it's loaded with AssetManager, of course
BitmapText text = new BitmapText(font);
text.setText("\\#FFF#");
Exception in thread "main" java.lang.NegativeArraySizeException
at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:68)
at java.lang.StringBuilder.<init>(StringBuilder.java:101)
at com.jme3.font.ColorTags.setText(ColorTags.java:80)
at com.jme3.font.Letters.setText(Letters.java:68)
at com.jme3.font.BitmapText.setText(BitmapText.java:181)
I think 6 is just as wrong as 7, isnāt it? It wonāt break but also why bother?
Wouldnāt it depend on the pattern that was triggered?
And really, to be honest Iām not sure why itās bothering to send a size to StringBuilder at all. Itās not really saving anything important.
Probably just replace it was new StringBuilder() and try not to micro-optimize. (BitmapText and related classes are a case study in wrong-headed micro-optimization.)