Skip to content

TextBox Viewport Scaling #623

@ftsf

Description

@ftsf

Text is misplaced depending on the viewport scaling.
The example below shows that with the viewport scaled by 100 text is placed in the wrong position.

It should display exactly the same no matter what sf is set to. At 1 everything is fine, but as it increases things change.
At 10 the line spacing is smaller.
At 25 the line spacing is larger.
At 50 everything is packed onto a single line.

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

local sf = 100

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

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

charcodes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,:;!?()&/-'
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas diam augue, laoreet vitae dapibus in, sodales in ligula. Nullam dapibus velit vel lectus pretium at ultricies massa bibendum. Nulla cursus suscipit malesuada. Donec sit amet nisl ac sem venenatis dictum.'

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

textbox = MOAITextBox.new ()
textbox:setString ( text )
textbox:setFont ( font )
textbox:setGlyphScale(1/sf)
textbox:setRect ( -150/sf, -230/sf, 150/sf, 230/sf )
textbox:setYFlip ( true )
layer:insertProp ( textbox )

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions