BitmapText getLineWidth() always returns 0

BitmapText getLineWidth() always returns 0 because it reads that from its local lineWidth variable, which is never changed.

[java] /**

  • @return width of line


    public float getLineWidth() {

    if (needRefresh) {

    assemble(); // (Does not change lineWidth)


    return lineWidth;


    The only required change to make it work with be to get the width from the underlying Letters object instead:

    [java] /**
  • @return width of line


    public float getLineWidth() {

    if (needRefresh) {



    return letters.getTotalWidth();


Thank you!

fixed. rev. 6803.

Thanks for fixing it so quickly. While we’re at it, could BitmapText also expose more information? Things like the number of lines when it’s in wrapping mode, number of lines that its current bounds can hold, etc. Thanks~

Added BitmapText.getLineCount()

rev. 6809

You can get the maximum lines by bound.height / bitmapText.getLineHeight().

Currently, there is no limitation when the text exceeds the bound height.

I don’t know BitmapText should crop the lines over the bound or not.

Thank you!

Hey, it’s me again with another bug!

Here is a sample application that creates BitmapTexts of different colors.


import com.jme3.font.BitmapText;

import com.jme3.math.ColorRGBA;

public class testtext extends SimpleApplication


public static void main(final String[] args)


new testtext().start();



public void simpleInitApp()



BitmapText red = new BitmapText(assetManager.loadFont(“Interface/Fonts/Default.fnt”));

red.setText(“This is red”);


red.setLocalTranslation(100, 100, 0);


BitmapText green = new BitmapText(assetManager.loadFont(“Interface/Fonts/Default.fnt”));

green.setText(“This is green”);


green.setLocalTranslation(200, 100, 0);


BitmapText blue = new BitmapText(assetManager.loadFont(“Interface/Fonts/Default.fnt”));

blue.setText(“This is blue”);


blue.setLocalTranslation(100, 200, 0);


BitmapText gray = new BitmapText(assetManager.loadFont(“Interface/Fonts/Default.fnt”));

gray.setText(“This is gray”);


gray.setLocalTranslation(200, 200, 0);


BitmapText white = new BitmapText(assetManager.loadFont(“Interface/Fonts/Default.fnt”));

white.setText(“This is white”);


white.setLocalTranslation(300, 200, 0);




But here is what happens:

As you can see, it seems that only the red color channel is taken into account sometimes. I say sometimes, because the white text is indeed white like it should. But the rest isn’t; the gray one isn’t gray, and the green and blue ones are completely black.

This sounds like the bug I reported here introduced in r6768. It’s not just a particular channel either, sometimes it gets a transparent alpha value too.


The color was incorrectly set, abgr instead of rgba

Fixed in svn. rev. 6814

Thanks again~