I think it will depend on the text editor.
Since you didn't identify the text editor, my comments will necessarily be generalized.
The primary feature I'd look for is named groups of attributes. Older versions of Xcode's editor had this feature. You could give the current set of font and color settings a name, and then reinstate them at any time by choosing the name from the popup menu. For example, I'd fiddle around with the colors for the attributes, then save them as "Dark Foobar", or "Dark Knigget", or whatever darkling name you wanted. With a named group of attributes, it should be much easier to activate manually, because it's just one choice. You could then also look into scripting that choice, maybe resorting to UI scripting as a last resort.
Another thing I'd look at is the scripting vocabulary of the text editor. If it exposes things like colors to AppleScript, then you can just write an AppleScript (or a bash script that runs the 'osascript' command) that tells the editor to set whatever colors you want.
If the text editor doesn't have named groups of attributes, or lacks scriptable color settings, then you'll probably end up needing to use
UI Scripting. That could become quite complex very quickly, so it might not be worth doing.
One other possibility is to use the 'defaults' command in a Terminal window to see what the text editor stores in its defaults parameters. The color settings might be accessible that way, which would make them accessible to shell scripts.