Crop text to fit size of button

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
User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Crop text to fit size of button

#1 Post by _ticlock_ »

Hi All,

What options can be used to crop text to fit the size of the textbutton (or label)?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Crop text to fit size of button

#2 Post by Per K Grok »

_ticlock_ wrote: Tue Feb 16, 2021 12:03 am Hi All,

What options can be used to crop text to fit the size of the textbutton (or label)?

The idea that jumps to my mind is to make the text into an image and crop that, and use the cropped image in the screen.
Technically you would not have a label or a textbutton, but you would have the visual effect.

Code: Select all


image croptext = Text("{color=#f00}TEXT TO CROP{/color}", size=35)
image croppedtext = Crop((0, 15, 220, 15), "croptext")

screen croptextshower():
    add "croppedtext"


User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Crop text to fit size of button

#3 Post by gas »

The core for textbutton is just a default button, then a text child on top of it. The text layer don't have any binded parameter on size.
All style parameters are in fact sent to the button-father, and you have to specifically use a text_ parameter to intervene to the child. And such damned child don't have text_cropping = 0.5, for example.
So, in a word, not only there's not an option, but there can't be ever one.

As a fun fact, the button does instead take the text one as default size, if no style intervene.
What a strange world.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Crop text to fit size of button

#4 Post by _ticlock_ »

Per K Grok wrote: Tue Feb 16, 2021 2:50 am
gas wrote: Tue Feb 16, 2021 3:12 am
Thank you. I thought I missed something obvious. I used something similar to what Per K Grok suggested but using add Text(..) inside a button with ATL. Everything looks neat, however, I don't like that it is a bit "bulky" for a single button, when you add styles, change font color on hover, etc. There are a couple of things I want to try and I will post the code later.

Post Reply

Who is online

Users browsing this forum: munni