#How to render text correctly regardless of its language?

13 messages · Page 1 of 1 (latest)

gentle light
#

My goal is to render the names of audio output devices and some of those names may depend on system's language.
Pic 1 is in Russian, everything renders correctly
Pic 2 is in English, the cyrillic part is not drawing (the Realtek ones)

What can I do about this?

#

How to render text correctly regardless of its language?

stuck tinsel
#

I think this is a font thing but have no further advice

gilded badger
#

it is
the characters simply don't exist in the loaded font (renogare)

simple light
#

you could try implementing a custom menu item in which you change the language before and after the ActiveFont.Draw_ call

#

wait no that's too complicated

#

you can just draw fonts directly

#

the issue is finding a font that has the letters you need

dusky lake
#

i think the ideal solution is having a fallback, so if a character isn't in one font it can be drawn from another font that does have it

gentle light
#

Solution 1:
Sanitize text by removing characters that are not in current language's font

public static String Sanitize(String text)
{
    String sanitized = "";
    foreach (char chr in text)
        sanitized += ActiveFont.FontSize.Get(chr) == null ? "?" : chr;
    
    return sanitized;
}
#

Solution 2:
Use custom Draw and Measure functions that finds characters in other fonts if it's not present in the current one
This method loads all fonts on PostLanguageLoad and removes font unload on language select

#

Can be marked as Resolved :)

dusky lake
#

might want to have those custom draw/measure methods into everest actually