summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-09-12 17:27:14 +0000
committerKarl Berry <karl@freefriends.org>2006-09-12 17:27:14 +0000
commite01a550ac84b66c412a6b080efb988e0b40ed703 (patch)
tree897230f487ab10bef637653e894053cfba1d1027 /Master/texmf-dist/tex/context
parent4205b615c67232ed1e75d407b0e3aa3f05f29d42 (diff)
supp-pdf from hans
git-svn-id: svn://tug.org/texlive/trunk@2108 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context')
-rw-r--r--Master/texmf-dist/tex/context/base/supp-pdf.tex665
1 files changed, 252 insertions, 413 deletions
diff --git a/Master/texmf-dist/tex/context/base/supp-pdf.tex b/Master/texmf-dist/tex/context/base/supp-pdf.tex
index b40a699f206..a982fa1c7b2 100644
--- a/Master/texmf-dist/tex/context/base/supp-pdf.tex
+++ b/Master/texmf-dist/tex/context/base/supp-pdf.tex
@@ -1,6 +1,6 @@
%D \module
%D [ file=supp-pdf,
-%D version=2004.12.16,
+%D version=2006.09.02, % 2004.12.16,
%D title=\CONTEXT\ Support Macros,
%D subtitle=\METAPOST\ to \PDF\ conversion,
%D author=Hans Hagen \& others (see text),
@@ -11,6 +11,141 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\ifx\writestatus\undefined
+ \immediate\write16{[Loading MPS to PDF converter (version 2006.09.02).]}
+\else
+ \writestatus{loading}{Context Support Macros / PDF}
+\fi
+
+%D This module is not optimized because it is used outside
+%D \CONTEXT\ and we cannot forsee what interference will take
+%D place. We no longer load supp-mis. I got too tired of
+%D keeping track of interferences with non \CONTEXT\ usage so
+%D I moved the necessary code in here and use a derived version
+%D in \CONTEXT. When I have the time I will clean up some of the
+%D code that is of no use for non||\CONTEXT\ users.
+
+\ifx\contextversion\undefined
+
+ \chardef\mptopdfstoredatcode\catcode`\@
+
+ \catcode\string`@=11
+
+ \def\unprotect
+ {\let\@@mpstopdf@@unprotect \unprotect
+ \let\@@mpstopdf@@protect \protect
+ \edef\protect
+ {\noexpand \let \noexpand \protect \noexpand \@@mpstopdf@@protect
+ \noexpand \let \noexpand \unprotect \noexpand \@@mpstopdf@@unprotect
+ % context specific
+ \catcode\string`\noexpand @=\the\catcode\string`@
+ \catcode\string`\noexpand !=\the\catcode\string`!
+ \catcode\string`\noexpand ?=\the\catcode\string`?
+ % latex specific
+ \catcode\string`\noexpand /=\the\catcode\string`/
+ \catcode\string`\noexpand -=\the\catcode\string`-
+ \catcode\string`\noexpand :=\the\catcode\string`:
+ \catcode\string`\noexpand ;=\the\catcode\string`;
+ \catcode\string`\noexpand "=\the\catcode\string`"
+ \catcode\string`\noexpand <=\the\catcode\string`<
+ \catcode\string`\noexpand >=\the\catcode\string`>
+ \catcode\string`\noexpand `=\the\catcode\string``}
+ \catcode\string`@=11 \catcode\string`!=11 \catcode\string`?=11
+ \catcode\string`/=12 \catcode\string`-=12
+ \catcode\string`:=12 \catcode\string`;=12
+ \catcode\string`>=12 \catcode\string`<=12
+ \catcode\string`"=12 \catcode\string``=12 }
+
+ \def\defineMPtoPDFfallbacks
+ {% shortcuts
+ \chardef\@@escape 0
+ \chardef\@@begingroup 1
+ \chardef\@@endgroup 2
+ \chardef\@@endofline 5
+ \chardef\@@ignore 9
+ \chardef\@@space 10
+ \chardef\@@letter 11
+ \chardef\@@other 12
+ \chardef\@@active 13
+ \chardef\@@comment 14
+ % placeholders
+ \ifx\withoutpt \undefined \let\withoutpt \@@mptopdf@@withoutpt \fi
+ \ifx\twodigitrounding \undefined \let\twodigitrounding \@@mptopdf@@twodigitrounding \fi
+ \ifx\forgetall \undefined \let\forgetall \@@mptopdf@@forgetall \fi
+ \ifx\uncatcodespecials \undefined \let\uncatcodespecials \@@mptopdf@@uncatcodespecials \fi
+ \ifx\setnaturalcatcodes\undefined \let\setnaturalcatcodes\@@mptopdf@@setnaturalcatcodes \fi
+ \ifx\dospecials \undefined \let\dospecials \@@mptopdf@@dospecials \fi}
+
+ \def\@@mptopdf@@forgetall
+ {\parskip0pt\leftskip0pt\parindent0pt\everypar{}}
+
+ \def\@@mptopdf@@twodigitrounding#1%
+ {#1}%
+
+ \def\@@mptopdf@@uncatcodespecials
+ {\def\do##1{\catcode`##1=\@@other}\dospecials
+ \catcode`\ =\@@space
+ \catcode`\^^L=\@@ignore
+ \catcode`\^^M=\@@endofline
+ \catcode`\^^?=\@@ignore}
+
+ \def\@@mptopdf@@setnaturalcatcodes
+ {\catcode`\!=\@@other \catcode`\?=\@@other \catcode`\@=\@@other
+ \catcode`\#=\@@other \catcode`\&=\@@other \catcode`\|=\@@other
+ \catcode`\$=\@@other \catcode`\^=\@@other \catcode`\_=\@@other
+ \catcode`\*=\@@other \catcode`\/=\@@other
+ \catcode`\-=\@@other \catcode`+=\@@other
+ \catcode`\==\@@other \catcode`\<=\@@other \catcode`\>=\@@other
+ \catcode`\"=\@@other \catcode`\'=\@@other \catcode`\`=\@@other
+ \catcode`\:=\@@other \catcode`\;=\@@other
+ \catcode`\,=\@@other \catcode`\.=\@@other \catcode`\~=\@@other
+ \catcode`\(=\@@other \catcode`\)=\@@other
+ \catcode`\{=\@@other \catcode`\}=\@@other
+ \catcode`\\=\@@other \catcode`\%=\@@other}
+
+ \def\@@mptopdf@@dospecials
+ {\do\ \do\\\do\{\do\}\do\$%
+ \do\#\do\^\do\_\do\&\do\%%
+ \do\~\do\^^A\do\^^K}
+
+ {
+ \catcode`\.=12
+ \catcode`\p=12
+ \catcode`\t=12
+ \gdef\@@MPTOPDF@@WITHOUTPT#1pt{#1}
+ }
+
+ \def\@@mptopdf@@withoutpt#1%
+ {\expandafter\@@MPTOPDF@@WITHOUTPT#1}
+
+ \def\@@mptopdf@@newabove#1#2% \dimen \name
+ {#1#2%
+ \ifnum\expandafter\gobblesixarguments\meaning#2>20\else
+ \expandafter\@@mptopdf@@newabove\expandafter#1\expandafter#2%
+ \fi}
+
+ \def\@@mptopdf@@stripnewabove#1%
+ {\ifnum10<9#1 #1\else\expandafter\@@mptopdf@@stripnewabove\fi}%
+
+ \def\@@mptopdf@@newabove#1#2% \dimen \name
+ {#1#2%
+ \ifnum\expandafter\@@mptopdf@@stripnewabove\meaning#2>20\else
+ \expandafter\@@mptopdf@@newabove\expandafter#1\expandafter#2%
+ \fi}
+
+ \@@mptopdf@@newabove \newcount \scratchcounter
+ \@@mptopdf@@newabove \newdimen \scratchdimen
+ \newbox \scratchbox
+ \expandafter \newif \csname ifdone\endcsname
+
+ \catcode`\@=\mptopdfstoredatcode
+
+\else
+
+ \let\defineMPtoPDFfallbacks\relax
+
+\fi
+
%D These macros are written as generic as possible. Some
%D general support macro's are loaded from a small module
%D especially made for non \CONTEXT\ use. In this module I
@@ -25,23 +160,10 @@
%D his initials. (We keep the old code around because it's a
%D nice illustration on how a module like this evolves.)
-% Beware, we cannot use \zeropoint here since it may be
-% defined in the range \dimen 0 - 20 which we happen to use
-% as scratch registers; inside context we may consider
-% using dedicated registers.
-
-% fails: ( ) vect10 9.96265 fshow % \040\040\040\040
-%
-% some optimizations are possible, but we need to be generic
-
-%D First we take care of non||\CONTEXT\ use (newlines needed,
-%D expandafter not -).
-
-\ifx \undefined \writestatus \input supp-mis.tex \relax \fi
-
-\ifx \undefined \convertMPtoPDF \else \expandafter \endinput \fi
-
-\ifx \undefined \StartLatexHack \else \StartLatexHack \fi
+%D Beware, we cannot use \zeropoint here since it may be
+%D defined in the range \dimen 0 - 20 which we happen to use
+%D as scratch registers; inside context we may consider
+%D using dedicated registers.
%D This module handles some \PDF\ conversion and insertions
%D topics. By default, the macros use the \PDFTEX\ primitive
@@ -49,8 +171,6 @@
%D default engine for \TEX\ distributions, we need a more complex
%D test.
-\writestatus{loading}{Context Support Macros / PDF (2004.03.26)}
-
\unprotect
\ifx\PDFcode\undefined
@@ -69,7 +189,7 @@
%D First we define a handy constant:
-\bgroup \catcode`\%=\@@other \xdef\letterpercent{\string%} \egroup
+\bgroup \defineMPtoPDFfallbacks \catcode`\%=\@@other \xdef\letterpercent{\string%} \egroup
%D \macros
%D {pdfimage,pdfimages,pdfclippedimage}
@@ -94,12 +214,6 @@
%D \pdfclippedimage <optional dimensions> {file} {l} {r} {t} {b}
%D \stoptyping
-% \ifx\pdftexversion\undefined % no \m!systems for the sake of latex
-% \writestatus{systems}{Why not use pdf(e)TeX binaries?}
-% \protect
-% \expandafter\endinput
-% \fi
-
\ifx\pdftexversion\undefined \else \ifnum\pdftexversion>13
\def\pdfimage#1#%
@@ -114,11 +228,8 @@
\def\dopdfimages#1#2#3%
{\immediate\pdfximage#1{#2}%
- \immediate\pdfobj
- {[ << /Image \the\pdflastximage\space0 R
- /DefaultForPrinting true >> ]}%
- \immediate\pdfximage#1
- attr {/Alternates \the\pdflastobj\space0 R}{#3}%
+ \immediate\pdfobj{[ << /Image \the\pdflastximage\space0 R /DefaultForPrinting true >> ]}%
+ \immediate\pdfximage#1 attr {/Alternates \the\pdflastobj\space0 R}{#3}%
\pdfrefximage\pdflastximage}
\def\pdfclippedimage#1#% specs {file}{left}{right}{top}{bottom}
@@ -165,218 +276,12 @@
\fi \fi
-%D \macros
-%D {convertPDFtoPDF}
-%D
-%D \PDFTEX\ supports verbatim inclusion of \PDF\ code. The
-%D following macro takes care of inserting externally defined
-%D illustrations in \PDF\ format. According to a suggestion
-%D Tanmoy Bhattacharya posted to the \PDFTEX\ mailing list, we
-%D first skip lines until \type{stream} is reached and then
-%D copy lines until \type{endstream} is encountered. This
-%D scheme only works with vectorized graphics in which no
-%D indirect references to objects are used. Bitmaps also don't
-%D work. Interpreting their specifications is beyond the
-%D current implementation.
-%D
-%D \starttyping
-%D \convertPDFtoPDF
-%D {filename}
-%D {x scale} {y scale}
-%D {x offset } {y offset}
-%D {width} {height}
-%D \stoptyping
-%D
-%D When the scales are set to~1, the last last four values
-%D are the same as the bounding box, e.g.
-%D
-%D \starttyping
-%D \convertPDFtoPDF{mp-pra-1.pdf} {1} {1}{-1bp}{-1bp}{398bp}{398bp}
-%D \convertPDFtoPDF{mp-pra-1.pdf}{.5}{.5} {0bp} {0bp}{199bp}{199bp}
-%D \stoptyping
-%D
-%D Keep in mind, that this kind of copying only works for
-%D pure and valid pdf code (without fonts).
-
-%D The scanning and copying is straightforward and quite fast.
-%D To speed up things we use two constants.
-
-\def\@@PDFstream@@ {stream}
-\def\@@PDFendstream@@ {endstream}
-
-%D \macros
-%D {PDFmediaboxprefered}
-%D
-%D If needed, the macros can scan for the mediabox that
-%D specifies the dimensions and offsets of the graphic. When
-%D we say:
-%D
-%D \starttyping
-%D \PDFmediaboxpreferedtrue
-%D \stoptyping
-%D
-%D the mediabox present in the file superseded the user
-%D specified, already scaled and calculated offset and
-%D dimensions. Beware: the user supplied values are not the
-%D bounding box ones!
-
-%D This code has become obsolete.
-
-% \newif\ifPDFmediaboxprefered
-
-\def\setPDFboundingbox#1#2#3#4#5#6%
- {\dimen0=#1\dimen0=#5\dimen0
- \ScaledPointsToBigPoints{\number\dimen0}\PDFxoffset
- \dimen0=#3\dimen0=#5\dimen0
- \xdef\PDFwidth{\the\dimen0}%
- \dimen0=#2\dimen0=#6\dimen0
- \ScaledPointsToBigPoints{\number\dimen0}\PDFyoffset
- \dimen0=#4\dimen0=#6\dimen0
- \xdef\PDFheight{\the\dimen0}%
- \global\let\PDFxoffset\PDFxoffset
- \global\let\PDFyoffset\PDFyoffset}
-
-\def\setPDFmediabox#1[#2 #3 #4 #5]#6\done
- {\dimen2=#2bp\dimen2=-\dimen2 % \dimen2=-#2bp also works since tex handles --
- \dimen4=#3bp\dimen4=-\dimen4 % \dimen4=-#3bp also works since tex handles --
- \dimen6=#4bp\advance\dimen6 \dimen2
- \dimen8=#5bp\advance\dimen8 \dimen4
- \setPDFboundingbox{\dimen2}{\dimen4}{\dimen6}{\dimen8}\PDFxscale\PDFyscale}
-
-% \def\checkPDFmediabox#1/MediaBox#2#3\done
-% {\ifx#2\relax \else
-% \message{mediabox}%
-% \setPDFmediabox#2#3\done
-% \fi}
-
-%D We use the general macro \type{\doprocessfile} and feed this
-%D with a line handling macro that changes it's behavior when
-%D the stream operators are encountered.
-
-% \def\handlePDFline
-% {\ifx\@@PDFstream@@\fileline
-% \let\doprocessPDFline\copyPDFobject
-% \startPDFtoPDF
-% \else\ifPDFmediaboxprefered
-% \expandafter\checkPDFmediabox\fileline/MediaBox\relax\done
-% \fi\fi}
-
-% \def\copyPDFobject
-% {\ifx\@@PDFendstream@@\fileline
-% \ifPDFmediaboxprefered
-% \let\doprocessPDFline\findPDFmediabox
-% \else
-% \let\doprocessPDFline\relax
-% \fi
-% \else
-% \advance\scratchcounter 1
-% \PDFcode{\fileline}%
-% \fi}
-
-% \def\findPDFmediabox
-% {\expandafter\checkPDFmediabox\fileline/MediaBox\relax\done}
-
%D The main conversion macro wraps the \PDF\ codes in a box
%D that is output as an object. The graphics are embedded
%D in~\type{q} and~\type{Q} and are scaled and positioned using
%D one transform call (\type{cm}). This saves some additional
%D scaling.
-%D \starttyping
-%D \def\startPDFtoPDF%
-%D {\setbox0=\vbox\bgroup
-%D \message{[PDF to PDF \PDFfilename}%
-%D \forgetall
-%D \scratchcounter=0
-%D \let\stopPDFtoPDF=\dostopPDFtoPDF}
-%D
-%D \def\dostopPDFtoPDF%
-%D {\ifnum\scratchcounter<0 \scratchcounter=1 \fi
-%D \message{(\the\scratchcounter\space lines)]}%
-%D \egroup
-%D \wd0=\PDFwidth
-%D \vbox to \PDFheight
-%D {\forgetall
-%D \vfill
-%D \PDFcode{q}%
-%D \PDFcode{1 0 0 1 \PDFxoffset\space \PDFyoffset\space cm}%
-%D \PDFcode{\PDFxscale\space 0 0 \PDFyscale\space 0 0 cm}%
-%D \box0
-%D \PDFcode{Q}}}
-%D
-%D \def\stopPDFtoPDF%
-%D {\message{[PDF to PDF \PDFfilename\space not found]}}
-%D
-%D \def\convertPDFtoPDF#1#2#3#4#5#6#7%
-%D {\bgroup
-%D \def\PDFfilename{#1}%
-%D \def\PDFxscale {#2}%
-%D \def\PDFyscale {#3}%
-%D \setPDFboundingbox{#4}{#5}{#6}{#7}{1}{1}%
-%D \uncatcodespecials
-%D \endlinechar=-1
-%D \let\doprocessPDFline=\handlePDFline
-%D \doprocessfile\scratchread\PDFfilename\doprocessPDFline
-%D \stopPDFtoPDF
-%D \egroup}
-
-\def\convertPDFtoPDF#1#2#3#4#5#6#7%
- {\message{[PDF to PDF use \string\PDFcode instead]}%
- \vbox{use the direct method instead}}
-
-%D \macros
-%D {dogetPDFmediabox}
-%D
-%D The next macro can be used to find the mediabox of a \PDF\
-%D illustration.
-%D
-%D \starttyping
-%D \dogetPDFmediabox
-%D {filename}
-%D {new dimen}{new dimen}{new dimen}{new dimen}
-%D \stoptyping
-%D
-%D Beware of dimen clashes: this macro uses the 5~default
-%D scratch registers! When no file or mediabox is found, the
-%D dimensions are zeroed.
-
-\def\dogetPDFmediabox#1#2#3#4#5%
- {\bgroup
- \def\PDFxscale{1}%
- \def\PDFyscale{1}%
- \uncatcodespecials
- \endlinechar\minusone
- \def\checkPDFtypepage##1/Type /Page##2##3\done%
- {\ifx##2\relax
- \else\if##2s% accept /Page and /Pages
- \let\doprocessPDFline\findPDFmediabox
- \else
- \let\doprocessPDFline\findPDFmediabox
- \fi\fi}%
- \def\findPDFtypepage
- {\expandafter\checkPDFtypepage\fileline/Type /Page\relax\done}%
- \def\checkPDFmediabox##1/MediaBox##2##3\done%
- {\ifx##2\relax \else
- \setPDFmediabox##2##3\done
- \fileprocessedtrue
- \fi}%
- \def\findPDFmediabox
- {\expandafter\checkPDFmediabox\fileline/MediaBox\relax\done}%
- \let\doprocessPDFline\findPDFtypepage
- \doprocessfile\scratchread{#1}\doprocessPDFline
- \egroup
- \ifx\PDFxoffset\undefined
- #2\zeropoint
- #3\zeropoint
- #4\zeropoint
- #5\zeropoint
- \else
- #2=\PDFxoffset\onebasepoint
- #3=\PDFyoffset\onebasepoint
- #4=\PDFwidth
- #5=\PDFheight
- \fi}
-
%D \macros
%D {convertMPtoPDF}
%D
@@ -505,17 +410,17 @@
\def\@@MP{@@MP}
\def\setMPargument% #1%
- {\advance\nofMParguments \plusone
+ {\advance\nofMParguments 1
\expandafter\def
\csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname} % {#1}
\def\letMPargument
- {\advance\nofMParguments \plusone
+ {\advance\nofMParguments 1
\expandafter\let
\csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname}
\def\setMPsequence#1 %
- {\advance\nofMParguments \plusone
+ {\advance\nofMParguments 1
\expandafter\def
\csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname{#1}%
\handleMPsequence}
@@ -527,12 +432,12 @@
{\csname\@@MP\the\nofMPsegments\number#1\endcsname}
\def\dogMPa#1%
- {\@EAEAEA\do\csname\@@MP0\number#1\endcsname}
+ {\expandafter\expandafter\expandafter\do\csname\@@MP0\number#1\endcsname}
\def\setMPkeyword#1 %
{\expandafter\def\csname\@@MP\the\nofMPsegments0\endcsname{#1}%
- \advance\nofMPsegments \plusone
- \nofMParguments\zerocount}
+ \advance\nofMPsegments 1
+ \nofMParguments0}
\def\getMPkeyword% #1%
{\csname\@@MP\the\nofMPsegments0\endcsname} % {\csname\@@MP#10\endcsname}
@@ -549,7 +454,7 @@
%D when dealing with comments.
\def\doresetMPstack
- {\nofMParguments\zerocount}
+ {\nofMParguments0}
\def\resetMPstack
{\let\handleMPgraphic\handleMPendgraphic
@@ -578,7 +483,6 @@
\def\octalMPcharacter#1#2#3%
{\char'#1#2#3\relax}
-
%D curly braces and squarly brackets are stored in the argument stack
%D as part of strings, for instance in:
%D
@@ -598,6 +502,7 @@
%D when needed we either ignore or obey them
\bgroup
+\defineMPtoPDFfallbacks
\catcode`\|=\@@comment
\catcode`\%=\@@active
\catcode`\[=\@@active
@@ -654,6 +559,7 @@
%D that we cannot change the catcodes in between.
\bgroup
+\defineMPtoPDFfallbacks
\catcode`\%=\@@active
\gdef\startMPscanning{\let%=\startMPconversion}
\egroup
@@ -681,17 +587,15 @@
%D speed up the conversion by handling the \type{path}
%D seperately.
-\def\@EAEAEA{\expandafter\expandafter\expandafter} % to be sure
-
\def\dohandleMPsequence#1%
{\ifdone
\ifcase\lccode`#1\relax
- \@EAEAEA\dohandleMPsequenceA
+ \expandafter\expandafter\expandafter\dohandleMPsequenceA
\else
- \@EAEAEA\dohandleMPsequenceB
+ \expandafter\expandafter\expandafter\dohandleMPsequenceB
\fi
\else
- \@EA\dohandleMPsequenceC
+ \expandafter\dohandleMPsequenceC
\fi#1}
%\def\dohandleMPsequenceA#1 %
@@ -851,20 +755,20 @@
{\ifnum#1>\currentMPboundingbox
\xdef\MPllx{#2}\xdef\MPlly{#3}%
\xdef\MPurx{#4}\xdef\MPury{#5}%
- \dimen0=#2\onepoint
+ \dimen0=#2pt
\dimen0=-\MPxscale\dimen0
- \dimen2=#3\onepoint
+ \dimen2=#3pt
\dimen2=-\MPyscale\dimen2
\xdef\MPxoffset{\withoutpt\the\dimen0}%
\xdef\MPyoffset{\withoutpt\the\dimen2}%
- \dimen0=#2\onebasepoint
+ \dimen0=#2bp
\dimen0=-\dimen0
- \dimen2=#3\onebasepoint
+ \dimen2=#3bp
\dimen2=-\dimen2
- \advance\dimen0 #4\onebasepoint
+ \advance\dimen0 #4bp
\dimen0=\MPxscale\dimen0
\xdef\MPwidth{\the\dimen0}%
- \advance\dimen2 #5\onebasepoint
+ \advance\dimen2 #5bp
\xdef\MPyshift{\the\dimen2}% unscaled
\dimen2=\MPyscale\dimen2
\xdef\MPheight{\the\dimen2}%
@@ -874,7 +778,7 @@
\let\handleMPsequence\dohandleMPsequence
\let\next\handleMPsequence
\ifskipemptyMPgraphic
- \ifdim\MPheight=\zeropoint\relax\ifdim\MPwidth=\zeropoint\relax
+ \ifdim\MPheight=0pt\relax\ifdim\MPwidth=0pt\relax
\def\next{\endinput\finishMPgraphic}%
\fi\fi
\fi
@@ -932,31 +836,31 @@
\let\ \relax % mp breaks long lines and appends a \
\edef\size{\gMPa\nofMParguments}%
\ifx\size\PSnfont % round font size (to pt)
- \advance\nofMParguments \minusone
- \expandafter\scratchdimen\gMPa\nofMParguments\onepoint\relax
- \ifdim\scratchdimen<\onepoint
+ \advance\nofMParguments -1
+ \expandafter\scratchdimen\gMPa\nofMParguments pt\relax
+ \ifdim\scratchdimen<1pt
\def\size{1pt}%
\else
- \advance\scratchdimen .5\onepoint
+ \advance\scratchdimen .5pt
\def\size##1.##2\relax{\def\size{##1pt}}%
\expandafter\size\the\scratchdimen\relax
\fi
\else
\edef\size{\size bp}%
\fi
- \advance\nofMParguments \minusone
+ \advance\nofMParguments -1
%\font\temp=\gMPa\nofMParguments\space at \size
\let\temp\relax % to be sure
\setMPfshowfont{\gMPa\nofMParguments}\size
- \advance\nofMParguments \minusone
+ \advance\nofMParguments -1
\temp
\MPfshowcommand
- {\ifnum\nofMParguments=\plusone
+ {\ifnum\nofMParguments=1
\def\do(##1){##1}%
\dogMPa1%
\else
% we need to catch ( a ) (a a a) (\123 \123 \123) etc
- \scratchcounter\plusone
+ \scratchcounter1
\def\dodo##1% Andreas Fieger's bug: (\304...)
{\edef\!!stringa{##1\empty\empty}% and another one: ( 11) -> \ifx 11
\ifx\!!stringa\MPspacechar\MPspacechar\else\expandafter##1\fi}%
@@ -964,7 +868,7 @@
\dogMPa\scratchcounter\MPspacechar
\let\do\relax
\loop
- \advance\scratchcounter \plusone
+ \advance\scratchcounter 1
\ifnum\scratchcounter<\nofMParguments\relax
\gMPa\scratchcounter\MPspacechar
\repeat
@@ -972,25 +876,11 @@
\dogMPa\scratchcounter
\fi
\unskip}}%
- %
- % this fails in some versions of pdftex
- %
- % \dimen0=\lastMPmoveY bp
- % \advance\dimen0 by \ht0
- % \ScaledPointsToBigPoints{\number\dimen0}\lastMPmoveY
- % \PDFcode{n q 1 0 0 1 \lastMPmoveX\space\lastMPmoveY\space cm}%
- % \dimen0=\ht0
- % \advance\dimen0 by \dp0
- % \box0
- % \vskip-\dimen0
- % \PDFcode{Q}%
- % \egroup}
- %
\setbox\scratchbox\hbox
- {\hskip\lastMPmoveX\onebasepoint\raise\lastMPmoveY\onebasepoint\box\scratchbox}%
- \ht\scratchbox\zeropoint
- \dp\scratchbox\zeropoint
- \wd\scratchbox\zeropoint
+ {\hskip\lastMPmoveX bp\raise\lastMPmoveY bp\box\scratchbox}%
+ \ht\scratchbox0pt%
+ \dp\scratchbox0pt%
+ \wd\scratchbox0pt%
\box\scratchbox
\egroup}
@@ -1032,11 +922,11 @@
{\bgroup
\ignoreMPspecials
\def\somestring{[}%
- \scratchcounter\plusone
+ \scratchcounter1
\loop
\ifnum\scratchcounter<\nofMParguments
\edef\somestring{\somestring\space\gMPa\scratchcounter}%
- \advance\scratchcounter \plusone
+ \advance\scratchcounter 1
\repeat
\edef\somestring{\somestring]\gMPa\scratchcounter\space d}%
\PDFcode{\somestring}%
@@ -1070,7 +960,7 @@
%D so we can use this one to trigger setting the linewidth.
\def\handleMPdtransform
- {\ifdim\gMPa1\onepoint>\zeropoint
+ {\ifdim\gMPa1 pt>0pt
\PDFcode{\gMPa1 w}%
\def\next##1 ##2 ##3 ##4 ##5 ##6 {\handleMPsequence}%
\else
@@ -1114,7 +1004,7 @@
\let\closeMPpath\relax
\let\flushMPpath\flushnormalMPpath
\resetMPstack
- \nofMPsegments\plusone
+ \nofMPsegments1
\let\handleMPsequence\dohandleMPpath
\dohandleMPpath}
@@ -1160,19 +1050,19 @@
% \def\flushnormalMPpath
% {\scratchcounter\nofMPsegments
-% \nofMPsegments\plusone
+% \nofMPsegments 1
% \loop
% \flushnormalMPsegment
-% \advance\nofMPsegments \plusone
+% \advance\nofMPsegments 1
% \ifnum\nofMPsegments<\scratchcounter
% \repeat}
%
% \def\flushconcatMPpath
% {\scratchcounter\nofMPsegments
-% \nofMPsegments\plusone
+% \nofMPsegments 1
% \loop
% \flushconcatMPsegment
-% \advance\nofMPsegments \plusone
+% \advance\nofMPsegments 1
% \ifnum\nofMPsegments<\scratchcounter
% \repeat}
%
@@ -1180,14 +1070,14 @@
\def\doflushsomeMPpath
{\dodoflushsomeMPpath
- \advance\nofMPsegments \plusone
+ \advance\nofMPsegments 1
\ifnum\nofMPsegments<\scratchcounter
\expandafter\doflushsomeMPpath
\fi}
\def\flushsomeMPpath
{\scratchcounter\nofMPsegments
- \nofMPsegments\plusone
+ \nofMPsegments 1
\doflushsomeMPpath}
\def\flushnormalMPpath{\let\dodoflushsomeMPpath\flushnormalMPsegment\flushsomeMPpath}
@@ -1225,7 +1115,7 @@
%OLD \def\doMPreducedimen#1
%OLD {\count0\MPconcatfactor
-%OLD \advance\dimen#1 \ifdim\dimen#1>\zeropoint .5\else -.5\fi\count0
+%OLD \advance\dimen#1 \ifdim\dimen#1>0pt .5\else -.5\fi\count0
%OLD \divide\dimen#1 \count0\relax}
%OLD % too inaccurate (see old pragma logo)
@@ -1235,7 +1125,7 @@
%OLD \divide\dimen#1 \count0\relax}
%OLD \def\doMPreducedimen#1
-%OLD {\advance\dimen#1 \ifdim\dimen#1>\zeropoint .5\else -.5\fi\MPconcatfactor
+%OLD {\advance\dimen#1 \ifdim\dimen#1>0pt .5\else -.5\fi\MPconcatfactor
%OLD \divide\dimen#1 \MPconcatfactor}
%D The transformation code is rewritten by Daniel H. Luecking who
@@ -1259,13 +1149,13 @@
\newdimen\MPscratchDim % will be assigned global
\def\MPadjustdimen % sets \MPscratchDim and \MPscratchCnt
- {\MPscratchCnt\zerocount
+ {\MPscratchCnt0
\doMPadjustdimen}
\def\doMPadjustdimen
- {\ifdim\MPscratchDim>\onepoint
+ {\ifdim\MPscratchDim>1pt
\divide\MPscratchDim 2
- \advance\MPscratchCnt \plusone
+ \advance\MPscratchCnt 1
\expandafter\doMPadjustdimen
\fi}
@@ -1293,14 +1183,14 @@
\def\doMPreadjustdimen
{\ifnum\MPscratchCnt>2
\divide\scratchdimen 2
- \advance\MPscratchCnt \minusone
+ \advance\MPscratchCnt -1
\expandafter\doMPreadjustdimen
\fi}
\def\MPreciprocaldeterminant
{\scratchdimen\withoutpt\the\dimen0 \dimen6 % s_x*s_y
\advance\scratchdimen - \withoutpt\the\dimen2 \dimen4 % s_x*s_y - r_x*r_y
- \ifdim\scratchdimen<\zeropoint % we need a positive dimension
+ \ifdim\scratchdimen<0pt % we need a positive dimension
\scratchdimen-\scratchdimen % for \MPadjustdimen (?)
\doMPreciprocal
\scratchdimen-\scratchdimen
@@ -1314,7 +1204,7 @@
% todo: dimexpr
\def\doMPreciprocal % replace \scratchdimen with its reciprocal
- {\ifdim\scratchdimen=\onepoint \else
+ {\ifdim\scratchdimen=1pt \else
\MPadjustdimen
\scratchcounter\MPnumerator
\divide\scratchcounter\scratchdimen
@@ -1323,20 +1213,20 @@
\fi}
%OLD \def\presetMPconcat
-%OLD {\dimen 0=\gMPs1\onepoint \doMPreducedimen 0 % r_x
-%OLD \dimen 2=\gMPs2\onepoint \doMPreducedimen 2 % s_x
-%OLD \dimen 4=\gMPs3\onepoint \doMPreducedimen 4 % s_y
-%OLD \dimen 6=\gMPs4\onepoint \doMPreducedimen 6 % r_y
-%OLD \dimen 8=\gMPs5\onepoint \doMPreducedimen 8 % t_x
-%OLD \dimen10=\gMPs6\onepoint \doMPreducedimen10 } % t_y
+%OLD {\dimen 0=\gMPs1pt \doMPreducedimen 0 % r_x
+%OLD \dimen 2=\gMPs2pt \doMPreducedimen 2 % s_x
+%OLD \dimen 4=\gMPs3pt \doMPreducedimen 4 % s_y
+%OLD \dimen 6=\gMPs4pt \doMPreducedimen 6 % r_y
+%OLD \dimen 8=\gMPs5pt \doMPreducedimen 8 % t_x
+%OLD \dimen10=\gMPs6pt \doMPreducedimen10 } % t_y
%OLD
%OLD \def\presetMPscale
-%OLD {\dimen 0=\gMPs1\onepoint \doMPreducedimen 0
-%OLD \dimen 2 \zeropoint
-%OLD \dimen 4 \zeropoint
-%OLD \dimen 6=\gMPs2\onepoint \doMPreducedimen 6
-%OLD \dimen 8 \zeropoint
-%OLD \dimen10 \zeropoint}
+%OLD {\dimen 0=\gMPs1pt \doMPreducedimen 0
+%OLD \dimen 2=0pt
+%OLD \dimen 4=0pt
+%OLD \dimen 6=\gMPs2pt \doMPreducedimen 6
+%OLD \dimen 8=0pt
+%OLD \dimen10=0pt}
\def\cleanupMPconcat
{\ignoreMPspecials
@@ -1345,24 +1235,24 @@
\keepMPspecials}
\def\presetMPconcat
- {\dimen 0=\gMPs1\onepoint % s_x
- \dimen 2=\gMPs2\onepoint % r_x
- \dimen 4=\gMPs3\onepoint % r_y
- \dimen 6=\gMPs4\onepoint % s_y
- \dimen 8=\gMPs5\onepoint % t_x
- \dimen10=\gMPs6\onepoint} % t_y
+ {\dimen 0=\gMPs1pt % s_x
+ \dimen 2=\gMPs2pt % r_x
+ \dimen 4=\gMPs3pt % r_y
+ \dimen 6=\gMPs4pt % s_y
+ \dimen 8=\gMPs5pt % t_x
+ \dimen10=\gMPs6pt} % t_y
\def\presetMPscale
- {\dimen 0=\gMPs1\onepoint
- \dimen 2 \zeropoint
- \dimen 4 \zeropoint
- \dimen 6=\gMPs2\onepoint
- \dimen 8 \zeropoint
- \dimen10 \zeropoint}
+ {\dimen 0=\gMPs1pt
+ \dimen 2=0pt
+ \dimen 4=0pt
+ \dimen 6=\gMPs2pt
+ \dimen 8=0pt
+ \dimen10=0pt}
\def\noMPtranslate % use this one grouped
- {\dimen 8 \zeropoint % t_x
- \dimen10 \zeropoint} % t_y
+ {\dimen 8=0pt % t_x
+ \dimen10=0pt} % t_y
%D \starttyping
%D \def\doMPconcat#1#2#3#4%
@@ -1538,18 +1428,18 @@
%OLD {\dimen12=#1pt % p_x
%OLD \dimen14=#3pt % p_y
%OLD %
-%OLD \chardef\MPfactor\zerocount
+%OLD \chardef\MPfactor0
%OLD \ifdim\dimen4<\MPcriteriumB\ifdim\dimen4>-\MPcriteriumB
%OLD \ifdim\dimen6<\MPcriteriumB\ifdim\dimen6>-\MPcriteriumB
%OLD \ifdim\dimen8<\MPcriteriumB\ifdim\dimen8>-\MPcriteriumB
%OLD \ifdim\dimen10<\MPcriteriumB\ifdim\dimen10>-\MPcriteriumB
-%OLD \chardef\MPfactor\plusone
+%OLD \chardef\MPfactor1
%OLD \fi\fi
%OLD \fi\fi
%OLD \fi\fi
%OLD \fi\fi
%OLD \ifcase\MPfactor % spurious 0 removed
-%OLD \chardef\MPfactor\plusone
+%OLD \chardef\MPfactor1
%OLD \ifdim\dimen12<\MPcriteriumA\ifdim\dimen12>-\MPcriteriumA
%OLD \ifdim\dimen14<\MPcriteriumA\ifdim\dimen14>-\MPcriteriumA
%OLD \chardef\MPfactor16
@@ -1591,8 +1481,8 @@
%OLD \multiply \dimen20 \dimen10
%OLD \advance \dimen12 -\dimen20
%OLD %
-%OLD \ifdim\dimen16=\onepoint \else
-%OLD \ifdim\dimen16>\MPconcatfactor \onepoint \relax
+%OLD \ifdim\dimen16=1pt \else
+%OLD \ifdim\dimen16>\MPconcatfactor 1pt \relax
%OLD \doMPreducedimen16
%OLD \divide \dimen18 \dimen16 \doMPexpanddimen18
%OLD \divide \dimen12 \dimen16 \doMPexpanddimen12
@@ -1622,8 +1512,8 @@
%D If this should ever cause problems, the scale factors can be reduced.
% \def\doMPconcat#1#2#3#4%
-% {\dimen12=#1pt % p_x % #1\onepoint
-% \dimen14=#3pt % p_y % #3\onepoint
+% {\dimen12=#1pt % p_x % #1pt
+% \dimen14=#3pt % p_y % #3pt
% \advance\dimen12 -\dimen8 % p_x - t_x
% \advance\dimen14 -\dimen10 % p_y - t_y
% \dimen18=\withoutpt\the\dimen6 \dimen12 % s_y(p_x - t_x)
@@ -1637,8 +1527,8 @@
% \edef#4{\withoutpt\the\dimen14}} % p_y^\prime
\def\doMPconcat#1#2#3#4%
- {\dimen12=#1pt % p_x % #1\onepoint
- \dimen14=#3pt % p_y % #3\onepoint
+ {\dimen12=#1pt % p_x % #1pt
+ \dimen14=#3pt % p_y % #3pt
\advance\dimen12 -\dimen8 % p_x - t_x
\advance\dimen14 -\dimen10 % p_y - t_y
\dimen18=\withoutpt\the\dimen6 \dimen12 % s_y(p_x - t_x)
@@ -1918,7 +1808,7 @@
\fi
\let\handleMPsequence\dohandleMPsequence
\resetMPstack
- \nofMPsegments\zerocount
+ \nofMPsegments0
\handleMPsequence}
%D The following \METAPOST\ code is quite valid but, when
@@ -1937,7 +1827,7 @@
{\ifcase\finiMPpath
\ifnum\nofMPsegments<3 % n is one ahead
\message{omitting zero clip path}%
- \nofMPsegments\zerocount
+ \nofMPsegments0
\fi
\fi}
@@ -1960,9 +1850,9 @@
\def\dohandleMPpath#1%
{\ifcase\lccode`#1\relax
- \@EA\dohandleMPpathA
+ \expandafter\dohandleMPpathA
\else
- \@EA\dohandleMPpathB
+ \expandafter\dohandleMPpathB
\fi#1}
%\def\dohandleMPpathA#1 %
@@ -2056,10 +1946,11 @@
\def\convertMPtoPDF % #1#2#3%
{\bgroup
+ \defineMPtoPDFfallbacks
\ifx\pdfdecimaldigits\undefined\else \pdfdecimaldigits=5 \fi % new
\setbox\scratchbox\vbox\bgroup
- \xdef\MPheight{\zeropoint}%
- \xdef\MPwidth {\zeropoint}%
+ \xdef\MPheight{0pt}%
+ \xdef\MPwidth {0pt}%
\forgetall
\offinterlineskip
\startMPresources
@@ -2072,16 +1963,11 @@
\let\finishMPgraphic\egroup
\doprocessMPtoPDFfile}
+\let\setMPextensions\relax
+
\def\doprocessMPtoPDFfile#1#2#3% file xscale yscale
- {% the following line is needed for latex where onepoint is not
- % onepoint but a number (maxdimen); some day i'll make a latex
- % variant of this file so that i no longer have to deal with such
- % issues; then i'll also speed up this module using a few context
- % tricks
- %
- \let\onepoint\onerealpoint
- %
- \setMPspecials
+ {\setMPspecials
+ \setMPextensions
\the\everyMPtoPDFconversion
\catcode`\^^M=\@@endofline
\startMPscanning
@@ -2090,63 +1976,16 @@
\xdef\MPyscale{#3}%
\xdef\MPxoffset{0}%
\xdef\MPyoffset{0}%
- \xdef\MPyshift{\zeropoint}%
+ \xdef\MPyshift{0pt}%
\donefalse
\let\handleMPsequence\dohandleMPsequence
\message{[MP to PDF]}% was: [MP to PDF #1] but there is a (#1) anyway
\input#1\relax}
-% strange rounding/clip in pdftex/viewer
-%
-% \def\finishMPgraphic
-% {\stopMPresources
-% \egroup
-% \ifx\pdftexversion\undefined\else\ifnum\pdftexversion<14 % for the moment
-% \chardef\makeMPintoPDFobject=0
-% \fi\fi
-% \ifcase\makeMPintoPDFobject\or\or\ifx\currentPDFresources\empty\else
-% \chardef\makeMPintoPDFobject=1
-% \fi\fi
-% \setbox\scratchbox=\vbox
-% {\forgetall
-% \hbox
-% {\PDFcode{q \MPxscale\space 0 0 \MPyscale\space \MPxoffset\space \MPyoffset\space cm}%
-% \lower\MPyshift\box\scratchbox % unscaled shift
-% \PDFcode{Q}}}%
-% \ht\scratchbox\MPheight
-% \wd\scratchbox\MPwidth
-% \dp\scratchbox\zeropoint
-% \ifcase\makeMPintoPDFobject
-% \box\scratchbox
-% \or
-% \immediate\pdfxform resources{\currentPDFresources}\scratchbox
-% \xdef\lastPDFMPobject{\the\pdflastxform}%
-% \pdfrefxform\lastPDFMPobject
-% \global\let\currentPDFresources\empty
-% \else
-% \box\scratchbox
-% \fi
-% \egroup}
-%
-% funny clip in viewer
-%
-% \setbox\scratchbox=\vbox
-% {\forgetall
-% \dimen0=\MPllx bp
-% \dimen2=\MPlly bp
-% \setbox\scratchbox=\hbox{\hskip-\dimen0\raise-\dimen2\box\scratchbox}%
-% \ht\scratchbox=\zeropoint
-% \dp\scratchbox=\zeropoint
-% \wd\scratchbox=\zeropoint
-% \hbox
-% {\PDFcode{q \MPxscale\space 0 0 \MPyscale\space 0 0 cm}%
-% \lower\MPshift\box\scratchbox
-% \PDFcode{Q}}}%
-
-% \let\PDFMPformoffset\zeropoint
-
\def\PDFMPformoffset
- {\ifx\objectoffset\undefined\zeropoint\else\objectoffset\fi}
+ {\ifx\objectoffset\undefined0pt\else\objectoffset\fi}
+
+\chardef\blackoutMPgraphic0 % in ConTeXt 1
\def\finishMPgraphic
{\stopMPresources
@@ -2155,11 +1994,12 @@
{\forgetall
\hbox
{\PDFcode{q \MPxscale\space 0 0 \MPyscale\space \MPxoffset\space \MPyoffset\space cm}%
+ \ifcase\blackoutMPgraphic\or\PDFcode{0 g 0 G}\fi
\lower\MPyshift\box\scratchbox % unscaled shift
\PDFcode{Q}}}%
\ht\scratchbox\MPheight
\wd\scratchbox\MPwidth
- \dp\scratchbox\zeropoint\relax
+ \dp\scratchbox0pt\relax
\dopackageMPgraphic\scratchbox
\egroup
\endinput}
@@ -2169,28 +2009,28 @@
\def\dopackageMPgraphic#1% #1 = boxregister
{%\ifx\pdfxform\undefined
- % \chardef\makeMPintoPDFobject\zerocount % no pdftex at all
+ % \chardef\makeMPintoPDFobject0 % no pdftex at all
%\else\ifx\pdftexversion\undefined
- % \chardef\makeMPintoPDFobject\zerocount % no pdftex at all
+ % \chardef\makeMPintoPDFobject0 % no pdftex at all
%\else\ifnum\pdftexversion<14
- % \chardef\makeMPintoPDFobject\zerocount % no resource support
+ % \chardef\makeMPintoPDFobject0 % no resource support
%\else
% % keep the default value
%\fi\fi\fi
\ifcase\makeMPintoPDFobject\or\or\ifx\currentPDFresources\empty\else
% an existing value of 2 signals object support (set elsewhere)
- \chardef\makeMPintoPDFobject\plusone
+ \chardef\makeMPintoPDFobject1
\fi\fi
\ifcase\makeMPintoPDFobject
\box#1%
\or
\scratchdimen\PDFMPformoffset\relax
- \ifdim\scratchdimen>\zeropoint % compensate for error
+ \ifdim\scratchdimen>0pt % compensate for error
\setbox#1\vbox spread 2\scratchdimen
{\forgetall\vss\hbox spread 2\scratchdimen{\hss\box#1\hss}\vss}%
\fi
\setMPPDFobject{\currentPDFresources}{#1}%
- \ifdim\scratchdimen>\zeropoint % compensate for error
+ \ifdim\scratchdimen>0pt % compensate for error
\vbox to \MPheight
{\forgetall\vss\hbox to \MPwidth{\hss\getMPPDFobject\hss}\vss}%
\else
@@ -2209,6 +2049,7 @@
\else\ifnum\pdftexversion<14
\def\getMPPDFobject{\box#2}%
\else
+ \ifx\everyPDFxform\undefined\else\the\everyPDFxform\fi
\immediate\pdfxform resources{#1}#2%
\edef\getMPPDFobject{\noexpand\pdfrefxform\the\pdflastxform}%
\fi\fi\fi}
@@ -2256,6 +2097,4 @@
%D does all the calculations. Converting other \POSTSCRIPT\
%D files would drive both me and \TEX\ crazy.
-\ifx\undefined\StopLatexHack \else \StopLatexHack \fi
-
\protect \endinput