Skip to content

Commit 9a97128

Browse files
committed
ImFontAtlas: Rewrote stb_truetype based builder.
- Atlas width is now properly based on total surface rather than glyph count (unless overridden with TexDesiredWidth). - Fixed atlas builder so missing glyphs won't influence the atlas texture width. (#2233) - Fixed atlas builder so duplicate glyphs (when merging fonts) won't be included in the rasterized atlas.
1 parent e3ccc96 commit 9a97128

File tree

5 files changed

+240
-164
lines changed

5 files changed

+240
-164
lines changed

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Other Changes:
7272
Missing calls to End(), past the assert, should not lead to crashes or to the fallback Debug window appearing on screen.
7373
Those changes makes it easier to integrate dear imgui with a scripting language allowing, given asserts are redirected
7474
into e.g. an error log and stopping the script execution.
75+
- ImFontAtlas: Stb: Atlas width is now properly based on total surface rather than glyph count (unless overridden with TexDesiredWidth).
76+
- ImFontAtlas: Stb: Fixed atlas builder so missing glyphs won't influence the atlas texture width. (#2233)
77+
- ImFontAtlas: Stb: Fixed atlas builder so duplicate glyphs (when merging fonts) won't be included in the rasterized atlas.
7578
- ImDrawList: Optimized some of the functions for performance of debug builds where non-inline function call cost are non-negligible.
7679
(Our test UI scene on VS2015 Debug Win64 with /RTC1 went ~5.9 ms -> ~4.9 ms. In Release same scene stays at ~0.3 ms.)
7780
- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by back-ends.

docs/TODO.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
235235
- pie menus patterns (#434)
236236
- markup: simple markup language for color change? (#902)
237237

238-
!- font: need handling of missing glyphs by not packing/rasterizing glyph 0 of a given font.
239-
- font: MergeMode: flags to select overwriting or not.
240-
- font: MergeMode: duplicate glyphs are stored in the atlas texture which is suboptimal.
238+
- font: MergeMode: flags to select overwriting or not (this is now very easy with refactored ImFontAtlasBuildWithStbTruetype)
241239
- font: free the Alpha buffer if user only requested RGBA.
242240
!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
243241
- font: a CalcTextHeight() helper could run faster than CalcTextSize().y
@@ -252,7 +250,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
252250
- font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
253251
- font/draw: need to be able to specify wrap start position.
254252
- font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines)
255-
- font: imgui_freetype.h alternative renderer (#618)
256253
- font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct).
257254
- font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
258255
- font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ struct ImFontAtlas
20472047
ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_)
20482048
ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
20492049
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
2050-
int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1.
2050+
int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0.
20512051

20522052
// [Internal]
20532053
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.

0 commit comments

Comments
 (0)