我正在使用屏幕高度百分比和设置百分比动态生成我的字体(很明显,将来会乘以密度)。
一些笔记。我在读一份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;我的字体生成器设置
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
FreeTypeFontGenerator generator;
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename));创建实际字体:
//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;
}现在,我在不同的设备上尝试了一些东西,但仍然有相同的问题。我想可能是因为它不是2的力量?(字体是否需要2的幂才能成为偶数?)
字体是在许多不同的屏幕分辨率上绘制的,因此不可能制作一定大小的三种位图字体。
有人能帮我一下吗?
发布于 2014-07-14 07:06:23
我明白了,如果你想要最终清晰的字体,你需要设置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));下一步是设置放大和小型化滤波器。(对于缩放,如果你也想,我不是因为我正在绘制几乎像素完美)。不管怎么说,这是代码:
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename));
this.parameter.minFilter = Texture.TextureFilter.Nearest;
this.parameter.magFilter = Texture.TextureFilter.MipMapLinearNearest;这会给你任何分辨率上超漂亮的、清晰的字体。GL.
https://stackoverflow.com/questions/24727294
复制相似问题