Oli*_*xon 6 java android opengl-es freetype libgdx
我使用屏幕高度百分比动态生成我的字体并设置百分比(显然将来乘以密度).
一些笔记.我正在读OTF文件.使用最新版本的LibGDX(版本1.2.0)
我有以下问题:(在字体大断裂,看上去很模糊,但仅限于媒体.大和小的外观非常尖锐)

我的预设字体大小:
//Font sizes, small, med, large as a percentage of the screen.
public static float
FONT_SIZE_LARGE = 0.175f,
FONT_SIZE_MEDIUM = 0.06f,
FONT_SIZE_SMALL = 0.04f;
Run Code Online (Sandbox Code Playgroud)
我的字体生成器设置
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
FreeTypeFontGenerator generator;
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename));
Run Code Online (Sandbox Code Playgroud)
创建实际字体:
//Create a new font and add it to available font sizes.
public BitmapFont createFont(float size, float color)
{
this.parameter.size = Math.round(size);
BitmapFont bitmapFont = generator.generateFont(parameter);
bitmapFont.setColor(color);
listOfFonts.add(new FontStorage(bitmapFont, size));
return bitmapFont;
}
Run Code Online (Sandbox Code Playgroud)
现在我在不同的设备上尝试了一些东西,但仍然有同样的问题.我想它可能是因为它不是2的力量?(字体需要是2的幂才能均匀吗?)
字体是在许多不同的屏幕分辨率上绘制的,因此制作一定大小的三种位图字体是不可能的.
有人可以帮帮我吗?
我发现,如果你想要终极清晰的字体,你需要设置 3 个设置。
前两个是在从文件(可以是 OTF 或 TTF)创建之前,它们是:
//Make sure you ceil for your current resolution otherwise you'll be nasty cut-offs.
this.parameter.size = (int)Math.ceil(size);
this.generator.scaleForPixelHeight((int)Math.ceil(size));
Run Code Online (Sandbox Code Playgroud)
下一步是设置放大和缩小过滤器。(如果你也想要缩放,我不是因为我画的是几乎完美的像素)。无论如何,这是代码:
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename));
this.parameter.minFilter = Texture.TextureFilter.Nearest;
this.parameter.magFilter = Texture.TextureFilter.MipMapLinearNearest;
Run Code Online (Sandbox Code Playgroud)
这将为您提供在任何分辨率下都非常漂亮的清晰字体。GL。
| 归档时间: |
|
| 查看次数: |
3938 次 |
| 最近记录: |