mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 04:28:47 +02:00
ImFontAtlas: heuristic increase texture width up to 4096 with 4000+ glyphs. Various comments (#491)
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' that you can use without any external files.
|
||||
Those are only provided as a convenience, you can load your own .TTF files.
|
||||
|
||||
Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
||||
|
||||
---------------------------------
|
||||
LOADING INSTRUCTIONS
|
||||
---------------------------------
|
||||
@ -20,10 +22,17 @@
|
||||
|
||||
ImFontConfig config;
|
||||
config.OversampleH = 3;
|
||||
config.OversampleV = 3;
|
||||
config.OversampleV = 1;
|
||||
config.GlyphExtraSpacing.x = 1.0f;
|
||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
|
||||
|
||||
If you have very large number of glyphs or multiple fonts:
|
||||
|
||||
- Mind the fact that some graphics drivers have texture size limitation.
|
||||
- Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function).
|
||||
- You may reduce oversampling, e.g. config.OversampleH = 2 or 1.
|
||||
- Reduce glyphs ranges, consider calculating them based on your source data if this is possible.
|
||||
|
||||
Combine two fonts into one:
|
||||
|
||||
// Load main font
|
||||
|
Reference in New Issue
Block a user