generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/client/java/net/vinrobot/mcemote/client/font/CustomFontStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package net.vinrobot.mcemote.client.font; | ||
|
||
import net.minecraft.client.font.BuiltinEmptyGlyph; | ||
import net.minecraft.client.font.Font; | ||
import net.minecraft.client.font.FontStorage; | ||
import net.minecraft.client.font.Glyph; | ||
import net.minecraft.client.font.GlyphRenderer; | ||
import net.minecraft.client.texture.TextureManager; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.util.List; | ||
|
||
public abstract class CustomFontStorage extends FontStorage { | ||
private final Identifier identifier; | ||
private final TextureManager textureManager; | ||
private final GlyphRenderer blankGlyphRenderer; | ||
|
||
public CustomFontStorage(final TextureManager textureManager, final Identifier id) { | ||
super(textureManager, id); | ||
this.identifier = id; | ||
this.textureManager = textureManager; | ||
|
||
// blankGlyphRenderer is private in FontStorage, but we can get it from the getObfuscatedGlyphRenderer | ||
// because if it doesn't find the glyph, it returns the blankGlyphRenderer. | ||
this.blankGlyphRenderer = super.getObfuscatedGlyphRenderer(BuiltinEmptyGlyph.MISSING); | ||
} | ||
|
||
public final Identifier getIdentifier() { | ||
return this.identifier; | ||
} | ||
|
||
protected TextureManager getTextureManager() { | ||
return this.textureManager; | ||
} | ||
|
||
@Override | ||
public void setFonts(final List<Font> fonts) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public abstract Glyph getGlyph(int codePoint, boolean validateAdvance); | ||
|
||
@Override | ||
public abstract GlyphRenderer getGlyphRenderer(int codePoint); | ||
|
||
@Override | ||
public GlyphRenderer getObfuscatedGlyphRenderer(final Glyph glyph) { | ||
// Don't obfuscate the glyph by default, children can override this. | ||
return this.blankGlyphRenderer; | ||
} | ||
|
||
public GlyphRenderer getBlankGlyphRenderer() { | ||
return this.blankGlyphRenderer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters