Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
imgui_freetype.h
Go to the documentation of this file.
1// dear imgui: FreeType font builder (used as a replacement for the stb_truetype builder)
2// (headers)
3
4#pragma once
5#include "imgui.h" // IMGUI_API
6#ifndef IMGUI_DISABLE
7
8// Usage:
9// - Add '#define IMGUI_ENABLE_FREETYPE' in your imconfig to automatically enable support
10// for imgui_freetype in imgui. It is equivalent to selecting the default loader with:
11// io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())
12
13// Optional support for OpenType SVG fonts:
14// - Add '#define IMGUI_ENABLE_FREETYPE_PLUTOSVG' to use plutosvg (not provided). See #7927.
15// - Add '#define IMGUI_ENABLE_FREETYPE_LUNASVG' to use lunasvg (not provided). See #6591.
16
17// Forward declarations
18struct ImFontAtlas;
19struct ImFontLoader;
20
21// Hinting greatly impacts visuals (and glyph sizes).
22// - By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter.
23// - When disabled, FreeType generates blurrier glyphs, more or less matches the stb_truetype.h
24// - The Default hinting mode usually looks good, but may distort glyphs in an unusual way.
25// - The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer.
26// You can set those flags globally in ImFontAtlas::FontLoaderFlags
27// You can set those flags on a per font basis in ImFontConfig::FontLoaderFlags
28typedef unsigned int ImGuiFreeTypeLoaderFlags;
30{
31 ImGuiFreeTypeLoaderFlags_NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
32 ImGuiFreeTypeLoaderFlags_NoAutoHint = 1 << 1, // Disable auto-hinter.
33 ImGuiFreeTypeLoaderFlags_ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter.
34 ImGuiFreeTypeLoaderFlags_LightHinting = 1 << 3, // 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.
35 ImGuiFreeTypeLoaderFlags_MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output.
36 ImGuiFreeTypeLoaderFlags_Bold = 1 << 5, // Styling: Should we artificially embolden the font?
37 ImGuiFreeTypeLoaderFlags_Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style?
38 ImGuiFreeTypeLoaderFlags_Monochrome = 1 << 7, // Disable anti-aliasing. Combine this with MonoHinting for best results!
39 ImGuiFreeTypeLoaderFlags_LoadColor = 1 << 8, // Enable FreeType color-layered glyphs
40 ImGuiFreeTypeLoaderFlags_Bitmap = 1 << 9, // Enable FreeType bitmap glyphs
41
42#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
53#endif
54};
55
56// Obsolete names (will be removed)
57#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
59#endif
60
62{
63 // This is automatically assigned when using '#define IMGUI_ENABLE_FREETYPE'.
64 // If you need to dynamically select between multiple builders:
65 // - you can manually assign this builder with 'atlas->SetFontLoader(ImGuiFreeType::GetFontLoader())'
66 // - prefer deep-copying this into your own ImFontLoader instance if you use hot-reloading that messes up static data.
67 IMGUI_API const ImFontLoader* GetFontLoader();
68
69 // Override allocators. By default ImGuiFreeType will use IM_ALLOC()/IM_FREE()
70 // However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired.
71 IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = nullptr);
72
73 // Display UI to edit ImFontAtlas::FontLoaderFlags (shared) or ImFontConfig::FontLoaderFlags (single source)
74 IMGUI_API bool DebugEditFontLoaderFlags(ImGuiFreeTypeLoaderFlags* p_font_loader_flags);
75
76 // Obsolete names (will be removed)
77#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
78 //IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); // Renamed/changed in 1.92. Change 'io.Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' to 'io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())' if you need runtime selection.
79 //static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontLoaderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
80#endif
81}
82
83#endif // #ifndef IMGUI_DISABLE
ImGuiFreeTypeLoaderFlags_ ImGuiFreeTypeBuilderFlags_
Definition imgui_freetype.h:58
unsigned int ImGuiFreeTypeLoaderFlags
Definition imgui_freetype.h:28
ImGuiFreeTypeLoaderFlags_
Definition imgui_freetype.h:30
@ ImGuiFreeTypeBuilderFlags_LightHinting
Definition imgui_freetype.h:46
@ ImGuiFreeTypeLoaderFlags_LoadColor
Definition imgui_freetype.h:39
@ ImGuiFreeTypeLoaderFlags_Bitmap
Definition imgui_freetype.h:40
@ ImGuiFreeTypeBuilderFlags_Bold
Definition imgui_freetype.h:48
@ ImGuiFreeTypeBuilderFlags_NoAutoHint
Definition imgui_freetype.h:44
@ ImGuiFreeTypeBuilderFlags_LoadColor
Definition imgui_freetype.h:51
@ ImGuiFreeTypeLoaderFlags_ForceAutoHint
Definition imgui_freetype.h:33
@ ImGuiFreeTypeLoaderFlags_Oblique
Definition imgui_freetype.h:37
@ ImGuiFreeTypeBuilderFlags_NoHinting
Definition imgui_freetype.h:43
@ ImGuiFreeTypeLoaderFlags_MonoHinting
Definition imgui_freetype.h:35
@ ImGuiFreeTypeLoaderFlags_Monochrome
Definition imgui_freetype.h:38
@ ImGuiFreeTypeBuilderFlags_MonoHinting
Definition imgui_freetype.h:47
@ ImGuiFreeTypeBuilderFlags_ForceAutoHint
Definition imgui_freetype.h:45
@ ImGuiFreeTypeLoaderFlags_NoAutoHint
Definition imgui_freetype.h:32
@ ImGuiFreeTypeBuilderFlags_Oblique
Definition imgui_freetype.h:49
@ ImGuiFreeTypeBuilderFlags_Monochrome
Definition imgui_freetype.h:50
@ ImGuiFreeTypeLoaderFlags_LightHinting
Definition imgui_freetype.h:34
@ ImGuiFreeTypeLoaderFlags_Bold
Definition imgui_freetype.h:36
@ ImGuiFreeTypeLoaderFlags_NoHinting
Definition imgui_freetype.h:31
@ ImGuiFreeTypeBuilderFlags_Bitmap
Definition imgui_freetype.h:52
Definition imgui_freetype.h:62
IMGUI_API const ImFontLoader * GetFontLoader()
Definition imgui_freetype.cpp:577
IMGUI_API bool DebugEditFontLoaderFlags(ImGuiFreeTypeLoaderFlags *p_font_loader_flags)
Definition imgui_freetype.cpp:600
IMGUI_API void SetAllocatorFunctions(void *(*alloc_func)(size_t sz, void *user_data), void(*free_func)(void *ptr, void *user_data), void *user_data=nullptr)
Definition imgui_freetype.cpp:593