1

我的 postscript 文件包含要打印的 windows 特殊字符。我试过像这样编码 Helvetica 字体。但它似乎仍然不起作用。

/WinEncoding
[
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /space
  /exclam
  /quotedbl
  /numbersign
  /dollar
  /percent
  /ampersand
  /quotesingle
  /parenleft
  /parenright
  /asterisk
  /plus
  /comma
  /hyphen
  /period
  /slash
  /zero
  /one
  /two
  /three
  /four
  /five
  /six
  /seven
  /eight
  /nine
  /colon
  /semicolon
  /less
  /equal
  /greater
  /question
  /at
  /A
  /B
  /C
  /D
  /E
  /F
  /G
  /H
  /I
  /J
  /K
  /L
  /M
  /N
  /O
  /P
  /Q
  /R
  /S
  /T
  /U
  /V
  /W
  /X
  /Y
  /Z
  /bracketleft
  /backslash
  /bracketright
  /asciicircum
  /underscore
  /grave
  /a
  /b
  /c
  /d
  /e
  /f
  /g
  /h
  /i
  /j
  /k
  /l
  /m
  /n
  /o
  /p
  /q
  /r
  /s
  /t
  /u
  /v
  /w
  /x
  /y
  /z
  /braceleft
  /bar
  /braceright
  /asciitilde
  /.notdef
  /.notdef
  /.notdef
  /quotesinglbase
  /florin
  /quotedblbase
  /ellipsis
  /dagger
  /daggerdbl
  /circumflex
  /perthousand
  /Scaron
  /guilsinglleft
  /OE
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /quoteleft
  /quoteright
  /quotedblleft
  /quotedblright
  /bullet
  /endash
  /emdash
  /tilde
  /trademark
  /scaron
  /guilsinglright
  /oe
  /dotlessi
  /.notdef
  /Ydieresis
  /.notdef
  /exclamdown
  /cent
  /sterling
  /currency
  /yen
  /brokenbar
  /section
  /dieresis
  /copyright
  /ordfeminine
  /guillemotleft
  /logicalnot
  /guilsinglright
  /registered
  /macron
  /ring
  /plusminus
  /twosuperior
  /threesuperior
  /acute
  /mu
  /paragraph
  /periodcentered
  /cedilla
  /onesuperior
  /ordmasculine
  /guillemotright
  /onequarter
  /onehalf
  /threequarters
  /questiondown
  /Agrave
  /Aacute
  /Acircumflex
  /Atilde
  /Adieresis
  /Aring
  /AE
  /Ccedilla
  /Egrave
  /Eacute
  /Ecircumflex
  /Edieresis
  /Igrave
  /Iacute
  /Icircumflex
  /Idieresis
  /Eth
  /Ntilde
  /Ograve
  /Oacute
  /Ocircumflex
  /Otilde
  /Odieresis
  /multiply
  /Oslash
  /Ugrave
  /Uacute
  /Ucircumflex
  /Udieresis
  /Yacute
  /Thorn
  /germandbls
  /agrave
  /aacute
  /acircumflex
  /atilde
  /adieresis
  /aring
  /ae
  /ccedilla
  /egrave
  /eacute
  /ecircumflex
  /edieresis
  /igrave
  /iacute
  /icircumflex
  /idieresis
  /eth
  /ntilde
  /ograve
  /oacute
  /ocircumflex
  /otilde
  /odieresis
  /divide
  /oslash
  /ugrave
  /uacute
  /ucircumflex
  /udieresis
  /yacute
  /thorn
  /ydieresis
]
def

% This procedure/function re encodes the copy of old font with win encoding
% and saves it with a newname
/reencodefont           % /NewName /OldName => <<fdict>>
{
        findfont dup
        length dict copy

        %dup /CharStrings get /aacute known
        %{ dup /Encoding WinEncoding put } if
        dup /Encoding WinEncoding put
        definefont
} bind def


% Re-Encode Fonts to use Win-Encoding:

/Helvetica-Win /Helvetica reencodefont
/Helvetica-Bold-Win /Helvetica-Bold reencodefont


100 500 moveto 
(this Menӳ text) show

这不会打印 cp1252 编码中的 aacute (0x92) 字符和其他字符。我的目标是在windows集中打印出一些特殊字符。有人有线索吗?

4

1 回答 1

2

上面的 PostScript 程序存在相当大的问题。

首先没有显示页操作符,所以实际上没有绘制文本。

其次,没有使用 setfont/selectfont 操作符,所以程序使用默认字体,如果这恰好是 Helvetica,那么就不清楚这不是预期的字体.....

第三,“reencodefont”过程在操作数堆栈上为重新编码的字体留下了字体字典的副本,从而在程序结束时在堆栈上产生了两个孤立的字典。这不是非法的,但它肯定是不好的做法。

Encoding 数组称为 WinEncoding,它看起来像是 WinAnsiEncoding,据我所知,它与 Code Page 1252 无关。如果我们查看 WinEncoding 数组,我们可以看到 /aacute 位于索引 225在数组中。为什么您认为这会导致字符代码 0x92(十进制 146)产生 aacute ?

在 WinEncoding 数组的索引 146 处,我们看到名称 /quoteright,这就是我在使用字符代码 0x92 时得到的。请注意,使用字符代码,尤其是形成较高的 ASCII 集,就像您在字符串中所做的那样,可能会导致错误,尤其是在粘贴到 Stack Overflow 之类的站点时。

这是您的程序的更正版本:

%!
/WinEncoding
[
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /space
  /exclam
  /quotedbl
  /numbersign
  /dollar
  /percent
  /ampersand
  /quotesingle
  /parenleft
  /parenright
  /asterisk
  /plus
  /comma
  /hyphen
  /period
  /slash
  /zero
  /one
  /two
  /three
  /four
  /five
  /six
  /seven
  /eight
  /nine
  /colon
  /semicolon
  /less
  /equal
  /greater
  /question
  /at
  /A
  /B
  /C
  /D
  /E
  /F
  /G
  /H
  /I
  /J
  /K
  /L
  /M
  /N
  /O
  /P
  /Q
  /R
  /S
  /T
  /U
  /V
  /W
  /X
  /Y
  /Z
  /bracketleft
  /backslash
  /bracketright
  /asciicircum
  /underscore
  /grave
  /a
  /b
  /c
  /d
  /e
  /f
  /g
  /h
  /i
  /j
  /k
  /l
  /m
  /n
  /o
  /p
  /q
  /r
  /s
  /t
  /u
  /v
  /w
  /x
  /y
  /z
  /braceleft
  /bar
  /braceright
  /asciitilde
  /.notdef
  /.notdef
  /.notdef
  /quotesinglbase
  /florin
  /quotedblbase
  /ellipsis
  /dagger
  /daggerdbl
  /circumflex
  /perthousand
  /Scaron
  /guilsinglleft
  /OE
  /.notdef
  /.notdef
  /.notdef
  /.notdef
  /quoteleft
  /quoteright
  /quotedblleft
  /quotedblright
  /bullet
  /endash
  /emdash
  /tilde
  /trademark
  /scaron
  /guilsinglright
  /oe
  /dotlessi
  /.notdef
  /Ydieresis
  /.notdef
  /exclamdown
  /cent
  /sterling
  /currency
  /yen
  /brokenbar
  /section
  /dieresis
  /copyright
  /ordfeminine
  /guillemotleft
  /logicalnot
  /guilsinglright
  /registered
  /macron
  /ring
  /plusminus
  /twosuperior
  /threesuperior
  /acute
  /mu
  /paragraph
  /periodcentered
  /cedilla
  /onesuperior
  /ordmasculine
  /guillemotright
  /onequarter
  /onehalf
  /threequarters
  /questiondown
  /Agrave
  /Aacute
  /Acircumflex
  /Atilde
  /Adieresis
  /Aring
  /AE
  /Ccedilla
  /Egrave
  /Eacute
  /Ecircumflex
  /Edieresis
  /Igrave
  /Iacute
  /Icircumflex
  /Idieresis
  /Eth
  /Ntilde
  /Ograve
  /Oacute
  /Ocircumflex
  /Otilde
  /Odieresis
  /multiply
  /Oslash
  /Ugrave
  /Uacute
  /Ucircumflex
  /Udieresis
  /Yacute
  /Thorn
  /germandbls
  /agrave
  /aacute
  /acircumflex
  /atilde
  /adieresis
  /aring
  /ae
  /ccedilla
  /egrave
  /eacute
  /ecircumflex
  /edieresis
  /igrave
  /iacute
  /icircumflex
  /idieresis
  /eth
  /ntilde
  /ograve
  /oacute
  /ocircumflex
  /otilde
  /odieresis
  /divide
  /oslash
  /ugrave
  /uacute
  /ucircumflex
  /udieresis
  /yacute
  /thorn
  /ydieresis
]
def

% This procedure/function re encodes the copy of old font with win encoding
% and saves it with a newname
/reencodefont           % /NewName /OldName => <<fdict>>
{
        findfont dup
        length dict copy

        %dup /CharStrings get /aacute known
        %{ dup /Encoding WinEncoding put } if
        dup /Encoding WinEncoding put
        definefont
} bind def


% Re-Encode Fonts to use Win-Encoding:

/Helvetica-Win /Helvetica reencodefont 
30 scalefont setfont

%/Helvetica-Bold-Win /Helvetica-Bold reencodefont

100 500 moveto 
(this Men) show <E192> show (text) show

showpage
于 2015-09-08T08:00:53.080 回答