Ren'Py Single text with multiple styles

liberatorus

Member
Jun 12, 2022
135
186
Here is a predefined style with outlines

Code:
    style choice_index is button_text:
        font "fonts/Aero.ttf"
        size 21
        color "#ffffff"
        hover_color "#ffffff"

        yoffset 1
        xoffset 50
        outlines [(1, "#4285f9", 0, 0)]
        hover_outlines [(1, "#005dff", 0, 0)]
It is used like this in screen choice

Code:
text "This is example text (I want the text in these paranthesis to not have outlines)" style "choice_index"
Basically applying style "choice_index" causes entire text to have outlines. But I want no outlines on the part that has the paranthesis. I tried using text style tags

Code:
text "This is example text  {=nooutlinestyle}(I want the text in these paranthesis to not have outlines){/}" style "choice_index"
But this doesn't work since style tags ignore outlines.

See

How do I get some text on the choice screen where one part of the text does have outlines and another part doesn't?
 

liberatorus

Member
Jun 12, 2022
135
186
It seems like this is basically impossible to do sicne the docs clarify

That

Outlines only work when applied to an entire Text displayable. They do not work when applied to a hyperlink, text tag, or other method that applies to only a portion of the text.
But I did manage to find a workaround. You can set both the color and outliine color tag to the same color to at least simulate the absence of outlines like this
Code:
"{color=#104d01}{outlinecolor=#104d01}%s{/outlinecolor}{/color}"
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
How do I get some text on the choice screen where one part of the text does have outlines and another part doesn't?
By being inventive.

Something like this should do it ; perhaps after some corrections:
Python:
screen choice( items ):

    [...]
        for i in items:
            if "marker" in i.kwargs:
                $ txt = i.caption.split( i.kwargs["marker"] )
                button:
                    action i.action
                    hbox:
                        text txt[0] style "choice_index"
                        text txt[1] style "nooutlinestyle"
                        text txt[2] style "choice_index"
            else:
                textbutton i.caption style "choice_index" action i.action

label whatever:
    menu:
        "choice 1":
            [...]
        "choice **be careful** 2".( marker="**" ):
            [...]
        "choice ||no worry here|| 3".( marker="||" ):
            [...]
Alternatively you can also rely directly on the choice arguments:
Python:
screen choice( items ):

    [...]
        for i in items:
            if "clipped" in i.kwargs:
                button:
                    action i.action
                    hbox:
                        text i.kwargs["clipped"][0] style "choice_index"
                        text i.kwargs["clipped"][1] style "nooutlinestyle"
                        text i.kwargs["clipped"][2] style "choice_index"
            else:
                textbutton i.caption style "choice_index" action i.action

label whatever:
    menu:
        "choice 1":
            [...]
        "".( clipped=[ "choice", "be careful", "2" ] ):
            [...]
        "".( clipped=[ "choice", "no worry here", "3" ] ):
            [...]
This last approach can also permit to not limits to a three parts text:
Python:
screen choice( items ):

    [...]
        for i in items:
            if "clipped" in i.kwargs:
                button:
                    action i.action
                    hbox:
                        for txt, altStyle in i.kwargs["clipped"]:
                            text txt style ( "nooutlinestyle" if altStyle else "choice_index" )
            else:
                textbutton i.caption style "choice_index" action i.action

label whatever:
    menu:
        "choice 1":
            [...]
        "".( clipped=[ ( "choice", False ), ( "be careful", True ), ( "2", False ), ( "no, really, be careful", True ) ] ):
            [...]
        "".( clipped=[ ( "choice", False ), ( "no worry here", True ), ( "3", False ) ] ):
            [...]