06-10-2011, 05:01 AM 
	
	
	
		Okay... this is the rewrite of the initialize method I mentioned:
And this is a map event 'Script Call' I wrote.
Rather than the window showing up at 0,0, it shows up at 20,20 (in pixels). The window resizes to fit the text... two small one-word lines.
	
	
	
	
Code:
def initialize(x,y,lines)
    @lines = []
    @lines = lines
    @line_width = []
    if @lines.size == 0
      print("Error: Auto-sizing windows must have at least one line")
      exit
    end
    @tester = Window_Base.new(0, 0, 640, 480)
    @tester.contents = Bitmap.new(@tester.width - 32, @tester.height - 32)
    @tester.contents.font.name = "Arial"
    @tester.contents.font.size = 18
    max = 0
    for i in 0..@lines.size - 1
      t = @lines[i]
      @line_width[i] = @tester.contents.text_size(t).width
      if @line_width[i] > max
        max = @line_width[i]
      end
    end
    w = max + 40
    h = @lines.size + 1
    h *= 32
    @tester.dispose
    super(x, y, w, h)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Arial"
    self.contents.font.size = 18
    refresh
  endAnd this is a map event 'Script Call' I wrote.
Code:
Window_Autosize.new(20,20,
["Here","There"])Rather than the window showing up at 0,0, it shows up at 20,20 (in pixels). The window resizes to fit the text... two small one-word lines.

![[Image: QrnbKlx.jpg]](https://i.imgur.com/QrnbKlx.jpg)
![[Image: sGz1ErF.png]](https://i.imgur.com/sGz1ErF.png)
![[Image: liM4ikn.png]](https://i.imgur.com/liM4ikn.png)
![[Image: fdzKgZA.png]](https://i.imgur.com/fdzKgZA.png)
![[Image: sj0H81z.png]](https://i.imgur.com/sj0H81z.png)
![[Image: QL7oRau.png]](https://i.imgur.com/QL7oRau.png)
![[Image: uSqjY09.png]](https://i.imgur.com/uSqjY09.png)
![[Image: GAA3qE9.png]](https://i.imgur.com/GAA3qE9.png)
![[Image: 2Hmnx1G.png]](https://i.imgur.com/2Hmnx1G.png)
![[Image: BwtNdKw.png%5B]](https://i.imgur.com/BwtNdKw.png%5B)