* [NTG-context] build_parshape and \getshapetext - need for a deeper understanding
@ 2024-05-19 12:29 garulfo
2024-05-19 15:12 ` [NTG-context] " Hans Hagen via ntg-context
0 siblings, 1 reply; 2+ messages in thread
From: garulfo @ 2024-05-19 12:29 UTC (permalink / raw)
To: ntg-context
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* [NTG-context] Re: build_parshape and \getshapetext - need for a deeper understanding
2024-05-19 12:29 [NTG-context] build_parshape and \getshapetext - need for a deeper understanding garulfo
@ 2024-05-19 15:12 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen via ntg-context @ 2024-05-19 15:12 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-19 15:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19 12:29 [NTG-context] build_parshape and \getshapetext - need for a deeper understanding garulfo
2024-05-19 15:12 ` [NTG-context] " Hans Hagen via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).