enscript 是否支持同一文件上的多种字体

enscript 是否支持同一文件上的多种字体

我的要求是以一种字体打印输入的某些部分(也可以是不同大小、粗体、背景等)并保留另一种字体。是否可以?

答案1

是的,文本中可以使用转义序列,必须使用命令行选项-e或激活--escapes

查看手册页 ( man enscript) 中的“SPECIAL ESCAPES”部分。

SPECIAL ESCAPES
       Enscript  supports  special  escape  sequences which can be used to add some page formatting commands to ASCII
       documents.  As a default, special escapes interpretation is off, so all ASCII  files  print  out  as  everyone
       expects.  Special escapes interpretation is activated by giving option -e, --escapes to enscript.

       All  special  escapes start with the escape character.  The default escape character is ^@ (octal 000); escape
       character can be changed with option -e, --escapes.   Escape  character  is  followed  by  escape's  name  and
       optional options and arguments.

       Currently enscript supports following escapes:

       bgcolor change the text background color.  The syntax of the escape is:

               ^@bgcolor{red green blue}

               where the color components red, green, and blue are given as decimal numbers between values 0 and 1.

       bggray  change the text background color.  The syntax of the escape is:

               ^@bggray{gray}

               where gray is the new text background gray value.  The default value is 1.0 (white).

       color   change the text color.  The syntax of the escape is:

               ^@color{red green blue}

               where color components red, green and blue are given as decimal numbers between values 0 and 1.

再往下说:

       font    select current font.  The syntax of the escape is:

               ^@font{fontname[:encoding]}

               where  fontname  is  a standard font specification.  Special font specification default can be used to
               select the default body font (enscript's default or the one specified by the command line  option  -f,
               --font).

               The optional argument encoding specifies the encoding that should be used for the new font.  Currently
               the encoding can only be the enscript's global input encoding or ps.

编辑:

一个例子:

me@debian:~$ echo "normal text @color{1 0 0}red text @font{Courier-Bold10}Courier-Bold 10pt @font{Helvetica-BoldOblique12}Helvetica-BoldOblique 12pt @font{default}default font again" > text.txt 
me@debian:~$ enscript -v -e@ text.txt -o text.ps
AFM: scanning path...
AFM: reading font map "/usr/share/enscript/afm/font.map"
processing file "text.txt"...
[ 1 page * 1 copy ] left in text.ps

查看 font.map 文件中定义的字体名称。取一个字体名称并添加大小(以 pt 为单位)。

相关内容