Main Menu
  • Welcome to The RPG Maker Resource Kit.

[request] Fitting text in small boundaries?

Started by shintashi, May 10, 2011, 04:46:05 AM

0 Members and 1 Guest are viewing this topic.

shintashi

so I'm trying to fit longer words like "murasaki" in this:


#====================================================================
#      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.

GregAzrael

If I remember right, try increasing the 90 in:

def initialize
    super(100, 278, 90,42)


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

pacdiggity

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

modern algebra

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:


        self.contents.draw_text(0, -10, 90, 32, term.to_s)


to:


        self.contents.draw_text(0, -10, 58, 32, term.to_s)


Then the text would autmatically resize