Skip to content
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

InputText not scaling with SetWindowFontScale #6471

Closed
vulcan-dev opened this issue May 29, 2023 · 3 comments
Closed

InputText not scaling with SetWindowFontScale #6471

vulcan-dev opened this issue May 29, 2023 · 3 comments

Comments

@vulcan-dev
Copy link

Version/Branch of Dear ImGui:
Version: 1.83
Branch: master

Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_dx11.cpp
Compiler: MSVC
Operating System: Windows

My Issue/Question:
I've got a scale slider and everything scales besides InputText, I expected it to scale as I think that's how it should work.

Screenshots/Video
Scale of 2:
image
I'm drawing it in a child window, hence the border. I expect InputText to fill that area.

Scale of 1:
image

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Example Bug");
ImGui::SetWindowFontScale(2);
ImGui::InputText("##input", buf, 256); // height will be the same no matter the scale
ImGui::End();
@Romop5
Copy link

Romop5 commented May 29, 2023

@vulcan-dev It turns out that SetWindowFontScale seems to be a deprecated function in master. It looks like it's no longer possible to adjust scale per-window.

The author also gives a tutorial in the code stating what you should do instead to achieve a scalable UI:

[OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

See

imgui/imgui.h

Line 372 in 7e03ae3

IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

@vulcan-dev
Copy link
Author

@vulcan-dev It turns out that SetWindowFontScale seems to be a deprecated function in master. It looks like it's no longer possible to adjust scale per-window.

The author also gives a tutorial in the code stating what you should do instead to achieve a scalable UI:

[OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

See

imgui/imgui.h

Line 372 in 7e03ae3

IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

Perfect, I'll try that out later when I have time.
Thanks for the help

@ocornut
Copy link
Owner

ocornut commented Jan 16, 2025

Closing this, as, in spite of SetWindowFontScale() not being recommended in the current version, I am sure this perfectly code and repro works. In fact, I just pasted the repro and confirmed it worked. Issue was probably somewhere else in user's code.

@ocornut ocornut closed this as completed Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants