Skip to content

Commit cf6b396

Browse files
committed
imgui_freetype: comments about correct blending and sRGB (#618, #578)
1 parent a33b86d commit cf6b396

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: misc/freetype/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ ImGuiFreeType::BuildFontAtlas(io.Fonts, flags);
1717
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
1818
```
1919
20+
**Gamma Correct Blending**
21+
FreeType assumes blending in linear space rather than gamma space.
22+
See FreeType note for [FT_Render_Glyph](https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Render_Glyph).
23+
For correct results you need to be using sRGB and convert to linear space in the pixel shader output.
24+
The default imgui styles will be impacted by this change (alpha values will need tweaking).
25+
2026
**Test code Usage**
2127
```cpp
2228
#include "misc/freetype/imgui_freetype.h"

Diff for: misc/freetype/imgui_freetype.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
// - v0.54: (2018/01/22) fix for addition of ImFontAtlas::TexUvscale member
1111
// - v0.55: (2018/02/04) moved to main imgui repository (away from http://www.github.com/ocornut/imgui_club)
1212

13+
// Gamma Correct Blending:
14+
// FreeType assumes blending in linear space rather than gamma space.
15+
// See https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Render_Glyph
16+
// For correct results you need to be using sRGB and convert to linear space in the pixel shader output.
17+
// The default imgui styles will be impacted by this change (alpha values will need tweaking).
18+
1319
// TODO:
1420
// - Output texture has excessive resolution (lots of vertical waste)
1521
// - FreeType's memory allocator is not overridden.

0 commit comments

Comments
 (0)