ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
@ -48,7 +48,7 @@ struct ImDrawData; // All draw command lists required to render
structImDrawList;// A single draw command list (generally one per window)
structImDrawVert;// A single vertex (20 bytes by default, override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)
structImFont;// Runtime data for a single font within a parent ImFontAtlas
structImFontAtlas;// Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF font loader
structImFontAtlas;// Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
structImFontConfig;// Configuration data when adding a font or merging fonts
structImColor;// Helper functions to create a color that can be converted to either u32 or float4
structImGuiIO;// Main configuration and I/O between your application and ImGui
@ -1301,10 +1301,10 @@ struct ImDrawData
structImFontConfig
{
void*FontData;// // TTF data
intFontDataSize;// // TTF data size
boolFontDataOwnedByAtlas;// true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
intFontNo;// 0 // Index of font within TTF file
void*FontData;// // TTF/OTF data
intFontDataSize;// // TTF/OTF data size
boolFontDataOwnedByAtlas;// true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
intFontNo;// 0 // Index of font within TTF/OTF file
floatSizePixels;// // Size in pixels for rasterizer
intOversampleH,OversampleV;// 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
boolPixelSnapH;// false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
@ -1320,7 +1320,7 @@ struct ImFontConfig
IMGUI_APIImFontConfig();
};
// Load and rasterize multiple TTF fonts into a same texture.
// Load and rasterize multiple TTF/OTF fonts into a same texture.
// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
// We also add custom graphic data into the texture that serves for ImGui.
// 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
IMGUI_APIImFont*AddFontFromMemoryTTF(void* ttf_data,int ttf_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
IMGUI_APIImFont*AddFontFromMemoryCompressedTTF(constvoid*compressed_ttf_data,intcompressed_ttf_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_ttf_data' still owned by caller. Compress with binary_to_compressed_c.cpp
IMGUI_APIImFont*AddFontFromMemoryCompressedBase85TTF(constchar*compressed_ttf_data_base85,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_ttf_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 paramaeter
IMGUI_APIImFont*AddFontFromMemoryTTF(void*font_data,intfont_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
IMGUI_APIImFont*AddFontFromMemoryCompressedTTF(constvoid*compressed_font_data,intcompressed_font_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp
IMGUI_APIImFont*AddFontFromMemoryCompressedBase85TTF(constchar*compressed_font_data_base85,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 paramaeter
IMGUI_APIvoidClearTexData();// Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory.
IMGUI_APIvoidClearInputData();// Clear the input TTF data (inc sizes, glyph ranges)
IMGUI_APIvoidClearFonts();// Clear the ImGui-side font data (glyphs storage, UV coordinates)