# How to display unicode text in monogame?

I'm looking for ways to draw any characters that may be entered in any language, on any keyboard, so that I don't have any trouble with limited language support in a monogame project.

So far I've only found how to add specific ranges of characters to SpriteFont, which is a bit insane because it means there will be a huge texture with all the characters, and it would probably eat up tons of memory. And then changing font size would mean more textures if I want to keep the quality 100%.

Is there a way to render text without pre-baking textures for every character like that? I've read that it's possible to use DirectWrite, GDI or Windows' means of drawing text to a DirectX texture, but that info is 6 years old, and I'd like to know if there are better ways now.

Update: So far I've found that Awesomium seems to be how people render nice GUIs these days, including the ability to write any text from any unicode region, provided you have the font files to render them. But it would require some alchemy to render that over the game's viewport. I haven't figured out exactly how to do it yet.

It exist various way to rasterize glyphes at runtime, like the freetype library or stb_truetype.h

All you need is a font with the set of character you want, and at runtime, you update a texture with the characters you need. The texture behave as a cache with a MRU logic to preserve glyphes across frames.

Another solution is to interpret the glyphe pathes directly and rasterize yourself.

You can use DrawString method of SpriteBatch object from: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.drawstring.aspx

For example, you can use SpriteBatch.DrawString (SpriteFont, String, Vector2, Color) to create your text sprite.

• If you read the question's text, you'll realize that you are proposing the option which doesn't work in this specific case. – user1306322 Mar 24 '17 at 2:57