如何对字体进行编码以在后记中使用 CP1252 (Windows-1252) 编码?
How do I encode a font to use CP1252 (Windows-1252) encoding in postscript?
我的 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
这不会打印 aacute (0x92) 字符和其他出现在 cp1252 编码中的字符。我的目标是打印出 windows 集中的一些特殊字符。有人知道吗?
上面的 PostScript 程序有很多问题。
首先没有显示页面运算符,所以实际上没有绘制文本。
其次没有使用 setfont/selectfont 运算符,所以程序使用默认字体,如果这恰好是 Helvetica 那么就不清楚这不是预期的字体.... .
第三,'reencodefont' 过程在操作数堆栈上为重新编码的字体留下字体字典的副本,导致程序末尾在堆栈上有两个孤立的字典。这不违法,但肯定是不好的做法。
Encoding 数组称为 WinEncoding,它看起来像 WinAnsiEncoding,据我所知,它与代码页 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
我的 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
这不会打印 aacute (0x92) 字符和其他出现在 cp1252 编码中的字符。我的目标是打印出 windows 集中的一些特殊字符。有人知道吗?
上面的 PostScript 程序有很多问题。
首先没有显示页面运算符,所以实际上没有绘制文本。
其次没有使用 setfont/selectfont 运算符,所以程序使用默认字体,如果这恰好是 Helvetica 那么就不清楚这不是预期的字体.... .
第三,'reencodefont' 过程在操作数堆栈上为重新编码的字体留下字体字典的副本,导致程序末尾在堆栈上有两个孤立的字典。这不违法,但肯定是不好的做法。
Encoding 数组称为 WinEncoding,它看起来像 WinAnsiEncoding,据我所知,它与代码页 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