gpt4 book ai didi

java - gdx-freetype 生成字体很慢

转载 作者:行者123 更新时间:2023-11-30 10:59:48 25 4
gpt4 key购买 nike

我目前正在使用 gdx-freetype 库为我的游戏生成 BitmapFonts。这真的很方便,因为我可以用它来处理 Android 上的不同屏幕尺寸。问题是制作字体需要很长时间。在启动时,我生成了一些不同大小的 BitmapFonts(来自同一个 .ttf 文件),因此生成字体所花费的时间增加了我的加载时间。这是一个问题,因为生成字体很容易需要 5-6 秒。

有什么我可以做的来加快这个过程,或者我应该尝试一些替代 gdx-freetype 的方法吗?也许我以错误的方式解决了这个问题?

最佳答案

正如 Tenfour04 在评论中正确指出的那样,执行此操作的方法是仅在游戏首次加载时生成一次字体,然后将它们保存为文件。后续运行将简单地从文件中加载它们,这样会快得多。

我听说过关于 gdx-smart-font 的好消息正是这样做的项目,虽然我应该补充一点,我自己从来没有真正尝试过......

This class provides several benefits:

Creating fonts for different screen sizes using Hiero or BMFont can be troublesome, if you have 4 fonts of different sizes and are targeting 5-6 different screen sizes, you then must generate 20-24 bitmap font pngs. By using generated fonts they can be dynamically scaled at the time of creation based on screen size.

Generating fonts cuts down on app download size, no need to include pngs.

Generating fonts can add significant time to app startup time. Caching the generated fonts to file, and only regenerating when needed allows for fast app startup most of the time.

关于java - gdx-freetype 生成字体很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792880/

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