2022-09-29 11:37 PM
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?
Solved! Go to Solution.
2022-10-11 05:48 AM
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
2022-09-30 12:54 AM
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?
2022-10-03 02:50 AM
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
2022-10-09 09:43 PM
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?
2022-10-11 05:48 AM
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
2022-10-11 05:51 AM
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!
2022-10-11 07:49 AM
You're welcome! :)