2020-10-09 12:36 AM
Hello,
On my project I want to change font of a TextArea according to some value.
First of all I created a topography to apply in TouchGFX.
I guess this is the good way to do.
Secondly I wondering how I can apply it on my TextArea ? How find the typography name and how to apply it ? I tried something like that :
Cont_LM_Simple_2_txt_lift_current_kg.setTypedText(touchgfx::TypedText());
But I didn't not managed to find how to set up my new typography.
[EDIT] Code insert
Solved! Go to Solution.
2020-10-09 01:48 AM
Hello,
First here is the screen in touchGFX designer where you can add you own typography (Roboto are my own typographies there) :
Then if you want to use Roboto Meidum 20 typo (in my case) whereas the original typo is Verdana 10. You should do this to change the font :
Cont_LM_Simple_2_txt_lift_current_kg.setTypedText(touchgfx::TypedText(T_SINGLEUSEID4));
Cont_LM_Simple_2_txt_lift_current_kg.invalidate();
Do not forget to invalidate the text area.
Here I wrote "T_SINGLEUSEID4" because in my case it designates roboto20 font. For you, it's not gonna be the same.
All these enums are declared in "TextKeysAndLanguages.hpp" file where you can include with this line
#include <texts/TextKeysAndLanguages.hpp>
Hope it can help.
Regards,
AJT141
PS : do not forget to use the </> code snippet button to insert code.
[EDIT!]
I forgot to say that if you didn't use once your personal typography in touchGFX deisgner, you won't be able to use the correct TEXTS enum in your code because touchGFX won't create it ;)
2020-10-09 01:48 AM
Hello,
First here is the screen in touchGFX designer where you can add you own typography (Roboto are my own typographies there) :
Then if you want to use Roboto Meidum 20 typo (in my case) whereas the original typo is Verdana 10. You should do this to change the font :
Cont_LM_Simple_2_txt_lift_current_kg.setTypedText(touchgfx::TypedText(T_SINGLEUSEID4));
Cont_LM_Simple_2_txt_lift_current_kg.invalidate();
Do not forget to invalidate the text area.
Here I wrote "T_SINGLEUSEID4" because in my case it designates roboto20 font. For you, it's not gonna be the same.
All these enums are declared in "TextKeysAndLanguages.hpp" file where you can include with this line
#include <texts/TextKeysAndLanguages.hpp>
Hope it can help.
Regards,
AJT141
PS : do not forget to use the </> code snippet button to insert code.
[EDIT!]
I forgot to say that if you didn't use once your personal typography in touchGFX deisgner, you won't be able to use the correct TEXTS enum in your code because touchGFX won't create it ;)
2020-10-09 07:39 AM
Hello,
Yes I finally managed.
Issue was that I didn't use it as you mentioned in your EDIT.
Thank you.
N.
2022-05-26 01:18 AM
Can you share the code you were able to run for successful operation of font changing.