From f5c9fa3301c2fc500eb8bdda3119048e7cc09d16 Mon Sep 17 00:00:00 2001 From: Death Fuel <108496936+DeathFuel@users.noreply.github.com> Date: Mon, 16 Feb 2026 03:49:44 +0100 Subject: [PATCH] slightly less stupid glyph size loading (#1390) --- .../client/font/BatchingFontRenderer.java | 5 +---- .../client/font/FontProviderUnicode.java | 19 +++++++++++++++++-- .../fontrenderer/MixinFontRenderer.java | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java b/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java index 3ffd1ac18..064eaa2aa 100644 --- a/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java @@ -75,11 +75,9 @@ public class BatchingFontRenderer { } } - public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, byte[] glyphWidth, - int[] colorCode, ResourceLocation locationFontTexture) { + public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, int[] colorCode, ResourceLocation locationFontTexture) { this.underlying = underlying; this.charWidth = charWidth; - this.glyphWidth = glyphWidth; this.colorCode = colorCode; this.locationFontTexture = locationFontTexture; @@ -92,7 +90,6 @@ public class BatchingFontRenderer { FontProviderMC.get(this.isSGA).charWidth = this.charWidth; FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture; - FontProviderUnicode.get().glyphWidth = this.glyphWidth; //noinspection deprecation fontShaderId = FontAAShader.getProgram().getProgramId(); diff --git a/src/main/java/com/gtnewhorizons/angelica/client/font/FontProviderUnicode.java b/src/main/java/com/gtnewhorizons/angelica/client/font/FontProviderUnicode.java index f8c412cf8..466abb74f 100644 --- a/src/main/java/com/gtnewhorizons/angelica/client/font/FontProviderUnicode.java +++ b/src/main/java/com/gtnewhorizons/angelica/client/font/FontProviderUnicode.java @@ -1,16 +1,31 @@ package com.gtnewhorizons.angelica.client.font; import com.gtnewhorizons.angelica.config.FontConfig; +import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; +import java.io.IOException; +import java.io.InputStream; + public final class FontProviderUnicode implements FontProvider { - private FontProviderUnicode() {} + private FontProviderUnicode() { + try { + InputStream inputstream = Minecraft.getMinecraft().getResourceManager() + .getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream(); + //noinspection ResultOfMethodCallIgnored + inputstream.read(this.glyphWidth); + } + catch (IOException ioexception) { + throw new RuntimeException(ioexception); + } + } + private static class InstLoader { static final FontProviderUnicode instance = new FontProviderUnicode(); } public static FontProviderUnicode get() { return FontProviderUnicode.InstLoader.instance; } private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; - public byte[] glyphWidth; + private final byte[] glyphWidth = new byte[65536]; private ResourceLocation getUnicodePageLocation(int page) { final ResourceLocation lookup = unicodePageLocations[page]; diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/fontrenderer/MixinFontRenderer.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/fontrenderer/MixinFontRenderer.java index 3e1fc718a..11bd90b00 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/fontrenderer/MixinFontRenderer.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/fontrenderer/MixinFontRenderer.java @@ -120,7 +120,7 @@ public abstract class MixinFontRenderer implements FontRendererAccessor, IFontPa @Inject(method = "", at = @At("TAIL")) private void angelica$injectBatcher(GameSettings settings, ResourceLocation fontLocation, TextureManager texManager, boolean unicodeMode, CallbackInfo ci) { - angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, this.charWidth, this.glyphWidth, this.colorCode, this.locationFontTexture); + angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, this.charWidth, this.colorCode, this.locationFontTexture); } @Unique