How to center multiple lines of text on a screen [SOLVED]

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
Hoomst
Newbie
Posts: 10
Joined: Wed Jun 08, 2022 9:46 am
Contact:

How to center multiple lines of text on a screen [SOLVED]

#1 Post by Hoomst »

I'd like to center multiple lines of text on a screen like this:

Input:

Code: Select all

screen example():
    text "This is an interresting \n description. \n Please read it." 
Output:
This is an interresting
description.
Please read it.
xalign 0.5 centers the whole text block and not every single line of the text.

Is there a way to achieve that without having to use xalign 0.5 on every line?
Last edited by Hoomst on Mon Oct 03, 2022 11:58 am, edited 1 time in total.

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

Re: How to center multiple lines of text on a screen

#2 Post by Ocelot »

https://www.renpy.org/doc/html/style_pr ... properties
text_align - float

This is used when a line is shorter than the width of the text displayable. It determines how much of the extra space is placed on the left side of the text. (And hence, the text alignment.)

0.0 will yield left-aligned text, 0.5 centered text, and 1.0 right-aligned text.
< < insert Rick Cook quote here > >

Hoomst
Newbie
Posts: 10
Joined: Wed Jun 08, 2022 9:46 am
Contact:

Re: How to center multiple lines of text on a screen

#3 Post by Hoomst »

Thank you! That does exactly what I wanted.

Post Reply

Who is online

Users browsing this forum: Google [Bot]