Replies: 1 comment 3 replies
-
https://github.com/FontStashSharp/FontStashSharp/wiki/Using-FontStashSharp-in-MonoGame-or-FNA |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I am new to MonoGame and game dev in general, so I will be grateful for your understanding in case I'm doing everything wrong 🥲
I have a bunch of questions to ask about drawing text, and I will be very thankful for help.
First of all, SpriteBatch.DrawString() requires SpriteFont, which defines the size of the text. Scaling will lead to resolution loss, so I need to create another sprite font every time I need to draw text with a different scale. Besides, I need to do it manually through the content pipeline. But this is very inconvenient, and I think that there might be another way to scale text. But I don't want to get into details of loading and rendering vector images yet.
How to use shaders with text? For example, I'm making a UI system, and I want to cull half of my text so it won't stick out of some scrollable menus (even if it sounds too expensive and probably unreasonable, I still want to learn how to work with shaders and text). But shaders apply to all the characters separately, while for my previous culling shader I calculated menu rectange relative to the size of the given texture to get UV coordinates after which shader should discard pixels, however now I have many rectangles per Draw() for each character, so I don't know what to do. Besides, I don't know whether there is any way to draw different characters with different shaders, or at least different parameters. I would like to draw text as a single texture. I tried using render targets, which worked but was an awful idea because switching between them, clearing, etc. for every text object is very slow, and I definitely don't want my UI to consume as many resources as the rest of the game.
Drawing text should be fast and lightweight, but I don't see such solutions for the problems mentioned above. Thanks for you attention.
Beta Was this translation helpful? Give feedback.
All reactions