summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:03:17 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:03:17 +0000
commitecf966f305f6aeff2bbdf42c82d8425921aa9eda (patch)
treedb606a57e3619610e4c35cae849d41cf4e0937d5 /Master/texmf-dist/source/metapost
parentac3c55a3216b5988f0e48ba9414ddb059f19a699 (diff)
source 1
git-svn-id: svn://tug.org/texlive/trunk@105 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/metapost')
-rw-r--r--Master/texmf-dist/source/metapost/mpattern/mpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/metapost/mpattern/mpp b/Master/texmf-dist/source/metapost/mpattern/mpp
new file mode 100644
index 00000000000..d5d81c5be59
--- /dev/null
+++ b/Master/texmf-dist/source/metapost/mpattern/mpp
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -i
+###########################################################################
+# This file is part of the MPATTERN package
+#
+# mpp: Postprocessing MetaPost output files in which patterns were used
+#
+# Author: Piotr Bolek
+# version: 0.2 (Sep 25, 1998)
+#
+# $Id: mpp,v 1.3 1998/09/25 10:49:30 piotrek Exp $
+###########################################################################
+
+$file=shift;
+($logfile = $file . ".log") =~ s/\.mp\.log/.log/;
+$file =~ s/\.mp$//;
+
+system("mpost $file");
+
+open LOG, $logfile;
+while(<LOG>) {
+ if (/Pattern:(\d+)/) {
+ push @pictures, $1;
+ }
+}
+
+print STDERR "Postprocessing patterns";
+
+for $i (@pictures) {
+ $newfile="$file.$i"; print STDERR ".";
+ $oldfile="$file.p!!";
+ rename($newfile,$oldfile);
+
+ open IN, $oldfile;
+ open OUT, ">$newfile";
+ $output = $fonts = "";
+ LINE:
+ while(<IN>){
+ if((/^%%EndProlog\s*$/../^%%EOF\s*$/) && /%*Font:/) {
+ $fonts .= $_;
+ next LINE;
+ }
+ if(/^% Pattern:(0\.[0-9]+):(.*)/) {
+ $pattern{$1}=$2;
+# print STDERR "\$pattern{$1}=$2\n";
+ }
+ if(/^ (0\.[0-9]+) setgray/ && (defined $pattern{$1})) {
+ s"^ (0\.[0-9]+).*"%$&\n$pattern{$1} setpattern";
+ }
+ $output .= $_;
+ }
+ $output =~ s/%%EndProlog/$fonts$&/;
+ print OUT $output;
+ unlink $oldfile;
+}
+print STDERR "\n";