Differents styles in a label

Hi everybody,

Is it possible to have a label with some of the text in bold and the rest of the text in a different style.
Or is it possible to use html tags to pass a party of a bold text

Thank you for your reply.

Hi @sebasme,

What type of text do you want to format?

  • Is it multiline? If yes, do you need to support new line symbol \n?
  • Do you need to handle multiple style and hierarchy on them like in HTML?

From your answer different solutions exist:

  • For a simple one line text, you could use a List of multiple label with different class selector for each style.
  • For a multiline without the support of the new line symbol, you could use a Flow of multiple label with different class selector for each style.
  • For a complex HTML like text style support, we have an internal library that will require more CPU and flash.

Regards,

Hi Pierre,

It’s a multiline text without the support of the new line symbol. So i prefer used a Flow of multiple label.
Do you have somes examples of this?

Thank for your reply.

Hi @sebasme,

	Flow flow = new Flow();
	flow.add(new Label("This "));
	Label label = new Label("is ");
	label.addClassSelector("BOLD");
	flow.add(label);
	flow.add(new Label("an example"));

With the class selector BOLD mapping a style with a bold font.

If you need the full text to be positioned somewhere, you can wrap it in a Wrapper:

	Wrapper wrapper = new Wrapper();
	wrapper.setWidget(flow);
	wrapper.setAdjustedToChild(false);
	wrapper.addClassSelector("CENTER");

Regards,

Hi Pierre,

It works fine.

Thanks for your help !!!