1
votes

My postscript file contains windows special characters to be printed out. I've tried encoding Helvetica font like this. But Still it doesn't seem to work.

/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

This doesn't print the aacute (0x92) character and other one's present in the cp1252 encoding. My aim is to print out some special characters in the windows set. Anyone has a clue?

1
0x92 is not aacute in cp1252, it is U+2019, "Right single quotation mark". Not covered by Postscript.Hans Passant

1 Answers

2
votes

There are considerable problems with the PostScript program above.

Firstly there is no showpage operator, so no text is actually drawn.

Secondly there is no setfont/selectfont operator used, so the program uses the default font, if this should happen to be Helvetica then it won't be clear that this is not the expected font.....

Thrdly the 'reencodefont' procedure leaves a copy of the font dictionary for the re-encoded font on the operand stack, leading to two orphaned dictionaries on the stack at the end of the program. This isn't illegal but its certainly bad practice.

The Encoding array is called WinEncoding, which looks like it is WinAnsiEncoding, it is, as far as I can tell, nothing to do with Code Page 1252. If we look at the WinEncoding array we can see that the /aacute is at index 225 in the array. Why do you think that this would result in character code 0x92 (decimal 146) producing an aacute ?

At index 146 of the WinEncoding array we see the name /quoteright, and that's what I get when I use a character code of 0x92. Note that using an character code, especially form the upper ASCII set, as you have done in your string is likely to lead to errors especially when pasting to a site like Stack Overflow.

Here is a corrected version of your program:

%!
/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