BitmapText()
Text made from image glyphs, such as font065.png for 'A'. Add it to a stage like a sprite. Its position is the top of the first line, with each line aligned left, centred or right. Spaces and line breaks do not load images. Image data uses the library cache, so changing text does not create sprites or reload files. Use ordinary Text for normal system/TrueType fonts.
Examples
import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.text.BitmapText;
/** @example.online false */
public class BitmapTextExample {
public BitmapTextExample() {
Window window = new Window(400, 240);
Stage stage = new Stage();
stage.setColor(30, 40, 60);
BitmapText score = new BitmapText("src/examples/java/reference/assets/bitmap-font/%03d.png");
score.showText("0123456789");
score.setAlign(TextAlign.CENTER);
score.setLetterSpacing(1);
score.setSpaceWidth(4);
score.setLineSpacing(2);
score.setSize(300);
score.setPosition(0, 20);
score.setIsUI(true);
stage.add(score);
stage.display("Image glyphs: " + score.getWidth() + " x " + score.getHeight());
window.setStage(stage);
}
public static void main(String[] args) { new BitmapTextExample(); }
}
Syntax
Java
new BitmapText(pattern)