Add better font support.

This commit is contained in:
Kyle Isom 2023-10-08 22:42:00 -07:00
parent 8125c18ae6
commit 47bba754f4
2 changed files with 17 additions and 2 deletions

View File

@ -38,7 +38,7 @@
#include "imgui_freetype.h" #include "imgui_freetype.h"
#include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*, #include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*,
#include <stdint.h> #include <stdint.h>
#include <freetype2/ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H // <freetype/freetype.h> #include FT_FREETYPE_H // <freetype/freetype.h>
#include FT_MODULE_H // <freetype/ftmodapi.h> #include FT_MODULE_H // <freetype/ftmodapi.h>
#include FT_GLYPH_H // <freetype/ftglyph.h> #include FT_GLYPH_H // <freetype/ftglyph.h>

17
kge.cc
View File

@ -15,6 +15,9 @@
#include "fonts/brassmono.h" #include "fonts/brassmono.h"
static const float fontPixelSizes[] = {16, 10, 12, 14, 18};
int int
main() main()
{ {
@ -78,7 +81,19 @@ main()
ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL3_Init(glsl_version); ImGui_ImplOpenGL3_Init(glsl_version);
io.Fonts->AddFontFromMemoryCompressedTTF(B612Mono_Regular_compressed_data, B612Mono_Regular_compressed_size, 12); for (auto pixelSize : fontPixelSizes) {
io.Fonts->AddFontFromMemoryCompressedTTF(BrassMono_Regular_compressed_data, BrassMono_Regular_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(B612Mono_Regular_compressed_data, B612Mono_Regular_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(B612Mono_Bold_compressed_data, B612Mono_Bold_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(BrassMono_Bold_compressed_data, BrassMono_Bold_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(B612Mono_BoldItalic_compressed_data, B612Mono_BoldItalic_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(BrassMono_BoldItalic_compressed_data, BrassMono_BoldItalic_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(B612Mono_Italic_compressed_data, B612Mono_Italic_compressed_size, pixelSize);
io.Fonts->AddFontFromMemoryCompressedTTF(BrassMono_Italic_compressed_data, BrassMono_Italic_compressed_size, pixelSize);
}
bool done = false; bool done = false;
bool show_demo_window = true; bool show_demo_window = true;