use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter in project libgdx by libgdx.
the class UnicodeFont method setRenderType.
public void setRenderType(RenderType renderType) {
this.renderType = renderType;
if (renderType != RenderType.FreeType) {
if (bitmapFont != null) {
bitmapFont.dispose();
generator.dispose();
}
} else {
String fontFile = getFontFile();
if (fontFile != null) {
generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile));
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.size = font.getSize();
param.incremental = true;
param.flip = true;
param.mono = mono;
param.gamma = gamma;
bitmapFont = generator.generateFont(param);
if (bitmapFont.getData().missingGlyph == null)
bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('�');
cache = bitmapFont.newFontCache();
layout = new GlyphLayout();
}
}
}
use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter in project libgdx by libgdx.
the class FreeTypeDisposeTest method render.
public void render() {
if (Gdx.input.justTouched()) {
for (int i = 0; i < 10; i++) {
if (font != null) {
font.dispose();
}
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
font = generator.generateFont(parameter);
generator.dispose();
}
for (int i = 0; i < 10; i++) System.gc();
Gdx.app.log("FreeTypeDisposeTest", "generated 10 fonts");
Gdx.app.log("FreeTypeDisposeTest", Gdx.app.getJavaHeap() + ", " + Gdx.app.getNativeHeap());
}
}
use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter in project libgdx by libgdx.
the class FreeTypeIncrementalTest method create.
public void create() {
batch = new SpriteBatch();
shapes = new ShapeRenderer();
shapes.setColor(Color.RED);
FreeTypeFontGenerator.setMaxTextureSize(128);
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.incremental = true;
param.size = 24;
param.characters = "howdY ";
FreeTypeBitmapFontData data = new FreeTypeBitmapFontData() {
public int getWrapIndex(Array<Glyph> glyphs, int start) {
return SimplifiedChinese.getWrapIndex(glyphs, start);
}
};
// By default latin chars are used for x and cap height, causing some fonts to display non-latin chars out of bounds.
data.xChars = new char[] { '动' };
data.capChars = new char[] { '动' };
font = generator.generateFont(param, data);
}
use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter in project libgdx by libgdx.
the class FreeTypeTest method create.
@Override
public void create() {
boolean flip = false;
batch = new SpriteBatch();
if (flip) {
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(flip);
cam.update();
batch.setProjectionMatrix(cam.combined);
}
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
parameter.flip = flip;
parameter.genMipMaps = true;
// parameter.shadowOffsetX = 1;
// parameter.shadowOffsetY = 1;
// parameter.shadowColor = Color.GREEN;
// parameter.borderWidth = 1f;
// parameter.borderColor = Color.PURPLE;
FreeTypeBitmapFontData fontData = generator.generateData(parameter);
ftFont = generator.generateFont(parameter);
generator.dispose();
}
use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter in project libgdx by libgdx.
the class FreeTypeMetricsTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
atlas = new TextureAtlas("data/pack");
smallFont = new BitmapFont();
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 60;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
font = generator.generateFont(parameter);
generator.dispose();
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
Aggregations