Hmmm, have come across a problem with true type font rendering in Gideros with regards to baselines (the line used to site characters upon, with descenders going below etc). The problem is Gideros doesn't give us a reference to this (this appears to be known about, I've found other threads on the forum about it) so, when using French for example and characters such as É (which ascend higher than a normal E) or when using strings with and without descenders, there's a problem in terms of alignment because the created sprites are different heights and not positioned according to the baseline.
@atilim - is there any way you could make the baseline available as a property of TextField, just in the normal 0 to 1 range or a Y reference? We could then use our own routines to position accordingly. As it stands I can't seem to get positioning accurate unless I know exactly what characters are going to be in a string (which you don't always know and for multi-language conversions makes the whole job really messy).
I've tried the baseline fix in the latest GiderosCodingEasy as well and this doesn't seem to make a difference either. And I've tried using getBounds() directly but this always seems to give me 0 for y. Has anybody else found a work around, specifically when dealing with true type fonts?
Any ideas? It's kind of messing things up for me at the moment
Comments
My recommendation is setting the y coordinates of all text fields same and use a constant height based on the font size. Here you shouldn't use getHeight or getBounds because these functions can give different results with different texts.
Likes: OZApps
I'm really stuck on this at the moment, and it's something that has become really noticeable now I am using translations in languages with with diacritics.
@Atilim, if you can provide us a but more handle on this or position the text at the top than at the baseline, it could be easier or not? (there has to be a reason why you are using baseline)
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
I think all @atilim needs to do is let us know where on y the baseline is for a TextField object. We can then position everything properly regardless.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Just an idea
The only way that might work is if you measure the height of each character individually and then do some calculations when creating a TextField to get a semi-accurate baseline. It wouldn't be perfect and I think its implementation would be very messy.
As far as I'm concerned we shouldn't have to do this anyway - I can't believe it's difficult for @atilim to make a property available for TextField objects that indicates where the baseline is. That way he doesn't have to change the rendering, so it doesn't break anybody's code, it's simply an addition that we can use if we want accurate control.
Likes: OZApps
1. Your solution is font and font size dependant. If you're showing text in multiple sizes, you'd need to make this more complex with different calculations for each font and font size.
2. It can get very complex if you're dealing with many different diacritics on capitals and lowercase letters (such as cédille) as each one can affect the overall height of the text field so the function would need to be much more complex.
3. Processing this for large blocks of text, or frequently updated text, may give a performance problem.
Something like this would be my last choice if the needed change to a TextField object is not forthcoming as it would be the only option of at least getting it more accurate than doing nothing at all!
I've prepared a simple example (attached the code). Here the base line of all texts are set to a constant value (40) and they all align correctly. If my text origin would be upper left instead of baseline, I couldn't align them.
I think GiderosCodingEasy, which is so useful for being able to setAnchorPoints on sprites is in some way interfering with this.
Likes: tuanleanh
Likes: moopf
Now which situation is more common?
Or how to allow both situations in GiderosCodingEasy?