CHARACTER WIDTH

Hello Happy Coders,

It’s been quiet a while now, however, I am happy for been on course.

All the same, my presence this time is quiet challenging, but I strongly believe some great and excellent developers out there may have a solution.

Now, what I am trying to do is to find a much reliable way to calculate a character’s width, regardless of the font. For instant, the width of the character “A” or “I”.

Though I know I can use newText method to grab it, which I am doing currently, but I am not comfortable this way. I want to be able to determine the width of the character without using the display text api.

Thanks in advance for the wiliness to help.

Corona SDK doesn’t provide any access to the font metrics. In fact all we do is pass the information to the OS’s font engine and tell it to generate an image with that text. The only way to get the width of an individual letter is to make a display.newText() object with just that letter, determine the width (which will include character spacing).

Rob

Hi.

I haven’t tried it myself, but you might want to look at this: Corona Textrender

First of all thank you very much for the quick response. That is great and a kind treatment on the side of Corona. I am very greatful to that.
Now @Rob, please thanks for the suggestion. And if you could get me in my post, that is what I said I am currently doing. So I am hoping that some day to come someone will come out with a better way to handle font metrics as you mentioned.
Also, @Starcrunch, yep! I have seen that module sometime ago, and I remember though that he used font metrics, but, he was implementing Rob’s suggestion in grabing the character width in his main textrender.lua file. If I am wrong, then somebody can direct me. Aside which, I also think it targets basic fonts.
Thanks once again, and still hoping to find the right way some day, coz as I said, though able to acheive the width through Rob’s suggestion, I don’t think that is the right thing to do. Thanks!

Corona SDK doesn’t provide any access to the font metrics. In fact all we do is pass the information to the OS’s font engine and tell it to generate an image with that text. The only way to get the width of an individual letter is to make a display.newText() object with just that letter, determine the width (which will include character spacing).

Rob

Hi.

I haven’t tried it myself, but you might want to look at this: Corona Textrender

First of all thank you very much for the quick response. That is great and a kind treatment on the side of Corona. I am very greatful to that.
Now @Rob, please thanks for the suggestion. And if you could get me in my post, that is what I said I am currently doing. So I am hoping that some day to come someone will come out with a better way to handle font metrics as you mentioned.
Also, @Starcrunch, yep! I have seen that module sometime ago, and I remember though that he used font metrics, but, he was implementing Rob’s suggestion in grabing the character width in his main textrender.lua file. If I am wrong, then somebody can direct me. Aside which, I also think it targets basic fonts.
Thanks once again, and still hoping to find the right way some day, coz as I said, though able to acheive the width through Rob’s suggestion, I don’t think that is the right thing to do. Thanks!