Fonts: added AddFontDefaultVector() with embedded ProggyVector data.

This commit is contained in:
ocornut
2025-12-23 18:16:33 +01:00
parent cde6ad3967
commit f006400f05
4 changed files with 386 additions and 6 deletions
+7
View File
@@ -69,6 +69,13 @@ Breaking Changes:
Other Changes:
- Fonts:
- Added AddFontDefaultVector(): a new embedded scalable font!
Based on ProggyVector by Tristan Grimmer, the same author as our good-old ProggyClean.
The font data was carefully subsetted, trimmed and compressed so the embedded
data is ~18 KB. Embedding a scalable default font ensures that Dear ImGui can
be easily and readily used in all contexts, even without file system access.
As always you can opt-out of the embedded font data if desired. A sizing tweak
was also applied to ensure the new font is a closer match to the classic font.
- Fixed an issue related to EllipsisChar handling, while changing
font loader or font loader flags dynamically in Style->Fonts menus.
- imgui_freetype: fixed overwriting ImFontConfig::PixelSnapH when hinting
+2 -1
View File
@@ -3640,7 +3640,8 @@ struct ImFontAtlas
IMGUI_API ImFontAtlas();
IMGUI_API ~ImFontAtlas();
IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg);
IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL);
IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); // Embedded classic pixel-clean font. Recommended at Size 13px with no scaling.
IMGUI_API ImFont* AddFontDefaultVector(const ImFontConfig* font_cfg = NULL); // Embedded scalable font. Recommended at any higher size.
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels = 0.0f, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_data_size, float size_pixels = 0.0f, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_data_size, float size_pixels = 0.0f, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
+360 -5
View File
File diff suppressed because it is too large Load Diff
+17
View File
@@ -0,0 +1,17 @@
# Usage: fontforge.exe -script ProggyVector-ExtractScript.txt
Open("ProggyVector-Regular.ttf")
SelectMore(0x20,0xFF)
SelectMore(0x20AC) # Euro sign
SelectInvert()
DetachAndRemoveGlyphs()
SelectAll()
RemoveOverlap()
Simplify()
i=0
while (i < 23)
SetTTFName(0x409,i,"")
i=i+1
endloop
SetFontNames(".",".",".",".",".",".")
Generate("ProggyVector-minimal.ttf")
# At this point you can use binary_to_compressed_c.exe -u8 ProggyVector-minimal.ttf proggy_vector_minimal_ttf