Skip to content

Commit

Permalink
MOAITextBox getStringBounds provides incorrect bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Ransom committed Jun 28, 2012
1 parent 0c684c9 commit 7493376
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions samples/test/textbox-getStringBounds-error/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
----------------------------------------------------------------
-- Copyright (c) 2010-2011 Zipline Games, Inc.
-- All Rights Reserved.
-- http://getmoai.com
----------------------------------------------------------------

MOAISim.openWindow ( "MOAITextBox", 320, 480 )

viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, 480 )

layer = MOAILayer.new ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )

charcodes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,:;!?()&/-'

font = MOAIFont.new ()
font:loadFromTTF ( 'arial-rounded.TTF', charcodes, 12, 163 )

textbox = MOAITextBox.new ()
textbox:setFont ( font )
textbox:setTextSize ( 12, 163 )
textbox:setRect ( -150, -230, 150, 230 )
textbox:setAlignment ( MOAITextBox.CENTER_JUSTIFY, MOAITextBox.CENTER_JUSTIFY )
textbox:setYFlip ( true )
layer:insertProp ( textbox )

text = 'Hello world. How are you today. I am doing well. How are you today. It seems peculiar that we are even having a conversation'
textbox:setString ( text )
xmin, ymin, xmax, ymax = textbox:getStringBounds ( 10, 50 )

gfxQuad = MOAIGfxQuad2D.new ()
gfxQuad:setTexture ( "box.png" )
gfxQuad:setRect ( xmin, ymin, xmax, ymax )
gfxQuad:setUVRect ( 0, 0, 1, 1 )

prop = MOAIProp2D.new ()
prop:setDeck ( gfxQuad )
layer:insertProp ( prop )

print ( 'Please exit the window now.' )

0 comments on commit 7493376

Please sign in to comment.