Simulator Rendering Problems

Hi,

We’re finding that the simulator doesn’t render text accurately in terms of text size and position.

On the simulator the text is:

  1. Frequently positioned lower than on the phone
  2. Sometimes bigger than on the phone

Can the simulator be fixed so that the rendering is pixel accurate to the phone?

One of the main things we’d like to do is take video captures of our Corona apps to post online as videos. We can’t currently do this since the emulator isn’t accurate.

Thanks

[import]uid: 2773 topic_id: 630 reply_id: 300630[/import]

(Logged as bug #126) [import]uid: 3007 topic_id: 630 reply_id: 2002[/import]

Seems like this bug does not fixed yet (Corona SDK 243).
TO evank or anybody at Ansca: Is this bug (text rendering problem) going to be fixed? Please comment.
Thanks! [import]uid: 7301 topic_id: 630 reply_id: 17912[/import]

Instead of this:

[lua]txt = display.newText(“Hello World”, 100, 100, native.systemFontBold, 13)[/lua]

try this:
[lua]txt = display.newText(“Hello World”, 0, 0, native.systemFontBold, 13)
txt.x = 100
txt.y = 100[/lua]
[import]uid: 11393 topic_id: 630 reply_id: 17922[/import]

I’m guessing there is something wrong internally with newText. Once the text is created it’s just a graphic object so it should follow the same rules of x,y positioning as any other graphic object.

Rather than setting the x,y after every call I just use my own function similar to this:

[lua]function drawText( str, x, y, font, size )
display.newText( str, x, y, font, size )
end[/lua]

I wouldn’t use display.newText even if they fix it as my custom function does set colour by name instead of RGB and has defaults if I don’t pass font and size parameters. So I guess there was a silverlining to that bug :slight_smile: [import]uid: 11393 topic_id: 630 reply_id: 17931[/import]

I have this bug in spades in my project; I’ve been mostly just sucking it up for now, but if that fix works I’ll be very happy. I’ll have to adjust ui.lua too for the text on my buttons.

ADDITION: That fix is closer but it’s still not perfect, which means I’m better off not bothering. Thanks anyway though. [import]uid: 12108 topic_id: 630 reply_id: 17926[/import]

Just curious; how is it not working for you? Corona sim and device are lining up nicely for me.

The only difference I perceive is that the native fonts for OSX and iOS are not the same which is causing it to look slightly different. [import]uid: 11393 topic_id: 630 reply_id: 17948[/import]

I guess I’ve found the issue. I use code Multiline text with width in pixel, but slightly modify

function autoWrappedText(text, font, size, color, width, linesTotal)  
 if text == '' then return false end  
 font = font or native.systemFont  
 size = tonumber(size) or 12  
 color = color or {255, 255, 255}  
 width = width or display.stageWidth  
   
 local result = display.newGroup()  
 local currentLine = ''  
 local currentLineLength = 0  
 local lineCount = 0  
 local left = 0  
 for line in string.gmatch(text, "[^\n]+") do  
 for word, spacer in string.gmatch(line, "([^%s%-]+)([%s%-]\*)") do  
 local tempLine = currentLine..word..spacer  
 local tempDisplayLine = display.newText(tempLine, 0, 0, font, size)  
 if tempDisplayLine.width \<= width then  
 currentLine = tempLine  
 currentLineLength = tempDisplayLine.width  
 else  
 local newDisplayLine = display.newText(currentLine, 0, (size \* 1.3) \* (lineCount - 1), font, size)  
 newDisplayLine:setTextColor(color[1], color[2], color[3])  
 result:insert(newDisplayLine)  
 lineCount = lineCount + 1  
 if string.len(word) \<= width then  
 currentLine = word..spacer  
 currentLineLength = string.len(word)  
 else  
 local newDisplayLine = display.newText(word, 0, (size \* 1.3) \* (lineCount - 1), font, size)  
 newDisplayLine:setTextColor(color[1], color[2], color[3])  
 result:insert(newDisplayLine)  
 lineCount = lineCount + 1  
 currentLine = ''  
 currentLineLength = 0  
 end   
 end  
 tempDisplayLine:removeSelf()  
 tempDisplayLine = nil  
 end  
 local newDisplayLine = display.newText(currentLine, 0, (size \* 1.3) \* (lineCount - 1), font, size)  
 newDisplayLine:setTextColor(color[1], color[2], color[3])  
 result:insert(newDisplayLine)  
 lineCount = lineCount + 1  
 currentLine = ''  
 currentLineLength = 0  
 end  
 --  
 -- new code  
 --  
 currentLine = '' -- works with currentLine = ' '  
 for i = lineCount+1, linesTotal do  
 local newDisplayLine = display.newText(currentLine, 0, (size \* 1.3) \* (i-1), font, size)  
 newDisplayLine:setTextColor(color[1], color[2], color[3], color[4])  
 result:insert(newDisplayLine)   
 end  
 result:setReferencePoint(display.CenterReferencePoint)  
 return result  
end  

linesTotal - parameter which determine how many text lines will be created, not depending on the input text, to have possibility to change the text later.

so using this code like this:

 local test = "Lorem ipsum Lorem ipsum"  
 local testAutoWrapText = autoWrappedText( test, "Arial", 42, {0,0,0}, 140, 5 )  
 testAutoWrapText.x = 120  
 testAutoWrapText.y = 200  

It shows text in different position in Corona Simulator and in iPhone Simulator and on Device. It looks like display.newText with empty string works different in Corona Simulator and on Device. [import]uid: 7301 topic_id: 630 reply_id: 18109[/import]

Just curious; how is it not working for you? Corona sim and device are lining up nicely for me.

It depends on the font; the default font works fine, but I’m using ArialRoundedMTBold and the placement is off. When I put in coordinates in the newText call directly, the text in the simulator is about 6 pixels too low but is placed correctly on device. [import]uid: 12108 topic_id: 630 reply_id: 18124[/import]

I’m not sure if it’s related yet, but I’m having trouble with font sizes using the display.newText ().

The default iOS font works fine, but my custom ones seem to stay a set font size. [import]uid: 20703 topic_id: 630 reply_id: 21094[/import]

This is a bug that Ansca logged back in june of 2010, and its still not fixed, thats pretty sad, i am now suffering from it in my project. These kind of things make me want to go else where for my next game project [import]uid: 19620 topic_id: 630 reply_id: 37322[/import]