Auto-Resize Text based on length

Status
Not open for further replies.

Koulucky

Veteran
Veteran
Joined
Jan 25, 2016
Messages
68
Reaction score
31
First Language
English
Primarily Uses
Is there a script and is it possible to: if a particular line of text in a ''box'' is bigger, instead of stretching, the font be automatically resized so it fits in the ''box'', BUT the font be resized only for that particular line, not for all the text.
This pic is like it is now(stretchy):

But this pic is like it would ideally be with the script:

Any help would be appreciated. :)
 

Koulucky

Veteran
Veteran
Joined
Jan 25, 2016
Messages
68
Reaction score
31
First Language
English
Primarily Uses
@A-Moonless-Night Sorry, but this doesn's work like what I need.
In some cases, the text exceeds the text ''box'' instead the font size being reduced(in the pic the B from the 2nd Elysium Bird can't be seen):

While in this case, it stretches like it did before:

I need something that makes the text fit into the ''box'', by automatically reducing the font size till it fits or something, not for the text to go outside the ''box''.

EDIT: Or maybe there is some script so I can manually determine the font size for the particular battler's title.
 
Last edited:

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
682
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Try this:
Code:
class Window_BattleEnemy < Window_Selectable
  def draw_item(index)
    change_color(normal_color)
    name = $game_troop.alive_members[index].name
    while text_size(name).width >= item_rect_for_text(index).width do
      contents.font.size -= 1
    end
    draw_text(item_rect_for_text(index), name)
    reset_font_settings
  end
end
 

Mooshry

BTS has consumed my very existence help.
Veteran
Joined
May 30, 2016
Messages
395
Reaction score
145
First Language
English
Primarily Uses
RMMV
When i tried it, enemies with long names like the Morphean Mushroom's letters were cut off. Like instead of Morphean Mushroom B, it says Morphean Mushroom without the letter B.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top