Example usage for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache

List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache.

Prototype

public BitmapFontCache(BitmapFont font, boolean integer) 

Source Link

Document

Creates a new BitmapFontCache

Usage

From source file:CB_UI_Base.GL_UI.Controls.Label.java

License:Open Source License

private void setText() {

    final int n = mText.length();

    for (int start = 0; start < n; start++) {
        if (mFont.getData().getGlyph(mText.charAt(start)) == null) {
            char c = mText.charAt(start);
            if (c != '\r' && c != '\n')
                log.error("Unknown Char {" + c + "} @:" + mText + "[" + start + "]");
        }//from   w  w w  . jav a 2  s  .  c om
    }

    if (mTextObject == null) {
        mTextObject = new BitmapFontCache(mFont, true);
    } else if (!mTextObject.getFont().equals(mFont)) {
        mTextObject = new BitmapFontCache(mFont, true);
    }
    if (!mColor.equals(mTextObject.getColor())) {
        mTextObject.setColor(mColor);
    }
    try {
        switch (mWrapType) {
        case SINGLELINE:
            bounds = mTextObject.setText(mText, 0f, 0f);
            break;
        case MULTILINE:
            bounds = mTextObject.setText(mText, 0f, 0f, this.getWidth(), GDX_HAlignment(mHAlignment), false);
            break;
        case WRAPPED:
            bounds = mTextObject.setText(mText, 0f, 0f, this.getWidth(), GDX_HAlignment(mHAlignment), true);
            break;
        }
    } catch (Exception e) {
        // java.lang.ArrayIndexOutOfBoundsException kommt mal vor
        e.printStackTrace();
        Log.err(log,
                this + " (" + mWrapType + "/" + mHAlignment + "/" + mVAlignment + ") " + " \"" + mText + "\"",
                e);
    }
    if (underlineStrikeoutDrawable != null) {
        underlineStrikeoutDrawable.dispose();
        underlineStrikeoutDrawable = null;
    }
    setTextPosition();
}