2018-02-04 11:44:31 +00:00
# imgui_freetype
2021-01-25 16:57:12 +00:00
Build font atlases using FreeType instead of stb_truetype (which is the default font rasterizer).
2019-01-10 21:11:27 +00:00
< br > by @vuhdo , @mikesart , @ocornut .
2018-02-04 11:44:31 +00:00
2019-01-10 21:11:27 +00:00
### Usage
2021-06-08 13:20:47 +00: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` ).
2021-01-25 16:57:12 +00:00
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
2018-02-04 11:44:31 +00:00
2021-01-25 16:57:12 +00:00
### About Gamma Correct Blending
2019-01-10 21:11:27 +00:00
2018-02-05 10:21:06 +00:00
FreeType assumes blending in linear space rather than gamma space.
2023-07-04 10:23:13 +00:00
See FreeType note for [FT_Render_Glyph ](https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_render_glyph ).
2018-02-05 10:21:06 +00:00
For correct results you need to be using sRGB and convert to linear space in the pixel shader output.
2019-06-11 14:11:19 +00:00
The default Dear ImGui styles will be impacted by this change (alpha values will need tweaking).
2018-02-05 10:21:06 +00:00
2021-01-25 16:57:12 +00:00
### Testbed for toying with settings (for developers)
2018-02-04 11:44:31 +00:00
2021-01-25 16:57:12 +00:00
See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
2018-02-04 11:44:31 +00:00
2019-01-10 21:11:27 +00:00
### Known issues
2018-02-04 11:44:31 +00:00
2023-08-01 07:33:56 +00:00
- Oversampling settings are ignored but also not so much necessary with the higher quality rendering.
2021-02-10 17:47:46 +00:00
2023-01-24 14:59:01 +00:00
### Comparison
2021-02-10 17:47:46 +00:00
2022-01-27 17:52:00 +00:00
Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting:
2021-02-10 17:47:46 +00:00
![comparing_font_rasterizers ](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif )
2021-05-24 10:49:58 +00:00
### Colorful glyphs/emojis
2022-01-27 17:52:00 +00:00
You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See the
2022-05-06 07:47:18 +00:00
["Using Colorful Glyphs/Emojis" ](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis ) section of FONTS.md.
2021-05-24 10:49:58 +00:00
![colored glyphs ](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png )
2023-08-01 07:27:08 +00:00
### 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 ](https://github.com/13rac1/twemoji-color-font ) and fonts made with [scfbuild ](https://github.com/13rac1/scfbuild ) is SVGinOT
- Requires: [lunasvg ](https://github.com/sammycage/lunasvg ) v2.3.2 and above
2023-08-01 07:33:56 +00:00
1. Add `#define IMGUI_ENABLE_FREETYPE_LUNASVG` in your `imconfig.h` .
2. Get latest lunasvg binaries or build yourself. Under Windows you may use vcpkg with: `vcpkg install lunasvg --triplet=x64-windows` .