cancel
Showing results for 
Search instead for 
Did you mean: 

left-aligned text rotated by 270 degrees not aligned by first character if translation is longer

unsigned_char_array
Senior III

 

I have a text field that's left aligned and rotated by 270 degrees so that the first character is at the bottom.
If I change the language where the text is longer the first character shifts down.
This is not what I expect.

I expect that a text that is rotated is the same as the unrotated text, but rotated around the side of the alignment (and perhaps shifted).
The problem is that the anchor point of the text is at the top left regardless of rotation, which is the right of the text when it's not rotated. So the text is effectively right aligned. For 0 and 90 degree rotation the behavior is correct.


A similar effect occurs when the text is right aligned and the text is rotated by 0 degrees and the translation is longer. In that case the text extends to the right instead of the left, so it is effectively left aligned. I understand that choice. But for manually setting text using a printf function there is a TouchGFX method called resizeToCurrentTextWithAlignment() which does extend longer text to the left if it is right aligned (I use this for printing real-time numbers, which you want right aligned for obvious reasons). I expect a similar method is used when rotating text so the extension behaves exactly the same as unrotated text so it would be consistent.


It would make more sense to change the rotation point to the bottom left in case of rotation by 270 degrees and left alignment, so the rotation point is always at the first character.

In case of Auto-size unchecked the text will increase length at the top, but won't extend beyond the anchor point and is masked. So this behavior is almost what I want.

I have two workarounds:

1) in constructor of screen view:

auto height = textAreaSide.getHeight();
textAreaSide.setXY(0, 426-height); // 426 is y+height of original text

This works, but is tedious as it requires me to calculate and type this for every rotated text in every screen. I don't like boiler plate.

2)

Auto-size unchecked and top lengthened by hand so height is larger than the width of the unrotated text.
This is slightly less tedious.

 

I don't know what resize method is called internally by TouchGFX in case of language change. It would make more sense to me to change this to an equivalent of resizeToCurrentTextWithAlignment() or at least give the user the option to change it ( an extra checkbox below Auto-size with something like "allow resize beyond anchor point", or "set anchor point to alignment side"). This won't take much CPU time.

I don't know whether this is a bug or poorly documented feature, but it would certainly help people to give the tools to get the desired behavior without having to use a lot of boiler plate.

 

 

 

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
0 REPLIES 0