Skip to main content
jimmii
Senior II
December 11, 2019
Solved

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

  • December 11, 2019
  • 5 replies
  • 3538 views

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

This topic has been closed for replies.
Best answer by Martin KJELDSEN

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

5 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
December 11, 2019

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
jimmiiAuthor
Senior II
December 11, 2019

Hi @Martin KJELDSEN​ 

Thanks for clarification.

/jimmii

Martin KJELDSEN
Principal III
December 11, 2019

No problem!

/Martin

SMark.3
Associate
May 7, 2021

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
jimmiiAuthor
Senior II
May 7, 2021

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.

SMark.3
Associate
May 7, 2021

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