Outlining only certain text in dialog

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
RewindTheGame
Regular
Posts: 80
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Outlining only certain text in dialog

#1 Post by RewindTheGame »

As per the title, how do I outline only a certain word in a say dialog. Take the following code:

Code: Select all

John "This card has {outlinecolor=#000000}{color=#FFD700}GOLD{/color}{/outlinecolor} rarity."
What I want this to do is display all the text normally, except for the word GOLD which should be displayed in gold with a black outline - the black outline being necessary because the background is yellow and you wouldn't otherwise be able to read the gold text.

When I do this, the outline doesn't appear and I'm led to believe that this is because I need to also tell the text to physically have an outline to colour. However, I can find nothing about how to add an outline to just specific words rather than for all text in the game.

Thanks in advance for any help.


jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Outlining only certain text in dialog

#3 Post by jeffster »

RewindTheGame wrote: Wed May 22, 2024 10:30 am When I do this, the outline doesn't appear and I'm led to believe that this is because I need to also tell the text to physically have an outline to colour. However, I can find nothing about how to add an outline to just specific words rather than for all text in the game.
You can add transparent outline to dialogue texts by default:

Code: Select all

define gui.outlineW = 5         # your default outline width in pixels

style say_dialogue:
    outlines [(outlineW, "#0000")]
    # Here you see four colour components, 4th being alpha (0 means transparent).
Now all dialogue texts have transparent outlines, and you can recolor any word's outline with

Code: Select all

John "This card has {outlinecolor=#000}{color=#FFD700}GOLD{/color}{/outlinecolor} rarity."
For convenience you can define Custom Text Tags as explained here:
https://renpy.org/doc/html/custom_text_tags.html

And then just

Code: Select all

John "This card has {gold}GOLD{/gold} rarity."
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2445
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Outlining only certain text in dialog

#4 Post by Ocelot »

Be aware that adding transparent outline to the text will increase letter spacing.
If you do not want that, then giorgi1111 has the link that can help you (second to last message in that thread)
< < insert Rick Cook quote here > >

giorgi1111
Regular
Posts: 81
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Outlining only certain text in dialog

#5 Post by giorgi1111 »

I found this too https://github.com/AlfredPros/ranim/tree/main/game
show dialogue "Instead of using {font=cmunbtl.ttf}{color=[cyellow]}show{/color} text{/font}, you can \nuse {font=cmunbtl.ttf}{color=[cyellow]}show{/color} dialogue{/font} to simulate a dialogue text!"

pause

show dialogue "It is possible to {outlinecolor=[cgray]}change{/outlinecolor} text outline {outlinecolor=[cbrown]}midsentence{/outlinecolor}!"

pause

hide dialogue

RewindTheGame
Regular
Posts: 80
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Outlining only certain text in dialog

#6 Post by RewindTheGame »

Thanks everyone. I've actually changed the way I'm displaying the text now and have gone about this a whole new way, but thanks for the pointers. It'll definitely come in useful later in development. Also, I suppose I could look at the sourcecode for Doki Doki Literature Club for a lot of these things, because that game does a hell of a lot of weird stuff with text display so it's probably a one stop shop for anything unusual...

jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Outlining only certain text in dialog

#7 Post by jeffster »

Ocelot wrote: Thu May 23, 2024 3:50 am Be aware that adding transparent outline to the text will increase letter spacing.
If you do not want that, then giorgi1111 has the link that can help you (second to last message in that thread)
Cool. But IMHO creating an image to show a word is like killing a mosquito with a bazooka.

Anyone anal about letter spacing can use kerning
https://renpy.org/doc/html/style_proper ... ty-kerning
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

RewindTheGame
Regular
Posts: 80
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Outlining only certain text in dialog

#8 Post by RewindTheGame »

jeffster wrote: Thu May 23, 2024 12:19 pm
Ocelot wrote: Thu May 23, 2024 3:50 am Be aware that adding transparent outline to the text will increase letter spacing.
If you do not want that, then giorgi1111 has the link that can help you (second to last message in that thread)
Cool. But IMHO creating an image to show a word is like killing a mosquito with a bazooka.

Anyone anal about letter spacing can use kerning
https://renpy.org/doc/html/style_proper ... ty-kerning
Lol. Totally agree, but we live in an age where it's sometimes easier to crowbar in a solution and then come back to it later.

Post Reply

Who is online

Users browsing this forum: No registered users