-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font display does not account for descent and ascent when using ImGuiFreeTypeBuilderFlags_Bitmap #8416
Comments
Fonts loaded using // Vuhdo: I'm not sure how to deal with font sizes properly. As far as I understand, currently ImGui assumes that the 'pixel_height'
// is a maximum height of an any given glyph, i.e. it's the sum of font's ascender and descender. Seems strange to me.
// NB: FT_Set_Pixel_Sizes() doesn't seem to get us the same result.
FT_Size_RequestRec req;
req.type = (UserFlags & ImGuiFreeTypeBuilderFlags_Bitmap) ? FT_SIZE_REQUEST_TYPE_NOMINAL : FT_SIZE_REQUEST_TYPE_REAL_DIM;
req.width = 0;
req.height = (uint32_t)(pixel_height * 64 * RasterizationDensity);
req.horiResolution = 0;
req.vertResolution = 0;
FT_Request_Size(Face, &req); We might have an issue to fix but you could specify which font you are using and provide e.g. a repro in the form of font loading code? |
I’m using the Noto Sans font, and the spacing issue is very easy to reproduce with Chinese characters. Below is my code.
|
Could you specify some example characters and show a screenshot? |
This is the font file, you can use it or download it from Google Fonts |
Thank you. I think it is specifically caused by |
Version/Branch of Dear ImGui:
Version 1.9.5, Branch: docking
Back-ends:
imgui_impl_SDL3.cpp + imgui_impl_SDL3Renderer.cpp
Compiler, OS:
Win22+vs2022
Full config/build information:
No response
Details:
“I’m using fonts created with Freetype and FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Bitmap. I noticed that in ImGui, the line height in RenderText is directly calculated using the font size, which results in no spacing between lines of text. I modified the line_height to (fabs(Descent) + fabs(Ascent)) * scale, and it displayed correctly. Is this a bug?”
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip)
{
if (!text_end)
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
The text was updated successfully, but these errors were encountered: