Changing text color within a single string


#1

Hi everyone:

I want to create blocks of text that have different colors within the same string, i.e.

a[color=#800040]single[/color][color=#8000FF]string[/color][color=#8040FF]with[/color][color=#8080BF]the[/color][color=#80BFBF]spaces[/color][color=#80FF40]suggested[/color][color=#BFBF00]by[/color][color=#FF8040]different[/color][color=#FF4080]colors[/color]

except with, you know, colors that aren’t totally hideous.

How would I do this within Juce? Using separate blocks of text requires aligning each block with the previous one, so it would be nice to just set the colors for individual words.

Thanks,

Sean Costello


#2

The easiest way I can think of would be with a TextEditor…


#3

Why a TextEditor instead of the TextLayout class? I want this to be part of the background - i.e. like an image, instead of text you can edit, copy and paste.

Thanks,

Sean Costello


#4

I don’t think a textlayout lets you specify colours.