Skip to main content
UVett.1
Associate
April 24, 2021
Solved

Rotate text at any angle

  • April 24, 2021
  • 3 replies
  • 4577 views

Currently it seems that text can only be rotated by a multiple of 90 °. In a current project, however, I have a customer requirement that text must be rotated by any angle, since the display must be mounted rotated. What would be the best approach to implement this in the current circumstances?

This topic has been closed for replies.
Best answer by Romain DIELEMAN

Hi,

Here is a demo I made a while back using a custom widget called TextArc which can rotate a text at any angle but also around a circle or a curve. Have a look at the implementation in Screen1View.cpp/hpp and at the code of the widget in TextArc.cpp/hpp in the TouchGFX/widgets folder. The demo was made for a STM32L4R9-dk board but that doesn't change anything in the code :thumbs_up:

Since this is a custom widget you will not be able to see it in TouchGFX Designer, which is why I use what I call "dummies" (the red circle and box) to help me set the coordinates and angles.

/Romain

3 replies

Romain DIELEMAN
ST Employee
April 27, 2021

Hi,

Is the text already known and will not change ? With this scenario you take an image of the text and use it with a texture mapper widget.

Otherwise I have a custom widget that does this but I am not 100% sure I can share it, I need to check.

/Romain

UVett.1
UVett.1Author
Associate
May 4, 2021

Hi,

thank you very much for your reply! In my current implementation I am using images of the text and rotate it with a texture mapper widget, exactly as you suggested. But this is not a good solution, especially since I am dealing with instances of the TextAreaWithOneWildcard class (so dyanmic text), and because the angle must be adjustable. So my first thought was that it might be possible to access the pixel data of the TextArea instance directly, rotate it with the use of a suitable rotational matrix and write it directly to the framebuffer (or a dynamic bitmap, or whatever the suitable approach would be). I would be very grateful for any help.

Ulrich

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
May 5, 2021

Hi,

Here is a demo I made a while back using a custom widget called TextArc which can rotate a text at any angle but also around a circle or a curve. Have a look at the implementation in Screen1View.cpp/hpp and at the code of the widget in TextArc.cpp/hpp in the TouchGFX/widgets folder. The demo was made for a STM32L4R9-dk board but that doesn't change anything in the code :thumbs_up:

Since this is a custom widget you will not be able to see it in TouchGFX Designer, which is why I use what I call "dummies" (the red circle and box) to help me set the coordinates and angles.

/Romain

UVett.1
UVett.1Author
Associate
May 10, 2021

Dear Romain,

thank you very much for your help! Hope these features will find their way into the framework.

Ulrich

scottSD
Senior III
July 22, 2022

@Romain DIELEMAN​ 

This is a pretty cool widget. Great job!

I second the vote to get it into the designer/framework.