LibGDX FreeType字体模糊
我正在使用屏幕高度百分比动态生成我的字体并设置百分比(显然将来乘以密度)。
一些笔记。 我正在读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的幂才能均匀?)
字体是在许多不同的屏幕分辨率上绘制的,因此制作一定大小的三种位图字体是不可能的。
有人可以帮帮我吗?
我想出来了,如果你想要最终的清晰字体,你需要设置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));
下一步是设置放大并缩小filter。 (如果你也想要缩放,我不是因为我画的像素几乎完美)。 无论如何这里是代码:
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename)); this.parameter.minFilter = Texture.TextureFilter.Nearest; this.parameter.magFilter = Texture.TextureFilter.MipMapLinearNearest;
这将为您提供任何分辨率的超级清晰字体。 GL。
- 如何将UTF字符串转换为ANSI并使用JAVA-ANDROID在SSD中创建ANSI文本文件
- “java.lang.IllegalStateException:在建立连接后无法设置请求属性”在Android中出错
- Android从MySql表中获取数据
- 部分加载来自URL的图像,就像在WhatsApp中实现的那样
- 如何在android中同时打开手电筒和前置摄像头
- JSON对象无法转换为JSON数组
- 如何使用JSch运行和显示shell命令ssh的结果?
- 解析数据时出错org.json.JSONException:java.lang.String类型的值<br无法转换为JSONObject
- 当Decrypting Image时,给出了javax.crypto.BadPaddingException:pad块损坏的Android