Font configuration for many languages


I studied about fonts and multilinguals through demo and documents.
(load font file from local or making texture etc…)
I was able to use several languages
using a font that supports Japanese, Korean, Chinese and so on.

But I have a problem.

for example…
I want to get a string through InputText( … )
the string is “どうも。谢谢。ขอบคุณค่ะ”
If the currently selected font is in Japanese font
the result is “どうも。??? ???”

In my small experience, the typical font file
did not have many of these languages at the same time.

In some other programs,
for languages that are not supported by the selected font,
they use a different kind of basic (probably system font) font to handle it.

Similarly (or in other better ways) in the imgui.
Can i handle various language inputs?

thanks always.

You can use the GlyphRangeBuilder to merge in different glyph ranges and request them from the same font, or you can merge multiple fonts into one.

Generally, supporting all languages together with text input in particular will be currently difficult with dear imgui, as text input imply that any character may be input. If you have a known script for the your app/game you can only render character used by the app/game, but if you have text input it’s not possible.

1 Like

Thank you for your answer.

Is “GlyphRangeBuilder” the only solution?
It feels too heavy to combine the fonts of all languages to display various languages.
Can I import and use a primary or an alternate font in Windows system???(how?)

Here’s a short example of my question:
to develop “window notepad” through the imgui.
What method do you use to input/display different languages?

Thank you always.

As weird as it sounds, dear imgui is currently not designed to be fully supporting internationalization, so this is actually a non-trivial problem to solve within dear imgui.

The way it would be possible to do this is to keep a GlyphRangeBuilders (never reset it). When a new characters gets added to your text file, add it to the GlyphRangeBuilders. When you hit a character that was never used before, then you can query for the updated ranges rebuild the font atlas (before NewFrame). This will work but won’t scale very well if you want to edit very large files, as later additions (new characters used for the first time) will each requires the full atlas to be rebuild which will incurr a lag when it happens.

Later on we will support more easily appending to a font atlas instead of rebuilding the whole thing. This is a planned feature but isn’t going to happen in the short term.

1 Like