aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-07 13:50:37 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-07 13:50:37 +0200
commit80e344c9506749e5ed3960a102cee1c1ec32a60f (patch)
tree332938ce953491f770b23faaecb6f472021b304d /src
parent28eb14969329b0cbf6e97c9d62917b17078bba0b (diff)
downloadOneConfig-80e344c9506749e5ed3960a102cee1c1ec32a60f.tar.gz
OneConfig-80e344c9506749e5ed3960a102cee1c1ec32a60f.tar.bz2
OneConfig-80e344c9506749e5ed3960a102cee1c1ec32a60f.zip
<@266571433663135744> reducing the amount of brain cells I have one at a time
Diffstat (limited to 'src')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java4
5 files changed, 16 insertions, 35 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
index d07f515..13f8fd8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -6,6 +6,8 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
+import java.awt.*;
+
public class HomePage extends Page {
private final BasicButton btn = new BasicButton(184, 36, "Socials", Images.SHARE, Images.LAUNCH, 1, BasicButton.ALIGNMENT_CENTER);
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
index 4d5df83..b596e0c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -152,15 +152,9 @@ public final class RenderManager {
nvgColor.free();
}
- public static float fontSizeToNVGFontSize(float fontSize, Font font) {
- float pixelsPerFUnit = (fontSize * 72f) / (72f * font.getUnitsPerEm());
- return font.getAscender() * pixelsPerFUnit - (font.getDescender() * pixelsPerFUnit);
- }
-
-
public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
+ nvgFontSize(vg, size);
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
@@ -171,7 +165,7 @@ public final class RenderManager {
public static void drawString(long vg, String text, float x, float y, int color, float size, int lineHeight, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
+ nvgFontSize(vg, size);
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
nvgTextMetrics(vg, new float[]{10f}, new float[]{10f}, new float[]{lineHeight});
@@ -183,7 +177,7 @@ public final class RenderManager {
public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Fonts font) {
nvgBeginPath(vg);
- nvgFontSize(vg, fontSizeToNVGFontSize(size, font.font));
+ nvgFontSize(vg, size);
nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
@@ -230,7 +224,7 @@ public final class RenderManager {
public static float getTextWidth(long vg, String text, float fontSize, Fonts font) {
float[] bounds = new float[4];
- nvgFontSize(vg, fontSizeToNVGFontSize(fontSize, font.font));
+ nvgFontSize(vg, fontSize);
nvgFontFace(vg, font.font.getName());
return nvgTextBounds(vg, 0, 0, text, bounds);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
index 649252b..a369f26 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java
@@ -1,5 +1,7 @@
package cc.polyfrost.oneconfig.lwjgl.font;
+import org.lwjgl.nanovg.NanoVG;
+
import java.nio.ByteBuffer;
public class Font {
@@ -7,16 +9,10 @@ public class Font {
private final String name;
private boolean loaded = false;
private ByteBuffer buffer = null;
- private final int unitsPerEm;
- private final int ascender;
- private final int descender;
- public Font(String name, String fileName, int unitsPerEm, int ascender, int descender) {
+ public Font(String name, String fileName) {
this.name = name;
this.fileName = fileName;
- this.unitsPerEm = unitsPerEm;
- this.ascender = ascender;
- this.descender = descender;
}
public String getName() {
@@ -43,15 +39,5 @@ public class Font {
this.buffer = buffer;
}
- public int getUnitsPerEm() {
- return unitsPerEm;
- }
-
- public int getAscender() {
- return ascender;
- }
-
- public int getDescender() {
- return descender;
- }
}
+
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
index f208131..ca6c971 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Fonts.java
@@ -1,11 +1,10 @@
package cc.polyfrost.oneconfig.lwjgl.font;
public enum Fonts {
- // https://opentype.js.org/font-inspector.html
- BOLD(new Font("inter-bold", "/assets/oneconfig/font/Bold.otf", 2816, 2728, -680)),
- SEMIBOLD(new Font("inter-semibold", "/assets/oneconfig/font/SemiBold.otf", 2816, 2728, -680)),
- MEDIUM(new Font("inter-medium", "/assets/oneconfig/font/Medium.otf", 2816, 2728, -680)),
- REGULAR(new Font("inter-regular", "/assets/oneconfig/font/Regular.otf", 2816, 2728, -680));
+ BOLD(new Font("inter-bold", "/assets/oneconfig/font/Bold.otf")),
+ SEMIBOLD(new Font("inter-semibold", "/assets/oneconfig/font/SemiBold.otf")),
+ MEDIUM(new Font("inter-medium", "/assets/oneconfig/font/Medium.otf")),
+ REGULAR(new Font("inter-regular", "/assets/oneconfig/font/Regular.otf"));
public final Font font;
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
index 475c68b..6b8e748 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
@@ -107,9 +107,9 @@ public class TestConfig extends Config {
public static int uniSelector7;
@Option(
- name = "Test option",
+ name = "Arrow Uniselect (1x)",
subcategory = "Test",
- options = {"Hello", "World", "Fish", "Cat"},
+ options = {"Option", "World", "Fish"},
type = OptionType.UNI_SELECTOR,
size = 2
)