/** * Adds some text. * * @param text Text to add */ public void append(String text) { // Note current buffer position final int start = builder.getVertexCount(); // Build glyphs for (char ch : text.toCharArray()) { // Handle carriage returns if (ch == '\n') { newline(); continue; } // Determine width of this character final float w = font.getWidth(ch); // Start newline if wrapped if (x + w > width) { newline(); } // Build quad for glyph final Quad quad = new Quad(new Point(x * scale, y * scale, 0), w * scale, font.getHeight() * scale, false); quad.setColour(col); quad.setTextureCoords(font.getTextureCoords(ch)); // Add glyph builder.addQuad(quad.getVertices()); // Move to next glyph location x += w; } // Update mesh builder.build(start, builder.getVertexCount()); builder.flag = true; }
/** Starts a new line of text. */ public void newline() { x = 0; y += font.getHeight(); }
public synchronized void setText(char[] chars) { mFont.generateText(this, chars, l, b, z + 0.02f, textColor); prevText = chars.clone(); }