Java 类com.badlogic.gdx.tools.hiero.BMFontUtil 实例源码

项目:featurea    文件:FontCreator.java   
public void createFont(final File fntFile, final String name, final int size, final boolean isBold, final boolean isItalic) {
    final JFrame frame = new JFrame() {{
        pack();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // IMPORTANT
    }};
    frame.getContentPane().add(new MyLwjglCanvas(new ApplicationAdapter() {
        private final UnicodeFont unicodeFont = new UnicodeFont(Font.decode(name), size, isBold, isItalic);

        @Override
        public void create() {
            unicodeFont.setMono(false);
            unicodeFont.setPaddingTop(PADDING);
            unicodeFont.setPaddingRight(PADDING);
            unicodeFont.setPaddingBottom(PADDING);
            unicodeFont.setPaddingLeft(PADDING);
            unicodeFont.setPaddingAdvanceX(-2 * PADDING);
            unicodeFont.setPaddingAdvanceY(-2 * PADDING);
            unicodeFont.setGlyphPageWidth(1024);
            unicodeFont.setGlyphPageHeight(512);
            unicodeFont.setRenderType(UnicodeFont.RenderType.Java);
            List effects = unicodeFont.getEffects();
            effects.add(new ColorEffect(Color.white));
            unicodeFont.addGlyphs(CHARACTERS);
            try {
                FileUtil.createNewFile(fntFile);
                new BMFontUtil(unicodeFont).save(fntFile);
            } catch (Throwable ex) {
                ex.printStackTrace();
            }
            if ("studio".equals(System.getProperty("featurea.launcher"))) {
                frame.dispose();
            } else {
                frame.setVisible(false);
            }
        }
    }).getCanvas());
}