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 !!!

@pierre.rivron
For a complex HTML like text style support, we have an internal library that will require more CPU and flash.

Which internal library?

Hello @shuhabazhar,

I am not sure what @pierre.rivron was referring to exactly.
I know about a DSL on top of an MicroUI/MWT 2.x we had drafted as well as a widget for some sort of a subset of a custom rich text format.
I am checking internally.

But anyway, the important thing is: what are you trying to do exactly?

Best regards,
Rémy