List of usage examples for com.badlogic.gdx.graphics.g2d.freetype FreeTypeFontGenerator DEFAULT_CHARS
String DEFAULT_CHARS
To view the source code for com.badlogic.gdx.graphics.g2d.freetype FreeTypeFontGenerator DEFAULT_CHARS.
Click Source Link
From source file:CB_UI_Base.GL_UI.Fonts.java
License:Open Source License
static String getCyrilCharSet() { int CharSize = 0x04ff - 0x0400; char[] cyril = new char[CharSize + 1]; for (int i = 0x0400; i < 0x04ff + 1; i++) { cyril[i - 0x0400] = (char) i; }// ww w . jav a 2 s . c o m return FreeTypeFontGenerator.DEFAULT_CHARS + String.copyValueOf(cyril) + "" + "???"; }
From source file:com.explatcreations.sft.Assets.java
License:Open Source License
private BitmapFont makeFont(String name, int size) { final String path = "fonts/" + name + ".ttf"; final FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal(path)); return gen.generateFont(size, FreeTypeFontGenerator.DEFAULT_CHARS, true); }
From source file:com.randombot.theme.Ttf2FntGenerator.java
License:Open Source License
/** * Convenience method for generating a font, and then writing the fnt and * png files. Writing a generated font to files allows the possibility of * only generating the fonts when they are missing, otherwise loading from a * previously generated file./*from ww w . j a va2 s . c o m*/ * * @param fontFile * @param fontSize * @param destiny */ private void generateFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight, FileHandle destiny) { FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile); PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.packer = packer; param.characters = FreeTypeFontGenerator.DEFAULT_CHARS; param.size = fontSize; param.flip = false; FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(param); saveFontToFile(fontData, fontSize, fontName, packer, destiny); generator.dispose(); packer.dispose(); }
From source file:de.cubicvoxel.openspacebox.assetmanagement.asset.FontAsset.java
License:Open Source License
FontAsset(String path, int size, Color color) { this(path, size, color, FreeTypeFontGenerator.DEFAULT_CHARS); }
From source file:de.cubicvoxel.openspacebox.assetmanagement.asset.FontAsset.java
License:Open Source License
FontAsset(String path, int size, Color color, Color borderColor, float borderWidth) { this(path, size, color, borderColor, borderWidth, FreeTypeFontGenerator.DEFAULT_CHARS); }
From source file:es.eucm.ead.maven.GenerateSkinMojo.java
License:Open Source License
/** * Convenience method for generating a font, and then writing the fnt and * png files. Writing a generated font to files allows the possibility of * only generating the fonts when they are missing, otherwise loading from a * previously generated file./*from w w w . ja va 2s. c o m*/ * * @param fontFile * @param fontSize * @param destiny */ private void generateFiles(String fontName, FileHandle fontFile, int fontSize, FileHandle destiny) { FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile); // compute the minimum page size for a square png FreeType.Library library = FreeType.initFreeType(); FreeType.Face face = FreeType.newFace(library, fontFile, 0); FreeType.setPixelSizes(face, 0, fontSize); FreeType.SizeMetrics fontMetrics = face.getSize().getMetrics(); float scale = FreeType.toInt(fontMetrics.getHeight()); for (int c = 32; c < (32 + face.getNumGlyphs()); c++) { if (FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT)) { int lh = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); scale = (lh > scale) ? lh : scale; } } // generate the glyphs int maxGlyphHeight = (int) Math.ceil(scale); float area = maxGlyphHeight * maxGlyphHeight * FreeTypeFontGenerator.DEFAULT_CHARS.length(); int pageWidth = MathUtils.nextPowerOfTwo((int) Math.sqrt(area)); pageWidth = Math.min(pageWidth, 1024); PixmapPacker packer = new PixmapPacker(pageWidth, pageWidth, Pixmap.Format.RGBA8888, 2, false); FreeTypeFontGenerator.FreeTypeFontParameter param = new FreeTypeFontGenerator.FreeTypeFontParameter(); param.packer = packer; param.characters = FreeTypeFontGenerator.DEFAULT_CHARS; param.size = fontSize; param.flip = false; FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(param); saveFontToFile(fontData, fontSize, fontName, packer, destiny); generator.dispose(); packer.dispose(); }
From source file:es.eucm.piel.fonts.TTFtoFNT.java
License:Apache License
public void toFnt(int size, float scale, int atlasSize, String characters, File dst) { int fontSize = (int) (size * scale); PixmapPacker packer = new PixmapPacker(atlasSize, atlasSize, Pixmap.Format.RGBA8888, 2, false); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.packer = packer;//from ww w. j av a 2 s . com parameter.characters = characters == null ? FreeTypeFontGenerator.DEFAULT_CHARS : characters; parameter.size = fontSize; parameter.flip = false; FreeTypeBitmapFontData data = generator.generateData(parameter); String fontName = ttfName + "-" + size; BitmapFontWriter.setOutputFormat(BitmapFontWriter.OutputFormat.Text); String[] pageRefs = BitmapFontWriter.writePixmaps(parameter.packer.getPages(), new FileHandle(dst), fontName); BitmapFontWriter.writeFont(data, pageRefs, new FileHandle(new File(dst, fontName + ".fnt")), new BitmapFontWriter.FontInfo(fontName, size), 1, 1); }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
/** * Retrieve the desired font and size (may load the font * if not cached)./*from w w w.ja v a2s . com*/ * * @param alias * @param size * @return the font */ private BitmapFont getFont(String alias, int size) { BitmapFont font = null; String mask = alias + ":" + size; if (this.fonts.containsKey(mask)) { font = this.fonts.get(mask); } else if (this.generators.containsKey(alias)) { FreeTypeFontParameter params = new FreeTypeFontParameter(); params.size = size; params.characters = FreeTypeFontGenerator.DEFAULT_CHARS; params.flip = true; font = this.generators.get(alias).generateFont(params); this.fonts.put(mask, font); } return font; }