The RichTextEditor component does this. If you look at that class's code, you'll see that it calls a function named setTextStyles and passes an argument of 'color'.
Basically, it creates a TextFormat object with the desired style (font color, in this case), and applies it to the selected text. Good luck.

