diff --git a/examples/allegro5_example/main.cpp b/examples/allegro5_example/main.cpp index 9d390853..a901e8c3 100644 --- a/examples/allegro5_example/main.cpp +++ b/examples/allegro5_example/main.cpp @@ -25,7 +25,7 @@ int main(int, char**) ImGui_ImplA5_Init(display); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -34,12 +34,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 5341121f..1a1d6702 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -152,7 +152,7 @@ int main(int, char**) ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -161,12 +161,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_col = ImColor(114, 144, 154); diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index 9c49a26f..ab4839a9 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -76,7 +76,7 @@ int main(int, char**) ImGui_ImplDX9_Init(hwnd, g_pd3dDevice); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -85,12 +85,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_col = ImColor(114, 144, 154); diff --git a/examples/marmalade_example/main.cpp b/examples/marmalade_example/main.cpp index e5b059c9..b0ca2824 100644 --- a/examples/marmalade_example/main.cpp +++ b/examples/marmalade_example/main.cpp @@ -17,7 +17,7 @@ int main(int, char**) ImGui_Marmalade_Init(true); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -26,12 +26,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index 8d3135d9..39354de9 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -31,7 +31,7 @@ int main(int, char**) ImGui_ImplGlfwGL3_Init(window, true); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -40,12 +40,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 01e9a679..b6d8dbdc 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -23,7 +23,7 @@ int main(int, char**) ImGui_ImplGlfw_Init(window, true); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -32,12 +32,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/sdl_opengl3_example/main.cpp b/examples/sdl_opengl3_example/main.cpp index ca640699..4c5d2ee4 100644 --- a/examples/sdl_opengl3_example/main.cpp +++ b/examples/sdl_opengl3_example/main.cpp @@ -31,7 +31,7 @@ int main(int, char**) ImGui_ImplSdlGL3_Init(window); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -40,12 +40,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/sdl_opengl_example/main.cpp b/examples/sdl_opengl_example/main.cpp index da837aaa..a87d0247 100644 --- a/examples/sdl_opengl_example/main.cpp +++ b/examples/sdl_opengl_example/main.cpp @@ -30,7 +30,7 @@ int main(int, char**) ImGui_ImplSdl_Init(window); // Load Fonts - // (see extra_fonts/README.txt for more details) + // (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f); @@ -39,12 +39,6 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) - //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. - //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); - bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/extra_fonts/README.txt b/extra_fonts/README.txt index 5f7b53ad..cac98e98 100644 --- a/extra_fonts/README.txt +++ b/extra_fonts/README.txt @@ -32,11 +32,11 @@ // Add character ranges and merge into main font // The ranges array is not copied by the AddFont* functions and is used lazily // so ensure it is available for duration of font usage - static const ImWchar ranges[] = { 0xf000, 0xf3ff, 0 }; + static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope. ImFontConfig config; config.MergeMode = true; - io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); - io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config, io.Fonts->GetGlyphRangesJapanese()); + io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 18.0f, &config, io.Fonts->GetGlyphRangesJapanese()); + io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges); Add a fourth parameter to bake specific font ranges only: diff --git a/imgui.cpp b/imgui.cpp index 4c8c900f..0f84d8c8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -80,7 +80,8 @@ - customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme). - getting started: - - initialisation: call ImGui::GetIO() to retrieve the ImGuiIO structure and fill the fields marked 'Settings'. + - init: call ImGui::GetIO() to retrieve the ImGuiIO structure and fill the fields marked 'Settings'. + - init: call io.Fonts->GetTexDataAsRGBA32(...) and load the font texture pixels into graphics memory. - every frame: 1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the fields marked 'Input' 2/ call ImGui::NewFrame(). @@ -101,6 +102,7 @@ // TODO: Fill others settings of the io structure // Load texture atlas + // There is a default font so you don't need to care about choosing a font yet unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height);