Fix default ImGui font and font scales.

This commit is contained in:
Skyth 2024-12-11 23:22:12 +03:00
parent 3eff02d19f
commit 8fa706558c
3 changed files with 4 additions and 4 deletions

View file

@ -179,10 +179,10 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
auto font = msdfgen::loadFontData(freeType, reinterpret_cast<const msdfgen::byte*>(config.FontData), config.FontDataSize);
msdf_atlas::FontGeometry fontGeometry(&glyphs);
fontGeometry.loadCharset(font, 1.0, charset);
fontGeometry.loadCharset(font, config.SizePixels, charset);
auto& metrics = fontGeometry.getMetrics();
config.DstFont->FontSize = 1.0f;
config.DstFont->FontSize = config.SizePixels;
config.DstFont->ConfigData = &config;
config.DstFont->ConfigDataCount = 1;
config.DstFont->ContainerAtlas = atlas;
@ -203,7 +203,6 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
TightAtlasPacker packer;
packer.spacing = 1;
packer.dimensionsConstraint = msdf_atlas::DimensionsConstraint::POWER_OF_TWO_RECTANGLE;
packer.minScale = 24.0;
packer.miterLimit = 1.0;
packer.pxRange = 8.0;
packer.pack(glyphs.data(), glyphs.size(), customRects.data(), customRects.size());

View file

@ -265,5 +265,5 @@ ImFont* ImFontAtlasSnapshot::GetFont(const char* name)
assert(false && "Unable to locate equivalent font in the atlas file.");
#endif
return fontAtlas->AddFontFromFileTTF(name, 1.0f, nullptr, g_glyphRanges.data());
return fontAtlas->AddFontFromFileTTF(name, 24.0f, nullptr, g_glyphRanges.data());
}

View file

@ -1124,6 +1124,7 @@ static void CreateImGuiBackend()
IM_DELETE(io.Fonts);
io.Fonts = ImFontAtlasSnapshot::Load();
#else
io.Fonts->AddFontDefault();
ImFontAtlasSnapshot::GenerateGlyphRanges();
#endif