Spacing / Concatenation issue with a RichText component

What I’m trying to do:
I’m trying to display a label where a number is bolded, like “383 Horses are arriving tomorrow”
What I’ve tried and what’s not working:
I have a rich text component, the contents are set like this: {s1} Horses are arriving tomorrow

My issue is that in s1 I have a label, which I set to bold. It works, but sometimes I see this:

383 Horses are arriving tomorrow

but on some lines in my RichText component, I see this:
383 <insert like 75 spaces here…> Horses are arriving tomorrow.

Now on some of the bolded labels, I can set the width to nothing, and the number concatenates with the text just fine. But on other lines, even if I set the width to nothing, when I click out it re-populates the width… no matter what I do.

Not sure why

If this is just for display purposes, you don’t need to put a label into the rich text component. Set it to Markdown, and use Markdown to make the number bold.

1 Like

Will test/try, thanks. I am using the label in the slot to display numbers that are variable, this is part of a .pdf generator.

Should work just the same. Instead of:

self.label_1.text = somevariable

You’d do:

self.rich_text_1.content = f"**{somevariable}** Horses are arriving tomorrow"

1 Like

interesting… so I set the field to markdown

then the code to load is this:

 var = '300'
 self.rt1.content = f"**{var}** Horses are arriving tomorrow"

but then I see this:
image

if I make that a single asterisk, it makes it italics so somethings working

I used this code:

        temp = '300'
        self.rich_text_2.content = f"**{temp}** Horses"

And got this:

image

which looks just like I’d expect. Not sure what’s happening with yours, since it looks like the same code.

Mine was on a fresh Material 3 app, maybe something CSS oriented?

Depending on the program and the font, some fonts do not “bold” properly. You might want to try with a different font, just to check.

2 Likes

Font was the problem. I had not specified a font - so that solved the issue. Thanks all.