diff --git a/bin/imgui-java.dll b/bin/imgui-java.dll index a6262fa..1b54c05 100755 Binary files a/bin/imgui-java.dll and b/bin/imgui-java.dll differ diff --git a/bin/imgui-java64.dll b/bin/imgui-java64.dll index 2a6cc7d..8b04c82 100755 Binary files a/bin/imgui-java64.dll and b/bin/imgui-java64.dll differ diff --git a/bin/libimgui-java.so b/bin/libimgui-java.so index e7e62ab..db596dd 100755 Binary files a/bin/libimgui-java.so and b/bin/libimgui-java.so differ diff --git a/bin/libimgui-java64.so b/bin/libimgui-java64.so index 2c4b708..66ef5ac 100755 Binary files a/bin/libimgui-java64.so and b/bin/libimgui-java64.so differ diff --git a/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy b/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy index 447d666..e3609e7 100644 --- a/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy +++ b/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy @@ -24,6 +24,7 @@ class GenerateLibs extends DefaultTask { // Copy ImGui h/cpp files project.copy { CopySpec spec -> spec.from(project.rootProject.file('imgui')) { CopySpec it -> it.include('*.h', '*.cpp') } + spec.from(project.rootProject.file('imgui/misc/freetype')) { CopySpec it -> it.include('*.h', '*.cpp') } spec.from(project.rootProject.file('imgui-binding/src/main/native')) spec.into(jniDir) } @@ -37,6 +38,17 @@ class GenerateLibs extends DefaultTask { def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false) def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true) + // Freetype Deps Config + win32.cppFlags += " -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" + win32.libraries += "-lfreetype -lbz2 -lssp" + win64.cppFlags += " -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" + win64.libraries += "-lfreetype -lbz2 -lssp" + linux32.cppFlags += " -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" + linux32.linkerFlags += " -lfreetype" + linux64.cppFlags += " -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" + linux64.linkerFlags += " -lfreetype" + // End + new AntScriptGenerator().generate(buildConfig, win32, win64, linux32, linux64) // Generate native libraries diff --git a/imgui-binding/src/main/java/imgui/ImGuiFreeType.java b/imgui-binding/src/main/java/imgui/ImGuiFreeType.java new file mode 100644 index 0000000..b4808b4 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImGuiFreeType.java @@ -0,0 +1,74 @@ +package imgui; + +/** + * Read: https://raw.githubusercontent.com/ocornut/imgui/v1.76/misc/freetype/README.md + */ +public final class ImGuiFreeType { + private ImGuiFreeType() { + } + + /*JNI + #include + #include + */ + + public static void buildFontAtlas(final ImFontAtlas atlas) { + nBuildFontAtlas(atlas.ptr, 0); + } + + public static void buildFontAtlas(final ImFontAtlas atlas, int extraFlags) { + nBuildFontAtlas(atlas.ptr, extraFlags); + } + + private static native void nBuildFontAtlas(long atlasPtr, int extraFlags); /* + ImGuiFreeType::BuildFontAtlas((ImFontAtlas*)atlasPtr, (unsigned int)extraFlags); + */ + + /** + * Hinting greatly impacts visuals (and glyph sizes). + * When disabled, FreeType generates blurrier glyphs, more or less matches the stb's output. + * The Default hinting mode usually looks good, but may distort glyphs in an unusual way. + * The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer. + *

+ * You can set those flags on a per font basis in ImFontConfig::RasterizerFlags. + * Use the 'extra_flags' parameter of BuildFontAtlas() to force a flag on all your fonts. + */ + public static final class RasterizerFlags { + /** + * By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter. + * Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes. + */ + public static final int NoHinting = 1; + /** + * Disable auto-hinter. + */ + public static final int NoAutoHint = 1 << 1; + /** + * Indicates that the auto-hinter is preferred over the font's native hinter. + */ + public static final int ForceAutoHint = 1 << 2; + /** + * A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. + * This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), + * as is done by Microsoft's ClearType and Adobe's proprietary font renderer. + * This preserves inter-glyph spacing in horizontal text. + */ + public static final int LightHinting = 1 << 3; + /** + * Strong hinting algorithm that should only be used for monochrome output. + */ + public static final int MonoHinting = 1 << 4; + /** + * Styling: Should we artificially embolden the font? + */ + public static final int Bold = 1 << 5; + /** + * Styling: Should we slant the font, emulating italic style? + */ + public static final int Oblique = 1 << 6; + /** + * Disable anti-aliasing. Combine this with MonoHinting for best results! + */ + public static final int Monochrome = 1 << 7; + } +} diff --git a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java index 1c2b95a..7d41fd9 100644 --- a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java +++ b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java @@ -1,6 +1,7 @@ import imgui.ImFontAtlas; import imgui.ImFontConfig; import imgui.ImGui; +import imgui.ImGuiFreeType; import imgui.ImGuiIO; import imgui.callbacks.ImStrConsumer; import imgui.callbacks.ImStrSupplier; @@ -262,7 +263,7 @@ public final class ImGuiGlfwExample { // ------------------------------ // Fonts from file/memory example - fontConfig.setRasterizerMultiply(1.2f); // This will make fonts a bit more readable +// fontConfig.setRasterizerMultiply(1.2f); // This will make fonts a bit more readable // We can add new fonts directly from file fontAtlas.addFontFromFileTTF("src/test/resources/DroidSans.ttf", 13, fontConfig); @@ -276,6 +277,8 @@ public final class ImGuiGlfwExample { fontConfig.destroy(); // After all fonts were added we don't need this config more + ImGuiFreeType.buildFontAtlas(fontAtlas, ImGuiFreeType.RasterizerFlags.LightHinting); + // Method initializes LWJGL3 renderer. // This method SHOULD be called after you've initialized your ImGui configuration (fonts and so on). // ImGui context should be created as well.