add more fonts

This commit is contained in:
Sen 2025-06-30 18:34:06 +02:00
parent 681bb4dc4e
commit a73901a584
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
6 changed files with 39 additions and 11 deletions

View file

@ -253,8 +253,9 @@ public class Client implements IThreadListener {
}
}
public static class FontFunction implements BoolFunction {
public void apply(BoolVar cv, boolean value) {
public static class FontFunction implements EnumFunction<Font> {
public void apply(EnumVar cv, Font value) {
Font.unload();
Font.load(value);
Client.CLIENT.rescale();
}
@ -473,8 +474,8 @@ public class Client implements IThreadListener {
public Style style = Style.DEFAULT;
@Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen")
public int scrollLines = 3;
@Variable(name = "gui_font_tiny", category = CVarCategory.GUI, display = "Kleine Schrift", callback = FontFunction.class)
public boolean tinyFont = false;
@Variable(name = "gui_font", category = CVarCategory.GUI, display = "Schriftart", callback = FontFunction.class)
public Font font = Font.LARGE;
@Variable(name = "draw_downfall_range", category = CVarCategory.RENDER, min = 0, max = 15, display = "Niederschlag-Radius")
public int downfallRange = 10;
@ -2249,7 +2250,7 @@ public class Client implements IThreadListener {
this.registerDebug();
System.gc();
System.gc();
Font.load(false);
Font.load(Font.LARGE);
GlState.enableBlend();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.initConsole();

View file

@ -10,14 +10,26 @@ import client.renderer.GlState;
import client.renderer.texture.TextureUtil;
import client.util.FileUtils;
import common.log.Log;
import common.util.Displayable;
import common.util.Identifyable;
public class Font {
public enum Font implements Identifyable, Displayable {
TINY("tiny", "Winzig", 6, 7),
SMALL("small", "Klein", 8, 10),
MEDIUM("medium", "Mittel", 10, 12),
LARGE("large", "Groß", 12, 14);
public static final FontChar[] SIZES = new FontChar[256];
public static int XGLYPH = 12;
public static int YGLYPH = 14;
private static int texture;
private final String name;
private final String display;
private final int width;
private final int height;
public static void bindTexture() {
GlState.bindTexture(texture);
@ -73,12 +85,12 @@ public class Font {
}
}
public static void load(boolean tiny) {
XGLYPH = tiny ? 6 : 12;
YGLYPH = tiny ? 7 : 14;
public static void load(Font font) {
XGLYPH = font.width;
YGLYPH = font.height;
BufferedImage img = null;
try {
img = TextureUtil.readImage(FileUtils.getResource("textures/font" + (tiny ? "_tiny" : "") + ".png"));
img = TextureUtil.readImage(FileUtils.getResource("textures/font_" + font.name + ".png"));
}
catch(FileNotFoundException e) {
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden");
@ -107,4 +119,19 @@ public class Font {
texture = 0;
}
}
private Font(String name, String display, int width, int height) {
this.name = name;
this.display = display;
this.width = width;
this.height = height;
}
public String getName() {
return this.name;
}
public String getDisplay() {
return this.display;
}
}

View file

@ -73,7 +73,7 @@ public class GuiStyle extends GuiOptions implements DropdownCallback<String>, Bu
}
this.addSelector("gui_scale", 0, 5 * 34 + (Style.values().length / 3) * 20, 181, 0);
this.addSelector("gui_font_tiny", 183, 5 * 34 + (Style.values().length / 3) * 20, 181, 0);
this.addSelector("gui_font", 183, 5 * 34 + (Style.values().length / 3) * 20, 181, 0);
if(this.gm.style != Style.CUSTOM) {
this.add(new ActButton(0, 3 * 34, 364, 0, new ButtonCallback() {

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB