Changing font color in WordPad
Is it possible to chang开发者_运维知识库e the font color of text while redirecting it to WordPad?
Examples:
C:\echo greencolor >> C:\colors.rtf
-----> This text should appear green in WordPad
C:\echo redcolor >> C:\colors.rtf
-----> This text should appear red in WordPad
C:\echo browncolor >> C:\colors.rtf
-----> This text should appear brown in WordPad
RTF uses its own markup. E.g. the words blue
and red
in respective colors are represented as:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033
{\fonttbl
{\f0\fswiss\fprq2\fcharset0 Arial;}
{\f1\fswiss\fcharset0 Arial;}
}
{\colortbl ;\red0\green0\blue255;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.15.1515;}
\viewkind4\uc1\pard\cf1\f0\fs20 blue, \cf2 red\cf0\f1\par
}
So, you need to output such markup for other colors and basically create a RTF document.
dirkgently is entirely correct. To take your examples, the following command line will produce a RTF document at C:\colors.rtf, containing the word 'green' in green.
C:\>echo {\rtf1\ansi\deff0{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red0\green128\blue0;}{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\cf1\lang1033\f0\fs20 green\cf0\par} >> c:\colors.rtf
You can then open c:\colors.rtf in Wordpad.
精彩评论