|
| 1 | +package imgui; |
| 2 | + |
| 3 | +/** |
| 4 | + * Read: https://raw.githubusercontent.com/ocornut/imgui/v1.76/misc/freetype/README.md |
| 5 | + */ |
| 6 | +public final class ImGuiFreeType { |
| 7 | + private ImGuiFreeType() { |
| 8 | + } |
| 9 | + |
| 10 | + /*JNI |
| 11 | + #include <imgui.h> |
| 12 | + #include <imgui_freetype.h> |
| 13 | + */ |
| 14 | + |
| 15 | + public static void buildFontAtlas(final ImFontAtlas atlas) { |
| 16 | + nBuildFontAtlas(atlas.ptr, 0); |
| 17 | + } |
| 18 | + |
| 19 | + public static void buildFontAtlas(final ImFontAtlas atlas, int extraFlags) { |
| 20 | + nBuildFontAtlas(atlas.ptr, extraFlags); |
| 21 | + } |
| 22 | + |
| 23 | + private static native void nBuildFontAtlas(long atlasPtr, int extraFlags); /* |
| 24 | + ImGuiFreeType::BuildFontAtlas((ImFontAtlas*)atlasPtr, (unsigned int)extraFlags); |
| 25 | + */ |
| 26 | + |
| 27 | + /** |
| 28 | + * Hinting greatly impacts visuals (and glyph sizes). |
| 29 | + * When disabled, FreeType generates blurrier glyphs, more or less matches the stb's output. |
| 30 | + * The Default hinting mode usually looks good, but may distort glyphs in an unusual way. |
| 31 | + * The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer. |
| 32 | + * <p> |
| 33 | + * You can set those flags on a per font basis in ImFontConfig::RasterizerFlags. |
| 34 | + * Use the 'extra_flags' parameter of BuildFontAtlas() to force a flag on all your fonts. |
| 35 | + */ |
| 36 | + public static final class RasterizerFlags { |
| 37 | + /** |
| 38 | + * By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter. |
| 39 | + * Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes. |
| 40 | + */ |
| 41 | + public static final int NoHinting = 1; |
| 42 | + /** |
| 43 | + * Disable auto-hinter. |
| 44 | + */ |
| 45 | + public static final int NoAutoHint = 1 << 1; |
| 46 | + /** |
| 47 | + * Indicates that the auto-hinter is preferred over the font's native hinter. |
| 48 | + */ |
| 49 | + public static final int ForceAutoHint = 1 << 2; |
| 50 | + /** |
| 51 | + * A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. |
| 52 | + * This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), |
| 53 | + * as is done by Microsoft's ClearType and Adobe's proprietary font renderer. |
| 54 | + * This preserves inter-glyph spacing in horizontal text. |
| 55 | + */ |
| 56 | + public static final int LightHinting = 1 << 3; |
| 57 | + /** |
| 58 | + * Strong hinting algorithm that should only be used for monochrome output. |
| 59 | + */ |
| 60 | + public static final int MonoHinting = 1 << 4; |
| 61 | + /** |
| 62 | + * Styling: Should we artificially embolden the font? |
| 63 | + */ |
| 64 | + public static final int Bold = 1 << 5; |
| 65 | + /** |
| 66 | + * Styling: Should we slant the font, emulating italic style? |
| 67 | + */ |
| 68 | + public static final int Oblique = 1 << 6; |
| 69 | + /** |
| 70 | + * Disable anti-aliasing. Combine this with MonoHinting for best results! |
| 71 | + */ |
| 72 | + public static final int Monochrome = 1 << 7; |
| 73 | + } |
| 74 | +} |
0 commit comments