feat(api): make FreeType a toggleable option which is disabled by default (#254)
* deps(build): bump FreeType from 2.12.1 to 2.13.3 * fix(generator): add missing ImGuiFreeTypeBuilderFlags * feat(generator): add possibility to provide additional defines specifically for AST * feat(api): make FreeType optional and disabled by default FreeType renderer is still included in the final build. Its usage is toggleable and DISABLED by default.
This commit is contained in:
1 parent
887e3d9c85
commit
d252c145c5
15 files changed
+370
-10
No files matched your search
@@ -460,6 +460,32 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
|
||||
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
|
||||
|
||||
/*JNI
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#include "misc/freetype/imgui_freetype.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
/**
|
||||
* <b>BINDING NOTICE:</b> This method is specific to the imgui-java binding.
|
||||
* <p>
|
||||
* Since FreeType is included in the final build, it's possible to use both font renderers (STB_TrueType and FreeType) simultaneously without needing to rebuild the library.
|
||||
* By default, we use small hacks to set STB_TrueType as the default font renderer. However, this method allows you to enforce the use of the FreeType renderer.
|
||||
* <p>
|
||||
* This method MUST be called before invoking the "#build" or "#getTexData*" methods.
|
||||
*
|
||||
* @param enabled true to enable the FreeType font renderer
|
||||
*/
|
||||
public native void setFreeTypeRenderer(boolean enabled); /*
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
if (enabled) {
|
||||
THIS->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType();
|
||||
} else {
|
||||
THIS->FontBuilderIO = NULL;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||
*/
|
||||
|
||||
@@ -5,5 +5,73 @@ public final class ImGuiFreeTypeBuilderFlags {
|
||||
private ImGuiFreeTypeBuilderFlags() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
|
||||
*
|
||||
* <p>Definition: {@code 1 << 0}
|
||||
*/
|
||||
public static final int NoHinting = 1;
|
||||
|
||||
/**
|
||||
* Disable auto-hinter.
|
||||
*
|
||||
* <p>Definition: {@code 1 << 1}
|
||||
*/
|
||||
public static final int NoAutoHint = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the auto-hinter is preferred over the font's native hinter.
|
||||
*
|
||||
* <p>Definition: {@code 1 << 2}
|
||||
*/
|
||||
public static final int ForceAutoHint = 4;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>Definition: {@code 1 << 3}
|
||||
*/
|
||||
public static final int LightHinting = 8;
|
||||
|
||||
/**
|
||||
* Strong hinting algorithm that should only be used for monochrome output.
|
||||
*
|
||||
* <p>Definition: {@code 1 << 4}
|
||||
*/
|
||||
public static final int MonoHinting = 16;
|
||||
|
||||
/**
|
||||
* Styling: Should we artificially embolden the font?
|
||||
*
|
||||
* <p>Definition: {@code 1 << 5}
|
||||
*/
|
||||
public static final int Bold = 32;
|
||||
|
||||
/**
|
||||
* Styling: Should we slant the font, emulating italic style?
|
||||
*
|
||||
* <p>Definition: {@code 1 << 6}
|
||||
*/
|
||||
public static final int Oblique = 64;
|
||||
|
||||
/**
|
||||
* Disable anti-aliasing. Combine this with MonoHinting for best results!
|
||||
*
|
||||
* <p>Definition: {@code 1 << 7}
|
||||
*/
|
||||
public static final int Monochrome = 128;
|
||||
|
||||
/**
|
||||
* Enable FreeType color-layered glyphs
|
||||
*
|
||||
* <p>Definition: {@code 1 << 8}
|
||||
*/
|
||||
public static final int LoadColor = 256;
|
||||
|
||||
/**
|
||||
* Enable FreeType bitmap glyphs
|
||||
*
|
||||
* <p>Definition: {@code 1 << 9}
|
||||
*/
|
||||
public static final int Bitmap = 512;
|
||||
}
|
||||
@@ -137,6 +137,32 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
|
||||
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
|
||||
|
||||
/*JNI
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#include "misc/freetype/imgui_freetype.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
/**
|
||||
* <b>BINDING NOTICE:</b> This method is specific to the imgui-java binding.
|
||||
* <p>
|
||||
* Since FreeType is included in the final build, it's possible to use both font renderers (STB_TrueType and FreeType) simultaneously without needing to rebuild the library.
|
||||
* By default, we use small hacks to set STB_TrueType as the default font renderer. However, this method allows you to enforce the use of the FreeType renderer.
|
||||
* <p>
|
||||
* This method MUST be called before invoking the "#build" or "#getTexData*" methods.
|
||||
*
|
||||
* @param enabled true to enable the FreeType font renderer
|
||||
*/
|
||||
public native void setFreeTypeRenderer(boolean enabled); /*
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
if (enabled) {
|
||||
THIS->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType();
|
||||
} else {
|
||||
THIS->FontBuilderIO = NULL;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,6 @@ public final class ImGuiFreeTypeBuilderFlags {
|
||||
private ImGuiFreeTypeBuilderFlags() {
|
||||
}
|
||||
|
||||
@BindingAstEnum(file = "ast-imgui.json", qualType = "ImGuiFreeTypeBuilderFlags_")
|
||||
@BindingAstEnum(file = "ast-imgui_freetype.json", qualType = "ImGuiFreeTypeBuilderFlags", sanitizeName = "ImGuiFreeTypeBuilderFlags_")
|
||||
public Void __;
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "jni_assertion.h"
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
@@ -30,6 +31,7 @@
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||
@@ -77,7 +79,7 @@
|
||||
|
||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
|
||||
Reference in new issue
Block a user