AnimTestbed/3rdparty/imgui/misc/freetype/README.md

38 lines
1.8 KiB
Markdown
Raw Normal View History

2021-11-11 21:22:24 +01:00
# imgui_freetype
2023-04-14 17:44:25 +02:00
Build font atlases using FreeType instead of stb_truetype (which is the default font rasterizer).
2021-11-11 21:22:24 +01:00
<br>by @vuhdo, @mikesart, @ocornut.
### Usage
2023-04-14 17:44:25 +02:00
1. Get latest FreeType binaries or build yourself (under Windows you may use vcpkg with `vcpkg install freetype --triplet=x64-windows`, `vcpkg integrate install`).
2. Add imgui_freetype.h/cpp alongside your project files.
3. Add `#define IMGUI_ENABLE_FREETYPE` in your [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) file
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
### About Gamma Correct Blending
2021-11-11 21:22:24 +01:00
FreeType assumes blending in linear space rather than gamma space.
See FreeType note for [FT_Render_Glyph](https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#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).
2023-04-14 17:44:25 +02:00
### Testbed for toying with settings (for developers)
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
### Known issues
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
- Oversampling settins are ignored but also not so much necessary with the higher quality rendering.
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
### Comparison
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting:
![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif)
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
### Colorful glyphs/emojis
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See the
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
2021-11-11 21:22:24 +01:00
2023-04-14 17:44:25 +02:00
![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png)