build_parshape and \getshapetext - need for a deeper understanding
I still get some difficulties with build_parshape, \getshapetex and sectionning. I though I find a solution by removing \blank with \setuphead [subsection] [before=, after=, style=, command=\MySubSectionCommand, alternative=text ] But actually it's not enough : when I add text before the first section, new issues appear. I tried to build a MVE by refactoring and tidying as much as I could. It build 3 comparative pages (i) basic issue, (ii) solution, (iii) remaining issue. Your guidance are most welcome :-) \setupbodyfont[11pt] %------------------------------------------------------------------------------ \usecolors[svg] \definemeasure [mywidth] [7cm] \definemeasure [mywidtha] [5cm] \definemeasure [myheight] [{\the\dimexpr\baselineskip*37+\lineskip\relax}] \definemeasure [myheighta] [{\the\dimexpr\baselineskip*18+\lineskip*1\relax}] \definemeasure [myheightb] [{\the\dimexpr\baselineskip*25-\lineskip*1\relax}] \startuseMPgraphic{mymetafunpath} path p ; numeric mywidth ; mywidth := \measure{mywidth}; numeric mywidtha ; mywidtha := \measure{mywidtha}; numeric myheight ; myheight := \measure{myheight}; numeric myheighta ; myheighta := \measure{myheighta}; numeric myheightb ; myheightb := \measure{myheightb}; p := (0,0) -- (mywidth,0) -- (mywidth,myheighta) -- (mywidtha,myheighta) -- (mywidtha,myheightb) -- (mywidth,myheightb) -- (mywidth,myheight) -- (0cm,myheight) -- cycle; build_parshape(p,0,0,0,\baselinedistance,\strutheight,\strutdepth,\topskip) ; fill p withcolor \MPcolor{tan}; \stopuseMPgraphic \defineoverlay[myoverlay][\useMPgraphic{mymetafunpath}] %------------------------------------------------------------------------------ \define[2]\MySubSectionCommand{\leftaligned{#2}} %------------------------------------------------------------------------------ \define[2]\MyPageBuilder{% \page \setupbackgrounds[page][background=testA] \definelayer[testA] [x=0mm, y=0mm,width=\paperwidth, height=\paperheight] ~ \startshapetext[mymetafunpath, mymetafunpath] % <=== WITHOUT \startsubsection #2 %\startsubsection[title={Title for section #1}] \MySubSectionCommand{1}{Title for section #1} \input knuth \endgraf \input ward %\stopsubsection \stopshapetext \setlayer [testA] [hoffset={\the\dimexpr\backspace\relax}, voffset={\the\dimexpr\topspace+\headerheight+\headerdistance\relax},] {\framed[background=myoverlay,frame=off]{\strut\getshapetext}} \startshapetext[mymetafunpath, mymetafunpath] % <===== WITH \startsubsection #2 \startsubsection[title={Title for section #1}] %\MySubSectionCommand{1}{Title for section #1} \input knuth \endgraf \input ward \stopsubsection \stopshapetext \setlayer [testA] [hoffset={\the\dimexpr\backspace+\measure{mywidth}+5mm\relax}, voffset={\the\dimexpr\topspace+\headerheight+\headerdistance\relax},] {\framed[background=myoverlay,frame=off]{\strut\getshapetext}} } %============================================================================== %\showboxes \starttext \MyPageBuilder{A}{} \setuphead [subsection] [ before=, after=, style=, command=\MySubSectionCommand, alternative=text, ] \MyPageBuilder{B}{} \MyPageBuilder{C}{\strut Hi from here. \endgraf} \stoptext
On 5/19/2024 2:29 PM, garulfo@azules.eu wrote:
I still get some difficulties with build_parshape, \getshapetex and sectionning.
I though I find a solution by removing \blank with \setuphead [subsection] [before=, after=, style=, command=\MySubSectionCommand, alternative=text ]
But actually it's not enough : when I add text before the first section, new issues appear.
I tried to build a MVE by refactoring and tidying as much as I could. It build 3 comparative pages (i) basic issue, (ii) solution, (iii) remaining issue.
Your guidance are most welcome :-)
you have to fight several issues: - parshapes being reset at the end paragraph (handled here by luametatex context) - parshapes operate on lines, not dimension (i might add an aletnative one day) - you use a bit old mechanism (checkout the luametafun-paragraphs chapter) Now, is there a solution? It really depends on the circumstances, so here is one. \setupbodyfont[11pt] \definemeasure [mywidth] [7cm] \definemeasure [mywidtha] [5cm] \definemeasure [myheight] [{\the\dimexpr\baselineskip*37+\lineskip\relax}] \definemeasure [myheighta] [{\the\dimexpr\baselineskip*18+\lineskip*1\relax}] \definemeasure [myheightb] [{\the\dimexpr\baselineskip*25-\lineskip*1\relax}] \startuseMPgraphic{shape:1} path p ; numeric mywidth ; mywidth := \measure{mywidth}; numeric mywidtha ; mywidtha := \measure{mywidtha}; numeric myheight ; myheight := \measure{myheight}; numeric myheighta ; myheighta := \measure{myheighta}; numeric myheightb ; myheightb := \measure{myheightb}; p := (0,0) -- (mywidth,0) -- (mywidth,myheighta) -- (mywidtha,myheighta) -- (mywidtha,myheightb) -- (mywidth,myheightb) -- (mywidth,myheight) -- (0cm,myheight) -- cycle; build_parshape(p,0,0,0,\baselinedistance,\strutheight,\strutdepth,\topskip) ; path SavedShape ; SavedShape := p ; \stopuseMPgraphic \startuseMPgraphic{shape:2} SavedShape := SavedShape shifted (0,-ypart urcorner OverlayBox) ; SavedShape := SavedShape shifted (0,positiony("test")) ; fill SavedShape withcolor red; setbounds currentpicture to OverlayBox; \stopuseMPgraphic \showframe \defineoverlay[myoverlay][\useMPgraphic{shape:2}] \setupbackgrounds[text][text][background=myoverlay] \startsection[title={test}] \startshapedparagraph[mp=shape:1]% \setupalign[verytolerant,stretch]% \hpos{test}{!}\samplefile{tufte} \samplefile{tufte} \stopshapedparagraph \stopsection The "test" position is hard coded but should be namespaced, the ! can be a \strut instead. So, more thinking from the end of the text flow. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
garulfo@azules.eu
-
Hans Hagen