summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpxl/mp-cont.mpxl107
-rw-r--r--metapost/context/base/mpxl/mp-page.mpxl156
-rw-r--r--metapost/context/base/mpxl/mp-tool.mpxl16
3 files changed, 162 insertions, 117 deletions
diff --git a/metapost/context/base/mpxl/mp-cont.mpxl b/metapost/context/base/mpxl/mp-cont.mpxl
index d153a9ccb..a89265224 100644
--- a/metapost/context/base/mpxl/mp-cont.mpxl
+++ b/metapost/context/base/mpxl/mp-cont.mpxl
@@ -29,47 +29,49 @@ permanent CurrentLayout, SwapPageState ;
extra_beginfig := extra_beginfig & "mfun_swapped := false ;" ;
-newscriptindex mfid_PaperHeight ; mfid_PaperHeight := scriptindex "PaperHeight" ; vardef PaperHeight = runscript mfid_PaperHeight enddef ;
-newscriptindex mfid_PaperWidth ; mfid_PaperWidth := scriptindex "PaperWidth" ; vardef PaperWidth = runscript mfid_PaperWidth enddef ;
-newscriptindex mfid_PrintPaperHeight ; mfid_PrintPaperHeight := scriptindex "PrintPaperHeight" ; vardef PrintPaperHeight = runscript mfid_PrintPaperHeight enddef ;
-newscriptindex mfid_PrintPaperWidth ; mfid_PrintPaperWidth := scriptindex "PrintPaperWidth" ; vardef PrintPaperWidth = runscript mfid_PrintPaperWidth enddef ;
-newscriptindex mfid_TopSpace ; mfid_TopSpace := scriptindex "TopSpace" ; vardef TopSpace = runscript mfid_TopSpace enddef ;
-newscriptindex mfid_BottomSpace ; mfid_BottomSpace := scriptindex "BottomSpace" ; vardef BottomSpace = runscript mfid_BottomSpace enddef ;
-newscriptindex mfid_BackSpace ; mfid_BackSpace := scriptindex "BackSpace" ; vardef BackSpace = runscript mfid_BackSpace enddef ;
-newscriptindex mfid_CutSpace ; mfid_CutSpace := scriptindex "CutSpace" ; vardef CutSpace = runscript mfid_CutSpace enddef ;
-newscriptindex mfid_MakeupHeight ; mfid_MakeupHeight := scriptindex "MakeupHeight" ; vardef MakeupHeight = runscript mfid_MakeupHeight enddef ;
-newscriptindex mfid_MakeupWidth ; mfid_MakeupWidth := scriptindex "MakeupWidth" ; vardef MakeupWidth = runscript mfid_MakeupWidth enddef ;
-newscriptindex mfid_TopHeight ; mfid_TopHeight := scriptindex "TopHeight" ; vardef TopHeight = runscript mfid_TopHeight enddef ;
-newscriptindex mfid_TopDistance ; mfid_TopDistance := scriptindex "TopDistance" ; vardef TopDistance = runscript mfid_TopDistance enddef ;
-newscriptindex mfid_HeaderHeight ; mfid_HeaderHeight := scriptindex "HeaderHeight" ; vardef HeaderHeight = runscript mfid_HeaderHeight enddef ;
-newscriptindex mfid_HeaderDistance ; mfid_HeaderDistance := scriptindex "HeaderDistance" ; vardef HeaderDistance = runscript mfid_HeaderDistance enddef ;
-newscriptindex mfid_TextHeight ; mfid_TextHeight := scriptindex "TextHeight" ; vardef TextHeight = runscript mfid_TextHeight enddef ;
-newscriptindex mfid_FooterDistance ; mfid_FooterDistance := scriptindex "FooterDistance" ; vardef FooterDistance = runscript mfid_FooterDistance enddef ;
-newscriptindex mfid_FooterHeight ; mfid_FooterHeight := scriptindex "FooterHeight" ; vardef FooterHeight = runscript mfid_FooterHeight enddef ;
-newscriptindex mfid_BottomDistance ; mfid_BottomDistance := scriptindex "BottomDistance" ; vardef BottomDistance = runscript mfid_BottomDistance enddef ;
-newscriptindex mfid_BottomHeight ; mfid_BottomHeight := scriptindex "BottomHeight" ; vardef BottomHeight = runscript mfid_BottomHeight enddef ;
-newscriptindex mfid_LeftEdgeWidth ; mfid_LeftEdgeWidth := scriptindex "LeftEdgeWidth" ; vardef LeftEdgeWidth = runscript mfid_LeftEdgeWidth enddef ;
-newscriptindex mfid_LeftEdgeDistance ; mfid_LeftEdgeDistance := scriptindex "LeftEdgeDistance" ; vardef LeftEdgeDistance = runscript mfid_LeftEdgeDistance enddef ;
-newscriptindex mfid_LeftMarginWidth ; mfid_LeftMarginWidth := scriptindex "LeftMarginWidth" ; vardef LeftMarginWidth = runscript mfid_LeftMarginWidth enddef ;
-newscriptindex mfid_LeftMarginDistance ; mfid_LeftMarginDistance := scriptindex "LeftMarginDistance" ; vardef LeftMarginDistance = runscript mfid_LeftMarginDistance enddef ;
-newscriptindex mfid_TextWidth ; mfid_TextWidth := scriptindex "TextWidth" ; vardef TextWidth = runscript mfid_TextWidth enddef ;
-newscriptindex mfid_RightMarginDistance ; mfid_RightMarginDistance := scriptindex "RightMarginDistance" ; vardef RightMarginDistance = runscript mfid_RightMarginDistance enddef ;
-newscriptindex mfid_RightMarginWidth ; mfid_RightMarginWidth := scriptindex "RightMarginWidth" ; vardef RightMarginWidth = runscript mfid_RightMarginWidth enddef ;
-newscriptindex mfid_RightEdgeDistance ; mfid_RightEdgeDistance := scriptindex "RightEdgeDistance" ; vardef RightEdgeDistance = runscript mfid_RightEdgeDistance enddef ;
-newscriptindex mfid_RightEdgeWidth ; mfid_RightEdgeWidth := scriptindex "RightEdgeWidth" ; vardef RightEdgeWidth = runscript mfid_RightEdgeWidth enddef ;
-newscriptindex mfid_InnerMarginDistance ; mfid_InnerMarginDistance := scriptindex "InnerMarginDistance" ; vardef InnerMarginDistance = runscript mfid_InnerMarginDistance enddef ;
-newscriptindex mfid_InnerMarginWidth ; mfid_InnerMarginWidth := scriptindex "InnerMarginWidth" ; vardef InnerMarginWidth = runscript mfid_InnerMarginWidth enddef ;
-newscriptindex mfid_OuterMarginDistance ; mfid_OuterMarginDistance := scriptindex "OuterMarginDistance" ; vardef OuterMarginDistance = runscript mfid_OuterMarginDistance enddef ;
-newscriptindex mfid_OuterMarginWidth ; mfid_OuterMarginWidth := scriptindex "OuterMarginWidth" ; vardef OuterMarginWidth = runscript mfid_OuterMarginWidth enddef ;
-newscriptindex mfid_InnerEdgeDistance ; mfid_InnerEdgeDistance := scriptindex "InnerEdgeDistance" ; vardef InnerEdgeDistance = runscript mfid_InnerEdgeDistance enddef ;
-newscriptindex mfid_InnerEdgeWidth ; mfid_InnerEdgeWidth := scriptindex "InnerEdgeWidth" ; vardef InnerEdgeWidth = runscript mfid_InnerEdgeWidth enddef ;
-newscriptindex mfid_OuterEdgeDistance ; mfid_OuterEdgeDistance := scriptindex "OuterEdgeDistance" ; vardef OuterEdgeDistance = runscript mfid_OuterEdgeDistance enddef ;
-newscriptindex mfid_OuterEdgeWidth ; mfid_OuterEdgeWidth := scriptindex "OuterEdgeWidth" ; vardef OuterEdgeWidth = runscript mfid_OuterEdgeWidth enddef ;
-newscriptindex mfid_PageOffset ; mfid_PageOffset := scriptindex "PageOffset" ; vardef PageOffset = runscript mfid_PageOffset enddef ;
-newscriptindex mfid_PageDepth ; mfid_PageDepth := scriptindex "PageDepth" ; vardef PageDepth = runscript mfid_PageDepth enddef ;
-newscriptindex mfid_LayoutColumns ; mfid_LayoutColumns := scriptindex "LayoutColumns" ; vardef LayoutColumns = runscript mfid_LayoutColumns enddef ;
-newscriptindex mfid_LayoutColumnDistance ; mfid_LayoutColumnDistance := scriptindex "LayoutColumnDistance" ; vardef LayoutColumnDistance = runscript mfid_LayoutColumnDistance enddef ;
-newscriptindex mfid_LayoutColumnWidth ; mfid_LayoutColumnWidth := scriptindex "LayoutColumnWidth" ; vardef LayoutColumnWidth = runscript mfid_LayoutColumnWidth enddef ;
+newscriptindex mfid_PaperHeight ; mfid_PaperHeight := scriptindex "PaperHeight" ; vardef PaperHeight = runscript mfid_PaperHeight enddef ;
+newscriptindex mfid_PaperWidth ; mfid_PaperWidth := scriptindex "PaperWidth" ; vardef PaperWidth = runscript mfid_PaperWidth enddef ;
+newscriptindex mfid_PrintPaperHeight ; mfid_PrintPaperHeight := scriptindex "PrintPaperHeight" ; vardef PrintPaperHeight = runscript mfid_PrintPaperHeight enddef ;
+newscriptindex mfid_PrintPaperWidth ; mfid_PrintPaperWidth := scriptindex "PrintPaperWidth" ; vardef PrintPaperWidth = runscript mfid_PrintPaperWidth enddef ;
+newscriptindex mfid_TopSpace ; mfid_TopSpace := scriptindex "TopSpace" ; vardef TopSpace = runscript mfid_TopSpace enddef ;
+newscriptindex mfid_BottomSpace ; mfid_BottomSpace := scriptindex "BottomSpace" ; vardef BottomSpace = runscript mfid_BottomSpace enddef ;
+newscriptindex mfid_BackSpace ; mfid_BackSpace := scriptindex "BackSpace" ; vardef BackSpace = runscript mfid_BackSpace enddef ;
+newscriptindex mfid_CutSpace ; mfid_CutSpace := scriptindex "CutSpace" ; vardef CutSpace = runscript mfid_CutSpace enddef ;
+newscriptindex mfid_MakeupHeight ; mfid_MakeupHeight := scriptindex "MakeupHeight" ; vardef MakeupHeight = runscript mfid_MakeupHeight enddef ;
+newscriptindex mfid_MakeupWidth ; mfid_MakeupWidth := scriptindex "MakeupWidth" ; vardef MakeupWidth = runscript mfid_MakeupWidth enddef ;
+newscriptindex mfid_TopHeight ; mfid_TopHeight := scriptindex "TopHeight" ; vardef TopHeight = runscript mfid_TopHeight enddef ;
+newscriptindex mfid_TopDistance ; mfid_TopDistance := scriptindex "TopDistance" ; vardef TopDistance = runscript mfid_TopDistance enddef ;
+newscriptindex mfid_HeaderHeight ; mfid_HeaderHeight := scriptindex "HeaderHeight" ; vardef HeaderHeight = runscript mfid_HeaderHeight enddef ;
+newscriptindex mfid_HeaderDistance ; mfid_HeaderDistance := scriptindex "HeaderDistance" ; vardef HeaderDistance = runscript mfid_HeaderDistance enddef ;
+newscriptindex mfid_TextHeight ; mfid_TextHeight := scriptindex "TextHeight" ; vardef TextHeight = runscript mfid_TextHeight enddef ;
+newscriptindex mfid_FooterDistance ; mfid_FooterDistance := scriptindex "FooterDistance" ; vardef FooterDistance = runscript mfid_FooterDistance enddef ;
+newscriptindex mfid_FooterHeight ; mfid_FooterHeight := scriptindex "FooterHeight" ; vardef FooterHeight = runscript mfid_FooterHeight enddef ;
+newscriptindex mfid_BottomDistance ; mfid_BottomDistance := scriptindex "BottomDistance" ; vardef BottomDistance = runscript mfid_BottomDistance enddef ;
+newscriptindex mfid_BottomHeight ; mfid_BottomHeight := scriptindex "BottomHeight" ; vardef BottomHeight = runscript mfid_BottomHeight enddef ;
+newscriptindex mfid_LeftEdgeWidth ; mfid_LeftEdgeWidth := scriptindex "LeftEdgeWidth" ; vardef LeftEdgeWidth = runscript mfid_LeftEdgeWidth enddef ;
+newscriptindex mfid_LeftEdgeDistance ; mfid_LeftEdgeDistance := scriptindex "LeftEdgeDistance" ; vardef LeftEdgeDistance = runscript mfid_LeftEdgeDistance enddef ;
+newscriptindex mfid_LeftMarginWidth ; mfid_LeftMarginWidth := scriptindex "LeftMarginWidth" ; vardef LeftMarginWidth = runscript mfid_LeftMarginWidth enddef ;
+newscriptindex mfid_LeftMarginDistance ; mfid_LeftMarginDistance := scriptindex "LeftMarginDistance" ; vardef LeftMarginDistance = runscript mfid_LeftMarginDistance enddef ;
+newscriptindex mfid_TextWidth ; mfid_TextWidth := scriptindex "TextWidth" ; vardef TextWidth = runscript mfid_TextWidth enddef ;
+newscriptindex mfid_RightMarginDistance ; mfid_RightMarginDistance := scriptindex "RightMarginDistance" ; vardef RightMarginDistance = runscript mfid_RightMarginDistance enddef ;
+newscriptindex mfid_RightMarginWidth ; mfid_RightMarginWidth := scriptindex "RightMarginWidth" ; vardef RightMarginWidth = runscript mfid_RightMarginWidth enddef ;
+newscriptindex mfid_RightEdgeDistance ; mfid_RightEdgeDistance := scriptindex "RightEdgeDistance" ; vardef RightEdgeDistance = runscript mfid_RightEdgeDistance enddef ;
+newscriptindex mfid_RightEdgeWidth ; mfid_RightEdgeWidth := scriptindex "RightEdgeWidth" ; vardef RightEdgeWidth = runscript mfid_RightEdgeWidth enddef ;
+newscriptindex mfid_InnerMarginDistance ; mfid_InnerMarginDistance := scriptindex "InnerMarginDistance" ; vardef InnerMarginDistance = runscript mfid_InnerMarginDistance enddef ;
+newscriptindex mfid_InnerMarginWidth ; mfid_InnerMarginWidth := scriptindex "InnerMarginWidth" ; vardef InnerMarginWidth = runscript mfid_InnerMarginWidth enddef ;
+newscriptindex mfid_OuterMarginDistance ; mfid_OuterMarginDistance := scriptindex "OuterMarginDistance" ; vardef OuterMarginDistance = runscript mfid_OuterMarginDistance enddef ;
+newscriptindex mfid_OuterMarginWidth ; mfid_OuterMarginWidth := scriptindex "OuterMarginWidth" ; vardef OuterMarginWidth = runscript mfid_OuterMarginWidth enddef ;
+newscriptindex mfid_InnerEdgeDistance ; mfid_InnerEdgeDistance := scriptindex "InnerEdgeDistance" ; vardef InnerEdgeDistance = runscript mfid_InnerEdgeDistance enddef ;
+newscriptindex mfid_InnerEdgeWidth ; mfid_InnerEdgeWidth := scriptindex "InnerEdgeWidth" ; vardef InnerEdgeWidth = runscript mfid_InnerEdgeWidth enddef ;
+newscriptindex mfid_OuterEdgeDistance ; mfid_OuterEdgeDistance := scriptindex "OuterEdgeDistance" ; vardef OuterEdgeDistance = runscript mfid_OuterEdgeDistance enddef ;
+newscriptindex mfid_OuterEdgeWidth ; mfid_OuterEdgeWidth := scriptindex "OuterEdgeWidth" ; vardef OuterEdgeWidth = runscript mfid_OuterEdgeWidth enddef ;
+newscriptindex mfid_PageOffset ; mfid_PageOffset := scriptindex "PageOffset" ; vardef PageOffset = runscript mfid_PageOffset enddef ;
+newscriptindex mfid_PageDepth ; mfid_PageDepth := scriptindex "PageDepth" ; vardef PageDepth = runscript mfid_PageDepth enddef ;
+newscriptindex mfid_LayoutColumns ; mfid_LayoutColumns := scriptindex "LayoutColumns" ; vardef LayoutColumns = runscript mfid_LayoutColumns enddef ;
+newscriptindex mfid_LayoutColumnDistance ; mfid_LayoutColumnDistance := scriptindex "LayoutColumnDistance" ; vardef LayoutColumnDistance = runscript mfid_LayoutColumnDistance enddef ;
+newscriptindex mfid_LayoutColumnWidth ; mfid_LayoutColumnWidth := scriptindex "LayoutColumnWidth" ; vardef LayoutColumnWidth = runscript mfid_LayoutColumnWidth enddef ;
+newscriptindex mfid_LastChangedLayoutPage ; mfid_LastChangedLayoutPage := scriptindex "LastChangedLayoutPage" ; vardef LastChangedLayoutPage = runscript mfid_LastChangedLayoutPage enddef ;
+newscriptindex mfid_SwapMarginDimensions ; mfid_SwapMarginDimensions := scriptindex "SwapMarginDimensions" ; vardef SwapMarginDimensions = runscript mfid_SwapMarginDimensions enddef ;
immutable % permanent
PaperHeight, PaperWidth, PrintPaperHeight, PrintPaperWidth, TopSpace,
@@ -80,7 +82,8 @@ immutable % permanent
RightMarginWidth, RightEdgeDistance, RightEdgeWidth, InnerMarginDistance,
InnerMarginWidth, OuterMarginDistance, OuterMarginWidth, InnerEdgeDistance,
InnerEdgeWidth, OuterEdgeDistance, OuterEdgeWidth, PageOffset, PageDepth,
- LayoutColumns, LayoutColumnDistance, LayoutColumnWidth ;
+ LayoutColumns, LayoutColumnDistance, LayoutColumnWidth,
+ LastChangedLayoutPage, SwapMarginDimensions ;
newscriptindex mfid_OnRightPage ; mfid_OnRightPage := scriptindex "OnRightPage" ; vardef OnRightPage = runscript mfid_OnRightPage enddef ;
newscriptindex mfid_OnOddPage ; mfid_OnOddPage := scriptindex "OnOddPage" ; vardef OnOddPage = runscript mfid_OnOddPage enddef ;
@@ -153,18 +156,18 @@ newscriptindex mfid_defaultcolormodel ; mfid_defaultcolormodel := scriptin
immutable % permanent
defaultcolormodel ;
-vardef LeftMarginWidth = if mfun_swapped and not OnRightPage : runscript mfid_RightMarginWidth else : runscript mfid_LeftMarginWidth fi enddef ;
-vardef RightMarginWidth = if mfun_swapped and not OnRightPage : runscript mfid_LeftMarginWidth else : runscript mfid_RightMarginWidth fi enddef ;
-vardef LeftMarginDistance = if mfun_swapped and not OnRightPage : runscript mfid_RightMarginDistance else : runscript mfid_LeftMarginDistance fi enddef ;
-vardef RightMarginDistance = if mfun_swapped and not OnRightPage : runscript mfid_LeftMarginDistance else : runscript mfid_RightMarginDistance fi enddef ;
+vardef LeftMarginWidth = runscript mfid_LeftMarginWidth enddef ;
+vardef RightMarginWidth = runscript mfid_RightMarginWidth enddef ;
+vardef LeftMarginDistance = runscript mfid_LeftMarginDistance enddef ;
+vardef RightMarginDistance = runscript mfid_RightMarginDistance enddef ;
-vardef LeftEdgeWidth = if mfun_swapped and not OnRightPage : runscript mfid_RightEdgeWidth else : runscript mfid_LeftEdgeWidth fi enddef ;
-vardef RightEdgeWidth = if mfun_swapped and not OnRightPage : runscript mfid_LeftEdgeWidth else : runscript mfid_RightEdgeWidth fi enddef ;
-vardef LeftEdgeDistance = if mfun_swapped and not OnRightPage : runscript mfid_RightEdgeDistance else : runscript mfid_LeftEdgeDistance fi enddef ;
-vardef RightEdgeDistance = if mfun_swapped and not OnRightPage : runscript mfid_LeftEdgeDistance else : runscript mfid_RightEdgeDistance fi enddef ;
+vardef LeftEdgeWidth = runscript mfid_LeftEdgeWidth enddef ;
+vardef RightEdgeWidth = runscript mfid_RightEdgeWidth enddef ;
+vardef LeftEdgeDistance = runscript mfid_LeftEdgeDistance enddef ;
+vardef RightEdgeDistance = runscript mfid_RightEdgeDistance enddef ;
-vardef BackSpace = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript mfid_BackSpace enddef ;
-vardef CutSpace = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript mfid_CutSpace enddef ;
+vardef BackSpace = runscript mfid_BackSpace enddef ;
+vardef CutSpace = runscript mfid_CutSpace enddef ;
% better use:
diff --git a/metapost/context/base/mpxl/mp-page.mpxl b/metapost/context/base/mpxl/mp-page.mpxl
index 525a5b157..c36dd6487 100644
--- a/metapost/context/base/mpxl/mp-page.mpxl
+++ b/metapost/context/base/mpxl/mp-page.mpxl
@@ -52,83 +52,109 @@ immutable % permanent
% We could go for just setting them (:=):
-path mfun_page_area[][] ;
-pair mfun_page_location[][] ;
-path mfun_page_field[][] ;
-numeric mfun_page_vsize[] ;
-numeric mfun_page_hsize[] ;
-numeric mfun_page_vstep[] ;
-numeric mfun_page_hstep[] ;
+path mfun_page_area [][][] ;
+pair mfun_page_location[][][] ;
+path mfun_page_field [][][] ;
+numeric mfun_page_vsize [][] ;
+numeric mfun_page_hsize [][] ;
+numeric mfun_page_vstep [][] ;
+numeric mfun_page_hstep [][] ;
-newinternal mfun_page_done ; mfun_page_done := 0 ;
+numeric mfun_page_odd ; mfun_page_odd := 1 ;
def mfun_page_check_vsize =
- mfun_page_vsize[Top] := TopHeight ;
- mfun_page_vsize[TopSeparator] := TopDistance ;
- mfun_page_vsize[Header] := HeaderHeight ;
- mfun_page_vsize[HeaderSeparator] := HeaderDistance ;
- mfun_page_vsize[Text] := TextHeight ;
- mfun_page_vsize[FooterSeparator] := FooterDistance ;
- mfun_page_vsize[Footer] := FooterHeight ;
- mfun_page_vsize[BottomSeparator] := BottomDistance ;
- mfun_page_vsize[Bottom] := BottomHeight ;
+ mfun_page_vsize[mfun_page_odd][Top] := TopHeight ;
+ mfun_page_vsize[mfun_page_odd][TopSeparator] := TopDistance ;
+ mfun_page_vsize[mfun_page_odd][Header] := HeaderHeight ;
+ mfun_page_vsize[mfun_page_odd][HeaderSeparator] := HeaderDistance ;
+ mfun_page_vsize[mfun_page_odd][Text] := TextHeight ;
+ mfun_page_vsize[mfun_page_odd][FooterSeparator] := FooterDistance ;
+ mfun_page_vsize[mfun_page_odd][Footer] := FooterHeight ;
+ mfun_page_vsize[mfun_page_odd][BottomSeparator] := BottomDistance ;
+ mfun_page_vsize[mfun_page_odd][Bottom] := BottomHeight ;
enddef ;
def mfun_page_check_hsize =
- mfun_page_hsize[LeftEdge] := LeftEdgeWidth ;
- mfun_page_hsize[LeftEdgeSeparator] := LeftEdgeDistance ;
- mfun_page_hsize[LeftMargin] := LeftMarginWidth ;
- mfun_page_hsize[LeftMarginSeparator] := LeftMarginDistance ;
- mfun_page_hsize[Text] := MakeupWidth ;
- mfun_page_hsize[RightMarginSeparator] := RightMarginDistance ;
- mfun_page_hsize[RightMargin] := RightMarginWidth ;
- mfun_page_hsize[RightEdgeSeparator] := RightEdgeDistance ;
- mfun_page_hsize[RightEdge] := RightEdgeWidth ;
+ mfun_page_hsize[mfun_page_odd][LeftEdge] := LeftEdgeWidth ;
+ mfun_page_hsize[mfun_page_odd][LeftEdgeSeparator] := LeftEdgeDistance ;
+ mfun_page_hsize[mfun_page_odd][LeftMargin] := LeftMarginWidth ;
+ mfun_page_hsize[mfun_page_odd][LeftMarginSeparator] := LeftMarginDistance ;
+ mfun_page_hsize[mfun_page_odd][Text] := MakeupWidth ;
+ mfun_page_hsize[mfun_page_odd][RightMarginSeparator] := RightMarginDistance ;
+ mfun_page_hsize[mfun_page_odd][RightMargin] := RightMarginWidth ;
+ mfun_page_hsize[mfun_page_odd][RightEdgeSeparator] := RightEdgeDistance ;
+ mfun_page_hsize[mfun_page_odd][RightEdge] := RightEdgeWidth ;
enddef ;
def mfun_page_check_vstep =
- mfun_page_vstep[TopSeparator] := PaperHeight-TopSpace ;
- mfun_page_vstep[Top] := mfun_page_vstep[TopSeparator] +mfun_page_vsize[TopSeparator] ;
- mfun_page_vstep[Header] := mfun_page_vstep[TopSeparator] -mfun_page_vsize[Header] ;
- mfun_page_vstep[HeaderSeparator] := mfun_page_vstep[Header] -mfun_page_vsize[HeaderSeparator] ;
- mfun_page_vstep[Text] := mfun_page_vstep[HeaderSeparator]-mfun_page_vsize[Text] ;
- mfun_page_vstep[FooterSeparator] := mfun_page_vstep[Text] -mfun_page_vsize[FooterSeparator] ;
- mfun_page_vstep[Footer] := mfun_page_vstep[FooterSeparator]-mfun_page_vsize[Footer] ;
- mfun_page_vstep[BottomSeparator] := mfun_page_vstep[Footer] -mfun_page_vsize[BottomSeparator] ;
- mfun_page_vstep[Bottom] := mfun_page_vstep[BottomSeparator]-mfun_page_vsize[Bottom] ;
+ mfun_page_vstep[mfun_page_odd][TopSeparator] := PaperHeight-TopSpace ;
+ mfun_page_vstep[mfun_page_odd][Top] := mfun_page_vstep[mfun_page_odd][TopSeparator] +mfun_page_vsize[mfun_page_odd][TopSeparator] ;
+ mfun_page_vstep[mfun_page_odd][Header] := mfun_page_vstep[mfun_page_odd][TopSeparator] -mfun_page_vsize[mfun_page_odd][Header] ;
+ mfun_page_vstep[mfun_page_odd][HeaderSeparator] := mfun_page_vstep[mfun_page_odd][Header] -mfun_page_vsize[mfun_page_odd][HeaderSeparator] ;
+ mfun_page_vstep[mfun_page_odd][Text] := mfun_page_vstep[mfun_page_odd][HeaderSeparator]-mfun_page_vsize[mfun_page_odd][Text] ;
+ mfun_page_vstep[mfun_page_odd][FooterSeparator] := mfun_page_vstep[mfun_page_odd][Text] -mfun_page_vsize[mfun_page_odd][FooterSeparator] ;
+ mfun_page_vstep[mfun_page_odd][Footer] := mfun_page_vstep[mfun_page_odd][FooterSeparator]-mfun_page_vsize[mfun_page_odd][Footer] ;
+ mfun_page_vstep[mfun_page_odd][BottomSeparator] := mfun_page_vstep[mfun_page_odd][Footer] -mfun_page_vsize[mfun_page_odd][BottomSeparator] ;
+ mfun_page_vstep[mfun_page_odd][Bottom] := mfun_page_vstep[mfun_page_odd][BottomSeparator]-mfun_page_vsize[mfun_page_odd][Bottom] ;
enddef ;
def mfun_page_check_hstep =
- mfun_page_hstep[Text] := BackSpace ;
- mfun_page_hstep[LeftMarginSeparator] := mfun_page_hstep[Text] -mfun_page_hsize[LeftMarginSeparator] ;
- mfun_page_hstep[RightMarginSeparator] := mfun_page_hstep[Text] +mfun_page_hsize[Text] ;
- mfun_page_hstep[LeftMargin] := mfun_page_hstep[LeftMarginSeparator] -mfun_page_hsize[LeftMargin] ;
- mfun_page_hstep[RightMargin] := mfun_page_hstep[RightMarginSeparator]+mfun_page_hsize[RightMarginSeparator] ;
- mfun_page_hstep[LeftEdgeSeparator] := mfun_page_hstep[LeftMargin] -mfun_page_hsize[LeftEdgeSeparator] ;
- mfun_page_hstep[LeftEdge] := mfun_page_hstep[LeftEdgeSeparator] -mfun_page_hsize[LeftEdge] ;
- mfun_page_hstep[RightEdgeSeparator] := mfun_page_hstep[RightMargin] +mfun_page_hsize[RightMargin] ;
- mfun_page_hstep[RightEdge] := mfun_page_hstep[RightEdgeSeparator] +mfun_page_hsize[RightEdgeSeparator] ;
+ mfun_page_hstep[mfun_page_odd][Text] := BackSpace ;
+ mfun_page_hstep[mfun_page_odd][LeftMarginSeparator] := mfun_page_hstep[mfun_page_odd][Text] -mfun_page_hsize[mfun_page_odd][LeftMarginSeparator] ;
+ mfun_page_hstep[mfun_page_odd][RightMarginSeparator] := mfun_page_hstep[mfun_page_odd][Text] +mfun_page_hsize[mfun_page_odd][Text] ;
+ mfun_page_hstep[mfun_page_odd][LeftMargin] := mfun_page_hstep[mfun_page_odd][LeftMarginSeparator] -mfun_page_hsize[mfun_page_odd][LeftMargin] ;
+ mfun_page_hstep[mfun_page_odd][RightMargin] := mfun_page_hstep[mfun_page_odd][RightMarginSeparator]+mfun_page_hsize[mfun_page_odd][RightMarginSeparator] ;
+ mfun_page_hstep[mfun_page_odd][LeftEdgeSeparator] := mfun_page_hstep[mfun_page_odd][LeftMargin] -mfun_page_hsize[mfun_page_odd][LeftEdgeSeparator] ;
+ mfun_page_hstep[mfun_page_odd][LeftEdge] := mfun_page_hstep[mfun_page_odd][LeftEdgeSeparator] -mfun_page_hsize[mfun_page_odd][LeftEdge] ;
+ mfun_page_hstep[mfun_page_odd][RightEdgeSeparator] := mfun_page_hstep[mfun_page_odd][RightMargin] +mfun_page_hsize[mfun_page_odd][RightMargin] ;
+ mfun_page_hstep[mfun_page_odd][RightEdge] := mfun_page_hstep[mfun_page_odd][RightEdgeSeparator] +mfun_page_hsize[mfun_page_odd][RightEdgeSeparator] ;
+enddef ;
+
+numeric mfun_last_changed_page ; mfun_last_changed_page := -1 ;
+boolean mfun_page_done_odd ; mfun_page_done_odd := false ;
+boolean mfun_page_done_even ; mfun_page_done_even := false ;
+
+def mfun_check_page_dimensions_indeed =
+ mfun_page_check_vsize ;
+ mfun_page_check_hsize ;
+ mfun_page_check_vstep ;
+ mfun_page_check_hstep ;
enddef ;
def mfun_check_page_dimensions =
- if mfun_page_done <> RealPageNumber :
- if LayoutHasChanged :
- mfun_page_check_vsize ;
- mfun_page_check_hsize ;
- mfun_page_check_vstep ;
- mfun_page_check_hstep ;
+ begingroup ;
+ save n ; n := LastChangedLayoutPage ;
+ SwapMarginDimensions ; % always
+ if mfun_last_changed_page <> n :
+ report("page", "layout changed") ;
+ mfun_page_done_odd := false ;
+ mfun_page_done_even := false ;
+ mfun_last_changed_page := n ;
+ fi ;
+ if odd RealPageNumber :
+ mfun_page_odd := 1 ;
+ if not mfun_page_done_odd :
+ report("page", "checking odd") ;
+ mfun_check_page_dimensions_indeed ;
+ mfun_page_done_odd := true ;
+ fi ;
+ else :
+ mfun_page_odd := 2 ;
+ if not mfun_page_done_even :
+ report("page", "checking even") ;
+ mfun_check_page_dimensions_indeed ;
+ mfun_page_done_even := true ;
fi ;
- mfun_page_done := RealPageNumber ;
fi ;
+ endgroup ;
enddef;
-
def mfun_check_page_area =
mfun_check_page_dimensions ;
for VerPos=Top step 10 until Bottom:
for HorPos=LeftEdge step 1 until RightEdge:
- mfun_page_area[HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[HorPos] yscaled mfun_page_vsize[VerPos] ;
- mfun_page_area[VerPos][HorPos] := mfun_page_area[HorPos][VerPos] ;
+ mfun_page_area[mfun_page_odd][HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[mfun_page_odd][HorPos] yscaled mfun_page_vsize[where][VerPos] ;
+ mfun_page_area[mfun_page_odd][VerPos][HorPos] := mfun_page_area[mfun_page_odd][HorPos][VerPos] ;
endfor ;
endfor ;
enddef ;
@@ -137,8 +163,8 @@ def mfun_check_page_location =
mfun_check_page_dimensions ;
for VerPos=Top step 10 until Bottom:
for HorPos=LeftEdge step 1 until RightEdge:
- mfun_page_location[HorPos][VerPos] := (mfun_page_hstep[HorPos],mfun_page_vstep[VerPos]) ;
- mfun_page_location[VerPos][HorPos] := mfun_page_location[HorPos][VerPos] ;
+ mfun_page_location[mfun_page_odd][HorPos][VerPos] := (mfun_page_hstep[mfun_page_odd][HorPos],mfun_page_vstep[mfun_page_odd][VerPos]) ;
+ mfun_page_location[mfun_page_odd][VerPos][HorPos] := mfun_page_location[mfun_page_odd][HorPos][VerPos] ;
endfor ;
endfor ;
enddef ;
@@ -147,19 +173,19 @@ def mfun_check_page_field =
mfun_check_page_dimensions ;
for VerPos=Top step 10 until Bottom:
for HorPos=LeftEdge step 1 until RightEdge:
- mfun_page_field[HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[HorPos] yscaled mfun_page_vsize[VerPos] shifted (mfun_page_hstep[HorPos],mfun_page_vstep[VerPos]) ;
- mfun_page_field[VerPos][HorPos] := mfun_page_field[HorPos][VerPos] ;
+ mfun_page_field[mfun_page_odd][HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[mfun_page_odd][HorPos] yscaled mfun_page_vsize[mfun_page_odd][VerPos] shifted (mfun_page_hstep[mfun_page_odd][HorPos],mfun_page_vstep[mfun_page_odd][VerPos]) ;
+ mfun_page_field[mfun_page_odd][VerPos][HorPos] := mfun_page_field[mfun_page_odd][HorPos][VerPos] ;
endfor ;
endfor ;
enddef ;
-def Area = hide(mfun_check_page_area ;) mfun_page_area enddef ;
-def Location = hide(mfun_check_page_location ;) mfun_page_location enddef ;
-def Field = hide(mfun_check_page_field ;) mfun_page_field enddef ;
-def Vsize = hide(mfun_check_page_dimensions ;) mfun_page_vsize enddef ;
-def Hsize = hide(mfun_check_page_dimensions ;) mfun_page_hsize enddef ;
-def Vstep = hide(mfun_check_page_dimensions ;) mfun_page_vstep enddef ;
-def Hstep = hide(mfun_check_page_dimensions ;) mfun_page_hstep enddef ;
+def Area = hide(mfun_check_page_area ;) mfun_page_area [mfun_page_odd] enddef ;
+def Location = hide(mfun_check_page_location ;) mfun_page_location[mfun_page_odd] enddef ;
+def Field = hide(mfun_check_page_field ;) mfun_page_field [mfun_page_odd] enddef ;
+def Vsize = hide(mfun_check_page_dimensions ;) mfun_page_vsize [mfun_page_odd] enddef ;
+def Hsize = hide(mfun_check_page_dimensions ;) mfun_page_hsize [mfun_page_odd] enddef ;
+def Vstep = hide(mfun_check_page_dimensions ;) mfun_page_vstep [mfun_page_odd] enddef ;
+def Hstep = hide(mfun_check_page_dimensions ;) mfun_page_hstep [mfun_page_odd] enddef ;
immutable % permanent
Area, Location, Field, Vsize, Hsize, Vstep, Hstep ;
diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl
index 474b68353..294dddcb9 100644
--- a/metapost/context/base/mpxl/mp-tool.mpxl
+++ b/metapost/context/base/mpxl/mp-tool.mpxl
@@ -3910,3 +3910,19 @@ vardef hatched(expr o) primary c =
enddef;
permanent hatched ;
+
+% By Mikael Sundqvist:
+
+numeric mfun_dash_len ;
+
+primarydef p withdashes len =
+ hide (
+ save l, n ;
+ l := arclength p ;
+ n := l div len ;
+ if odd(n) : n := n + 1 fi ;
+ mfun_dash_len := l / n ;
+ )
+ p dashed dashpattern (on mfun_dash_len off mfun_dash_len)
+enddef ;
+