libGDX导入字体处理工具freetype

9 篇文章 0 订阅
8 篇文章 0 订阅

使用

new LwjglApplication(new ApplicationAdapter() {
	public void create () {
		FontInfo info = new FontInfo();
		info.padding = new Padding(1, 1, 1, 1);

		FreeTypeFontParameter param = new FreeTypeFontParameter();
		param.size = 13;
		param.gamma = 2f;
		param.shadowOffsetY = 1;
		param.renderCount = 3;
		param.shadowColor = new Color(0, 0, 0, 0.45f);
		param.characters = Hiero.EXTENDED_CHARS;
		param.packer = new PixmapPacker(512, 512, Format.RGBA8888, 2, false, new SkylineStrategy());

		FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.absolute("some-font.ttf"));
		FreeTypeBitmapFontData data = generator.generateData(param);

		BitmapFontWriter.writeFont(data, new String[] {"font.png"},
			Gdx.files.absolute("font.fnt"), info, 512, 512);
		BitmapFontWriter.writePixmaps(param.packer.getPages(), Gdx.files.absolute("imageDir"), name);

		System.exit(0);
	}
});



build.gradle结构

并非完整配置,我只是把freetype需要的依赖显示出来
其余配置按你自己的项目来定

allprojects {
    ext {
        gdxVersion = '1.12.1'
    }
}


project(":core") {
    dependencies {
        api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    }
}

project(":desktop") {

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    dependencies {
        implementation project(":core")
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
    }
}

project(":ios") {
    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
   
    }
}


  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值