Problem with text size and fontSize

In the simulator fontSize and size dont give the same text size :

txt=display.newText{text="",x=150,y=50,fontSize=22}
txt.text=“Hello world!”
–txt.size=22 --if you uncomment it, text will be bigger! WHY!?

And on my android device the behavior is again different. It seems .size doesn’t give a correct text size.

Maybe the formula would be : size = fontSize / 1.2

I don’t see a .size documented for display.newText().  I don’t know that its intended for you to change the font and size after the fact.

But if setting the size does change the size, it should be right.  I would recommend filing a bug report on this so Engineering can look at it to see what’s going on.

Thanks

Rob

Changing the size can be useful like any other properties you can change after the creation of an object… In this case it can be useful so that the same text object can print texts with different sizes, without creating a new instance just because the size of a text change. This property was documented in the past if I remember but since it’s not possible to modify fontSize after the creation, I found that the size property is equal to fontSize/1.2. Well, I will try to report this bug.

Thanks :wink:

After some tests what I wrote previously is ok in the simulator but on devices .size is not stable, so it’s better not to use it and wait for an update where .fontSize can be changed after the text creation.

I hope we can help each other…

From another topic:

When playing with the text.size property after creation, the simulator shows the iPad Retina with really larger text while other devices look mostly fine but still inconsistent. Adjusting the size property in accordance with display.contentScaleX / 0.625 appears to fix that. However, I am not sure if it is fixed on a real device… can anyone confirm on the iPad?

textObject.size = 30 * display.contentScaleX 

I don’t see a .size documented for display.newText().  I don’t know that its intended for you to change the font and size after the fact.

But if setting the size does change the size, it should be right.  I would recommend filing a bug report on this so Engineering can look at it to see what’s going on.

Thanks

Rob

Changing the size can be useful like any other properties you can change after the creation of an object… In this case it can be useful so that the same text object can print texts with different sizes, without creating a new instance just because the size of a text change. This property was documented in the past if I remember but since it’s not possible to modify fontSize after the creation, I found that the size property is equal to fontSize/1.2. Well, I will try to report this bug.

Thanks :wink:

After some tests what I wrote previously is ok in the simulator but on devices .size is not stable, so it’s better not to use it and wait for an update where .fontSize can be changed after the text creation.

I hope we can help each other…

From another topic:

When playing with the text.size property after creation, the simulator shows the iPad Retina with really larger text while other devices look mostly fine but still inconsistent. Adjusting the size property in accordance with display.contentScaleX / 0.625 appears to fix that. However, I am not sure if it is fixed on a real device… can anyone confirm on the iPad?

textObject.size = 30 * display.contentScaleX 

I just ran into this problem yesterday.  I updated to the latest daily build (Version 2014.2155 (2014.1.25)) so I could get the GameAnalytics stuff.  Prior to yesterday, I don’t know what version I was running, but I hadn’t updated for 4-6 months maybe.  But after updating, I noticed one of my scenes just blew up, and had stuff all over the place and wrong.  Took me a day to track down one of the issues is the text.size bug. 

I used this prior just fine.  I used it for the purpose of the user selecting one of 3 things to say to NPC, and the one they selected would do a transformation on the size to enlarge it as well as center it.  It worked perfect, and now not only is the .size broken, but transforming the x/y coordinates with an reference point set is broken too.  Now I have to recode a module I had working perfect for almost a year to fix these bugs that popped in.

anyone have any updates on this bug?  it’s obviously not fixed in the latest build, but you guys reported it almost 3 months ago.

Hi @tielore,
The engineers report to me that this issue is fixed in daily build #2156. This will, of course, be included in the next public build. For Starter users who don’t have access to daily builds, the workaround is to either:

  1. Never set the “size” property. Only set the text size within the “display.newText()” call.
  2. If you must set the “size” property post-declaration, divide the font size by the scale like this…
    [lua]
    text.size = 24 / display.contextScaleX
    [/lua]

Best regards,
Brent

I just ran into this problem yesterday.  I updated to the latest daily build (Version 2014.2155 (2014.1.25)) so I could get the GameAnalytics stuff.  Prior to yesterday, I don’t know what version I was running, but I hadn’t updated for 4-6 months maybe.  But after updating, I noticed one of my scenes just blew up, and had stuff all over the place and wrong.  Took me a day to track down one of the issues is the text.size bug. 

I used this prior just fine.  I used it for the purpose of the user selecting one of 3 things to say to NPC, and the one they selected would do a transformation on the size to enlarge it as well as center it.  It worked perfect, and now not only is the .size broken, but transforming the x/y coordinates with an reference point set is broken too.  Now I have to recode a module I had working perfect for almost a year to fix these bugs that popped in.

anyone have any updates on this bug?  it’s obviously not fixed in the latest build, but you guys reported it almost 3 months ago.

Hi @tielore,
The engineers report to me that this issue is fixed in daily build #2156. This will, of course, be included in the next public build. For Starter users who don’t have access to daily builds, the workaround is to either:

  1. Never set the “size” property. Only set the text size within the “display.newText()” call.
  2. If you must set the “size” property post-declaration, divide the font size by the scale like this…
    [lua]
    text.size = 24 / display.contextScaleX
    [/lua]

Best regards,
Brent