cancel
Showing results for 
Search instead for 
Did you mean: 

Change Font

Zui
Senior

Is there any way to change font of an application? I have a button that change the application style( buttons image ecc) but i need (graphic guy want) also to change the font, size and colout of the text. Is it that possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @Zui​,

Yes. If you go the texts tab in TouchGFX designer you'll see that you associate specific fonts with "typographies". You reference these typographies when you create static texts or wildcard texts. So when you use these text ids in your text areas in code (generated for you based on text definitions) the font which was used to generate the glyphs is implicit.

Take look at the Texts tab in the designer and you should see what i mean.

EDIT: Check out this tutorial step on adding text: https://touchgfx.zendesk.com/hc/en-us/articles/205587571-Step-3-Adding-Text.

The color is changed programatically. TextArea::setColor(colortype). So, you see, fonts are just referenced behind the scenes to tell the fontconverter where to find the glyphs. You will only ever interface with the "names" that you give each text string.

e.g.

myTextArea.setTypedText(TypedText(T_MY_STRING_NAME));

/Martin

View solution in original post

6 REPLIES 6
Martin KJELDSEN
Chief III

Hi @Zui​,

Yes. If you go the texts tab in TouchGFX designer you'll see that you associate specific fonts with "typographies". You reference these typographies when you create static texts or wildcard texts. So when you use these text ids in your text areas in code (generated for you based on text definitions) the font which was used to generate the glyphs is implicit.

Take look at the Texts tab in the designer and you should see what i mean.

EDIT: Check out this tutorial step on adding text: https://touchgfx.zendesk.com/hc/en-us/articles/205587571-Step-3-Adding-Text.

The color is changed programatically. TextArea::setColor(colortype). So, you see, fonts are just referenced behind the scenes to tell the fontconverter where to find the glyphs. You will only ever interface with the "names" that you give each text string.

e.g.

myTextArea.setTypedText(TypedText(T_MY_STRING_NAME));

/Martin

Martin KJELDSEN
Chief III

maybe i wasn't clear enough, i know how to change text font in touchGfx designer, but i need to change fonts with a button, programmatically

In that case, i suppose you could do something simple like setting a flag somewhere when pressing the button. If that flag is set, then you will use a certain pattern of text ids in your text areas. e.g.

If "Arial" button is presssed, you'll use "T_ARIAL_MY_TEXT_ID"

If "Consolas" button is pressed you'll use "T_CONSOLAS_MY_TEXT_ID".

The font type is tied to the ID behind the scenes, so you cannot change "font" in the same way you change languages.

/Martin

ok, as i thought, i was hoping for a super clever way only an expert knows, but i will try that way (if my almost full memory will let me)

Thanks

There is no "clever" way to do this since it's a common thing to mix and match font types in an application. Tying the font type to the ID of the text string exposing only a single ID to the user is the most user friendly thing.

You may be able to abuse the "language" feature, though =) Simply create a new language and have this language adopt the same values as your original language. Then, for each entry, select a new typography that points to the new font you want to use.

/Martin