Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

postscript terminal - how to typeset a unicode character (correct syntax)?

3,284 views
Skip to first unread message

Christian

unread,
Aug 3, 2009, 5:42:38 AM8/3/09
to
Hello,

I am using the latest Gnuplot precompiled binary (4.3.0 - dated July
2009) for Windows. The help system says that one can request Unicode
characters by setting "set encoding utf8". I want to typeset greek
characters, e.g. an uppercase "Delta". (Please do not redirect me to the
Symbol font now ... this is not what I want.) After reading the help
section on 'postcript adobeglyphnames' I tried both - requesting the
Delta via "/Delta" or "/uni0394", including some combinations of slashes
and backslashes. No success - please see my sample input:

###
set encoding utf8
set term postscript eps enhanced "Helvetica,14" adobeglyphnames
set output "test.eps"
set label "this is a Delta: \/Delta /\uni0394" at screen 0.5,0.5
set border 0
unset xtics
unset ytics
plot [][0:1] 2 notitle
###

What am I doing wrong here?

BTW: Entering the character 'Delta' directly into an utf-encoded gnuplot
input file does not work either since gnuplot does not seem to accept
unicode input files (it complains about unknown characters at the
beginning of the input file).

Regards -
Christian

sfeam

unread,
Aug 3, 2009, 12:20:48 PM8/3/09
to
Christian wrote:

> Hello,
>
> I am using the latest Gnuplot precompiled binary (4.3.0 - dated July
> 2009) for Windows. The help system says that one can request Unicode
> characters by setting "set encoding utf8". I want to typeset greek
> characters, e.g. an uppercase "Delta". (Please do not redirect me to the
> Symbol font now ... this is not what I want.) After reading the help
> section on 'postcript adobeglyphnames' I tried both - requesting the
> Delta via "/Delta" or "/uni0394", including some combinations of slashes
> and backslashes. No success - please see my sample input:
>
> ###
> set encoding utf8
> set term postscript eps enhanced "Helvetica,14" adobeglyphnames

PostScript itself does not normally support unicode characters or
UTF8 encoding. You need to construct a special font file, as described
briefly in the file .../term/PostScript/unicode_maps.README, and then
pass it to the postscript terminal by adding to the 'set term postscript'
command, e.g.:

set term postscript ... fontfile 'arialuni.ps' font 'ArialUnicodeMS'

IMHO, it is not worth the effort to make up for the lack of UTF support
in the PostScript language. It is far easier to use a more modern
alternative like PDF that does support it.


> BTW: Entering the character 'Delta' directly into an utf-encoded gnuplot
> input file does not work either since gnuplot does not seem to accept
> unicode input files (it complains about unknown characters at the
> beginning of the input file).

Gnuplot is perfectly happy with UTF-8 encoded files.
That is, in fact, the default for most linux systems.
However, some Windows programs place extra characters at the start
of a file containing an encoding they don't recognize. It is possible
that is what has happened to your input file. Just delete the junk at
the beginning of the file and you should be fine.


>
> Regards -
> Christian

Christian

unread,
Aug 4, 2009, 10:51:10 AM8/4/09
to
sfeam schrieb:

> ... However, some Windows programs place extra characters at the start


> of a file containing an encoding they don't recognize. It is possible
> that is what has happened to your input file. Just delete the junk at
> the beginning of the file and you should be fine.

Yes, indeed - there was a byte-order-marker at the beginning of the
file. After deleting the BOM gnuplot did not complain any longer. Now I
was able to place the character "Delta" directly into the utf-encoded
input file and the eps-file was showing the "Delta" correctly.

Note: This works only when the option 'adobeglyphnames' is used, and I
observed the following issue. You start an interactive Windows gnuplot
session and load an input file1 that, e.g., says

set encoding utf8
set term postscript eps enhanced "Helvetica,14" noadobeglyphnames

Then the resulting eps-file contains

[(Helvetica) 140.0 0.0 true true 0 /uni0394]

Now (same session!) you load another file2 activating 'adobeglyphnames':

set encoding utf8
set term postscript eps enhanced "Helvetica,14" adobeglyphnames

The resulting eps-file is the same, still with "/uni0394".

Now you start a new(!) interactive gnuplot session and load file2 first,
then file1. Then both eps-files contain

[(Helvetica) 140.0 0.0 true true 0 /Delta]

which was to be expected with file2, but not with file1. 'show
termoptions' shows that the options were recognized correctly each time,
but internally only the setting applied first during a gnuplot session
stays active for the full session. This is an issue the developers might
check ...

> PostScript itself does not normally support unicode characters or
> UTF8 encoding. You need to construct a special font file, as described
> briefly in the file .../term/PostScript/unicode_maps.README, and then
> pass it to the postscript terminal by adding to the 'set term postscript'
> command, e.g.:
>
> set term postscript ... fontfile 'arialuni.ps' font 'ArialUnicodeMS'

The embedding of font files turned out to be important (at least in my
case) when converting the eps-file into pdf. Without embedded fonts the
resulting pdf-file was showing a "Delta" from another font, embedded
with a wrong kerning.
(I converted the .pfb files shipped with gs into .pfa format using the
tool 't12ascii'.)

> IMHO, it is not worth the effort to make up for the lack of UTF support
> in the PostScript language. It is far easier to use a more modern
> alternative like PDF that does support it.

Supposed I had the pdf terminal available and want to write input files
which are not utf-encoded (cannot enter special characters directly
because the editor does not support it) ... what is the correct syntax
to request unicode characters (glyphnames or unicode numbers)? Shouldn't
the same syntax apply to the postscript terminal as well?

Thank you so far.

- Christian

0 new messages