當前位置: 首頁>>代碼示例>>Java>>正文


Java FreeTypeFontGenerator.DEFAULT_CHARS屬性代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.DEFAULT_CHARS屬性的典型用法代碼示例。如果您正苦於以下問題:Java FreeTypeFontGenerator.DEFAULT_CHARS屬性的具體用法?Java FreeTypeFontGenerator.DEFAULT_CHARS怎麽用?Java FreeTypeFontGenerator.DEFAULT_CHARS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator的用法示例。


在下文中一共展示了FreeTypeFontGenerator.DEFAULT_CHARS屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateFiles

/**
 * 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
 * @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();
}
 
開發者ID:randombot,項目名稱:skinpacker,代碼行數:29,代碼來源:Ttf2FntGenerator.java

示例2: getFont

/**
 * 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;
}
 
開發者ID:tonysparks,項目名稱:seventh,代碼行數:29,代碼來源:GdxCanvas.java

示例3: generateFontWriteFiles

/** 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);
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = fontSize;
    parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    parameter.packer = packer;
    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);//(fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, false, packer);
    Array<PixmapPacker.Page> pages = packer.getPages();
    Array<TextureRegion> texRegions = new Array<TextureRegion>(pageSize);
    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(fontData,texRegions,false); //fontData, texRegions, false);
    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:35,代碼來源:SmartFontGenerator.java

示例4: generateFont

private BitmapFont generateFont(String fontName, int fontSize) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(PATH + fontName + FORMAT));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = fontSize;
    parameter.color = com.badlogic.gdx.graphics.Color.GREEN;
    parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    BitmapFont product = generator.generateFont(parameter);
    generator.dispose();
    return product;
}
 
開發者ID:vs-slavchev,項目名稱:Virtual-Evil,代碼行數:10,代碼來源:FontManager.java

示例5: generateFontWriteFiles

/** 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;
}
 
開發者ID:jrenner,項目名稱:gdx-smart-font,代碼行數:37,代碼來源:SmartFontGenerator.java

示例6: loadAssets

@Override
public void loadAssets()
{
    loader.parseLevel(world);
    for (Maryo.MaryoState ms : Maryo.MaryoState.values())
    {
        game.assets.manager.load("data/maryo/" + ms.toString() + ".pack", TextureAtlas.class);
    }
    game.assets.manager.load("data/animation/fireball.pack", TextureAtlas.class);
    game.assets.manager.load("data/animation/particles/fireball_emitter_2.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/particles/fireball_explosion_emitter.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/particles/iceball_emitter.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/particles/iceball_explosion_emitter.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/particles/star_trail.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/particles/maryo_star.p", ParticleEffect.class, game.assets.particleEffectParameter);
    game.assets.manager.load("data/animation/iceball.png", Texture.class, game.assets.textureParameter);
    game.assets.manager.load("data/game/game_over.png", Texture.class);
    hud.loadAssets();

    //audio
    game.assets.manager.load("data/sounds/audio_on.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/goldpiece_1.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/goldpiece_red.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/dead.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/jump_big.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/jump_big_power.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/jump_small.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/jump_small_power.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/pickup_item.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/powerdown.mp3", Sound.class);
    game.assets.manager.load("data/sounds/player/run_stop.mp3", Sound.class);
    game.assets.manager.load("data/sounds/wall_hit.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/fireball.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/iceball.mp3", Sound.class);

    game.assets.manager.load("data/sounds/sprout_1.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/star_kill.mp3", Sound.class);
    game.assets.manager.load("data/sounds/itembox_set.mp3", Sound.class);
    game.assets.manager.load("data/sounds/leave_pipe.mp3", Sound.class);
    game.assets.manager.load("data/sounds/enter_pipe.mp3", Sound.class);

    game.assets.manager.load("data/sounds/enemy/furball/die.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/fireball_repelled.mp3", Sound.class);

    game.assets.manager.load("data/sounds/item/iceball_explosion.mp3", Sound.class);
    game.assets.manager.load("data/sounds/item/fireball_explosion.mp3", Sound.class);

    game.assets.manager.load("data/music/game/lost_1.mp3", Music.class);
    game.assets.manager.load("data/music/game/courseclear.mp3", Music.class);

    FreetypeFontLoader.FreeTypeFontLoaderParameter debugFontParams = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
    debugFontParams.fontFileName = "data/fonts/MyriadPro-Regular.otf";
    debugFontParams.fontParameters.size = (int) (height / 25f);
    debugFontParams.fontParameters.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    game.assets.manager.load("debug.ttf", BitmapFont.class, debugFontParams);

    debugFontParams = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
    debugFontParams.fontFileName = Constants.DEFAULT_FONT_FILE_NAME;
    debugFontParams.fontParameters.size = (int) (height / 40f);
    debugFontParams.fontParameters.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    game.assets.manager.load("debug_object.ttf", BitmapFont.class, debugFontParams);

    exitDialog.loadAssets();

    FreetypeFontLoader.FreeTypeFontLoaderParameter pointsParams = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
    pointsParams.fontFileName = Constants.DEFAULT_FONT_FILE_NAME;
    pointsParams.fontParameters.size = 19;
    pointsParams.fontParameters.magFilter = Texture.TextureFilter.Linear;
    pointsParams.fontParameters.minFilter = Texture.TextureFilter.Linear;
    pointsParams.fontParameters.characters = "0123456789";
    game.assets.manager.load("kill-points.ttf", BitmapFont.class, pointsParams);

}
 
開發者ID:pedja1,項目名稱:SMC-Android,代碼行數:73,代碼來源:GameScreen.java

示例7: generateFiles

/**
 * 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
 * @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();
}
 
開發者ID:e-ucm,項目名稱:ead,代碼行數:53,代碼來源:GenerateSkinMojo.java


注:本文中的com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.DEFAULT_CHARS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。