Custom Fonts

This commit is contained in:
PeytonPlayz595 2023-10-29 15:41:39 +00:00
parent c12b251741
commit 4a546fdd3e
10 changed files with 108643 additions and 108387 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -226,6 +226,10 @@ public class Config {
}
}
public static boolean isCustomFonts() {
return Minecraft.getMinecraft().gameSettings.ofCustomFonts;
}
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) {
return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
}

View File

@ -0,0 +1,99 @@
package net.PeytonPlayz585.shadow;
import net.minecraft.client.Minecraft;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import net.minecraft.util.ResourceLocation;
public class FontUtils {
public static Properties readFontProperties(ResourceLocation p_readFontProperties_0_) {
String s = p_readFontProperties_0_.getResourcePath();
Properties properties = new Properties();
String s1 = ".png";
if (!s.endsWith(s1)) {
return properties;
} else {
String s2 = s.substring(0, s.length() - s1.length()) + ".properties";
try {
ResourceLocation resourcelocation = new ResourceLocation(p_readFontProperties_0_.getResourceDomain(), s2);
InputStream inputstream = Config.getResourceStream(Minecraft.getMinecraft().getResourceManager(), resourcelocation);
if (inputstream == null) {
return properties;
}
Config.log("Loading " + s2);
properties.load(inputstream);
} catch (FileNotFoundException var7) {
;
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
return properties;
}
}
public static void readCustomCharWidths(Properties p_readCustomCharWidths_0_, float[] p_readCustomCharWidths_1_) {
for (Object s0 : p_readCustomCharWidths_0_.keySet()) {
String s = (String) s0;
String s1 = "width.";
if (s.startsWith(s1)) {
String s2 = s.substring(s1.length());
int i = Config.parseInt(s2, -1);
if (i >= 0 && i < p_readCustomCharWidths_1_.length) {
String s3 = p_readCustomCharWidths_0_.getProperty(s);
float f = Config.parseFloat(s3, -1.0F);
if (f >= 0.0F) {
p_readCustomCharWidths_1_[i] = f;
}
}
}
}
}
public static float readFloat(Properties p_readFloat_0_, String p_readFloat_1_, float p_readFloat_2_) {
String s = p_readFloat_0_.getProperty(p_readFloat_1_);
if (s == null) {
return p_readFloat_2_;
} else {
float f = Config.parseFloat(s, Float.MIN_VALUE);
if (f == Float.MIN_VALUE) {
Config.warn("Invalid value for " + p_readFloat_1_ + ": " + s);
return p_readFloat_2_;
} else {
return f;
}
}
}
public static ResourceLocation getHdFontLocation(ResourceLocation p_getHdFontLocation_0_) {
if (!Config.isCustomFonts()) {
return p_getHdFontLocation_0_;
} else if (p_getHdFontLocation_0_ == null) {
return p_getHdFontLocation_0_;
} else {
String s = p_getHdFontLocation_0_.getResourcePath();
String s1 = "textures/";
String s2 = "mcpatcher/";
if (!s.startsWith(s1)) {
return p_getHdFontLocation_0_;
} else {
s = s.substring(s1.length());
s = s2 + s;
ResourceLocation resourcelocation = new ResourceLocation(p_getHdFontLocation_0_.getResourceDomain(), s);
return Config.hasResource(Minecraft.getMinecraft().getResourceManager(), resourcelocation) ? resourcelocation : p_getHdFontLocation_0_;
}
}
}
}

View File

@ -133,6 +133,7 @@ public class TextureUtils {
CustomSky.reset();
update();
BetterGrass.update();
BetterSnow.update();
CustomSky.update();
SmartLeaves.updateLeavesModels();
}

View File

@ -10,7 +10,7 @@ public class GuiQuality extends GuiScreen {
protected String title;
private GameSettings settings;
//private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.AA_LEVEL, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS};
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS};
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS};
public GuiQuality(GuiScreen p_i53_1_) {
this.prevScreen = p_i53_1_;

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.HString;
@ -21,6 +22,9 @@ import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.ResourceLocation;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.FontUtils;
/**+
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
*
@ -44,7 +48,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
/**+
* Array of width of all the characters in default.png
*/
protected int[] charWidth = new int[256];
protected float[] charWidth = new float[256];
/**+
* the height in pixels of default text
*/
@ -61,7 +65,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
* shadows.
*/
protected int[] colorCode = new int[32];
protected final ResourceLocation locationFontTexture;
protected ResourceLocation locationFontTexture;
protected final TextureManager renderEngine;
protected float posX;
protected float posY;
@ -77,12 +81,17 @@ public class FontRenderer implements IResourceManagerReloadListener {
protected boolean italicStyle;
protected boolean underlineStyle;
protected boolean strikethroughStyle;
public float offsetBold = 1.0F;
public ResourceLocation locationFontTextureBase;
public FontRenderer(GameSettings gameSettingsIn, ResourceLocation location, TextureManager textureManagerIn,
boolean unicode) {
this.locationFontTextureBase = location;
this.locationFontTexture = location;
this.renderEngine = textureManagerIn;
this.unicodeFlag = unicode;
this.locationFontTexture = FontUtils.getHdFontLocation(this.locationFontTextureBase);
textureManagerIn.bindTexture(this.locationFontTexture);
for (int i = 0; i < 32; ++i) {
@ -116,6 +125,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
}
public void onResourceManagerReload(IResourceManager resourceManager) {
this.locationFontTexture = FontUtils.getHdFontLocation(this.locationFontTextureBase);
this.readFontTexture();
}
@ -128,6 +138,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
throw new RuntimeException(ioexception);
}
Properties properties = FontUtils.readFontProperties(this.locationFontTexture);
int i = bufferedimage.width;
int j = bufferedimage.height;
int[] aint = bufferedimage.pixels;
@ -135,6 +146,13 @@ public class FontRenderer implements IResourceManagerReloadListener {
int l = i / 16;
byte b0 = 1;
float f = 8.0F / (float) l;
float f1 = Config.limit(f, 1.0F, 2.0F);
this.offsetBold = 1.0F / f1;
float f2 = FontUtils.readFloat(properties, "offsetBold", -1.0F);
if (f2 >= 0.0F) {
this.offsetBold = f2;
}
for (int i1 = 0; i1 < 256; ++i1) {
int j1 = i1 % 16;
@ -164,6 +182,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
this.charWidth[i1] = (int) (0.5D + (double) ((float) l1 * f)) + b0;
}
FontUtils.readCustomCharWidths(properties, this.charWidth);
}
private void readGlyphSizes() {
@ -198,37 +217,26 @@ public class FontRenderer implements IResourceManagerReloadListener {
*/
private float renderDefaultChar(int parInt1, boolean parFlag) {
int i = parInt1 % 16 * 8;
int j = parInt1 / 16 * 8;
int k = parFlag ? 1 : 0;
this.renderEngine.bindTexture(this.locationFontTexture);
int l = this.charWidth[parInt1];
float f = (float) l - 0.01F;
int j = parInt1 / 16 * 8;
int k = parFlag ? 1 : 0;
this.renderEngine.bindTexture(this.locationFontTexture);
float f = this.charWidth[parInt1];
float f1 = 7.99F;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(Tessellator.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos(this.posX + (float) k, this.posY, 0.0F).tex((float) i / 128.0F, (float) j / 128.0F)
.endVertex();
worldrenderer.pos(this.posX - (float) k, this.posY + 7.99F, 0.0F)
.tex((float) i / 128.0F, ((float) j + 7.99F) / 128.0F).endVertex();
worldrenderer.pos(this.posX + f - 1.0F + (float) k, this.posY, 0.0F)
.tex(((float) i + f - 1.0F) / 128.0F, (float) j / 128.0F).endVertex();
worldrenderer.pos(this.posX + f - 1.0F - (float) k, this.posY + 7.99F, 0.0F)
.tex(((float) i + f - 1.0F) / 128.0F, ((float) j + 7.99F) / 128.0F).endVertex();
worldrenderer.pos(this.posX + (float) k, this.posY, 0.0F).tex((float) i / 128.0F, (float) j / 128.0F).endVertex();
worldrenderer.pos(this.posX - (float) k, this.posY + 7.99F, 0.0F).tex((float) i / 128.0F, ((float) j + 7.99F) / 128.0F).endVertex();
worldrenderer.pos(this.posX + f - 1.0F + (float) k, this.posY, 0.0F).tex(((float) i + f - 1.0F) / 128.0F, (float) j / 128.0F).endVertex();
worldrenderer.pos(this.posX + f - 1.0F - (float) k, this.posY + 7.99F, 0.0F).tex(((float) i + f - 1.0F) / 128.0F, ((float) j + 7.99F) / 128.0F).endVertex();
tessellator.draw();
return (float) l;
return f;
}
private ResourceLocation getUnicodePageLocation(int parInt1) {
if (unicodePageLocations[parInt1] == null) {
unicodePageLocations[parInt1] = new ResourceLocation(
HString.format("textures/font/unicode_page_%02x.png", new Object[] { Integer.valueOf(parInt1) }));
unicodePageLocations[parInt1] = new ResourceLocation(HString.format("textures/font/unicode_page_%02x.png", new Object[] { Integer.valueOf(parInt1) }));
unicodePageLocations[parInt1] = FontUtils.getHdFontLocation(unicodePageLocations[parInt1]);
}
return unicodePageLocations[parInt1];
@ -408,7 +416,7 @@ public class FontRenderer implements IResourceManagerReloadListener {
c0 = c1;
}
float f1 = this.unicodeFlag ? 0.5F : 1.0F;
float f1 = j != -1 && !this.unicodeFlag ? this.offsetBold : 0.5F;
boolean flag = (c0 == 0 || j == -1 || this.unicodeFlag) && parFlag;
if (flag) {
this.posX -= f1;
@ -533,67 +541,70 @@ public class FontRenderer implements IResourceManagerReloadListener {
* FontMetrics.stringWidth(String s).
*/
public int getStringWidth(String text) {
if (text == null) {
return 0;
} else {
int i = 0;
boolean flag = false;
if (text == null) {
return 0;
} else {
float f = 0.0F;
boolean flag = false;
for (int j = 0; j < text.length(); ++j) {
char c0 = text.charAt(j);
int k = this.getCharWidth(c0);
if (k < 0 && j < text.length() - 1) {
++j;
c0 = text.charAt(j);
if (c0 != 108 && c0 != 76) {
if (c0 == 114 || c0 == 82) {
flag = false;
}
} else {
flag = true;
}
for (int i = 0; i < text.length(); ++i) {
char c0 = text.charAt(i);
float f1 = this.getCharWidthFloat(c0);
k = 0;
}
if (f1 < 0.0F && i < text.length() - 1) {
++i;
c0 = text.charAt(i);
i += k;
if (flag && k > 0) {
++i;
}
}
if (c0 != 108 && c0 != 76) {
if (c0 == 114 || c0 == 82) {
flag = false;
}
} else {
flag = true;
}
return i;
}
}
f1 = 0.0F;
}
f += f1;
if (flag && f1 > 0.0F) {
f += this.unicodeFlag ? 1.0F : this.offsetBold;
}
}
return (int)f;
}
}
/**+
* Returns the width of this character as rendered.
*/
public int getCharWidth(char character) {
if (character == 167) {
return -1;
} else if (character == 32) {
return 4;
} else {
int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000"
.indexOf(character);
if (character > 0 && i != -1 && !this.unicodeFlag) {
return this.charWidth[i];
} else if (this.glyphWidth[character] != 0) {
int j = this.glyphWidth[character] >>> 4;
int k = this.glyphWidth[character] & 15;
if (k > 7) {
k = 15;
j = 0;
}
return Math.round(this.getCharWidthFloat(character));
}
++k;
return (k - j) / 2 + 1;
} else {
return 0;
}
}
}
private float getCharWidthFloat(char p_getCharWidthFloat_1_) {
if (p_getCharWidthFloat_1_ == 167) {
return -1.0F;
} else if (p_getCharWidthFloat_1_ == 32) {
return this.charWidth[32];
} else {
int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_getCharWidthFloat_1_);
if (p_getCharWidthFloat_1_ > 0 && i != -1 && !this.unicodeFlag) {
return this.charWidth[i];
} else if (this.glyphWidth[p_getCharWidthFloat_1_] != 0) {
int j = this.glyphWidth[p_getCharWidthFloat_1_] >>> 4;
int k = this.glyphWidth[p_getCharWidthFloat_1_] & 15;
j = j & 15;
++k;
return (float)((k - j) / 2 + 1);
} else {
return 0.0F;
}
}
}
/**+
* Trims a string to fit a specified Width.

View File

@ -195,6 +195,7 @@ public class GameSettings {
public boolean ofCustomSky = true;
public boolean ofClearWater = false;
public boolean ofBetterSnow = false;
public boolean ofCustomFonts = true;
public int ofBetterGrass = 3;
public int ofDynamicLights = 3;
@ -759,6 +760,12 @@ public class GameSettings {
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.CUSTOM_FONTS) {
this.ofCustomFonts = !this.ofCustomFonts;
this.mc.fontRendererObj.onResourceManagerReload(this.mc.getResourceManager());
this.mc.standardGalacticFontRenderer.onResourceManagerReload(this.mc.getResourceManager());
}
this.saveOptions();
}
@ -1105,6 +1112,8 @@ public class GameSettings {
return this.ofDynamicFov ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.BETTER_SNOW) {
return this.ofBetterSnow ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.CUSTOM_FONTS) {
return this.ofCustomFonts ? s + "ON" : s + "OFF";
} else {
return s;
}
@ -1582,6 +1591,10 @@ public class GameSettings {
this.ofBetterSnow = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofCustomFonts") && astring.length >= 2) {
this.ofCustomFonts = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory.values()) {
@ -1732,6 +1745,7 @@ public class GameSettings {
printwriter.println("ofDynamicFov:" + this.ofDynamicFov);
printwriter.println("ofMipmapType:" + this.ofMipmapType);
printwriter.println("ofBetterSnow:" + this.ofBetterSnow);
printwriter.println("ofCustomFonts:" + this.ofCustomFonts);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1919,7 +1933,8 @@ public class GameSettings {
VIGNETTE("Vignette", false, false),
DYNAMIC_FOV("Dynamic FOV", false, false),
MIPMAP_TYPE("Mipmap Type", true, false, 0.0F, 3.0F, 1.0F),
BETTER_SNOW("Better Snow", false, false);
BETTER_SNOW("Better Snow", false, false),
CUSTOM_FONTS("Custom Fonts", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;