# How do I render Unicode characters that my font doesn't support?

How would I go about rendering all Unicode characters?

Most font files don't include characters like these.

• Why not use a font that supports them?
– Anko
Nov 15 '15 at 23:04
• Unless you let the OS do the font rendering for you: you can't. Nov 16 '15 at 0:48
• That is, you can't render characters that your font doesn't support, by definition. The question body asks a different question... Nov 16 '15 at 1:51
• ´@immibis How can I let the OS render text in my application? Nov 16 '15 at 7:03
• Please, your question is too broad, could you add more info about the platform you are developing in and any SDK or Tool kit you are using? Jan 20 '18 at 10:42

My approach is to do the following:

1. Convert your font file to an image
2. Store each character as a VAO (use a loop to store them all - array index = unicode number)
3. Use a sprite batch to draw the text whenever its needed

Below is a snippet of my Java sprite batching code, used to draw the text.

public void draw(final String text, final float sx, final float y, final int layer) {
float x = sx;
for (final char c : text.toCharArray()) {
this.draw(CHARACTERS.get(c), x, y, layer);
x += 7 * this.scale;
}
}


As for the font files not including the characters: if you don't have the characters to draw, you can't draw them, so you'll have trouble finding a sheet with all of these different characters.

• -1. OP asks how to draw characters that he don't has in his font, not how to draw texts with ready font. Also, separate VAO for each character (and also matrix manipulations for each character) are expensive and introduce lots of draw calls. It's faster to have single VAO that is dynamically modified each time you need to draw a text. Nov 16 '15 at 18:10
• @HolyBlackCat, I have addressed that drawing characters that you do not have is not possible. You do raise a good point about the matrices though. However, the shader that I use this with only accepts a vec2 uniform to position the letters, so that isn't a problem. Modifying a VAO each time is also more complicated and IMO, 36 bindings isn't that much each frame. Nov 16 '15 at 18:19
• Oh, you lucky person. I have 256 glyphs in my fonts. :D So only solution for me is to modify a VBO each time. | About OPs question: Best solution for him is to find a font that contains almost every unicode symbol and use this font when his font does not have a needed glyph. It's better than just ignoring missing characters. So, saying that it's impossible is not best answer for this. Nov 16 '15 at 19:17
• I see. In that case, you're right. However, I did not say that it is impossible. Nov 16 '15 at 20:19

If you cannot find a single font containing all glyphs you want, you will have to have multiple fonts.

Some text rasterisation APIs have "font linking" or "font substitution" in which they use more than one font as fallback for missing glyphs. This tends to result in a sub-optimal result in terms of character advances, relative glyph size, and kerning - but it at least shows something that may be recognizable as a glyph.

If you do your own rasterisation of individual glyphs, gather enough fonts with suitable licenses, rank then in order of preference and gather glyphs from them.

You may have to restrict yourself to a subset of character ranges -- do you really need every current codepoint in existence in your game?