cancel
Showing results for 
Search instead for 
Did you mean: 

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

Loppi
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

6 REPLIES 6
Loppi
Associate III

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 Employee

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

Osman SOYKURT
ST Software Developer | TouchGFX

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?

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

Osman SOYKURT
ST Software Developer | TouchGFX
Loppi
Associate III

Perfect, I will call setBaselineY() based on modification during runtime in either setupScreen() or in the custom function that alters the text.

Thank you for your help Oskt!

You're welcome! 🙂

Osman SOYKURT
ST Software Developer | TouchGFX