

SpigotException
Members-
Content count
2 -
Joined
-
Last visited
Community Reputation
0 NeutralAbout SpigotException
-
Rank
Tree Puncher
-
Custom FontRenderer with custom sized ascii.png file
SpigotException replied to SpigotException's topic in Modder Support
I had Minecraft in window mode at full size at 1080p. I also had it smaller, but nothing changed, so I don't think the resolution is the rendering problem. Maybe I'm wrong... -
Custom FontRenderer with custom sized ascii.png file
SpigotException posted a topic in Modder Support
Hello, I'm pretty new at developing forge mods and wanted to use my own fonts for titles etc for the main menu. I created my own FontRenderer and overwrote the renderUnicodeChar method there, but the text still looks pretty strange. The custom class: import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; public class CustomFontRenderer extends FontRenderer { public CustomFontRenderer(GameSettings gameSettingsIn, ResourceLocation location, TextureManager textureManagerIn, boolean unicode) { super(gameSettingsIn, location, textureManagerIn, unicode); } @Override protected float renderUnicodeChar(char ch, boolean italic) { int i = this.glyphWidth[ch] & 255; if (i == 0) { return 0.0F; } else { this.bindTexture(locationFontTexture); int k = i >>> 4; int l = i & 15; float f = (float) k; float f1 = (float) (l + 1); float f2 = (float) (ch % 16 * 16) + f; float f3 = (float) ((ch & 255) / 16 * 16); float f4 = f1 - f - 0.02F; float f5 = italic ? 1.0F : 0.0F; GlStateManager.glBegin(5); GlStateManager.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); GlStateManager.glVertex3f(this.posX + f5, this.posY, 0.0F); GlStateManager.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); GlStateManager.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); GlStateManager.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); GlStateManager.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); GlStateManager.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); GlStateManager.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); GlStateManager.glEnd(); return (f1 - f) / 2.0F + 1.0F; } } } Preview of the custom font. I initialized the renderer as follows: FontRenderer fontrenderer = new CustomFontRenderer(mc.gameSettings, new ResourceLocation("mountainmod", "textures/font/cammron/ascii.png"), mc.renderEngine, true); My idea where the problem is is the size / resolution of the ascii.png. The ascii.png of Minecraft is 128x128 pixel large, the ascii.png of my font(s) is 1024x1024 pixels or 2048x2048 pixels large (I tried 2 fonts). Best regards.