EASILY Make Your Text Sharp on Retina Displays

Jon, I tried your suggestion (my build is 591)…

require "widget"  
display.newText(....  

…however (at least in the simulator) text changes size and position when viewed in iPhone4 or iPad mode (only renders well in iPhone mode).

Is it something that happens only in the simulator (i don’t have a retina display to test)?

Alex [import]uid: 4883 topic_id: 4573 reply_id: 59779[/import]

There seems to be problems whichever route you take, and since the widget library is currently in beta, things could change with it regarding displaying of retina text.

So right now, for everyone, I recommend using the logic below and just manually generating retina-compatible text on your own, until all bugs, etc. are squared away with the widget library’s implementation:

  • Check display.contentScaleX and display.contentScaleY to see if user is on a retina-display device.

  • If yes, then create your text double the size it should be.

  • Set the xScale and yScale of your text object to display.contentScaleX and display.contentScaleY

And that should give you really sharp text on a retina-display device :slight_smile: [import]uid: 52430 topic_id: 4573 reply_id: 59802[/import]

Let me see if I get it right.

  1. I check if contentScale if iPhone (960x640)
  2. if it is the case, text.size = (text.size)*2
  3. text.xScale = 960; text.yScale = 640

just it? [import]uid: 4883 topic_id: 4573 reply_id: 59819[/import]

@d3mac123: Here’s an example:

local csX, csY = display.contentScaleX, display.contentScaleYlocal textSize = 12if csX == 0.5 and csY == 0.5 then -- retina device textSize = 24endlocal myText = display.newText( "This is text", 0, 0, "Helvetica", textSize )myText:setTextColor( 0 )-- scale text down (or do nothing if it's 1.0)myText.xScale = csXmyText.yScale = csY[/code]Then just make manual adjustments to the text sizes to get it to the right size you want it to be. [import]uid: 52430 topic_id: 4573 reply_id: 59958[/import]

Is there something like this that will work for native.newTextBox? [import]uid: 14935 topic_id: 4573 reply_id: 116137[/import]