diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index a35206db8..f826d8c9b 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -218,7 +218,6 @@ void InitImGui() io.Font = new ImFont(); io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); - io.Font->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 20.0f, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; IM_ASSERT(io.Font->IsLoaded()); diff --git a/extra_fonts/Karla-Regular.ttf b/extra_fonts/Karla-Regular.ttf new file mode 100644 index 000000000..81b3de6eb Binary files /dev/null and b/extra_fonts/Karla-Regular.ttf differ diff --git a/extra_fonts/ProggyClean.ttf b/extra_fonts/ProggyClean.ttf new file mode 100644 index 000000000..0270cdfe3 Binary files /dev/null and b/extra_fonts/ProggyClean.ttf differ diff --git a/extra_fonts/ProggyClean.zip b/extra_fonts/ProggyClean.zip deleted file mode 100644 index 06108e1dd..000000000 Binary files a/extra_fonts/ProggyClean.zip and /dev/null differ diff --git a/extra_fonts/ProggySmall.zip b/extra_fonts/ProggySmall.zip deleted file mode 100644 index f7e267184..000000000 Binary files a/extra_fonts/ProggySmall.zip and /dev/null differ diff --git a/extra_fonts/ProggyTiny.ttf b/extra_fonts/ProggyTiny.ttf new file mode 100644 index 000000000..1c4312c3d Binary files /dev/null and b/extra_fonts/ProggyTiny.ttf differ diff --git a/extra_fonts/README.txt b/extra_fonts/README.txt index 523996285..3ff694cf7 100644 --- a/extra_fonts/README.txt +++ b/extra_fonts/README.txt @@ -1,100 +1,30 @@ -Extra fonts for ImGui. -THOSE FONTS ARE OPTIONAL. +--------------------------------- + EXTRA FONTS FOR IMGUI +--------------------------------- -ImGui embeds a copy of 'proggy_clean' that you can use without any external files. -Export your own font with bmfont (www.angelcode.com/products/bmfont). +ImGui embeds a copy of 'ProggyClean.ttf' that you can use without any external files. -bmfont reads fonts (.ttf, .fon, etc.) and output a .fnt file and a texture file, e.g: +Load .TTF file with: - proggy_clean.fon --> [bmfont] ---> proggy_clean_13.fnt - proggy_clean_13.png + ImGuiIO& io = ImGui::GetIO(); + io.Font = new ImFont(); + io.Font->LoadFromFileTTF("myfontfile.ttf", size_pixels); + +Add a third parameter to bake specific font ranges: -If you need a free font that supports chinese/japanese characters, you can use the M+ fonts. -TTF and sources are availables at http://mplus-fonts.sourceforge.jp/mplus-outline-fonts. -This directory include some of the M+ fonts converted by bmfont. + io.Font->LoadFromFileTTF("myfontfile.ttf", size_pixels, ImFont::GetGlyphRangesDefault()); // Basic Latin, Extended Latin + io.Font->LoadFromFileTTF("myfontfile.ttf", size_pixels, ImFont::GetGlyphRangesJapanese()); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs + io.Font->LoadFromFileTTF("myfontfile.ttf", size_pixels, ImFont::GetGlyphRangesChinese()); // Japanese + full set of about 21000 CJK Unified Ideographs -//----------------------------------------------------------------------------- +Offset font by altering the io.Font->DisplayOffset value: -Configure bmfont: + io.Font->DisplayOffset.y += 1; // Render 1 pixel down - - Export .fnt as Binary - - Output .png, 32-bits (or whatever is suitable for your loader/renderer) - - Tip: uncheck "Render from TrueType outline" and "Font Smoothing" for best result with non-anti-aliased type fonts. - But you can experiment with other settings if you want anti-aliased fonts. - - Tip: use pngout.exe (http://advsys.net/ken/utils.htm) to further reduce the file size of .png files - All files in this folder have been optimised with pngout.exe +----------------------------------- + RECOMMENDED SIZES +----------------------------------- ------------------------------------------------------------------------------ - -(A) Use font data embedded in ImGui - - // Access embedded font data - const void* fnt_data; // pointer to FNT data - unsigned fnt_size; // size of FNT data - const void* png_data; // pointer to PNG data - unsigned int png_size; // size of PNG data - ImGui::GetDefaultFontData(&fnt_data, &fnt_size, &png_data, &png_size); - - 1. Load the .FNT data from 'fnt_data' (NB: this is done for you by default if you don't do anything) - - ImGuiIO& io = ImGui::GetIO(); - io.Font = new ImFont(); - io.Font->LoadFromMemory(fnt_data, fnt_size); - - 2. Load the .PNG data from 'png_data' into a texture - -//----------------------------------------------------------------------------- - -(B) Use fonts from external files - - You need to set io.Font->TexUvForWhite to UV coordinates pointing to a white pixel in the texture. - You can either locate a white pixel manually or use code at runtime to find or write one. - The OpenGL example include sample code to find a white pixel given an uncompressed 32-bits texture: - - // Automatically find white pixel from the texture we just loaded - // (io.Font->TexUvForWhite needs to contains UV coordinates pointing to a white pixel in order to render solid objects) - for (int tex_data_off = 0; tex_data_off < tex_x*tex_y; tex_data_off++) - if (((unsigned int*)tex_data)[tex_data_off] == 0xffffffff) - { - io.Font->TexUvForWhite = ImVec2((float)(tex_data_off % tex_x)/(tex_x), (float)(tex_data_off / tex_x)/(tex_y)); - break; - } - - 1. Load the .FNT data, e.g. - - ImGuiIO& io = ImGui::GetIO(); - - // proggy_clean_13 [default] - io.Font = new ImFont(); - io.Font->LoadFromFile("proggy_clean_13.fnt"); - IM_ASSERT(io.Font->IsLoaded()); - io.Font->TexUvForWhite = ImVec2(0.0f/256.0f,0.0f/128); - io.Font->DisplayOffset = ImVec2(0.0f, +1.0f); - - // proggy_small_12 - io.Font = new ImFont(); - io.Font->LoadFromFile("proggy_small_12.fnt"); - IM_ASSERT(io.Font->IsLoaded()); - io.Font->TexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64); - io.Font->DisplayOffset = ImVec2(0.0f, +2.0f); - - // proggy_small_14 - io.Font = new ImFont(); - io.Font->LoadFromFile("proggy_small_14.fnt"); - IM_ASSERT(io.Font->IsLoaded()); - io.Font->TexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64); - io.Font->DisplayOffset = ImVec2(0.0f, +3.0f); - - // courier_new_16 - io.Font->LoadFromFile("courier_new_16.fnt"); - io.Font->TexUvForWhite = ImVec2(1.0f/256.0f,4.0f/128); - - // courier_new_18 - io.Font->LoadFromFile("courier_new_18.fnt"); - io.Font->TexUvForWhite = ImVec2(4.0f/256.0f,5.0f/256); - - - 2. Load the matching .PNG data into a texture - -//----------------------------------------------------------------------------- + ProggyTiny.ttf Size: 10.0f Offset: Y: +1 + ProggyClean.ttf Size: 13.0f Offset: Y: +1 + diff --git a/extra_fonts/courier_new_16.fnt b/extra_fonts/courier_new_16.fnt deleted file mode 100644 index bd5c7fba3..000000000 Binary files a/extra_fonts/courier_new_16.fnt and /dev/null differ diff --git a/extra_fonts/courier_new_16.png b/extra_fonts/courier_new_16.png deleted file mode 100644 index 3e9f99e8e..000000000 Binary files a/extra_fonts/courier_new_16.png and /dev/null differ diff --git a/extra_fonts/courier_new_18.fnt b/extra_fonts/courier_new_18.fnt deleted file mode 100644 index a254fe636..000000000 Binary files a/extra_fonts/courier_new_18.fnt and /dev/null differ diff --git a/extra_fonts/courier_new_18.png b/extra_fonts/courier_new_18.png deleted file mode 100644 index d23c96cd8..000000000 Binary files a/extra_fonts/courier_new_18.png and /dev/null differ diff --git a/extra_fonts/mplus-2m-medium_18.fnt b/extra_fonts/mplus-2m-medium_18.fnt deleted file mode 100644 index 24ef69ea0..000000000 Binary files a/extra_fonts/mplus-2m-medium_18.fnt and /dev/null differ diff --git a/extra_fonts/mplus-2m-medium_18.png b/extra_fonts/mplus-2m-medium_18.png deleted file mode 100644 index 8c2c2bc6d..000000000 Binary files a/extra_fonts/mplus-2m-medium_18.png and /dev/null differ diff --git a/extra_fonts/proggy_clean_13.fnt b/extra_fonts/proggy_clean_13.fnt deleted file mode 100644 index 126ff7f01..000000000 Binary files a/extra_fonts/proggy_clean_13.fnt and /dev/null differ diff --git a/extra_fonts/proggy_clean_13.png b/extra_fonts/proggy_clean_13.png deleted file mode 100644 index 19922df33..000000000 Binary files a/extra_fonts/proggy_clean_13.png and /dev/null differ diff --git a/extra_fonts/proggy_small_12.fnt b/extra_fonts/proggy_small_12.fnt deleted file mode 100644 index f645aabc9..000000000 Binary files a/extra_fonts/proggy_small_12.fnt and /dev/null differ diff --git a/extra_fonts/proggy_small_12.png b/extra_fonts/proggy_small_12.png deleted file mode 100644 index 7954a6ec6..000000000 Binary files a/extra_fonts/proggy_small_12.png and /dev/null differ diff --git a/extra_fonts/proggy_small_14.fnt b/extra_fonts/proggy_small_14.fnt deleted file mode 100644 index 546f8fb97..000000000 Binary files a/extra_fonts/proggy_small_14.fnt and /dev/null differ diff --git a/extra_fonts/proggy_small_14.png b/extra_fonts/proggy_small_14.png deleted file mode 100644 index 7954a6ec6..000000000 Binary files a/extra_fonts/proggy_small_14.png and /dev/null differ diff --git a/imgui.h b/imgui.h index b4cb11c4f..98855a51a 100644 --- a/imgui.h +++ b/imgui.h @@ -771,7 +771,7 @@ struct ImFont IMGUI_API bool IsLoaded() const { return TexPixels != NULL && !Glyphs.empty(); } // Retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) - static IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin + a few more + static IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin static IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs static IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs