RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[request] Fitting text in small boundaries?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
so I'm trying to fit longer words like "murasaki" in this:

Code: [Select]
#====================================================================
#      Fragment 1 - super (x, y, width, height)
#====================================================================
class Fragment_1 < Window_Base #Window_Fragment
attr_accessor :term

  def initialize
    super(100, 278, 90,42)
    self.contents = Bitmap.new(width-32, height-32)
    refresh
    self.back_opacity = 255
    @term = "" #$data_chants[0].name
    end
   
  def refresh
    self.contents.clear
        self.contents.font.color = text_color(0)#white
        self.contents.font.size = 16 #was 20
        self.contents.draw_text(0, -10, 90, 32, term.to_s)
      end
     
  def update
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
 
end

But all I get is "mura" and then the rest is cut off several pixels before the text hits the boundary. Is there a way to make text fit without using an illegible font size? I would really like to use those extra border pixels.
« Last Edit: May 11, 2011, 12:23:24 AM by shintashi »

**
Rep: +0/-0Level 70
RMRK Junior
If I remember right, try increasing the 90 in:

Code: [Select]
def initialize
    super(100, 278, 90,42)

Remember to have a backup of your work in case something happens.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
That's odd, I know that at least in VX the window automatically resizes the text if it doesn't fit. At GregAzrael said, increase the width (third value) of the super. If it collides with another window, you'll have to reset them all.
Although, XP should resize the text as well.
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Well, it does in XP too. But your window is only 90 pixels wide, and 32 pixels of that is the border, so you don't have 90 pixels to draw in - you only have 58. If you change:

Code: [Select]
        self.contents.draw_text(0, -10, 90, 32, term.to_s)

to:

Code: [Select]
        self.contents.draw_text(0, -10, 58, 32, term.to_s)

Then the text would autmatically resize