diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/page-app.mkiv | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-app.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-app.mkiv | 197 |
1 files changed, 109 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-app.mkiv b/Master/texmf-dist/tex/context/base/page-app.mkiv index b42eef05403..df9607daaca 100644 --- a/Master/texmf-dist/tex/context/base/page-app.mkiv +++ b/Master/texmf-dist/tex/context/base/page-app.mkiv @@ -5,7 +5,7 @@ %D subtitle=Independent page building, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -17,106 +17,127 @@ \unprotect +\installcorenamespace{fittingpage} + +\installframedcommandhandler \??fittingpage {fittingpage} \??fittingpage + +\newdimen\d_page_fitting_width +\newdimen\d_page_fitting_height +\newbox \b_page_fitting + \definepapersize - [\??fp\s!dummy] - [\c!width=\fittingwd, - \c!height=\fittinght] + [fittingpage] + [\c!width=\d_page_fitting_width, + \c!height=\d_page_fitting_height] + +\definemakeup + [fittingpage] + [\c!textstate=\v!empty, + \c!doublesided=\v!no, + \c!pagestate=\fittingpageparameter\c!pagestate]% \definelayout - [\??fp\s!dummy] - [\c!width=\fittingwd,\c!height=\fittinght,\c!location=\v!middle, - \c!topspace=\!!zeropoint,\c!backspace=\!!zeropoint, - \c!cutspace=\!!zeropoint,\c!bottomspace=\!!zeropoint, - \c!textdistance=\!!zeropoint,\c!lines=0,\c!grid=\v!no, - \c!top=\!!zeropoint,\c!bottom=\!!zeropoint, - \c!margin=\!!zeropoint,\c!edge=\!!zeropoint, - \c!leftmargin=\!!zeropoint,\c!leftedge=\!!zeropoint, - \c!rightmargin=\!!zeropoint,\c!rightedge=\!!zeropoint, - \c!header=\!!zeropoint,\c!footer=\!!zeropoint] - -\def\dostartfittingpage[#1][#2]% + [fittingpage] + [\v!page] + [\c!width=\d_page_fitting_width, + \c!height=\d_page_fitting_height, + \c!location=\v!middle] + +\appendtoks + \setuevalue{\e!start\currentfittingpage}{\startfittingpage[\currentfittingpage]}% + \setuevalue{\e!stop \currentfittingpage}{\stopfittingpage}% +\to \everydefinefittingpage + +\unexpanded\def\startfittingpage + {\dodoubleempty\page_fitting_start} + +\def\page_fitting_start[#1][#2]% {\page % this is kind of tricky! there can be preceding page refs \autostarttext \bgroup % resulting in a zero height page; test fig-make ! + \setupinterlinespace[\v!top=0]% no topskip \def\currentfittingpage{#1}% \dontcomplain % runs under current page regime, i.e. page variables passed to mp - \getparameters[\currentfittingpage][\c!paper=,#2]% auto or size or nothing - \setbox\scratchbox\hbox - \bgroup - % needed later \getparameters[\currentfittingpage][\c!paper=,#2]% auto or size or nothing - \doifvalue{\currentfittingpage\c!margin}\v!page % undocumented - {\offsetbox + \setupcurrentfittingpage[\c!paper=,#2]% auto or size or nothing + \doifelsenothing{\fittingpageparameter\c!command} + \page_fitting_start_normal + \page_fitting_start_command} + +\def\page_fitting_start_command + {\grabuntil{\e!stop\currentfittingpage}\page_fitting_stop_command} + +\def\page_fitting_stop_command#1% + {\page_fitting_start_normal + \fittingpageparameter\c!command{#1}% + \page_fitting_stop_normal} + +\def\page_fitting_start_normal + {\setbox\b_page_fitting\hbox + \bgroup + \inheritedfittingpageframed + \bgroup + \gobblespacetokens} + +\unexpanded\def\page_fitting_stop_normal % todo: figure out why a small mp image gets shifted + {\removeunwantedspaces + \egroup + \egroup + % finalize + \doif{\fittingpageparameter\c!margin}\v!page + {\setbox\b_page_fitting\hbox\bgroup + \offsetbox [\c!leftoffset=\backspace, \c!rightoffset=\cutspace, \c!topoffset=\topspace, - \c!bottomoffset=\bottomspace]\hbox}% - \bgroup - \scale[\c!scale=\getvalue{\currentfittingpage\c!scale}]% - \bgroup\localframed[\currentfittingpage]% - \bgroup} - -\def\dostopfittingpage - {\egroup % localframed - \egroup % scale - \egroup % offsetbox - \egroup % scratchbox - \edef\fittingwd{\the\wd\scratchbox}% - \edef\fittinght{\the\ht\scratchbox}% - \startlocallayout - \ifdim\fittinght<\lineheight - % write status : too small - \setbox\scratchbox\vbox to \lineheight{\vss\box\scratchbox\vss}% - \edef\fittinght{\the\lineheight}% + \c!bottomoffset=\bottomspace] + {\box\b_page_fitting}% + \egroup}% + \doifsomething{\fittingpageparameter\c!scale} + {\setbox\b_page_fitting\hbox\bgroup + \scale[\c!scale=\fittingpageparameter\c!scale]{\box\b_page_fitting}% + \egroup}% + \ifdim\ht\b_page_fitting=\zeropoint + \ht\b_page_fitting\onepoint + \fi + \ifdim\wd\b_page_fitting=\zeropoint + \wd\b_page_fitting\onepoint \fi + \d_page_fitting_width \wd\b_page_fitting + \d_page_fitting_height\ht\b_page_fitting + \startlocallayout % still valid? \let\checkcurrentlayout\relax % else interference with odd/even layout \processaction - [\getvalue{\currentfittingpage\c!paper}] + [\fittingpageparameter\c!paper] [ \v!auto=>\def\fittingpapersize{\printpapersize}, \s!unknown=>\let\fittingpapersize\commalistelement, - \s!default=>\def\fittingpapersize{\??fp\s!dummy}]% - \expanded{\setuppapersize[\??fp\s!dummy][\fittingpapersize]}% - \definelayout - [\v!page]% - [\c!location=\v!middle, - \c!width=\fittingwd, - \c!height=\fittinght]% - \setuplayout - [\v!page]% - \startmakeup[\v!standard][\c!textstate=\v!empty,\c!doublesided=\v!no,\c!pagestate=\getvalue{\currentfittingpage\c!pagestate}]% - \centerbox{\box\scratchbox}% + \s!default=>\def\fittingpapersize{fittingpage}]% + \expanded{\setuppapersize[fittingpage][\fittingpapersize]}% + \startmakeup[fittingpage]% + \box\b_page_fitting \stopmakeup - \stoplocallayout + \stoplocallayout % still valid? \egroup \autostoptext} -%D \TEX\ pages (for \METAPOST\ pages, see \type {meta-fig}): - -\presetlocalframed[\??tg] - -\unexpanded\def\setupTEXpage - {\dodoubleargument\getparameters[\??tg]} - -\unexpanded\def\startTEXpage - {\dosingleempty\dostartTEXpage} - -\def\dostartTEXpage[#1]% - {\dostartfittingpage[\??tg][#1]\gobblespacetokens} +\let\stopfittingpage\page_fitting_stop_normal -\unexpanded\def\stopTEXpage - {\removelastspace - \dostopfittingpage} - -\setupTEXpage - [\c!scale=1000, - \c!pagestate=, +\setupfittingpage + [%\c!scale=1000, + %\c!pagestate=, \c!strut=\v!no, - \c!align=\v!normal, % needed, else problems ! + \c!align=\v!normal, \c!offset=\v!overlay, \c!width=\v!fit, \c!height=\v!fit, \c!frame=\v!off] +%D \TEX\ pages (for \METAPOST\ pages, see \type {meta-fig}): + +\definefittingpage + [TEXpage] + [\c!align=\v!normal] % needed, else problems ! + %D For Mojca: %D %D \starttyping @@ -127,17 +148,17 @@ %D maybe I should support stream=yes in framed. \unexpanded\def\startTEXstream - {\dosingleempty\dostartTEXstream} + {\dosingleempty\page_streams_TEX_start} -\def\dostartTEXstream[#1]% old code, to be redone +\def\page_streams_TEX_start[#1]% old code, to be redone {\page - \defineoutputstream[tex]% - \enableoutputstream[tex]% - \unexpanded\def\stopTEXstream - {\disableoutputstream - \startTEXpage - \outputstreamunvbox[tex]% - \stopTEXpage}} + \enableoutputstream[tex]} + +\unexpanded\def\stopTEXstream + {\disableoutputstream + \startTEXpage + \outputstreamunvbox[tex]% + \stopTEXpage} %D Application pages, a quick \MKIV\ hack: @@ -148,7 +169,7 @@ \def\TEXapplicationfilename{\jobname-texapplication.tex} -\def\stopTEXapplication +\unexpanded\def\stopTEXapplication {\savebuffer[\thedefinedbuffer{TEXapplication}][\TEXapplicationfilename]% \typesetfile[TEXapplication][\TEXapplicationfilename]\relax} @@ -160,9 +181,9 @@ %D \stoptyping \unexpanded\def\startpagefigure - {\dodoubleempty\dostartpagefigure} + {\dodoubleempty\page_figures_start} -\def\dostartpagefigure[#1][#2]% +\def\page_figures_start[#1][#2]% {\bgroup \getparameters[\??ex][\c!offset=\v!overlay,#2]% \startTEXpage[\c!offset=\@@exoffset]% @@ -173,9 +194,9 @@ \egroup} \def\pagefigure - {\dodoubleempty\dopagefigure} + {\dodoubleempty\page_figure} -\def\dopagefigure[#1][#2]% - {\dostartpagefigure[#1][#2]\stoppagefigure} +\def\page_figure[#1][#2]% + {\page_figures_start[#1][#2]\stoppagefigure} \protect \endinput |