Font problems
From Metapost
(→Create your Fontmap file) |
(→Create your Fontmap file) |
||
Line 66: | Line 66: | ||
/CMR10 (cmr10.pfb) ; | /CMR10 (cmr10.pfb) ; | ||
- | If not, use this [ | + | If not, use this [http://www.cl.cam.ac.uk/~pz215/files/Fontmap Fontmap] file or generate your own using the following script: |
#!/bin/bash | #!/bin/bash |
Revision as of 23:23, 24 September 2006
Sometimes, text in the diagrams produced by MetaPost might look ugly. The most common reason, lack of sufficient font information in Metapost output, is dealt with on this page. You might also want to read more about different methods of typesetting text in Metapost.
By default, files produced by Metapost are Postcript fragments, which are not self-contained. This is fine, as long as you don't plan to view them directly but embed in other files or/and do some post-processing (see the first two sections). If you want to be able to view your Metapost output directly, see the last section.
For more information, see [1]
Contents |
Standalone output
PS
mps2eps converts a given MPS to a self-contained EPS file with the necessary fonts included.
mpost mydiagrams.mp mps2eps mydiagrams.1 > mydiagrams-1.eps
The following will produce mydiagrams-1.pdf
:
mpost mydiagrams.mp mptopdf mydiagrams.1
Standalone output with latex
Prepare a Latex file mydocument.tex
that embeds your diagrams. If you just want to see your diagrams, use the standard mproof.tex
:
tex mproof mydiagrams.1 mydiagrams.2 ...
PS
Use the "-j0" option of dvips:
mpost mydiagrams.mp latex mydocument.tex dvips -j0 mydocument.dvi > mydocument.ps
PDFLatex can handle MPS files directly. See the Latex page for examples and more information.
mpost mydiagrams.mp pdflatex mydocument.tex
Viewing non-standalone MPS-files
First of all you need to ensure that MetaPost's output is a valid PS file by putting the statement
prologues := 2
at the beginning of your MP file, or calling mpost as
mpost "prologues:=2; input mydiagrams.mp"
Ghostscript and ghostview
Check your psfonts.map
Check whether your psfonts.map file includes the fonts you want to use. For Computer Modern fonts look for lines like
cmr10 CMR10 <cmr10.pfb
Create your Fontmap file
Make sure your Fontmap file includes lines like
/CMR10 (cmr10.pfb) ;
If not, use this Fontmap file or generate your own using the following script:
#!/bin/bash cat $(kpsewhich psfonts.map) | awk '!/^%.*/ && NF>2 { printf "/%-32s%-32s;\
", $1, sprintf("(%s)", substr($NF,2));
printf "/%-32s%-32s;\
", $2, sprintf("(%s)", substr($NF,2));
}'
Set up font directories
To display fonts propertly, you must tell ghostscript where your fonts are (note the colon at the end)
export GS_LIB=/your/fontmap/file/dir/:$(dirname $(kpsewhich cmr10.pfb)):$(dirname $(kpsewhich lasy10.pfb)):
Typically, this will expand to something like
export GS_LIB=/home/yourname/local/share/fonts/:/usr/share/texmf-tetex/fonts/type1/bluesky/cm:/usr/share/texmf-tetex/fonts/type1/bluesky/latex:
which tell ghostscript where to find Computer Modern fonts. If you use other non-standard fonts, you will have to include the path to them in the above definition.
Debugging font problems
To debug font problems, type
gs yourfile.ps
and look for error messages.
DVI
DVI previewers (such as xdvi) usually use Ghostscript for rendering embedded Postscript. Make sure to enable this feature; it might not be turned on by default. Once your Ghostscript is set up properly (see above), you shouldn't have problems.