diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-04-16 01:55:58 +0900 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-04-16 01:55:58 +0900 |
commit | fff43b4d2a89ae50aa1d315fc4dad65055e654be (patch) | |
tree | 1868409a8282572894cafe73dd97bbf0009bbb7e /src/main | |
parent | 30df3e578cef533cacedf737449bbd35d4ea5d11 (diff) | |
download | OneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.tar.gz OneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.tar.bz2 OneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.zip |
misc things
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java | 4 | ||||
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java | 20 | ||||
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java | 5 | ||||
-rw-r--r-- | src/main/resources/assets/oneconfig/font/Inter-Bold.ttf | bin | 0 -> 316100 bytes | |||
-rw-r--r-- | src/main/resources/assets/oneconfig/font/OFL-INTER-BOLD.txt | 93 | ||||
-rw-r--r-- | src/main/resources/assets/oneconfig/font/Roboto-Regular.ttf | bin | 145348 -> 0 bytes |
6 files changed, 105 insertions, 17 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java index d0f54f7..eb830df 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import static org.lwjgl.BufferUtils.createByteBuffer; import static org.lwjgl.system.MemoryUtil.memSlice; +@SuppressWarnings("RedundantCast") final class IOUtil { private IOUtil() { @@ -21,7 +22,7 @@ final class IOUtil { private static ByteBuffer resizeBuffer(ByteBuffer buffer, int newCapacity) { ByteBuffer newBuffer = createByteBuffer(newCapacity); - buffer.flip(); + ((Buffer) buffer).flip(); newBuffer.put(buffer); return newBuffer; } @@ -57,7 +58,6 @@ final class IOUtil { } } - //noinspection RedundantCast ((Buffer) buffer).flip(); return memSlice(buffer); } diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java index c9d0615..f8dcafb 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java @@ -6,14 +6,13 @@ import net.minecraft.client.shader.Framebuffer; import org.lwjgl.nanovg.NVGColor; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; -import org.lwjgl.system.MemoryStack; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.function.LongConsumer; import static org.lwjgl.nanovg.NanoVG.*; -import static org.lwjgl.nanovg.NanoVGGL2.*; +import static org.lwjgl.nanovg.NanoVGGL2.NVG_ANTIALIAS; +import static org.lwjgl.nanovg.NanoVGGL2.nvgCreate; public final class NanoVGUtils { private NanoVGUtils() { @@ -31,7 +30,7 @@ public final class NanoVGUtils { } if (font == -1) { try { - font = nvgCreateFontMem(vg, "custom-font", IOUtil.resourceToByteBuffer("/assets/oneconfig/font/Roboto-Regular.ttf", 150 * 1024), 0); + font = nvgCreateFontMem(vg, "custom-font", IOUtil.resourceToByteBuffer("/assets/oneconfig/font/Inter-Bold.ttf", 200 * 1024), 0); } catch (IOException e) { e.printStackTrace(); } @@ -80,15 +79,10 @@ public final class NanoVGUtils { nvgBeginPath(vg); nvgFontSize(vg, size); nvgFontFace(vg, "custom-font"); - nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); - try (MemoryStack stack = MemoryStack.stackPush()) { - ByteBuffer textByte = stack.ASCII(text, false); - nvgFontBlur(vg, 0); - color(vg, color); - nvgText(vg, x, y, textByte); - } catch (Exception e) { - e.printStackTrace(); - } + nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); + color(vg, color); + nvgText(vg, x, y, text); + nvgFill(vg); } public static void color(long vg, int color) { diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java index 74d6a1e..67e0a68 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java @@ -10,10 +10,11 @@ public class TestNanoVGGui extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); + drawRect(0, 0, width, height, Color.BLACK.getRGB()); NanoVGUtils.setupAndDraw((vg) -> { NanoVGUtils.drawRect(vg, 0, 0, 300, 300, Color.BLUE.getRGB()); - NanoVGUtils.drawRoundedRect(vg, 305, 305, 100, 100, Color.BLACK.getRGB(), 8); - NanoVGUtils.drawString(vg, "Hello!", 500, 500, Color.BLACK.getRGB(), 50); + NanoVGUtils.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); + NanoVGUtils.drawString(vg, "Hello!", 500, 500, Color.WHITE.getRGB(), 50); }); } } diff --git a/src/main/resources/assets/oneconfig/font/Inter-Bold.ttf b/src/main/resources/assets/oneconfig/font/Inter-Bold.ttf Binary files differnew file mode 100644 index 0000000..76a215c --- /dev/null +++ b/src/main/resources/assets/oneconfig/font/Inter-Bold.ttf diff --git a/src/main/resources/assets/oneconfig/font/OFL-INTER-BOLD.txt b/src/main/resources/assets/oneconfig/font/OFL-INTER-BOLD.txt new file mode 100644 index 0000000..b525cbf --- /dev/null +++ b/src/main/resources/assets/oneconfig/font/OFL-INTER-BOLD.txt @@ -0,0 +1,93 @@ +Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/main/resources/assets/oneconfig/font/Roboto-Regular.ttf b/src/main/resources/assets/oneconfig/font/Roboto-Regular.ttf Binary files differdeleted file mode 100644 index 3e6e2e7..0000000 --- a/src/main/resources/assets/oneconfig/font/Roboto-Regular.ttf +++ /dev/null |