[OK]Font Groups - How to associate character points for font

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
saruri
Regular
Posts: 41
Joined: Wed Sep 12, 2012 2:11 am
Contact:

[OK]Font Groups - How to associate character points for font

#1 Post by saruri » Mon Jul 29, 2013 1:33 am

Ref: http://www.renpy.org/doc/html/text.html#font-groups

As subject, I don't understand how do you set the start and end of a range of unicode character points for the font you want to use.

The example given is using two fonts in a group, which I don't understand their respective unicode character points set:

Code: Select all

init python:
     style.default.font = FontGroup().add("english.ttf", 0x0020, 0x007f).add("japanese.ttf", 0x0000, 0xffff)
Let's say if I want to add one more font to the code above, how?

Thanks in advance.
Last edited by saruri on Wed Jul 31, 2013 4:47 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15427
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: Font Groups - How to associate character points for font

#2 Post by PyTom » Mon Jul 29, 2013 1:37 am

You'd add another .add call. Since the first one to contain a point is the one that's used, you'd have to add it in the middle.

Code: Select all

init python:
     style.default.font = FontGroup().add("english.ttf", 0x0020, 0x007f).add("braille.ttf", 0x2800, 0x28ff).add("japanese.ttf", 0x0000, 0xffff)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
saruri
Regular
Posts: 41
Joined: Wed Sep 12, 2012 2:11 am
Contact:

Re: Font Groups - How to associate character points for font

#3 Post by saruri » Tue Jul 30, 2013 12:46 am

PyTom wrote:You'd add another .add call. Since the first one to contain a point is the one that's used, you'd have to add it in the middle.

Code: Select all

init python:
     style.default.font = FontGroup().add("english.ttf", 0x0020, 0x007f).add("braille.ttf", 0x2800, 0x28ff).add("japanese.ttf", 0x0000, 0xffff)
Thank you very much for your kind reply.

I understand need to add another .add call but don't know how to set the character points for it. Like your braille.ttf, how to know its character points are "0x2800, 0x28ff"???

User avatar
PyTom
Ren'Py Creator
Posts: 15427
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: Font Groups - How to associate character points for font

#4 Post by PyTom » Tue Jul 30, 2013 1:07 am

You look them up in the code charts here:

http://www.unicode.org/charts/
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
saruri
Regular
Posts: 41
Joined: Wed Sep 12, 2012 2:11 am
Contact:

Re: Font Groups - How to associate character points for font

#5 Post by saruri » Tue Jul 30, 2013 10:20 pm

I can't find my font in the chart......OTZ
I see some names with "Chinese" in the index but I don't understand them. Ren'Py's default font cannot be found too......

Let's just take my current case as an example. I'm now creating a game using 2 fonts: Ren'Py's default ttf (for English) and simhei.ttf (for Simplified Chinese), which both I can't find them in the chart.
Since the example given got english.ttf, I'm guessing that I can use its points for all english fonts so I'll just replace it with DejaVuSans.ttf. What about my Chinese font, simhei.ttf?

User avatar
PyTom
Ren'Py Creator
Posts: 15427
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: Font Groups - How to associate character points for font

#6 Post by PyTom » Tue Jul 30, 2013 11:14 pm

If you're just using English and Chinese, you could use the ASCII range for English, and then 0x0000 to 0xffff for Chinese. (That would prevent you from using, say, Arabic characters - but that's unlikely, anyway.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
saruri
Regular
Posts: 41
Joined: Wed Sep 12, 2012 2:11 am
Contact:

Re: Font Groups - How to associate character points for font

#7 Post by saruri » Wed Jul 31, 2013 4:47 am

Ok, thank you very much, PyTom! ^ ^

Post Reply

Who is online

Users browsing this forum: Google [Bot]