Posted February 10, 20196 yr 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.
February 12, 20196 yr I think it’s probably the game resolution being too small to render all the pixels of your font, what does it look like in full screen? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
February 12, 20196 yr Author 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...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.