Text object changes size from simulator to Android. Why?!?!?!?!

Im experiencing a strange problem that I can’t for the life of me figure out. The code below is what I’m using in most of its entirety (save for the lorem ipsum text which is substantially longer). I am using it in a scrollview widget, and I’m splitting it up because scrollview seems incapable of handling long pieces of text without cutting it off.

When I load this up on the simulator, both xText and yText (which show height and contentHeight) both show 644 as the height. When I load it up on my Galaxy S1, it shows up as 820.

In the code below, the text is spaced out nicely, no huge gaps or anything that would stand out. On the phone, as you can imagine by the height difference, there are huge gaps between each set of text objects.

I’ve played around with the font, resolution, heights, sizes and things like that, but I have no idea what is causing this. As far as I can tell, scrollView is not causing this (I’m not sure why it would), as removing it doesn’t change anything.

Judging by the text displayed both in the simulator and on the phone, they are wrapping at the same places, nothing is out of the ordinary, just that the phone version has a huge gap of white at the bottom.

Anyone encounter anything similar or have any ideas as to what exactly is going on here?

[code]
local widget = require( “widget” )

local function scrollListener( event )
print( “ScrollView Event:”, event.type )
return true
end

local scrollView = widget.newScrollView{
top = 0, left = 0,
width = 320, height = 480,
friction = 0.1,
listener = scrollListener
}

local lotsOfText = “Lorem ipsum super long string of text…”
local text2 = lotsOfText
local text3 = text2
local text4 = text3
local text5 = text4

local textArray = {lotsOfText, text2, text3, text4, text5}
local textDArray = {}

local function hDisplay()
if xText ~= nil then
xText:removeSelf()
xText = nil
yText:removeSelf()
yText = nil
end
xText = display.newText(textDArray[1].height, 0, 0, native.systemFont, 36)
xText:setTextColor(255, 0, 0)
xText.x = 30
xText.y = 30
yText = display.newText(textDArray[1].contentHeight, 0, 0, native.systemFont, 36)
yText:setTextColor(0, 255, 0)
yText.x = 30
yText.y = 90
end

for i = 1, #textArray do
textDArray[i] = {}
textDArray[i] = display.newText(textArray[i], 0, 0, 320, 0, native.systemFont, 14)
textDArray[i]:setTextColor(0)
textDArray[i]:setReferencePoint(display.TopCenterReferencePoint)
textDArray[i].x = display.contentWidth/2
if i > 1 then
textDArray[i].y = textDArray[i-1].y + textDArray[i-1].height
else
–textDArray[i].y = titleText.y + titleText.contentHeight + 10 + textDArray[i].contentHeight/2
textDArray[i].y = 0
end
scrollView:insert(textDArray[i])
end

timer.performWithDelay(500, hDisplay, -1)
[/code] [import]uid: 67886 topic_id: 32141 reply_id: 332141[/import]

@nekromansur,

What do you have in your config.lua file?

Try this:

application = {  
 content = {  
 width = 320,  
 height = 480,   
 scale = "letterBox", -- left in for you to play around with  
 --scale = "zoomStretch", -- left in for you to play around with  
 --scale = "zoomEven", -- left in for you to play around with  
 --scale = "none", -- left in for you to play around with  
 },  
 },  
}  

Also, take a look here:
http://www.coronalabs.com/blog/2010/11/20/content-scaling-made-easy/
and here:
http://www.coronalabs.com/blog/2011/01/27/dynamic-image-resolution-made-easy/

Cheers,
Ed
Roaming Gamer, LLC.
SSK for Corona SDK (github) (videos)
[import]uid: 110228 topic_id: 32141 reply_id: 128011[/import]

Never thought to change the scaling, but I just tried all four scale options and there was no change. I’ve tried 640x960 and 480x800 for resolutions, but saw no difference so I’m just using 320x480 for now.

I’m using build 905, so its a tiny bit old, but I’m gonna hop on my dev account and get the latest daily build, see if that helps. I highly doubt that it will do anything but hey, you never know. [import]uid: 67886 topic_id: 32141 reply_id: 128015[/import]

(EDIT - Changed step #5)
@nekromansur,

Can you try the following?

  1. Download this app and run it on your android: http://downloads.roaminggamer.com/fire/sska.apk
  2. Start the app
  3. Run this demo =>
    – SSK Feature Testing (3 of 7)
    – Labels (16 of 27)
  4. Snap a screenshot on your device.
  5. Mail the screenshot to roaminggamer (at) gmail (dot) com (Please put ‘nekromansur’ in the title)

I’d like to see what it looks like on your device. Thanks!
-Ed [import]uid: 110228 topic_id: 32141 reply_id: 128018[/import]

A deeper analysis of the situation shows that a single line of text at font size 38 results in an object with a height of 43 in the simulator and 53 on the phone.

When a second line of text is added, those numbers jump to 88 and 106. There is roughly a 9.5 pixel difference per line in height when it goes from the simulator to the phone. This is boulderdash. Changing fonts to something custom changed the pixel difference, but there is still a substantial difference in the end.

Ed, I took a couple screenshots, I’ll be sending them in a second. [import]uid: 67886 topic_id: 32141 reply_id: 128022[/import]

@nekromansur,

Hi I got your screenshot.
I then made a screenshot using the simulator and the Nexus 1 which reports a screen width 799 x 480 and compared it to yours (by overlaying and using translucency).

This turned out to be a wasted effort. There was a minor difference but it didn’t tell me anything useful.

So, I did this instead.

  • I modified the app that you downloaded to print out the width/height of the middle line (quick label#2).
  • This line uses a custom font so it should be much more consistently scaled than whatever happens to be default on the device.
  • I told the device to use scaling mode “letterbox” again this should give the most consistent results.

I then uploaded the app and ran it on a number of devices and the simulator. These are my results:

Simulator iPhone 4 Resolution: 960x640 ==\> Text width: 300 height: 27  
Simulator Nexus One Resolution: 799x480 ==\> Text width: 301 height: 28  
Simulator Kindle Fire Gen1 Resolution: 1024x600 ==\> Text width: 300 height: 27  
Device Kindle Fire Gen1 Resolution: 1024x600 ==\> Text width: 298 height: 27  
Device Nexus 7 Resolution: 1280x800 ==\> Text width: 302 height: 27  

nekromansur and anyone else reading this thread:

If you want to repeat this test and add your results to this thread, please download one of these two binaries, run the labels example (first example that comes up when you start) and add your results to the thread using a similar amount of detail as shown above:

http://downloads.roaminggamer.com/fire/sska.apk - Android Binary

http://downloads.roaminggamer.com/fire/ssk.apk - Kindle Fire (gen 1) Binary

At this point, I’m not sure if these results are right or wrong. Part of me thinks, “Oh boy! This is an issue.”, but then I’m not sure I’ve given this proper thought. So, let me think about this and get back to you.

-Ed [import]uid: 110228 topic_id: 32141 reply_id: 128031[/import]

After spending hours trying to find a solution, I’m ultimately going to just use the text wrapper class. The problem with that is long texts, which is what I need them for, causes a substantial lag when loading it up.

For anyone who runs into this problem, you can try using that class, but if you have super huge walls of text, it can lag long enough that your phone will think it stopped responding. Not very good.

Nevertheless, I’m tired of trying to figure out why Corona isn’t working like it seems it should. [import]uid: 67886 topic_id: 32141 reply_id: 128041[/import]

@nekromansur,

What do you have in your config.lua file?

Try this:

application = {  
 content = {  
 width = 320,  
 height = 480,   
 scale = "letterBox", -- left in for you to play around with  
 --scale = "zoomStretch", -- left in for you to play around with  
 --scale = "zoomEven", -- left in for you to play around with  
 --scale = "none", -- left in for you to play around with  
 },  
 },  
}  

Also, take a look here:
http://www.coronalabs.com/blog/2010/11/20/content-scaling-made-easy/
and here:
http://www.coronalabs.com/blog/2011/01/27/dynamic-image-resolution-made-easy/

Cheers,
Ed
Roaming Gamer, LLC.
SSK for Corona SDK (github) (videos)
[import]uid: 110228 topic_id: 32141 reply_id: 128011[/import]

Never thought to change the scaling, but I just tried all four scale options and there was no change. I’ve tried 640x960 and 480x800 for resolutions, but saw no difference so I’m just using 320x480 for now.

I’m using build 905, so its a tiny bit old, but I’m gonna hop on my dev account and get the latest daily build, see if that helps. I highly doubt that it will do anything but hey, you never know. [import]uid: 67886 topic_id: 32141 reply_id: 128015[/import]

(EDIT - Changed step #5)
@nekromansur,

Can you try the following?

  1. Download this app and run it on your android: http://downloads.roaminggamer.com/fire/sska.apk
  2. Start the app
  3. Run this demo =>
    – SSK Feature Testing (3 of 7)
    – Labels (16 of 27)
  4. Snap a screenshot on your device.
  5. Mail the screenshot to roaminggamer (at) gmail (dot) com (Please put ‘nekromansur’ in the title)

I’d like to see what it looks like on your device. Thanks!
-Ed [import]uid: 110228 topic_id: 32141 reply_id: 128018[/import]

A deeper analysis of the situation shows that a single line of text at font size 38 results in an object with a height of 43 in the simulator and 53 on the phone.

When a second line of text is added, those numbers jump to 88 and 106. There is roughly a 9.5 pixel difference per line in height when it goes from the simulator to the phone. This is boulderdash. Changing fonts to something custom changed the pixel difference, but there is still a substantial difference in the end.

Ed, I took a couple screenshots, I’ll be sending them in a second. [import]uid: 67886 topic_id: 32141 reply_id: 128022[/import]

@nekromansur,

Hi I got your screenshot.
I then made a screenshot using the simulator and the Nexus 1 which reports a screen width 799 x 480 and compared it to yours (by overlaying and using translucency).

This turned out to be a wasted effort. There was a minor difference but it didn’t tell me anything useful.

So, I did this instead.

  • I modified the app that you downloaded to print out the width/height of the middle line (quick label#2).
  • This line uses a custom font so it should be much more consistently scaled than whatever happens to be default on the device.
  • I told the device to use scaling mode “letterbox” again this should give the most consistent results.

I then uploaded the app and ran it on a number of devices and the simulator. These are my results:

Simulator iPhone 4 Resolution: 960x640 ==\> Text width: 300 height: 27  
Simulator Nexus One Resolution: 799x480 ==\> Text width: 301 height: 28  
Simulator Kindle Fire Gen1 Resolution: 1024x600 ==\> Text width: 300 height: 27  
Device Kindle Fire Gen1 Resolution: 1024x600 ==\> Text width: 298 height: 27  
Device Nexus 7 Resolution: 1280x800 ==\> Text width: 302 height: 27  

nekromansur and anyone else reading this thread:

If you want to repeat this test and add your results to this thread, please download one of these two binaries, run the labels example (first example that comes up when you start) and add your results to the thread using a similar amount of detail as shown above:

http://downloads.roaminggamer.com/fire/sska.apk - Android Binary

http://downloads.roaminggamer.com/fire/ssk.apk - Kindle Fire (gen 1) Binary

At this point, I’m not sure if these results are right or wrong. Part of me thinks, “Oh boy! This is an issue.”, but then I’m not sure I’ve given this proper thought. So, let me think about this and get back to you.

-Ed [import]uid: 110228 topic_id: 32141 reply_id: 128031[/import]

After spending hours trying to find a solution, I’m ultimately going to just use the text wrapper class. The problem with that is long texts, which is what I need them for, causes a substantial lag when loading it up.

For anyone who runs into this problem, you can try using that class, but if you have super huge walls of text, it can lag long enough that your phone will think it stopped responding. Not very good.

Nevertheless, I’m tired of trying to figure out why Corona isn’t working like it seems it should. [import]uid: 67886 topic_id: 32141 reply_id: 128041[/import]