Overview
Dear ImGui manages fonts throughImFontAtlas, which loads and rasterizes multiple TTF/OTF fonts into a single texture. Since version 1.92.0, fonts can be rendered at any size dynamically.
Adding Fonts
AddFontDefault
const ImFontConfig*
default:"NULL"
Optional font configuration
ImFont*
Pointer to loaded font
AddFontFromFileTTF
const char*
Path to .ttf or .otf file
float
default:"0.0f"
Legacy base size. Use 0.0f for default size (13px), or specify a size for legacy behavior.
const ImFontConfig*
default:"NULL"
Optional font configuration
const ImWchar*
default:"NULL"
Glyph ranges to load (NULL = default ranges)
ImFont*
Pointer to loaded font, or NULL on error
AddFontFromMemoryTTF
font_data to ImFontAtlas!
void*
Font data in memory (ownership transferred unless
FontDataOwnedByAtlas=false)int
Size of font data in bytes
AddFontFromMemoryCompressedTTF
Font Configuration
ImFontConfig Structure
Font Merging
Merge multiple fonts into one to combine different Unicode ranges:Glyph Ranges
GetGlyphRangesDefault
Other Glyph Ranges
Custom Glyph Ranges
ImFontGlyphRangesBuilder
Build custom glyph ranges from text:Using Fonts
PushFont
ImFont*
Font to use (NULL = keep current font)
float
Base font size before global scaling (0.0f = keep current size)
PopFont
GetFont
GetFontSize
ImFont Structure
Text Measurement
CalcTextSize
const char*
Text to measure
const char*
default:"NULL"
End of text (NULL for null-terminated)
bool
default:"false"
Hide text after ##
float
default:"-1.0f"
Width for text wrapping (-1.0f = no wrapping)
ImVec2
Text size in pixels