Thanks Rob for the clarification!
Not sure if only the multi line textfield uses openGL, because for single line text field doesn’t have the problem. So I end up writing a new multi line script based on your blog entry http://coronalabs.com/blog/2013/04/16/lua-string-magic/
I break the string and insert them in multiple single line texts, then put them in one display group.
The downside is I can’t update the text after created, but that is fine for me.
I’ll share the code here. Probably will add in code to adjust line spacing and alignment in future.
--------------------------------------------------------------- -- MULTI LINE TEXT --------------------------------------------------------------- function string:split( inSplitPattern, outResults ) if not outResults then outResults = { } end local theStart = 1 local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) while theSplitStart do table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) ) theStart = theSplitEnd + 1 theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) end table.insert( outResults, string.sub( self, theStart ) ) return outResults end local function multiText(textOptions) local textTable = string.split( textOptions.text, " " ) local tempTextGrp = display.newGroup() local tempT = "" local tempT2 = "" local lineGrp = display.newText(tempTextGrp, "", 0, 0, textOptions.font, textOptions.fontSize) local function addText(whatText) -------------------------------------- --insert to text field tempT2 = tempT tempT = tempT ..whatText.." " lineGrp.text = tempT if textOptions.width and lineGrp.width \> textOptions.width then --check width, if too wide, next line lineGrp.text = tempT2 tempT = whatText.." " lineGrp = display.newText(tempTextGrp, "", 0, 0, textOptions.font, textOptions.fontSize) end end for i = 1, #textTable do if textTable[i] == "" then addText(textTable[i]) else -------------------------------------- --take out \n local textTable2 = string.split( textTable[i], "\n" ) for j = 1, #textTable2 do addText(textTable2[j]) if j ~= #textTable2 then --add new line lineGrp = display.newText(tempTextGrp, "", 0, 0, textOptions.font, textOptions.fontSize) tempT = "" end end end end --arrange text --checkHighestHeight local tempHeight = 0 for j = 1, tempTextGrp.numChildren do if tempTextGrp[j].height \> tempHeight then tempHeight = tempTextGrp[j].height end end for j = 1, tempTextGrp.numChildren do tempTextGrp[j].y = tempHeight\*(j-1) local tempColor = textOptions.textColor if tempColor then tempTextGrp[j]:setFillColor(tempColor[1], tempColor[2], tempColor[3]) end end tempTextGrp.anchorX = 0.5 tempTextGrp.anchorY = 0.5 tempTextGrp.anchorChildren = true if textOptions.x then tempTextGrp.x = textOptions.x end if textOptions.y then tempTextGrp.y = textOptions.y end if textOptions.displayGrp then textOptions.displayGrp:insert(tempTextGrp) end return tempTextGrp end -------------------------------------------- --testing the text -------------------------------------------- local sayWhat = "TESTING\nThe quick brown fox jumps over the lazy dog" local testGroup = display.newGroup() local textOptions = { displayGrp=testGroup, text = sayWhat, x = display.contentCenterX, y = display.contentCenterY , width = 150, font = "Bromine", fontSize = 13, textColor = {0, 0, 0} } testGroup.myText = multiText(textOptions)