8

If I use following example (or any other):

input metauml;

beginfig(1);
Class.A("Point")
       ("+x: int",
        "+y: int") ();

Class.B("Circle")
       ("radius: int")
       ("+getRadius(): int",
        "+setRadius(r: int):void");

topToBottom(45)(A, B);

drawObjects(A, B);

clink(aggregationUni)(A, B)
endfig;

end;

It generates PS that I cannot view in evince and gs:

GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in ptmr8r
Operand stack:
   (Point)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1894   1   3   %oparray_pop   1893   1   3   %oparray_pop   1877   1   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1157/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Current file position is 895
GPL Ghostscript  9.00: Unrecoverable error, exit code 1

Generated code:

%!PS
%%BoundingBox: -33 -141 71 1 
%%HiResBoundingBox: -32.34918 -140.52289 70.86105 0.25 
%%Creator: MetaPost 1.211
%%CreationDate: 2010.11.13:2050
%%Pages: 1
%*Font: ptmr8r 9.96265 9.96265 20:80c000201000a0005d4b3ec
%%BeginProlog
%%EndProlog
%%Page: 1 1
 0.7 0.7 0.7 setrgbcolor
newpath 1 -1 moveto
38.76186 -1 lineto
38.76186 -43.25916 lineto
1 -43.25916 lineto
 closepath fill
 0.9 0.9 0.9 setrgbcolor
newpath 0 0 moveto
37.76186 0 lineto
37.76186 -42.25916 lineto
0 -42.25916 lineto
 closepath fill
 0 0 0 setrgbcolor 0 0.5 dtransform truncate idtransform setlinewidth pop
 [] 0 setdash 1 setlinejoin 10 setmiterlimit
newpath 0 0 moveto
37.76186 0 lineto
37.76186 -42.25916 lineto
0 -42.25916 lineto
 closepath stroke
 1 setlinecap
newpath 0 -12.75458 moveto
37.76186 -12.75458 lineto stroke
newpath 0 -37.75916 moveto
37.76186 -37.75916 lineto stroke
8.3605 -9.75458 moveto
(Point) ptmr8r 9.96265 fshow
13 -23.25916 moveto
(x:\040int) ptmr8r 9.96265 fshow
13 -33.75916 moveto
(y:\040int) ptmr8r 9.96265 fshow
 0.4 0.4 0.4 setrgbcolor
newpath 2 -20.5592 moveto
7.95004 -20.5592 lineto
7.95004 -23.25916 lineto
2 -23.25916 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath 7.95004 -23.25916 moveto
9 -22.2092 lineto
9 -19.50925 lineto
7.95004 -20.5592 lineto
 closepath fill
 0.6 0.6 0.6 setrgbcolor
newpath 7.95004 -20.5592 moveto
9 -19.50925 lineto
3.04996 -19.50925 lineto
2 -20.5592 lineto
 closepath fill
 0.4 0.4 0.4 setrgbcolor
newpath 2 -31.0592 moveto
7.95004 -31.0592 lineto
7.95004 -33.75916 lineto
2 -33.75916 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath 7.95004 -33.75916 moveto
9 -32.7092 lineto
9 -30.00925 lineto
7.95004 -31.0592 lineto
 closepath fill
 0.6 0.6 0.6 setrgbcolor
newpath 7.95004 -31.0592 moveto
9 -30.00925 lineto
3.04996 -30.00925 lineto
2 -31.0592 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath -31.09918 -88.25916 moveto
70.86105 -88.25916 lineto
70.86105 -140.52289 lineto
-31.09918 -140.52289 lineto
 closepath fill
 0.9 0.9 0.9 setrgbcolor
newpath -32.09918 -87.25916 moveto
69.86105 -87.25916 lineto
69.86105 -139.52289 lineto
-32.09918 -139.52289 lineto
 closepath fill
 0 0 0 setrgbcolor
newpath -32.09918 -87.25916 moveto
69.86105 -87.25916 lineto
69.86105 -139.52289 lineto
-32.09918 -139.52289 lineto
 closepath stroke
newpath -32.09918 -100.01373 moveto
69.86105 -100.01373 lineto stroke
newpath -32.09918 -114.51831 moveto
69.86105 -114.51831 lineto stroke
6.7068 -97.01373 moveto
(Circle) ptmr8r 9.96265 fshow
-19.09918 -110.51831 moveto
(radius:\040int) ptmr8r 9.96265 fshow
-19.09918 -125.02289 moveto
(getRadius\(\):\040int) ptmr8r 9.96265 fshow
-19.09918 -135.52289 moveto
(setRadius\(r:\040int\):void) ptmr8r 9.96265 fshow
 0.4 0.4 0.4 setrgbcolor
newpath -30.09918 -107.81836 moveto
-24.14914 -107.81836 lineto
-24.14914 -110.51831 lineto
-30.09918 -110.51831 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath -24.14914 -110.51831 moveto
-23.09918 -109.46835 lineto
-23.09918 -106.7684 lineto
-24.14914 -107.81836 lineto
 closepath fill
 0.6 0.6 0.6 setrgbcolor
newpath -24.14914 -107.81836 moveto
-23.09918 -106.7684 lineto
-29.04922 -106.7684 lineto
-30.09918 -107.81836 lineto
 closepath fill
 0.3 0.3 0.3 setrgbcolor 0 0.79701
 dtransform truncate idtransform setlinewidth pop 0 setlinecap
newpath -28.5242 -105.04338 moveto
-28.00685 -104.4082 -27.40976 -103.75253 -26.59918 -103.76831 curveto
-25.12357 -103.79704 -24.63 -105.58928 -24.67416 -107.29338 curveto stroke
 0.4 0.4 0.4 setrgbcolor
newpath -30.09918 -122.32294 moveto
-24.14914 -122.32294 lineto
-24.14914 -125.02289 lineto
-30.09918 -125.02289 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath -24.14914 -125.02289 moveto
-23.09918 -123.97293 lineto
-23.09918 -121.27298 lineto
-24.14914 -122.32294 lineto
 closepath fill
 0.6 0.6 0.6 setrgbcolor
newpath -24.14914 -122.32294 moveto
-23.09918 -121.27298 lineto
-29.04922 -121.27298 lineto
-30.09918 -122.32294 lineto
 closepath fill
 0.4 0.4 0.4 setrgbcolor
newpath -30.09918 -132.82294 moveto
-24.14914 -132.82294 lineto
-24.14914 -135.52289 lineto
-30.09918 -135.52289 lineto
 closepath fill
 0.7 0.7 0.7 setrgbcolor
newpath -24.14914 -135.52289 moveto
-23.09918 -134.47293 lineto
-23.09918 -131.77298 lineto
-24.14914 -132.82294 lineto
 closepath fill
 0.6 0.6 0.6 setrgbcolor
newpath -24.14914 -132.82294 moveto
-23.09918 -131.77298 lineto
-29.04922 -131.77298 lineto
-30.09918 -132.82294 lineto
 closepath fill
 0 0 0 setrgbcolor 0.5
 0 dtransform exch truncate exch idtransform pop setlinewidth
newpath 18.88094 -54.75896 moveto
18.88094 -74.75975 lineto stroke
newpath 18.88094 -54.75896 moveto
18.88094 -42.25922 lineto stroke
 0 0.5 dtransform truncate idtransform setlinewidth pop
newpath 18.88094 -42.25922 moveto
13.88094 -54.75896 lineto stroke
newpath 18.88094 -42.25922 moveto
23.88094 -54.75896 lineto stroke
 1 1 1 setrgbcolor
newpath 18.88094 -74.75957 moveto
23.88094 -81.00945 lineto
18.88094 -87.25931 lineto
13.88094 -81.00945 lineto
 closepath fill
 0 0 0 setrgbcolor
newpath 18.88094 -74.75957 moveto
23.88094 -81.00945 lineto
18.88094 -87.25931 lineto
13.88094 -81.00945 lineto
 closepath stroke
showpage
%%EOF

What am I doing wrong?

Edit: When I use pdflatex it generates a proper pdf (at least with /usr/share/ghostscript/GS_Version/Resource/Init/Fontmap.GS modified)

4 Answers4

3

I too had the same problem. Fortunately, I just now came across the solution: Displaying MetaPost output in ghostscript

To avoid this problem, as they suggested, you just have to add the following line at the beginning of your .mp file:

prologues := 2;

Then process your .mp file with gs or convert or whatever tool you like.

I'm not much knowledgeable about MetaPost, so, I don't know what exactly it does. But it atleast avoid that irritating error :)

Hope others find it useful too!

David Carlisle
  • 757,742
Barun
  • 158
  • 2
    Linking the the UK FAQ is a good idea, but it's also useful to add a summary of the material here so that {TeX} stands "on it's own". Please consider editing your answer to include what you did: you'll get more upvotes that way. – Joseph Wright Feb 27 '11 at 11:49
  • @Joseph Wright♦: Thank you, will keep that in mind :) – Barun Feb 28 '11 at 09:29
  • 1
    In general, prologues:=3; is safer, as that actually includes a font subset in the generated PS, so that it will also work for fonts that do not exist in the ghostscript installation at all. – Taco Hoekwater Feb 28 '11 at 10:35
3

create a LaTeX document:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{<mpfile>.1}
\end{document}

or use mptopdf from ConTeXt or use it this way

mpost -tex=tex <mpfile>
tex "\input epsf\relax\epsfbox{<mpfile>.1}\bye"
dvips zz

it will generate a ps with included ptmr8r font. replace with your file name.

0

If you do not want to edit your files you can create a custom memory dump:

mpost -ini <<EOF

\input plain
prologues := 2
\dump

EOF

You should get a mpout.mem file. Rename it to whatever you like (say foobar.mem) and use it with:

mpost '&foobar' file

You could define an alias:

alias mp2eps="mpost '&foobar'"

(You might want to place the mem file into the kpathsea search path but I do not know how to set it up).

ysdx
  • 101
0

There is probably something wrong with the font ptmr8r. A quick googling found some advice at http://www.mediawiki.org/wiki/Extension:UML on how to fix that.