com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyConfiguration.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	loadSkin(SkinType.KEY_CONFIG);
	if(getSkin() == null) {
		this.setSkin(new KeyConfigurationSkin(Resolution.HD, main.getConfig().getResolution()));
	}

	FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
			Gdx.files.internal("skin/default/VL-Gothic-Regular.ttf"));
	FreeTypeFontParameter parameter = new FreeTypeFontParameter();
	parameter.size = (int) (20 * getSkin().getScaleY());
	titlefont = generator.generateFont(parameter);
	shape = new ShapeRenderer();

	input = main.getInputProcessor();
	keyboard = input.getKeyBoardInputProcesseor();
	controllers = input.getBMInputProcessor();
	midiinput = input.getMidiInputProcessor();
	setMode(0);
}
 
Example #2
Source File: GdxCanvas.java    From seventh with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve the desired font and size (may load the font
 * if not cached).
 * 
 * @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;
        params.magFilter = TextureFilter.Linear;
        params.minFilter = TextureFilter.Linear;
        
        font = this.generators.get(alias).generateFont(params);
        this.fonts.put(mask, font);
    }
    
    return font;
}
 
Example #3
Source File: SuperSnake.java    From super-snake with MIT License 5 votes vote down vote up
@Override
public void create () {
	batch = new SpriteBatch();

       WIDTH = Gdx.graphics.getBackBufferWidth();
       HEIGHT = Gdx.graphics.getBackBufferHeight();

       PADDED_WIDTH = WIDTH - PADDING;
       PADDED_HEIGHT = HEIGHT - PADDING;

       Gdx.app.log("Snake", "VIEWPORT " + WIDTH + ", " + HEIGHT);

       shapeRenderer = new ShapeRenderer();

       snake = new Snake(WIDTH / 2, HEIGHT / 2, INITIAL_SNAKE_LENGTH);
       pause_snake = new Snake(WIDTH / 2, 200, 100);

       FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/PatrickHand.ttf"));
       FreeTypeFontParameter parameter = new FreeTypeFontParameter();
       parameter.size = 32;
       font = generator.generateFont(parameter);

       parameter.size = 52;
       parameter.borderColor = Colors.spray;
       parameter.borderWidth = 2;
       fontBtn = generator.generateFont(parameter);

       parameter.size = 80;
       parameter.color = Color.WHITE;
       parameter.borderWidth = 2;
       parameter.borderColor = Colors.red;
       fontBig = generator.generateFont(parameter);

       generator.dispose();
}
 
Example #4
Source File: MessageRenderer.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void init(FreeTypeFontGenerator generator) {
	FreeTypeFontParameter parameter = new FreeTypeFontParameter();
	parameter.size = 24;
	parameter.characters += text;
	font = generator.generateFont(parameter);
	font.setColor(color);
}
 
Example #5
Source File: LaneRenderer.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public LaneRenderer(BMSPlayer main, BMSModel model) {

		this.main = main;
		Pixmap hp = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
		hp.drawPixel(0, 0, Color.toIntBits(255, 255, 255, 255));
		blank = new TextureRegion(new Texture(hp));
		hp.dispose();

		FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
				Gdx.files.internal("skin/default/VL-Gothic-Regular.ttf"));
		FreeTypeFontParameter parameter = new FreeTypeFontParameter();
		parameter.size = 18;
		font = generator.generateFont(parameter);
		generator.dispose();

		this.skin = (PlaySkin) main.getSkin();
		this.conf = main.main.getPlayerResource().getConfig();
		this.config = main.main.getPlayerResource().getPlayerConfig();
		this.playconfig = config.getPlayConfig(model.getMode()).getPlayconfig().clone();

		init(model);

		for (CourseData.CourseDataConstraint i : main.main.getPlayerResource().getConstraint()) {
			if (i == NO_SPEED) {
				playconfig.setHispeed(1.0f);
				playconfig.setLanecover(0);
				playconfig.setLift(0);
				playconfig.setHidden(0);
			}
		}
	}
 
Example #6
Source File: PracticeConfiguration.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void create(BMSModel model) {
	property.judgerank = model.getJudgerank();
	property.endtime = model.getLastTime() + 1000;
	Path p = Paths.get("practice/" + model.getSHA256() + ".json");
	if (Files.exists(p)) {
		Json json = new Json();
		try {
			property = json.fromJson(PracticeProperty.class, new FileReader(p.toFile()));
		} catch (FileNotFoundException | SerializationException e) {
			e.printStackTrace();
		}
	}

	if(property.gaugecategory == null) {
		property.gaugecategory = BMSPlayerRule.getBMSPlayerRule(model.getMode()).gauge;
	}
	this.model = model;
	if(property.total == 0) {
		property.total = model.getTotal();
	}
	FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
			Gdx.files.internal("skin/default/VL-Gothic-Regular.ttf"));
	FreeTypeFontParameter parameter = new FreeTypeFontParameter();
	parameter.size = 18;
	titlefont = generator.generateFont(parameter);
	
	for(int i = 0; i < graph.length; i++) {
		graph[i].setDestination(0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, new int[0]);
	}
}
 
Example #7
Source File: KillingSpree.java    From killingspree with MIT License 5 votes vote down vote up
@Override
	public void create () {
	    generator = new FreeTypeFontGenerator
	            (Gdx.files.internal("fonts/splash.ttf"));
	    parameter = new FreeTypeFontParameter();
	    
	    AssetLoader.instance.loadAll();
	    currentScreen = new SplashScreen(this);
	    Gdx.audio.getClass();
//	    GameScreen gameScreen = new GameScreen(this);
//        gameScreen.startServer();
//        gameScreen.loadLevel("maps/retro-small.tmx", "localhost");
//        currentScreen = gameScreen;
	}
 
Example #8
Source File: HUDRenderer.java    From killingspree with MIT License 5 votes vote down vote up
public HUDRenderer() {
    bomb = new Sprite(AssetLoader.instance.
            getTexture("sprites/bomb.png"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 7;
    font = new FreeTypeFontGenerator
            (Gdx.files.internal("fonts/game.ttf")).generateFont(parameter);
}
 
Example #9
Source File: SmartFontGenerator.java    From gdx-smart-font with MIT License 5 votes vote down vote up
/** 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.
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) {
	FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

	PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);
	FreeTypeFontParameter parameter = new FreeTypeFontParameter();
	parameter.size = fontSize;
	parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
	parameter.flip = false;
	parameter.packer = packer;
	FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);
	Array<PixmapPacker.Page> pages = packer.getPages();
	Array<TextureRegion> texRegions = new Array<>();
	for (int i = 0; i < pages.size; i++) {
		PixmapPacker.Page p = pages.get(i);
		Texture tex = new Texture(
				new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
			@Override
			public void dispose() {
				super.dispose();
				getTextureData().consumePixmap().dispose();
			}
		};
		tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
		texRegions.add(new TextureRegion(tex));
	}
	BitmapFont font = new BitmapFont((BitmapFont.BitmapFontData) fontData, texRegions, false);
	saveFontToFile(font, fontSize, fontName, packer);
	generator.dispose();
	packer.dispose();
	return font;
}