Does the new display.newText() with line-wrap support the Retina display? [import]uid: 295 topic_id: 16585 reply_id: 316585[/import]
No, but the retina hack can be hacked to work with it. Here are my additional hacks with the widget work around included.
[lua]local priorNewText = display.newText
local widget = require(“widget”)
display.newText = function( text, xPos, yPos, textWidth, textHeight, font, size )
local actualText = text or “”
local multiline = false
local actualFont = font or “Helvetica”
local actualSize = size or 16
if tonumber(textWidth) == nil then
– single line mode
actualFont = textWidth
actualSize = textHeight
else
multiline = true
end
local xScale, yScale = display.contentScaleX, display.contentScaleY
local sizeMultiply = 1
if xScale < 1.0 or yScale < 1.0 then
sizeMultiply = 2
end
local t
if multiline then
t = priorNewText( actualText, xPos, yPos, tonumber(textWidth) * sizeMultiply, tonumber(textHeight) * sizeMultiply, actualFont, actualSize * sizeMultiply )
else
t = priorNewText( actualText, xPos, yPos, actualFont, actualSize * sizeMultiply )
end
–t:setReferencePoint( display.TopLeftReferencePoint )
t.xScale, t.yScale = xScale, yScale
t.x, t.y = xPos, yPos or 0, 0
return t
end[/lua]
I’m not sure I"m checking the optional parameters correctly, but I’m using this now.
[import]uid: 19626 topic_id: 16585 reply_id: 61944[/import]
Thanks robmiracle. But why are you requiring the Widget library when you’re not using it anywhere? [import]uid: 295 topic_id: 16585 reply_id: 61947[/import]
Thanks robmiracle. But why are you requiring the Widget library when you’re not using it anywhere? [import]uid: 295 topic_id: 16585 reply_id: 61948[/import]
Actually, in one game I am using it. There is a bug where the widget library hoses the ability to specify fonts and font sizes in the latest daily build, and Ansca provided the work around to cache the original display.newText before the widget library changes it, and then set it back to the cached version. I can apply the same concept here.
Obviously if you’re not using the widget library, you can leave that line out. But if you are using it, you need to capture the original display.newText() before loading the widget library.
[import]uid: 19626 topic_id: 16585 reply_id: 61952[/import]
The display.newText() bug in the widget library will be fixed soon.
In the meantime, I recommend rob’s workaround (storing original display.newText() in a separate variable, then resetting it after including the widget library).
Thanks rob
[import]uid: 52430 topic_id: 16585 reply_id: 61971[/import]
I’m trying this out.
I have some text on the main menu.
If I use change to another screen and come back again, my text has doubled in size. If I do it again, it’s twice the new size.
What am I doing wrong pls? [import]uid: 10389 topic_id: 16585 reply_id: 68897[/import]
Regarding retina text:
display.newText() has been modified to handle “retina text” automatically, and therefore display.newRetinaText() has been deprecated since it is no longer needed.
The changes will be reflected in the next daily build (the one posted *after* 2012.770).
[import]uid: 52430 topic_id: 16585 reply_id: 94930[/import]