Skip to content

FreeType: AddFontDefaultVector makes the font blurry #9348

@RDMCz

Description

@RDMCz

Version/Branch of Dear ImGui:

Version 1.92.7, downloaded from the GitHub release tag v1.92.7

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Windows 10 + MinGW, also tested on MSVC

Full config/build information:

Dear ImGui 1.92.7 (19270)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: _WIN32
define: _WIN64
define: __MINGW32__
define: __MINGW64__
define: __GNUC__=13
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw (3400)
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000001E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
 RendererHasTextures
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: FreeType
io.DisplaySize: 900.00,823.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

This is a followup to my comment on the ProggyForever issue.

This happens when you use Dear ImGui (1.92.6 or 1.92.7) with FreeType and want to use the new ProggyForever font via AddFontDefaultVector. The font is loaded but looks blurry. If you download ProggyForever TTF file and import it using AddFontFromFileTTF, everything looks fine.

I have made an example project and some screenshots, see DearImGuiAddFontDefaultVectorFreeTypeObservations.

Some notes:

  • Commenting out the line font_cfg.ExtraSizeScale *= 1.015f; in AddFontDefaultVector makes the biggest difference (at least from what I found out, I can't afford to dig deeper right now)
  • There is a difference on how the font looks between FreeType versions 2.13 and 2.14
  • In addition to the blurriness, the tops of the capital letters are also slightly cut off
  • It seems like there are some kerning issues in FreeType v2.14

Screenshots/Video:

I made a repo for this issue, all the screenshots are in its README.

Open the images in new tab or download them to see the difference

Minimal, Complete and Verifiable Example code:

// in init
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontDefaultVector();
ImFont* font_proggyforever = io.Fonts->AddFontFromFileTTF("./Resource/ProggyForever-Regular.ttf");

// in update
constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize;
constexpr auto text = "Dear ImGui Aa Bb Cc Dd Ee";

ImGui::Begin("Blurry forever", nullptr, flags);

ImGui::PushFont(nullptr, 28.0f);
ImGui::Text("%s (added via AddFontDefaultVector)", text);
ImGui::PopFont();

ImGui::PushFont(font_proggyforever, 28.0f);
ImGui::Text("%s (added via AddFontFromFileTTF)", text);
ImGui::PopFont();

ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions