Skip to content

Set font line height #4578

@makew0rld

Description

@makew0rld
Dear ImGui 1.83 (18300)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 4, sizeof(ImDrawVert): 20
define: __cplusplus=201703
define: __linux__
define: __GNUC__=7
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000000
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000140E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 512,1024
io.DisplaySize: 1280.00,800.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

My Issue/Question:

I am using a custom font that has minimal vertical margins. This makes reading text with the font difficult. Obviously I can modify the font to increase those, but modifying fonts is non-trivial and error-prone. I was hoping that Dear Imgui would have a way to set the line height/spacing for the font, or some way to add more vertical margin. That way whenever the font was used, it would have the desired spacing.

Screenshots/Video

image

Standalone, minimal, complete and verifiable example: (see #2261)

The font I am using is AcPlus_IBM_BIOS.ttf, as seen here. It can be downloaded as part of this ZIP.

I am using DearPyGUI so I don't have C/C++ code for you. I filed this issue here because I can't find anything about this in the upstream API.

My Python code simply just loads the font and the demo:

import dearpygui.dearpygui as dpg

font_chars = # all the character codes for this font

with dpg.font_registry():
    with dpg.font("AcPlus_IBM_BIOS.ttf", 16, default_font=True):
        dpg.add_font_chars(font_chars)

dpg.show_imgui_demo()
dpg.start_dearpygui()

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions