Created
October 7, 2017 16:24
-
-
Save dmitrykolesnikovich/0220abb0b1e576162465479b9f22a101 to your computer and use it in GitHub Desktop.
ConvertFontService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.badlogic.gdx.tools.hiero; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.backends.lwjgl.LwjglCanvas; | |
import com.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont; | |
import com.badlogic.gdx.tools.hiero.unicodefont.effects.ColorEffect; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.io.File; | |
public final class ConvertFontService { | |
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\"!`?'.,;:()[]{}<>|/@\\^$-%+=#_&~*\u0000\u007F"; | |
private ConvertFontService() { | |
// no op | |
} | |
public static void convertFont() { | |
final JFrame frame = new JFrame() {{ | |
pack(); | |
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | |
}}; | |
EventQueue.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
frame.getContentPane().add(new LwjglCanvas(new ApplicationAdapter() { | |
private final UnicodeFont unicodeFont = new UnicodeFont(Font.decode("Verdana"), 20, false, false); | |
private final File saveBmFontFile = new File("D:/qqww.fnt"); | |
@Override | |
public void create() { | |
unicodeFont.setMono(false); | |
unicodeFont.setPaddingTop(1); | |
unicodeFont.setPaddingRight(1); | |
unicodeFont.setPaddingBottom(1); | |
unicodeFont.setPaddingLeft(1); | |
unicodeFont.setPaddingAdvanceX(1); | |
unicodeFont.setPaddingAdvanceY(1); | |
unicodeFont.setGlyphPageWidth(512); | |
unicodeFont.setGlyphPageHeight(512); | |
unicodeFont.setRenderType(UnicodeFont.RenderType.Java); | |
unicodeFont.getEffects().add(new ColorEffect()); | |
unicodeFont.addGlyphs(CHARACTERS); | |
try { | |
new BMFontUtil(unicodeFont).save(saveBmFontFile); | |
} catch (Throwable ex) { | |
System.out.println("Error saving BMFont files: " + saveBmFontFile.getAbsolutePath()); | |
ex.printStackTrace(); | |
} | |
frame.dispose(); | |
} | |
}).getCanvas()); | |
} | |
}); | |
} | |
public static void main(String[] args) { | |
convertFont(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment