Change font to a single word in a sentence

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
Gianserpe
Newbie
Posts: 21
Joined: Mon May 27, 2019 4:20 pm
Contact:

Change font to a single word in a sentence

#1 Post by Gianserpe »

Hi everyone, I'm trying to change the font of a single word in a sentence. I tried to do such a thing

Code: Select all

image test_word = Text("[the_word]", what_font="Pixellari.ttf")
label start:
    $ the_word = "Test_Word_Sentence"
    "Verify that it works [the_word ]"
Only the font I set is not taken.Obviously I put the .ttf file in the game folder.
Can anyone help me?

User avatar
parttimestorier
Veteran
Posts: 429
Joined: Thu Feb 09, 2017 10:29 pm
Completed: No Other Medicine, Well Met By Moonlight, RE:BURN, The Light at the End of the Ocean, Take A Hike!, Wizard School Woes
Projects: Seeds of Dreams
itch: janetitor
Location: Canada
Contact:

Re: Change font to a single word in a sentence

#2 Post by parttimestorier »

I believe that code might work if you wanted to treat that one word on its own like an image, and "show" it separate from the textbox. But if you want to change the font of part of your normal text, it's actually simpler than that. You should be able to just write something like, "Here's the text where the font changes for one {font=Pixellari.ttf}word{/font}."
ImageImageImage

Gianserpe
Newbie
Posts: 21
Joined: Mon May 27, 2019 4:20 pm
Contact:

Re: Change font to a single word in a sentence

#3 Post by Gianserpe »

parttimestorier wrote: Fri Mar 19, 2021 10:18 am I believe that code might work if you wanted to treat that one word on its own like an image, and "show" it separate from the textbox. But if you want to change the font of part of your normal text, it's actually simpler than that. You should be able to just write something like, "Here's the text where the font changes for one {font=Pixellari.ttf}word{/font}."
It was what I had tried to do initially. however when that string is processed the game gives this error

Exeption: Unknown text tag u'font = font = Pixellari.ttf

This is the sentence I try to put

Code: Select all

"This is a test to see if it works {font = Pixellari.ttf} word font{/font}"
Did I do something wrong? I looked at the official guide and this method is the one reported

User avatar
puppetbomb
Regular
Posts: 123
Joined: Fri May 19, 2017 4:04 pm
Tumblr: puppetbomb
itch: puppetbomb
Location: USA
Contact:

Re: Change font to a single word in a sentence

#4 Post by puppetbomb »

Would it be difficult to create a raster image of the word and insert it in the text string?

Gianserpe
Newbie
Posts: 21
Joined: Mon May 27, 2019 4:20 pm
Contact:

Re: Change font to a single word in a sentence

#5 Post by Gianserpe »

puppetbomb wrote: Fri Mar 19, 2021 6:32 pm Would it be difficult to create a raster image of the word and insert it in the text string?
I found the error in the code, it was a matter of spaces. I got lost in a glass of water.
I wrote

Code: Select all

{font = Pixellari.ttf} word font{/font}"
Instead of

Code: Select all

{font=Pixellari.ttf} word font{/font}"
Thanks so much for taking the time

Post Reply

Who is online

Users browsing this forum: No registered users