cancel
Showing results for 
Search instead for 
Did you mean: 

TextArea font : how to change dynamically a font

NMena.1
Associate

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

1 ACCEPTED SOLUTION

Accepted Solutions
AJT141
Associate III

Hello,

First here is the screen in touchGFX designer where you can add you own typography (Roboto are my own typographies there) :

0693W000004JDMJQA4.png 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 ;)

View solution in original post

3 REPLIES 3
AJT141
Associate III

Hello,

First here is the screen in touchGFX designer where you can add you own typography (Roboto are my own typographies there) :

0693W000004JDMJQA4.png 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 ;)

NMena.1
Associate

Hello,

Yes I finally managed.

Issue was that I didn't use it as you mentioned in your EDIT.

Thank you.

N.

Can you share the code you were able to run for successful operation of font changing.