newText returning wrong values on multiline texts

Both are not work for me.

I have 3 devices for testing.

For a ), each devices have different ratio of space, which I cannot simply use ratio to trim the space

For b ), it seems not applicable since I have a relatively large paragraph to display. It will need a heavy calculation to make the app hang a while when I create the text.

a ) I believe that should work depending on the content scale that you are using (it worked for me).

b ) I also thought that but then I implemented a custom display text that do that and it works very well with a huge amount of text. In addition, Corona recommends that when you have a huge text to split it in several newText objects because newText objects are rendered as images and so you are capped by the texture limit. (https://coronalabs.com/blog/2014/06/17/tutorial-working-with-large-blocks-of-text/)

a ) I’m not sure if the display content setting is ok

width = 1080,

height = 1080*heightRatio,   – where heightRatio = display.pixelHeight/display.pixelWidth

In my test, not all the device can fit for one scale even I use custom font. I tried to tune a value to use in all device, but the range is too large, which makes me cannot just use scaling.

There are two devices, Redmi and Samsung S3, have the same screen size, but the corresponding suitable ratio should be 0.73 and 0.63 respectively.

b ) I have already split the paragraph by /r/n. But if the text is split by line, we need to create and destroy the text objects many time for every row. So I thought it is not applicable.

However, the method b is seems the ONLY method that I can try. I’ll see if it is work for me.

Thanks for your advice.

If you want, take a look on my code. In my case a split word by word because I wanted to control the word spacing and line spacing.

Just do a 

require "custom-display"

and call

local myText = display.newText2(optionsTable)

where optionsTable is the same that you provide to Corona newText.

You can get my code at: https://www.dropbox.com/s/hswbx2yxgc538nu/custom-display.lua?dl=0

Thanks for your great help ;) 
Your source code helps me to have a better direction to work on this. :slight_smile: