cancel
Showing results for 
Search instead for 
Did you mean: 

Resource ID vs. Typography or "Using the same ID with different Typography"

jimmii
Senior II

Hi there

Is there a way to have one ID with different Fonts?

I don't see the point in generating the same string multiple times with different fonts. That is event cumbersome with the translation offices who have to translate the same string multiple times.

We use a lot of the same strings in different places in the GUI.

For example I get a String ID from a TCP/PI packet and want to display it on the screen.

The sender of the packet does not care which font / typography is used, but I do, so with our old GUI library I could do something like "show_text(TEXT_ID, FONT_A_30px)"

How can I do that with TouchGFX? Is there a workaround?

Thanks,

jimmii

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

There's no way to define a string just once and then specify different typographies you want it to be generated for.

I see your point, but this is not the way it's designed currently.

You'll just have to write your own layer that can generate a text.xlsx file. We've seen this done by customers before.

With respect to receiving a text ID, you'll just have to make that ID reference a unique string and then also receive something to indicate font and size. There's no way around that - Either by specifying a Unique ID from the TypedTextDatabase OR by receiving an ID you come up with yourself in your intermediary format and then something to indicate font and size to ultimately use the ID from the TypedTextDatabase.

/Martin

View solution in original post

11 REPLIES 11
Martin KJELDSEN
Chief III

There's no way to define a string just once and then specify different typographies you want it to be generated for.

I see your point, but this is not the way it's designed currently.

You'll just have to write your own layer that can generate a text.xlsx file. We've seen this done by customers before.

With respect to receiving a text ID, you'll just have to make that ID reference a unique string and then also receive something to indicate font and size. There's no way around that - Either by specifying a Unique ID from the TypedTextDatabase OR by receiving an ID you come up with yourself in your intermediary format and then something to indicate font and size to ultimately use the ID from the TypedTextDatabase.

/Martin

jimmii
Senior II

Hi @Martin KJELDSEN​ 

Thanks for clarification.

/jimmii

Martin KJELDSEN
Chief III

No problem!

/Martin

SMark.3
Associate II

Hi @Roman Schläpfer​  did you find a work around for this? I'm trying to achieve the same thing, and have text ID separate from the font type/size. I'm wondering how you solved this problem?

@Martin KJELDSEN​ do you have any further information about how any other customers have solved this?

jimmii
Senior II

I generate a text ID for every string and every font size. (It's a waste of ressources, but anyway...)

Then I have following function:

//---------------------------------------------------------------------------------------------------------------------
///	@brief			Get TextId based on FONT
///	@param[in]	    baseId:		Base TextID
///	@param[in]	    FONT:		Used Font e.g Typography::F_30_PT
///	@return			TextID in corresponding Font
//---------------------------------------------------------------------------------------------------------------------
TEXTS GetText(TEXTS baseId, touchgfx::FontId FONT) {
	return TEXTS(baseId + FONT);
}

e.g

TextTitle.setTypedText(touchgfx::TypedText(GetText(T_5_DEF, Typography::F_18_PT)));

Hope this helps.

Hi, thanks for the quick reply, that's really helpful.

Hi, Can you describe which header files should be included to access Typography::

textArea2.setTypedText(TypedText(T_RESOURCEID1));
TA3.setTypedText(touchgfx::TypedText(GetText(textArea2, Typography::TYPOGRAPHY_00)));

responds to error:

C:/TouchGFXProjects/MyApplication_23/TouchGFX/gui/src/screen1_screen/Screen1View.cpp:54:58: error: cannot convert 'touchgfx::TextArea' to 'TEXTS'

  54 |       TA3.setTypedText(touchgfx::TypedText(GetText(textArea2, Typography::TYPOGRAPHY_00)));

   |                             ^~~~~~~~~

   |                             |

   |                             touchgfx::TextArea

Hi @A.Qasim​ 

TYPOGRAPHY_00 is defined as TextArea? That is not correct...

The Typography is coming from the File ApplicationFontProvider.hpp in struct Typography.

In my case:

struct Typography
{
    static const touchgfx::FontId F_22_PT = 0;
    static const touchgfx::FontId F_30_PT = 1;
    static const touchgfx::FontId F_18_PT = 2;
    static const touchgfx::FontId F_16_PT = 3;
    static const touchgfx::FontId F_10_PT = 4;
};

Hope this helps.