use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader in project libgdx by libgdx.
the class FreeTypeFontLoaderTest method create.
@Override
public void create() {
manager = new AssetManager();
// set the loaders for the generator and the fonts themselves
FileHandleResolver resolver = new InternalFileHandleResolver();
manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
// load to fonts via the generator (implicitely done by the FreetypeFontLoader).
// Note: you MUST specify a FreetypeFontGenerator defining the ttf font file name and the size
// of the font to be generated. The names of the fonts are arbitrary and are not pointing
// to a file on disk!
FreeTypeFontLoaderParameter size1Params = new FreeTypeFontLoaderParameter();
size1Params.fontFileName = "data/arial.ttf";
size1Params.fontParameters.size = 10;
manager.load("size10.ttf", BitmapFont.class, size1Params);
FreeTypeFontLoaderParameter size2Params = new FreeTypeFontLoaderParameter();
size2Params.fontFileName = "data/arial.ttf";
size2Params.fontParameters.size = 20;
manager.load("size20.ttf", BitmapFont.class, size2Params);
// we also load a "normal" font generated via Hiero
manager.load("data/default.fnt", BitmapFont.class);
batch = new SpriteBatch();
}
use of com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader in project libgdx by libgdx.
the class APKExpansionTest method create.
@Override
public void create() {
if ((((AndroidFiles) Gdx.files)).setAPKExpansion(1, 0)) {
resolver = new ZipFileHandleResolver();
} else {
Gdx.app.error("libgdx", "No Expansion can be opened");
}
assetManager = new AssetManager();
FileHandleResolver resolver = new InternalFileHandleResolver();
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
loadFont(assetManager, "data/DroidSerif-Regular.ttf", 12);
loadFont(assetManager, "data/" + extensionPrefix + "DroidSerif-Regular.ttf", 12);
assetManager.load("data/" + extensionPrefix + "testpackobb", TextureAtlas.class);
assetManager.finishLoading();
sound = Gdx.audio.newSound(Gdx.files.internal("data/" + extensionPrefix + "chirp.ogg"));
sound.play();
texture = new Texture(resolver.resolve("data/" + extensionPrefix + "badlogic.jpg"));
batch = new SpriteBatch();
TextureAtlas atlas = assetManager.get("data/" + extensionPrefix + "testpackobb");
atlasTextureRegion = new TextureRegion(atlas.findRegion("water"));
sound = Gdx.audio.newSound(Gdx.files.internal("data/shotgun.ogg"));
sound.play();
}
Aggregations