Well I am using a resource cache to retrieve the font and the rest of my calls for generating the textbox's are contained within my UI framework factory functions. But, this code produces the same result and is essentially the same:
- Code: Select all
MOAISim.openWindow ( "test", 512, 512 )
viewport = MOAIViewport.new ()
viewport:setSize( 512, 512 )
viewport:setScale( 256, 256 )
layer = MOAILayer.new()
layer:setViewport( viewport )
text = 'Example Text'
charcode = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 _'
font = MOAIFont.new()
font:load( 'Dwarves.TTF' )
font:preloadGlyphs( charcode, 70, 72 )
textbox = MOAITextBox.new()
textbox:setString( text )
textbox:setRect( -128, -128, 128, 128 )
textbox:setYFlip( true )
textbox:setAlignment ( MOAITextBox.CENTER_JUSTIFY, MOAITextBox.CENTER_JUSTIFY )
textbox:setColor( 0, 0, 1, 1 )
textbox:setFont( font )
layer:insertProp( textbox )
MOAIGfxDevice.setClearColor( 200/255, 200/255, 255/255, 1 )
MOAISim.pushRenderPass ( layer )
In my game, I setup a global viewport to be used for all my layers. The code for setting up the viewport creates a viewport with the same size as the screen and a scale with a constant height of 200 'world units' and a width proportional to that and the original aspect ratio of the screen. Kind of like this:
- Code: Select all
Viewport = MOAIViewport.new()
Viewport:setSize( Config.screen_width, Config.screen_height )
local w = math.floor( ( Config.screen_width / Config.screen_height ) * 200 )
Viewport:setScale( w, 200 )
Setting up the viewport like this makes handling different screen aspect ratios and resolutions a breeze and works great for the rest of my graphics. I think this is the source of the fuzzy text though. It seems like MOAIFont isn't scaling correctly to the 'world units' I am using.
Edit: I am using the Snapshot Developer Build from a few days ago, I believe it is v1.2 build 36