mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-27 10:06:35 +00:00
2.4 KiB
2.4 KiB
imgui_freetype
Build font atlases using FreeType instead of stb_truetype (which is the default font rasterizer).
by @vuhdo, @mikesart, @ocornut.
Usage
- Get latest FreeType binaries or build yourself (under Windows you may use vcpkg with
vcpkg install freetype --triplet=x64-windows
,vcpkg integrate install
). - Add imgui_freetype.h/cpp alongside your project files.
- Add
#define IMGUI_ENABLE_FREETYPE
in your imconfig.h file
About Gamma Correct Blending
FreeType assumes blending in linear space rather than gamma space. See FreeType note for FT_Render_Glyph. For correct results you need to be using sRGB and convert to linear space in the pixel shader output. The default Dear ImGui styles will be impacted by this change (alpha values will need tweaking).
Testbed for toying with settings (for developers)
See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
Known issues
- Oversampling settings are ignored but also not so much necessary with the higher quality rendering.
Comparison
Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting:
Colorful glyphs/emojis
You can use the ImGuiFreeTypeBuilderFlags_LoadColor
flag to load certain colorful glyphs. See the
"Using Colorful Glyphs/Emojis" section of FONTS.md.
Using OpenType SVG fonts (SVGinOT)
- SVG in Open Type is a standard by Adobe and Mozilla for color OpenType and Open Font Format fonts. It allows font creators to embed complete SVG files within a font enabling full color and even animations.
- Popular fonts such as twemoji and fonts made with scfbuild is SVGinOT
- Requires: lunasvg v2.3.2 and above
- Add
#define IMGUI_ENABLE_FREETYPE_LUNASVG
in yourimconfig.h
. - Get latest lunasvg binaries or build yourself. Under Windows you may use vcpkg with:
vcpkg install lunasvg --triplet=x64-windows
.
- Add