Ren'Py [SOLVED]text style for textbutton

GoldenD

Member
Sep 30, 2018
102
70
I let this post to punish me but in fact there was no problem. The only was my stupidity.

I just want the same style of font in some parts of the screen. But it seems to be more difficult than i thought.
Look at:
text_size.jpg

Left of arrow, it's some textbutton and at right, it's dialog text.
I use the same font and same size
For textbutton, i have to style "text_size 30" and "text_bold False" because i don't wanna change "gui.interface_text_size"
Bold seems to have no effect.
An idea !?
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
You can change the presentation of any text in place any time you like by just overriding the defaults with explicit styling.

You can also mix different styles, mid sentence.

Python:
    "This is a normal sentence."
    "This is a mix of {color=#FF0000}Red{/color} and {color=#00FF00}Green{/color} text."
    "This is the same thing, except the {color=#FF0000}{b}Red{/b}{/color} is bold and the {color=#00FF00}{i}Green{/i}{/color} is in italics."
    "And this sentence has something written {font=mikachan.ttf}in a completely different font{/font} {i}(assuming that font file is in your /game/ folder){/i}."
    "And this text is {size=45}HUGE{/size}, whereas this text is {size=8}tiny{/size}."
Details of all of that (and more) can be found here :

If you're planning to use the same styling of font/size/bold/italic over and over, you might want to consider defining a custom style.

Python:
    "And this text is uses a style I pre-defined earlier" style "my_style"
(I haven't tested that last one... I could be making too many assumptions, based on the documentation).

Again, more details here :

To the best of my knowledge, pre-defined styles can be applied individually or to entire types of RenPy objects (like all menus for example).
 

GoldenD

Member
Sep 30, 2018
102
70
You can change the presentation of any text in place any time you like by just overriding the defaults with explicit styling.

You can also mix different styles, mid sentence.

Python:
    "This is a normal sentence."
    "This is a mix of {color=#FF0000}Red{/color} and {color=#00FF00}Green{/color} text."
    "This is the same thing, except the {color=#FF0000}{b}Red{/b}{/color} is bold and the {color=#00FF00}{i}Green{/i}{/color} is in italics."
    "And this sentence has something written {font=mikachan.ttf}in a completely different font{/font} {i}(assuming that font file is in your /game/ folder){/i}."
    "And this text is {size=45}HUGE{/size}, whereas this text is {size=8}tiny{/size}."
Details of all of that (and more) can be found here :

If you're planning to use the same styling of font/size/bold/italic over and over, you might want to consider defining a custom style.

Python:
    "And this text is uses a style I pre-defined earlier" style "my_style"
(I haven't tested that last one... I could be making too many assumptions, based on the documentation).

Again, more details here :

To the best of my knowledge, pre-defined styles can be applied individually or to entire types of RenPy objects (like all menus for example).
Yeah,
i read and use all what you say (maybe not all), to my small and humble level. But the problem isn't how to change style but why same options (font, color, size) gives a different result ?
My opinion is I didn't change all params, but i don't know what more I can change.
And I can understand that my english isn't so clear, the net is the only place where people pretend to understand me !:giggle:
But great thanks for your help
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Ah. So you've used a common style for both, but one is bold and one isn't.
(My bad, I missed that detail of your original post).

The only thing that comes to mind is that while both are inheriting their styles from a common place - perhaps each are separate at the detail level and one has something which is overriding the definition you think both are using.

Styles and such are something I usually stay away from. I'm beginning to remember why now. :whistle:
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,782
Python:
screen bold_test():
    vbox align (.5, .5):
        text "normal text"
        textbutton "normal button":
            action NullAction()
        text "bold text" style "bold_text"
        textbutton "bold button":
            style "bold_button"
            action NullAction()

style bold_text is text:
    size 30
    bold True

style bold_button is button

style bold_button_text is button_text:
    size 30
    bold True

label start:
    call screen bold_test
the text of the buttons is offset because of the padding property of the background frame used for buttons.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,005
You don't have permission to view the spoiler content. Log in or register now.
if you are ever going to make that tutorial you've been thinking about, it might be nice to make notes of common questions, or questions that seem simple but have a secret complexity like this one. Just to know what to cover if you do get started, or maybe it will help you get started when you see that you have enough interesting topics on your list of notes.
 

GoldenD

Member
Sep 30, 2018
102
70
Python:
screen bold_test():
    vbox align (.5, .5):
        text "normal text"
        textbutton "normal button":
            action NullAction()
        text "bold text" style "bold_text"
        textbutton "bold button":
            style "bold_button"
            action NullAction()

style bold_text is text:
    size 30
    bold True

style bold_button is button

style bold_button_text is button_text:
    size 30
    bold True

label start:
    call screen bold_test
the text of the buttons is offset because of the padding property of the background frame used for buttons.
Ok boss,
I send you a Like(y) but in fact, I was afraid of that kind of answer and I don't like it.
But it's life.
The only alternative i think would be to can use text instead textbutton but i think i can't do tooltp on text.
So, i wait some tests, and if I find the strength, i'll solved this thread!!!
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,782
:WaitWhat: what's the problem?
text and text of the textbutton look the same and if you set the padding property of the buttons to (0, 0), even the offset is gone.
 

GoldenD

Member
Sep 30, 2018
102
70
:WaitWhat: what's the problem?
text and text of the textbutton look the same and if you set the padding property of the buttons to (0, 0), even the offset is gone.
You're right, there's no problem, i just finish to correct my code and i don't know if i'm right to say you the truth. I'm ashamed.

In fact when I code my textbutton, I format the caption with "{b}" and I forgot it. I code my style somewhere else and quietly, Billy, I open a thread to show the world my excellent level.
(n):sick:
Sorry for the inconvenience.