ImFontAtlas: heuristic increase texture width up to 4096 with 4000+ glyphs. Various comments (#491)

This commit is contained in:
ocornut
2016-01-20 10:30:28 +00:00
parent 3922988dea
commit e585204d82
3 changed files with 15 additions and 6 deletions

View File

@ -359,6 +359,7 @@
Q: How can I load multiple fonts?
A: Use the font atlas to pack them into a single texture:
(Read extra_fonts/README.txt and the code in ImFontAtlas for more details.)
ImGuiIO& io = ImGui::GetIO();
ImFont* font0 = io.Fonts->AddFontDefault();
@ -371,7 +372,7 @@
// Options
ImFontConfig config;
config.OversampleH = 3;
config.OversampleV = 3;
config.OversampleV = 1;
config.GlyphExtraSpacing.x = 1.0f;
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config);
@ -383,8 +384,6 @@
io.Fonts->LoadFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges);
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese());
Read extra_fonts/README.txt or ImFontAtlas class for more details.
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
A: When loading a font, pass custom Unicode ranges to specify the glyphs to load. ImGui will support UTF-8 encoding across the board.
Character input depends on you passing the right character code to io.AddInputCharacter(). The example applications do that.