gpt4 book ai didi

android - 设置自定义字体

转载 作者:行者123 更新时间:2023-11-29 16:03:08 26 4
gpt4 key购买 nike

我正在尝试为我的游戏设置自定义字体,但我真的不知道该怎么做。我目前选择字体的方式就是用这个方法

    public void loadFont() {
font = FontFactory.createStroke(activity.getFontManager(), activity.getTextureManager(), 256, 256, Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD), 50,
true, Color.WHITE_ABGR_PACKED_INT, 2, Color.BLACK_ABGR_PACKED_INT);
font.load();
}

其中“Typeface.SANS_SERIF”是字体

如果您知道如何从 Assets 文件夹加载字体,您能帮帮我吗?谢谢

**我正在使用 AndEngine-GLES2-AnchorCenter

最佳答案

将您的 yourfont.ttfyourfont.otf 添加到您的 ProjectAssets 中并加载自定义字体,例如

Typeface tf = null;
tf = Typeface.createFromAsset(context.getAssets(), "Helvetica neue.ttf");
TextView text = (TextView) findViewById(R.id.yourtextview);
tv.setTypeface(face);

关于android - 设置自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22004084/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com