How to use different fonts #5771
Closed
rainzee
started this conversation in
Build/Link/Run/Fonts issues ONLY!
Replies: 1 comment 2 replies
-
Hi, no it's not a bad question😄 For Example:
ImFont* font_title = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\Roboto-Bold.ttf", 23.0f, NULL, io.Fonts->GetGlyphRangesDefault());
IM_ASSERT(title != NULL);
ImFont* font_body = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\Roboto-Regular.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesDefault());
IM_ASSERT(body != NULL);
ImGui::Begin("Hello");
//Title ImGui Text Here
ImGui::PushFont(font_title);
ImGui::Text("Title");
ImGui::PopFont();
//Normal ImGui Text Here
PushFont(font_body);
ImGui::Text("Normal");
ImGui::PopFont();
ImGui::End(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a very basic question, I want to create a text like a title that is more eye-catching than normal
ImGui::Text
, with a larger font and different colors.I checked the documentation and this can be achieved with different fonts.
Load multiple fonts:
As I was on an open source project to make some modifications, The project is structured like this
├─Project
│ │ GUI.cpp
│ │ GUI.hpp
│ │ Hooks.cpp
│ │ Hooks.hpp
In GUI.cpp
In Hook.cpp
Now my question is where should I add my title font and how do I use it in GUI.cpp.
Sorry, this seems like a very rookie question, but I have checked all the documentation I can read, and since this is a small open source project and not all code in one file, So I don't quite understand how to do.
Beta Was this translation helpful? Give feedback.
All reactions