Skip to content

Conversation

@kkolyan
Copy link
Contributor

@kkolyan kkolyan commented Jun 8, 2020

Forum Discussion: https://hub.jmonkeyengine.org/t/bitmaptext-colortags-negativearraysizeexception/43357


        // 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)
// ColorTags.java:80
StringBuilder builder = new StringBuilder(charSeq.length()-7);

Looks like it expects color tag in \#RGBA# (7 characters) and doesn't count that \#RGB# (6 characters) is valid too.

@stephengold
Copy link
Member

Looks good to me. Thanks for your latest contribution!

@stephengold stephengold merged commit dd0c169 into jMonkeyEngine:master Jun 9, 2020
@stephengold stephengold added this to the v3.4.0 milestone Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants