question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to change font in monogame?

See original GitHub issue

Hello this code is not working in monogame:

io.Fonts.AddFontFromFileTTF("GOTHIC.TTF", 22);

How to change font?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
zcyemicommented, Aug 27, 2019

Try this, it works for me.

Load font

ImGuiRenderer render;
//...
var font = ImGui.GetIO().Fonts.AddFontFromFileTTF(@"C:\Windows\Fonts\ARIAL.TTF", 13);
render.RecreateFontDeviceTexture();

Enable font on rendering

render.Update((float)deltaSec, inputs);
ImGui.PushFont(font);

ImGui.Text("It works");
1reaction
kasperhbocommented, Jun 14, 2023

Hey guys, I figured it out.

The problem is in the sample XNA renderer.

ImGuiRenderer.cs line 188:

ImGui.GetIO().Fonts.AddFontDefault();

You need to relpace it with:

//ImGui.GetIO().Fonts.AddFontDefault();
ImGui.GetIO().Fonts.AddFontFromFileTTF("your/path", your_font_size);

I haven’t figured out how to change it in code afterwards, but this is trivial as you can change it just fine using the demo window.

image image

Did you ever figure this out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing the font of a SpriteFont?
you can change the font by editing the spritefont file before compilation eg, <FontName>Segoe UI Mono</FontName>.
Read more >
how to change fontsize during the game in XNA?
Open the x.spritefont file from solution explorer. Go to the tag and edit it to your desired font size. To make multiple size...
Read more >
How to change font in monogame? - ImGuiNET/ImGui.NET
// In load ImFontPtr font = ImGui.GetIO().Fonts.AddFontFromFileTTF("Roboto-Regular.ttf", 13); // In draw ImGui.PushFont(font); ImGui.Text( ...
Read more >
Monogame - Drawing Text With Spritefonts - RB Whitaker's Wiki
In MonoGame, we will work with a thing called sprite fonts. A sprite font takes a normal, vector-based font and turns it into...
Read more >
MonoGame Micro Tutorial Series #9 - Drawing Text - YouTube
... MonoGame Micro Tutorial we learn how to draw text to the screen! ... https://discord.com/invite/6THUkfy # monogame #csharptutorial # Xna ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found