mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Make font atlas packing padding configurable
This commit is contained in:
@ -1061,6 +1061,7 @@ ImFontAtlas::ImFontAtlas()
|
||||
TexPixelsAlpha8 = NULL;
|
||||
TexPixelsRGBA32 = NULL;
|
||||
TexWidth = TexHeight = TexDesiredWidth = 0;
|
||||
TexGlyphPadding = 1;
|
||||
TexUvWhitePixel = ImVec2(0, 0);
|
||||
}
|
||||
|
||||
@ -1314,13 +1315,13 @@ bool ImFontAtlas::Build()
|
||||
}
|
||||
}
|
||||
|
||||
// Start packing. We need a known width for the skyline algorithm. Using a cheap heuristic here to decide of width. User can override TexDesiredWidth if they wish.
|
||||
// Start packing. We need a known width for the skyline algorithm. Using a cheap heuristic here to decide of width. User can override TexDesiredWidth and TexGlyphPadding if they wish.
|
||||
// After packing is done, width shouldn't matter much, but some API/GPU have texture size limitations and increasing width can decrease height.
|
||||
TexWidth = (TexDesiredWidth > 0) ? TexDesiredWidth : (total_glyph_count > 4000) ? 4096 : (total_glyph_count > 2000) ? 2048 : (total_glyph_count > 1000) ? 1024 : 512;
|
||||
TexHeight = 0;
|
||||
const int max_tex_height = 1024*32;
|
||||
stbtt_pack_context spc;
|
||||
stbtt_PackBegin(&spc, NULL, TexWidth, max_tex_height, 0, 1, NULL);
|
||||
stbtt_PackBegin(&spc, NULL, TexWidth, max_tex_height, 0, TexGlyphPadding, NULL);
|
||||
|
||||
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
||||
ImVector<stbrp_rect> extra_rects;
|
||||
|
Reference in New Issue
Block a user