@Override public void create () { this.batch = new SpriteBatch(); this.assets = new AssetManager(); BitmapFontParameter params = new BitmapFontParameter(); params.atlasName = ATLAS; this.assets.load(FONT_1, BitmapFont.class, params); this.assets.load(FONT_2, BitmapFont.class, params); this.assets.load(FONT_3, BitmapFont.class, params); this.assets.finishLoading(); this.fonts = new BitmapFont[3]; this.fonts[0] = assets.get(FONT_1); this.fonts[1] = assets.get(FONT_2); this.fonts[2] = assets.get(FONT_3); this.fonts[0].setColor(Color.RED); this.fonts[1].setColor(Color.BLUE); this.fonts[2].setColor(Color.GREEN); this.testStrings = new String[] {"I'm loaded from an atlas!", "I, too, am loaded from an atlas", "I'm with stupid ^"}; Gdx.gl.glClearColor(1, 1, 1, 1); }
private static void loadFonts(final String atlasPath, final String[] fontPaths, final AssetService assetService) { if (fontPaths.length != 0) { final BitmapFontParameter loadingParameters = new BitmapFontParameter(); loadingParameters.atlasName = atlasPath; for (final String fontPath : fontPaths) { assetService.finishLoading(fontPath, BitmapFont.class, loadingParameters); } } }
private void loadAssetLists() { TextureParameter param = new TextureParameter(); param.minFilter = param.magFilter = Texture.TextureFilter.Linear; assetManager.loadAssetList("data/json/images.json", Texture.class, param); assetManager.loadAssetList("data/json/sounds.json", Sound.class, null); assetManager.loadAssetList("data/json/music.json", Music.class, null); assetManager.loadAssetListWithParam("data/json/animations.json", AnimationExtended.class, AnimationExtendedLoader.AnimationExtendedParameter.class); BitmapFontParameter fontParam = new BitmapFontParameter(); fontParam.flip = true; assetManager.loadAssetList("data/json/fonts.json", BitmapFont.class, fontParam); }
@Override public BitmapFont loadSync( AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter ) { int fontSize = 10; String scrubbedFileName = fileName; int qMark = fileName.lastIndexOf( "?" ); if ( qMark != -1 ) { scrubbedFileName = scrubbedFileName.substring( 0, qMark ); Matcher m = argsPtn.matcher( fileName ); m.region( qMark+1, fileName.length() ); while ( m.lookingAt() ) { if ( m.group( 1 ).equals( "size" ) ) { fontSize = Integer.parseInt( m.group( 2 ) ); } if ( m.group( 3 ).length() > 0 ) break; // Hit the "#" separator. m.region( m.end(), fileName.length() ); } } boolean flip = parameter != null ? parameter.flip : false; FreeTypeFontGenerator generator = new FreeTypeFontGenerator( file ); FreeTypeBitmapFontData data = generator.generateData( fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, flip ); generator.dispose(); return new BitmapFont( data, data.getTextureRegions(), true ); }
public void loadFont(String name, String atlas) { BitmapFontParameter bfp = new BitmapFontParameter(); bfp.atlasName = atlas; assets.load(name, BitmapFont.class, bfp); }
public BmpFontAsset (String relativePath, BitmapFontParameter fontParameter) { super(relativePath); this.fontParameter = fontParameter; }
public BitmapFontParameter getFontParameter () { return fontParameter; }
@Override public void loadAsync( AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter ) { // No-op. }
@Override public Array<AssetDescriptor> getDependencies( String fileName, FileHandle file, BitmapFontParameter parameter ) { return new Array<AssetDescriptor>(); }