Hello and good time of day.
How ?
Tried 11 different fonts and not a single works - just squares.
How to display text in Hindi - हिन्दी
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to display text in Hindi - हिन्दी
I'm not sure that Ren'Py can display Hindi properly. I think it requires a level of text shaping that Ren'Py doesn't support. That being said, if you're just getting squares, you're not using a font that supports the character set.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: How to display text in Hindi - हिन्दी
You may have to turn your text into images, and display those images instead of text.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: How to display text in Hindi - हिन्दी
If you're making your whole game in Hindi, you just need to change the font to a Devanagari one and make sure that the font file (ex. font.ttf) is copied in your game directory folder, or else renpy won't be able to find it and you'll just get squares (even if the font works elsewhere on your computer).
If you're using multiple languages (ex. Hindi and English) simultaneously, you'll still need to have the fonts in your game folder but you can get Hindi to appear in one of two ways:
1) If it's only on a few occasions, tagging the font every time you have text in Hindi using the font tag or creating a custom tag as a shorthand that will write this out for you:
which you can use in your script like this:
2) If it's throughout your game, using front groups and specifying the font and unicode range for Hindi and adding this code into the style specifications for default like this:
This automatically applies the font to all Devanagari characters within the specified range (0x0900 to 0x097F), so you don't have to use font tags to get them to show up.
Unfortunately, if you were planning to port to mobile and wanted to let your players provide text input in Hindi, the keyboard will revert to QWERTY on phones. Input works fine though on desktop, and you can try and make a soft keyboard for Hindi input for mobile if needed.
Hope this helps!
If you're using multiple languages (ex. Hindi and English) simultaneously, you'll still need to have the fonts in your game folder but you can get Hindi to appear in one of two ways:
1) If it's only on a few occasions, tagging the font every time you have text in Hindi using the font tag or creating a custom tag as a shorthand that will write this out for you:
Code: Select all
init python:
def hindi_tag(tag, argument, contents):
font = "NotoSansDevanagariUI-Regular.ttf"
return [
(renpy.TEXT_TAG, u"font={}".format(font)),
] + contents + [
(renpy.TEXT_TAG, u"/font"),
]
config.custom_text_tags["hindi"] = hindi_tag
Code: Select all
{hindi}your text{/hindi}
Code: Select all
style default:
#### make sure to remove
#properties gui.text_properties()
#### in order for this to work
font FontGroup().add("DejaVuSans.ttf", 0x0020, 0x007f).add("DejaVuSans.ttf", 0x200B, 0x200B).add("NotoSansDevanagariUI-Regular.ttf",0x0900, 0x097F)
Unfortunately, if you were planning to port to mobile and wanted to let your players provide text input in Hindi, the keyboard will revert to QWERTY on phones. Input works fine though on desktop, and you can try and make a soft keyboard for Hindi input for mobile if needed.
Hope this helps!
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to display text in Hindi - हिन्दी
@aswang, does this actuallyt work? I know that there are some issues with text shaping when it comes to Indic languages, but I don't know which languages those issues apply to.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: How to display text in Hindi - हिन्दी
Checking again... it does, to an extent. I didn't use the best example when testing this with Devanagari the first time it seems, so I missed some issues, but I do have an interim fix for that for OP now as well.
As for the squares, as you said it mostly seems to be an issue with the unicode scope of the in-built font and whether or not the replacement font is available. I've been playing around with another abugida script in renpy this past week (similar to Devanagari, but also a little less complex in the handling of clusters and diacritics) and the solution I posted has worked for me on both desktop and android (again aside from mobile keyboard reverting to QWERTY). But doing another test with Devanagari now, it works alright, aside from consonant clusters and some diacritics not combining the way they should in Hindi (see how the first vowel is off and the n-d (न् and द्) is different in my screenshots vs the title of this thread). The consonant clusters are still readable, the first vowel isn't (it's basically saying there should be an "i" after the "n", but the virama on the "n" is also saying that there should be no vowel after it).
Here's default renpy vs with fontgroup, vs setting my whole game's font to a Devanagari one:
"Hindi" "Devanagari" So looking closer, the main trouble renpy is having with Devanagari aside from special ligatures not combining and staying as-is is with the positioning of its vowel diacritics, namely the fact that some go before the consonant, some go after, others above or below, and it can manage all of them except for the ones that go before but are typed in after the consonant. So in "Hindi", it's giving the "i" to the N, and not the H as it should, because the symbol for "i" is typed in after the H, not before it.
And I can test this theory now by typing in the "i" before the H instead... and now it appears properly on screen! This also works if there's a consonant or consonant-vowel pair before it as well. Unfortunately there's still the issue of ligatures and as for vowels this is gonna be annoying for anyone having to type this all out / make changes to script, but it's something.
edit: I found a couple Hindi fonts that bypass these issues as they are typed out in roman script and don't use ligatures, so they should work in renpy without issue, but may be more difficult to work with if you're not writing in a word processor/coding program with custom keymapping/shortcuts/easy symbol input since not all of the characters are mapped to keys and they dont automatically combine for things like clusters, and have the same issue with diacritics appearing before needing to be written in before the consonant.
Who is online
Users browsing this forum: Google [Bot]