diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-06 20:54:39 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-06 20:54:39 +0200 |
commit | 1e58db410a03088ab793b24fa999311c792f2337 (patch) | |
tree | 42693d8914f958a4cc78a8c2424bad6d079831d7 /src | |
parent | 1cfdef78d7f51f1d6e50dec4a16ac9dfe5f61a58 (diff) | |
download | OneConfig-1e58db410a03088ab793b24fa999311c792f2337.tar.gz OneConfig-1e58db410a03088ab793b24fa999311c792f2337.tar.bz2 OneConfig-1e58db410a03088ab793b24fa999311c792f2337.zip |
maybe fix font size
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java | 3 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java | 14 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java index abae368..00dbd9f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java @@ -70,8 +70,7 @@ public class ConfigSlider extends BasicOption { RenderManager.drawRoundedRect(vg, i - 2, y + 9, 4, 14, color, 2f); } } - if (step == 0) - RenderManager.drawRoundedRect(vg, xCoordinate - 12, y + 4, 24, 24, OneConfigConfig.WHITE, 12f); + if (step == 0) RenderManager.drawRoundedRect(vg, xCoordinate - 12, y + 4, 24, 24, OneConfigConfig.WHITE, 12f); else RenderManager.drawRoundedRect(vg, xCoordinate - 4, y + 4, 8, 24, OneConfigConfig.WHITE, 4f); inputField.draw(vg, x + 892, y); } diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java index 9af7122..94a2650 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -145,10 +145,16 @@ public final class RenderManager { nvgColor.free(); } + public static float fontSizeToNVGFontSize(float fontSize) { + int dpi = 72; + float pixelsPerFUnit = (fontSize * dpi) / (72f * 2816f); + return 2728f * pixelsPerFUnit - (-680 * pixelsPerFUnit); + } + public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) { nvgBeginPath(vg); - nvgFontSize(vg, size); + nvgFontSize(vg, fontSizeToNVGFontSize(size)); nvgFontFace(vg, font.font.getName()); nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); NVGColor nvgColor = color(vg, color); @@ -159,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, size); + nvgFontSize(vg, fontSizeToNVGFontSize(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}); @@ -171,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, size); + nvgFontSize(vg, fontSizeToNVGFontSize(size)); nvgFontFace(vg, font.font.getName()); nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); NVGColor nvgColor = color(vg, color); @@ -218,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, fontSize); + nvgFontSize(vg, fontSizeToNVGFontSize(fontSize)); nvgFontFace(vg, font.font.getName()); return nvgTextBounds(vg, 0, 0, text, bounds); } |