@Override public void create() { camera = new OrthographicCamera(); batch = new SpriteBatch(); long start = System.currentTimeMillis(); int glyphCount = createFonts(); long time = System.currentTimeMillis() - start; text = glyphCount + " glyphs packed in " + packer.getPages().size + " page(s) in " + time + " ms"; }
glyph.page = packer.getPages().size - 1; // Glyph is always packed into the last page for now. glyph.srcX = (int)rect.x; glyph.srcY = (int)rect.y;
glyph.page = packer.getPages().size - 1; // Glyph is always packed into the last page for now. glyph.srcX = (int)rect.x; glyph.srcY = (int)rect.y;
BitmapFontWriter.writePixmaps(param.packer.getPages(), Gdx.files.local(""), "bitmapWrittenFont");
@Override public void render() { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.setProjectionMatrix(camera.combined); batch.begin(); float x = 10; float y = Gdx.graphics.getHeight() - 10; int renderCalls = 0; // NOTE: Before production release on mobile, you should cache the array from values() // inside the Enum in order to reduce allocations in the render loop. for (FontStyle style : FontStyle.values()) { for (FontSize size : FontSize.values()) { BitmapFont fnt = getFont(style, size); fnt.draw(batch, style.name() + " " + size.size + "pt: The quick brown fox jumps over the lazy dog", x, y); y -= fnt.getLineHeight() + 10; } y -= 20; } BitmapFont font = getFont(FontStyle.Regular, FontSize.Medium); font.draw(batch, text, 10, font.getCapHeight() + 10); // draw all glyphs in background batch.setColor(1f, 1f, 1f, 0.15f); batch.draw(packer.getPages().first().getTexture(), 0, 0); batch.setColor(1f, 1f, 1f, 1f); batch.end(); }
Array<Page> pages = packer.getPages(); Array<TextureRegion> regions = getRegions(); for (int i = 0, regSize = regions.size - 1; i < pages.size; i++) {
glyph.page = packer.getPages().size - 1; // Glyph is always packed into the last page for now. glyph.srcX = (int)rect.x; glyph.srcY = (int)rect.y;
for (Page page : packer.getPages()) { page.getPixmap().dispose();