Upload files to "src/openonyx/render/group_e"
This commit is contained in:
1 parent
8c3a0a5645
commit
3f5227161f
5 files changed
+499
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package openonyx.render.group_e;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class FontFamily {
|
||||
public static final float i = 16.0F;
|
||||
private static GlyphFont glyphFont;
|
||||
private static final String H = "/assets/onyx/font/ttf/";
|
||||
private static final GlyphFont[][] GLYPH_FONTS = new GlyphFont[FontFamilyMode.values().length][TargetHudTextSettingsWeightMode.values().length];
|
||||
|
||||
private FontFamily() {
|
||||
}
|
||||
|
||||
public static GlyphFont L() {
|
||||
if (glyphFont == null) {
|
||||
glyphFont = GlyphFont.L("/assets/onyx/font/ttf/materialicons-regular.ttf", 16.0F);
|
||||
}
|
||||
|
||||
return glyphFont;
|
||||
}
|
||||
|
||||
public static GlyphFont L(FontFamilyMode fontFamilyMode, TargetHudTextSettingsWeightMode targetHudTextSettingsWeightMode) {
|
||||
FontFamilyMode fontFamilyMode1 = fontFamilyMode;
|
||||
GlyphFont glyphFontx;
|
||||
if ((glyphFontx = GLYPH_FONTS[fontFamilyMode1.ordinal()][targetHudTextSettingsWeightMode.ordinal()]) != null) {
|
||||
return glyphFontx;
|
||||
}
|
||||
|
||||
GlyphFont glyphFont1 = GlyphFont.L(
|
||||
new StringBuilder()
|
||||
.insert(0, "/assets/onyx/font/ttf/googlesansflex_")
|
||||
.append(fontFamilyMode1.L())
|
||||
.append("-")
|
||||
.append(targetHudTextSettingsWeightMode.name().toLowerCase(Locale.ROOT).replace("_", ""))
|
||||
.append(".ttf")
|
||||
.toString(),
|
||||
fontFamilyMode1.L()
|
||||
);
|
||||
GLYPH_FONTS[fontFamilyMode1.ordinal()][targetHudTextSettingsWeightMode.ordinal()] = glyphFont1;
|
||||
return glyphFont1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package openonyx.render.group_e;
|
||||
|
||||
public enum FontFamilyMode {
|
||||
PT72("72pt", 54.0F),
|
||||
PT120("120pt", 144.0F),
|
||||
PT36("36pt", 36.0F),
|
||||
PT24("24pt", 24.0F),
|
||||
PT9("9pt", 18.0F);
|
||||
|
||||
private final String d;
|
||||
private final float e;
|
||||
|
||||
public String L() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
FontFamilyMode(String string1, float f) {
|
||||
this.d = string1;
|
||||
this.e = f;
|
||||
}
|
||||
|
||||
public float L() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
private static FontFamilyMode[] L() {
|
||||
FontFamilyMode[] fontFamilyModes = new FontFamilyMode[5];
|
||||
boolean bl = true;
|
||||
fontFamilyModes[0] = PT9;
|
||||
fontFamilyModes[1] = PT24;
|
||||
fontFamilyModes[2] = PT36;
|
||||
fontFamilyModes[3] = PT72;
|
||||
fontFamilyModes[4] = PT120;
|
||||
return fontFamilyModes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package openonyx.render.group_e;
|
||||
|
||||
public record FontStyle(FontFamilyMode optical, TargetHudTextSettingsWeightMode weight, float size, float lineHeight) {
|
||||
public float h() {
|
||||
return this.i() + this.D();
|
||||
}
|
||||
|
||||
public static String decrypt(String string) {
|
||||
String string1 = string;
|
||||
int k = (--3 ^ 5) << 3 ^ 4;
|
||||
String string2;
|
||||
int n = (string2 = string1).length();
|
||||
char[] e = new char[n];
|
||||
boolean bl = true;
|
||||
int i;
|
||||
int m = i = n - 1;
|
||||
char[] c = e;
|
||||
byte d = 125;
|
||||
k = m;
|
||||
byte b = 101;
|
||||
|
||||
while (k >= 0) {
|
||||
int l = i;
|
||||
int j = string2.charAt(i);
|
||||
i--;
|
||||
c[l] = (char)(j ^ b);
|
||||
if (i < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
j = i--;
|
||||
c[j] = (char)(string2.charAt(j) ^ d);
|
||||
k = i;
|
||||
}
|
||||
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
public float i() {
|
||||
return this.L().d() * this.L();
|
||||
}
|
||||
|
||||
public float D() {
|
||||
return this.L().L() * this.L();
|
||||
}
|
||||
|
||||
public float L() {
|
||||
return this.size / this.optical.L();
|
||||
}
|
||||
|
||||
public GlyphFont L() {
|
||||
return FontFamily.L(this.optical, this.weight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
package openonyx.render.group_e;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import openonyx.core.OnyxClient;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class GlyphFont {
|
||||
private boolean E;
|
||||
private final Map<Character, GlyphFontData> glyphFontDataMap;
|
||||
private final float G;
|
||||
private int A;
|
||||
private final float K;
|
||||
private int B;
|
||||
private int C;
|
||||
private static final int J = 8;
|
||||
private int D;
|
||||
private static final GlyphFontData GLYPH_FONT_DATA = GlyphFont.GLYPH_FONT_DATA2;
|
||||
private static final int a = 512;
|
||||
private static final int k = 3;
|
||||
private final Font font;
|
||||
private static final int M = 2048;
|
||||
private static final int L = 8;
|
||||
private static final int j = 192;
|
||||
private static final float m = 100.0F;
|
||||
private static final GlyphFontData GLYPH_FONT_DATA2 = new GlyphFontData(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
public static final int l = 4;
|
||||
private static final int I = 12;
|
||||
private final FontRenderContext fontRenderContext;
|
||||
private final int i;
|
||||
private final float f;
|
||||
private static final float H = 0.72F;
|
||||
private static final float e = 0.21F;
|
||||
|
||||
public float D(char c) {
|
||||
return this.d(c).advance();
|
||||
}
|
||||
|
||||
private static byte[] L(byte[] b, int i, int j, int k, int l) {
|
||||
byte[] d = b;
|
||||
byte[] ex = new byte[kx * lx];
|
||||
byte fx = 1;
|
||||
byte[] c = ex;
|
||||
|
||||
int mx;
|
||||
for (int t = mx = 0; t < lx; t = ++mx) {
|
||||
int n;
|
||||
int o = Math.min((n = mx * 2) + 1, jx - 1);
|
||||
|
||||
int p;
|
||||
for (int u = p = 0; u < kx; u = p) {
|
||||
int r;
|
||||
int q = Math.min((r = p * 2) + 1, ix - 1);
|
||||
int s = (d[n * ix + r] & 255) + (d[n * ix + q] & 255) + (d[o * ix + r] & 255) + (d[o * ix + q] & 255);
|
||||
int v = mx * kx + p;
|
||||
fx = (byte)(s >> 2);
|
||||
p++;
|
||||
c[v] = fx;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public float d() {
|
||||
return this.G;
|
||||
}
|
||||
|
||||
private float d(char c) {
|
||||
return -this.L(c).y * this.K;
|
||||
}
|
||||
|
||||
private void L(int i, int j, int k, int l, int m, byte[] b) {
|
||||
ByteBuffer byteBuffer;
|
||||
(byteBuffer = BufferUtils.createByteBuffer(lx * mx)).put(b, 0, lx * mx).flip();
|
||||
GL11.glTexSubImage2D(3553, ix, jx, kx, lx, mx, 6406, 5121, byteBuffer);
|
||||
}
|
||||
|
||||
public static GlyphFont L(String string, float f) {
|
||||
String string1 = string;
|
||||
|
||||
try {
|
||||
InputStream inputStream = GlyphFont.class.getResourceAsStream(string1);
|
||||
|
||||
GlyphFont glyphFont;
|
||||
try {
|
||||
if (inputStream == null) {
|
||||
throw new IOException(new StringBuilder().insert(0, "Missing font ").append(string1).toString());
|
||||
}
|
||||
|
||||
glyphFont = new GlyphFont(Font.createFont(0, inputStream), fx);
|
||||
} catch (Throwable throwable1) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (Throwable throwable) {
|
||||
throwable1.addSuppressed(throwable);
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
return glyphFont;
|
||||
} catch (Exception exception) {
|
||||
Logger logger = OnyxClient.LOGGER;
|
||||
Object[] objects = new Object[2];
|
||||
boolean bl = true;
|
||||
objects[0] = string1;
|
||||
objects[1] = exception;
|
||||
logger.error("Failed to load font '{}'", objects);
|
||||
return new GlyphFont(new Font("SansSerif", 0, 1), fx);
|
||||
}
|
||||
}
|
||||
|
||||
private GlyphFont(Font font, float f) {
|
||||
GlyphFont glyphFont1 = this;
|
||||
glyphFont1./* $VF: Unable to resugar constructor */<init>();
|
||||
glyphFont1.glyphFontDataMap = new HashMap<>();
|
||||
glyphFont1.fontRenderContext = new FontRenderContext(null, true, true);
|
||||
glyphFont1.B = -1;
|
||||
float h = Math.min(fx * 4.0F, 192.0F);
|
||||
LineMetrics lineMetrics;
|
||||
float lx;
|
||||
float g = (lx = (lineMetrics = fontx.deriveFont(100.0F).getLineMetrics("Ayg", glyphFont1.fontRenderContext)).getAscent() + lineMetrics.getDescent())
|
||||
<= 0.0F
|
||||
? 1.0F
|
||||
: 100.0F / lx;
|
||||
glyphFont1.font = fontx.deriveFont(h * g);
|
||||
glyphFont1.K = fx / h;
|
||||
int jx = (int)h + 16;
|
||||
glyphFont1.i = Math.min(2048, Math.max(512, Integer.highestOneBit(jx * 12 - 1) * 2));
|
||||
float kx = glyphFont1.d('H');
|
||||
float ix = glyphFont1.L('p');
|
||||
glyphFont1.G = kx > 0.0F ? kx : fx * 0.72F;
|
||||
glyphFont1.f = ix > 0.0F ? ix : fx * 0.21F;
|
||||
}
|
||||
|
||||
public float L(String string) {
|
||||
GlyphFont glyphFont1 = this;
|
||||
float fx = 0.0F;
|
||||
|
||||
int ix;
|
||||
for (int jx = ix = 0; jx < string.length(); jx = ix) {
|
||||
char c = string.charAt(ix);
|
||||
ix++;
|
||||
fx += glyphFont1.D(c);
|
||||
}
|
||||
|
||||
return fx;
|
||||
}
|
||||
|
||||
private static int L(int i) {
|
||||
return ix + 8 - 1 & -8;
|
||||
}
|
||||
|
||||
private int[] L(int i, int j) {
|
||||
if (this.E) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ix = L(ix);
|
||||
jx = L(jx);
|
||||
if (this.A + ix > this.i) {
|
||||
this.A = 0;
|
||||
this.C = this.C + this.D;
|
||||
this.D = 0;
|
||||
}
|
||||
|
||||
if (this.C + jx > this.i) {
|
||||
this.E = true;
|
||||
Logger logger = OnyxClient.LOGGER;
|
||||
Object[] objects = new Object[1];
|
||||
boolean bl1 = true;
|
||||
objects[0] = this.i;
|
||||
logger.warn("Glyph atlas full at {}px", objects);
|
||||
return null;
|
||||
} else {
|
||||
int[] kx = new int[2];
|
||||
boolean bl = true;
|
||||
kx[0] = this.A;
|
||||
kx[1] = this.C;
|
||||
this.A += ix;
|
||||
this.D = Math.max(this.D, jx);
|
||||
return kx;
|
||||
}
|
||||
}
|
||||
|
||||
public float L() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
private void L(BufferedImage bufferedImage, int i, int j, int k, int l) {
|
||||
if (this.B == -1) {
|
||||
this.L();
|
||||
}
|
||||
|
||||
int[] o;
|
||||
byte[] c = new byte[(o = ((DataBufferInt)bufferedImage.getRaster().getDataBuffer()).getData()).length];
|
||||
byte d = 1;
|
||||
byte[] b = c;
|
||||
|
||||
int mx;
|
||||
for (int q = mx = 0; q < o.length; q = mx) {
|
||||
int s = mx;
|
||||
d = (byte)(o[mx] >>> 24);
|
||||
mx++;
|
||||
b[s] = d;
|
||||
}
|
||||
|
||||
GlStateManager.bindTexture(this.B);
|
||||
GL11.glPixelStorei(3317, 1);
|
||||
mx = kx;
|
||||
int p = lx;
|
||||
|
||||
for (int r = kx = 0; r <= 3; r = kx) {
|
||||
this.L(kx, ix >> kx, jx >> kx, mx, p, b);
|
||||
if (kx == 3) {
|
||||
break;
|
||||
}
|
||||
|
||||
lx = Math.max(1, mx >> 1);
|
||||
int n = Math.max(1, p >> 1);
|
||||
b = L(b, mx, p, lx, n);
|
||||
kx++;
|
||||
mx = lx;
|
||||
p = n;
|
||||
}
|
||||
|
||||
GL11.glPixelStorei(3317, 4);
|
||||
}
|
||||
|
||||
public GlyphFontData d(char c) {
|
||||
GlyphFont glyphFont1 = this;
|
||||
GlyphFontData glyphFontData;
|
||||
if ((glyphFontData = glyphFont1.glyphFontDataMap.get(c)) != null) {
|
||||
return glyphFontData;
|
||||
}
|
||||
|
||||
GlyphFontData glyphFontData1 = glyphFont1.L(c);
|
||||
glyphFont1.glyphFontDataMap.put(c, glyphFontData1);
|
||||
return glyphFontData1;
|
||||
}
|
||||
|
||||
private GlyphFontData L(char c) {
|
||||
if (!this.font.canDisplay(c)) {
|
||||
return GLYPH_FONT_DATA;
|
||||
}
|
||||
|
||||
char[] d = new char[1];
|
||||
boolean bl = true;
|
||||
d[0] = c;
|
||||
GlyphVector glyphVector = this.font.createGlyphVector(this.fontRenderContext, d);
|
||||
float fx = glyphVector.getGlyphMetrics(0).getAdvanceX() * this.K;
|
||||
Rectangle rectangle;
|
||||
if ((rectangle = glyphVector.getPixelBounds(this.fontRenderContext, 0.0F, 0.0F)).width > 0 && rectangle.height > 0) {
|
||||
int jx = rectangle.width + 16;
|
||||
int ix = rectangle.height + 16;
|
||||
if (jx <= this.i && ix <= this.i) {
|
||||
BufferedImage bufferedImage;
|
||||
Graphics2D graphics2D = (bufferedImage = new BufferedImage(jx, ix, 2)).createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
graphics2D.setColor(Color.WHITE);
|
||||
graphics2D.setFont(this.font);
|
||||
graphics2D.drawGlyphVector(glyphVector, 8 - rectangle.x, 8 - rectangle.y);
|
||||
graphics2D.dispose();
|
||||
int[] kx;
|
||||
if ((kx = this.L(jx, ix)) == null) {
|
||||
return GLYPH_FONT_DATA2;
|
||||
}
|
||||
|
||||
this.L(bufferedImage, kx[0], kx[1], jx, ix);
|
||||
return new GlyphFontData(
|
||||
(float)kx[0] / this.i,
|
||||
(float)kx[1] / this.i,
|
||||
(float)(kx[0] + jx) / this.i,
|
||||
(float)(kx[1] + ix) / this.i,
|
||||
(rectangle.x - 8) * this.K,
|
||||
(rectangle.y - 8) * this.K,
|
||||
jx * this.K,
|
||||
ix * this.K,
|
||||
fx
|
||||
);
|
||||
} else {
|
||||
return GLYPH_FONT_DATA2;
|
||||
}
|
||||
} else {
|
||||
return new GlyphFontData(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, fx);
|
||||
}
|
||||
}
|
||||
|
||||
private float L(char c) {
|
||||
Rectangle rectangle = this.L(c);
|
||||
return (rectangle.y + rectangle.height) * this.K;
|
||||
}
|
||||
|
||||
public boolean d(char c) {
|
||||
return Character.isWhitespace(c) ? true : this.L(c) && !this.d(c).L();
|
||||
}
|
||||
|
||||
public int L() {
|
||||
return this.B;
|
||||
}
|
||||
|
||||
public boolean L(char c) {
|
||||
return this.font.canDisplay(c);
|
||||
}
|
||||
|
||||
private Rectangle L(char c) {
|
||||
char[] d = new char[1];
|
||||
boolean bl = true;
|
||||
d[0] = c;
|
||||
return this.font.createGlyphVector(this.fontRenderContext, d).getPixelBounds(this.fontRenderContext, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
private void L() {
|
||||
GlyphFont glyphFont1 = this;
|
||||
glyphFont1.B = TextureUtil.glGenTextures();
|
||||
GlStateManager.bindTexture(glyphFont1.B);
|
||||
GL11.glTexParameteri(3553, 10241, 9987);
|
||||
GL11.glTexParameteri(3553, 10240, 9729);
|
||||
GL11.glTexParameteri(3553, 10242, 33071);
|
||||
GL11.glTexParameteri(3553, 10243, 33071);
|
||||
GL11.glTexParameteri(3553, 33085, 3);
|
||||
GL11.glPixelStorei(3317, 1);
|
||||
|
||||
for (int kx = jx = 0; kx <= 3; kx = jx) {
|
||||
int ix = glyphFont1.i >> jx;
|
||||
GL11.glTexImage2D(3553, jx++, 6406, ix, ix, 0, 6406, 5121, BufferUtils.createByteBuffer(ix * ix));
|
||||
}
|
||||
|
||||
GL11.glPixelStorei(3317, 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package openonyx.render.group_e;
|
||||
|
||||
public record GlyphFontData(float u0, float v0, float u1, float v1, float bearingX, float bearingY, float width, float height, float advance) {
|
||||
public boolean L() {
|
||||
return this.width <= 0.0F || this.height <= 0.0F;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user