cancel
Showing results for 
Search instead for 
Did you mean: 

Regular and Bold font in Single String in Touchgfx

MVagh.2
Associate

I want to have my single text string consisting of both regular and bold typographies of same size in touchgfx.

Take Below Example in consideration of TGX screen designing:

MVagh2_1-1689843078386.png

I want my Text to look as "Hello All, My name is Sanem. I am working on TouchGFX."

Here, Sanem and TouchGFX are my wildcard text, and above string is a text area with 2 wildcard entries. I tried to have 4 different text areas ( 2 Regular with regular fonts and 2 wildcard texts) but when I launch the UI on my LCD the Text overlaps on each other.

Is it possible in touchgfx to have a text area with wildcards in bold? Can someone guide me for the same?

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hello

I think easiest is to use 4 text areas like you probably allready tried and set the fonts normal or bold.  Then, after setting the wildcard texts, set the text postitions so that they dont overlap each other. Like this:

 

 

    int x,y;
    Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "Sanem");
    textArea2.resizeToCurrentText();
    textArea2.invalidate();

    Unicode::snprintf(textArea4Buffer, TEXTAREA4_SIZE, "TouchGFX");
    textArea4.resizeToCurrentText();
    textArea4.invalidate();

    y=textArea1.getY();
    x=textArea1.getX()+textArea1.getWidth();
    textArea2.moveTo(x,y);

    x+=textArea2.getWidth();
    textArea3.moveTo(x,y);

    x+=textArea3.getWidth();
    textArea4.moveTo(x,y);

 

This code sets position starting from position of first text area.

 Looks like this:

JTP1_0-1689850418029.png

 

View solution in original post

1 REPLY 1
JTP1
Lead

Hello

I think easiest is to use 4 text areas like you probably allready tried and set the fonts normal or bold.  Then, after setting the wildcard texts, set the text postitions so that they dont overlap each other. Like this:

 

 

    int x,y;
    Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "Sanem");
    textArea2.resizeToCurrentText();
    textArea2.invalidate();

    Unicode::snprintf(textArea4Buffer, TEXTAREA4_SIZE, "TouchGFX");
    textArea4.resizeToCurrentText();
    textArea4.invalidate();

    y=textArea1.getY();
    x=textArea1.getX()+textArea1.getWidth();
    textArea2.moveTo(x,y);

    x+=textArea2.getWidth();
    textArea3.moveTo(x,y);

    x+=textArea3.getWidth();
    textArea4.moveTo(x,y);

 

This code sets position starting from position of first text area.

 Looks like this:

JTP1_0-1689850418029.png