I agree that the ideal solution seems to be to only apply this auto-color-change functionality when no background color is explicitly given. As others have stated, if someone chooses to specify fg and bg colors that are difficult or impossible to read, then that is their decision, and the text should be displayed without being changed.

-genius_at_work