Best Practices For Consistently Displaying Text Objects (Simulator Vs. Hardware)?

Hi All,

Text objects ( display.newText() ) appear positionally different for me whether I’m viewing them on my simulator on my PC, on my simulator on my Mac or viewing them on iOS based hardware.

What’s the best approach for getting locational consistency between these platforms? I guess I can understand there might be some difference between my PC and my Mac since the display.newText references fonts that are housed on those machines (even though it’s the same font).

I guess I’m a bit surprised about the discrepancy between the simulator on my Mac and my iOS hardware builds.

To be clear, the fonts are correct, the discrepancy is their location. The text object is centered correctly on my PC. If I open that project on my Mac, the font displays further down by about the size of the font (substantial difference). When I then build from that Mac and put the build on my iPhone the font is much more as it appeared on my PC (which I primarily develop on so that’s the desired location) but it is shifted slightly up (enough to not look polished).

Any tips on how I can get a “what you see is what you get” result with text objects?

Is there some other approach I should be considering for displaying scores, etc other than display.newText?

It’s not the end of the world if I’m stuck with some discrepancy between my PC and Mac but I would hope that my Mac build would appear the same on hardware.

Thanks in advance for any help you can offer,

Erik

Hi Erik,

This is, unfortunately, an “accepted” issue with fonts that are rendered to bitmaps by the system. The positioning will be close, but not exact, on different devices. It could even be different between devices on the same OS, i.e. iPhone vs. iPad2 vs. iPad4. I’ve noticed a slight variation between my text on iPad2 and the Retina iPad.

We might be able to improve the consistency slightly in the future, but at this time, the only way that you can achieve perfect alignment across every device is to make your text into graphics manually, which is a great solution for a few items that remain static, but obviously not for text that will change dynamically (scores, etc.).

Brent

Hi Brent,

I appreciate the information. I was certainly hoping there might be a better solution I was missing but I’m relieved to at least know the state of things so I can make the best choice for approaching polishing this.

As far as a main score goes, I’m actually thinking that a pre-rendered solution might not be that difficult to implement? Make 10 tiles (one each for 0-9) and then a function to display them based on the value I’m tracking? What do you think?

I’m trying to remember back to some contrived programming class problems as far as how to approach this and am thinking using the modulo command might help me “dissect” an integer into individual “hundreds”, “tens”, “ones”, etc. What do you think? Couldn’t I do Score%10 to get the “one” value of the score? Then Score%100-the “one” digit to get the tens and so on up?

Thanks :slight_smile:

Hi Erik,

This is, unfortunately, an “accepted” issue with fonts that are rendered to bitmaps by the system. The positioning will be close, but not exact, on different devices. It could even be different between devices on the same OS, i.e. iPhone vs. iPad2 vs. iPad4. I’ve noticed a slight variation between my text on iPad2 and the Retina iPad.

We might be able to improve the consistency slightly in the future, but at this time, the only way that you can achieve perfect alignment across every device is to make your text into graphics manually, which is a great solution for a few items that remain static, but obviously not for text that will change dynamically (scores, etc.).

Brent

Hi Brent,

I appreciate the information. I was certainly hoping there might be a better solution I was missing but I’m relieved to at least know the state of things so I can make the best choice for approaching polishing this.

As far as a main score goes, I’m actually thinking that a pre-rendered solution might not be that difficult to implement? Make 10 tiles (one each for 0-9) and then a function to display them based on the value I’m tracking? What do you think?

I’m trying to remember back to some contrived programming class problems as far as how to approach this and am thinking using the modulo command might help me “dissect” an integer into individual “hundreds”, “tens”, “ones”, etc. What do you think? Couldn’t I do Score%10 to get the “one” value of the score? Then Score%100-the “one” digit to get the tens and so on up?

Thanks :slight_smile: