Skip to main content
Loppi
Associate III
September 30, 2022
Solved

Why is the virtual and actual location of some text boxes on display not the same?

  • September 30, 2022
  • 2 replies
  • 1662 views

I am currently developing a GUI on a STM32F429-DISCO with a custom display (also 320x240) and have run into an issue with the positioning of displayed text. The text is shown on the display several lines below the location it was set to. This offset changes direction with text rotation. I am currently using the roboto font from google fonts. Depending on the font this offset seems to change direction.

So why are fonts not shown correctly on the actual screen or why is there a clear offset of the shown content?

This topic has been closed for replies.
Best answer by Osman SOYKURT

Hi Loppi,

I think the idea would be to call this function when you update text only. the setupScreen() function will be launched only once by default, so it's not the place to call your setBaselineY() function if you need to update your TextAreas TypedText to one with a different font or font size during runtime. But if you don't need to update it with another TypedText which has a different font or size then it's fine to call it there yes.

/Osman

2 replies

Loppi
LoppiAuthor
Associate III
September 30, 2022

While searching for clues I found the respective part in the documentation:

"As for all TouchGFX widgets a TextArea is placed on the screen by specifying a position (X and Y) and a dimension (width and height). This is easily done via TouchGFX Designer in the widgets properties, However the rendering of text in TouchGFX Designer is not always 100% acurrate compared to how the text is rendered by TouchGFX."

So the solution is to set the correct location by calling one of these functions:

TextArea::setBaselineY(y)
TextArea::setXBaselineY(x, y)

At the moment I call setBaselineY(y) everytime I update the screen. Is there a better solution for this as long as I don't change the front?

Osman SOYKURT
ST Technical Moderator
October 3, 2022

Hello Loppi,

The setBaselineY(y) function is indeed the function you'll need to call. As described in the documentation, you'll need to call "setBaselineY" again if you change the TextAreas TypedText to one with a different font or font size. So not necessarily every time you update your screen.

And I don't think there's any other better solution.

/Osman

ST Software Developer | TouchGFX
Loppi
LoppiAuthor
Associate III
October 10, 2022

Hi Oskt,

And thank you for the answer!

I am currently calling the function in a view.cpp custom function. Where should I call setBaselineY() for texts that doe not get changed during runtime. Is the View::setupScreen() the right place for this?

Osman SOYKURT
Osman SOYKURTBest answer
ST Technical Moderator
October 11, 2022

Hi Loppi,

I think the idea would be to call this function when you update text only. the setupScreen() function will be launched only once by default, so it's not the place to call your setBaselineY() function if you need to update your TextAreas TypedText to one with a different font or font size during runtime. But if you don't need to update it with another TypedText which has a different font or size then it's fine to call it there yes.

/Osman

ST Software Developer | TouchGFX