From c0ef8abc0300368205ccc9e1f92c339912e3609e Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Tue, 1 Feb 2022 14:53:02 +0100 Subject: [PATCH] Auto add plane0 to ImGui --- .../distributedrebirth/demo4d/ImGuiSetup.java | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/core/src/love/distributedrebirth/demo4d/ImGuiSetup.java b/core/src/love/distributedrebirth/demo4d/ImGuiSetup.java index fa04050b..a0f57969 100644 --- a/core/src/love/distributedrebirth/demo4d/ImGuiSetup.java +++ b/core/src/love/distributedrebirth/demo4d/ImGuiSetup.java @@ -8,9 +8,6 @@ import imgui.ImGui; import imgui.ImGuiIO; import imgui.gl3.ImGuiImplGl3; import imgui.glfw.ImGuiImplGlfw; -import love.distributedrebirth.numberxd.base2t.BasePartFactory; -import love.distributedrebirth.numberxd.base2t.facet.BasePart; -import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; /** * Create and shutdown of ImGui and font activations. @@ -20,10 +17,6 @@ import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; public class ImGuiSetup { public static final ImGuiImplGlfw imGuiImp = new ImGuiImplGlfw(); public static final ImGuiImplGl3 imGuiGlImp = new ImGuiImplGl3(); - private static final short[] glyphRangesHebrew = new short[]{0x0590, 0x05F4}; - private static final short[] glyphRangesArabic = new short[]{0x0600, 0x06FF}; - private static final short[] glyphRangesSubSuper0 = new short[]{0x00B2, 0x00B9}; - private static final short[] glyphRangesSubSuper1 = new short[]{0x2070, 0x209F}; public static void init() { long windowHandle = -1; @@ -44,40 +37,26 @@ public class ImGuiSetup { private static void initFonts(final ImGuiIO io) { io.getFonts().addFontDefault(); - - ImFontGlyphRangesBuilder rangesBuilder = new ImFontGlyphRangesBuilder(); - rangesBuilder.addRanges(io.getFonts().getGlyphRangesDefault()); - rangesBuilder.addRanges(io.getFonts().getGlyphRangesCyrillic()); - rangesBuilder.addRanges(io.getFonts().getGlyphRangesJapanese()); - rangesBuilder.addRanges(io.getFonts().getGlyphRangesChineseFull()); - rangesBuilder.addRanges(glyphRangesHebrew); - rangesBuilder.addRanges(glyphRangesArabic); - rangesBuilder.addRanges(glyphRangesSubSuper0); - rangesBuilder.addRanges(glyphRangesSubSuper1); - rangesBuilder.addText("@Ω\u4ed9⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@"); - rangesBuilder.addText("©Δ∞ \u4ed9\u4e0a\u4e3b\u5929"); - - for (int base:BasePartFactory.getSupportedBases()) { - for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) { - rangesBuilder.addText(part.getIdentifierTone()); - rangesBuilder.addText(part.getIdentifierLetter()); - rangesBuilder.addText(part.getChinaKey()); - if (part instanceof BasePartAlt1) { - rangesBuilder.addText(BasePartAlt1.class.cast(part).getAlt1Value()); - } - } - } - ImFontConfig fontConfig = new ImFontConfig(); fontConfig.setMergeMode(true); - - final short[] glyphRanges = rangesBuilder.buildRanges(); + ImFontGlyphRangesBuilder fontBuilder = new ImFontGlyphRangesBuilder(); + addRangeUnicodePlane0(fontBuilder); + final short[] glyphRanges = fontBuilder.buildRanges(); + io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/NotoSansCJKjp-Medium.otf").readBytes(), 14, fontConfig, glyphRanges); io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/FreeSans.ttf").readBytes(), 14, fontConfig, glyphRanges); fontConfig.destroy(); } + private static void addRangeUnicodePlane0(ImFontGlyphRangesBuilder fontBuilder) { + for (int c=0x0100;c<=0xFFEF;c++) { + StringBuilder buf = new StringBuilder(); + buf.append(""+(char)c); + fontBuilder.addText(buf.toString()); + } + } + public static void dispose() { imGuiImp.dispose(); imGuiGlImp.dispose();