ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Emanuel Han via ntg-context <ntg-context@ntg.nl>
To: "ntg-context@ntg.nl" <ntg-context@ntg.nl>
Cc: Emanuel Han <emanuel@labonneheure.ch>
Subject: [NTG-context] multipage metapost output from ConTeXt
Date: Mon, 27 Nov 2023 19:49:17 +0100	[thread overview]
Message-ID: <F8C14B66-CDFB-4783-A640-D91D997FE1B0@getmailspring.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 4311 bytes --]

How can I achieve multipage metapost output from ConTeXt? The result should be a multipage pdf. It contains just a metapost graphic per page. The graphic has always the same bounding box and evolves from page to page: Some elements to be drawn are added, and some others would ideally also be removed, while keeping elements which has already been drawn on previous pages. I can manage when it is not possible to remove elements (in that case I'll just cover them with a covering element).

I saw that it is possible to achieve my goal with standalone metapost, as described here: https://tex.stackexchange.com/questions/471662/mptopdf-is-multipage-output-pdf-possible
But I'll need to achieve this with Metapost inside ConTeXt because I use labels in Metapost which print text in Japanese, Korean , Arabic and Roman script: Thanks to ConTeXt, I can define appropriate fonts for each script. All this works already in my working example.
The only unsolved problem is to ship out multiple pages.
For the minimal working example, I didn't remove the font defining part, because having 4 different fonts is a condition of my use case. The graphic on the other hand is some simple dummy nonsense graphic not from my project. The graphic is in the provided example drawn as a summing up of layered drawing steps (6 steps, to be precise), so no removing is implemented here (because I don't know how that would be done). If each of the figures 1 to 6 of my mwe can be put alone on a page, I'd be already very happy. Now, they're put on top of each other all on the same single page, also on top of figure 0.
The desired multipage pdf will be used in presentation mode of a pdf viewer and skipped forward and backward from page to page (that is from drawing step to drawing step).
mwe:
\enableregime[utf] % enable unicoded input
\definefontfamily [RomanFont] [rm] [calluna]
\definefontfamily [KoreanFont] [rm] [applemyungjo]
\definefontfamily [JapaneseFont] [rm] [hannotatesc]
\definefontfeature
[fea]
[mode=node,language=dflt,script=arab,
init=yes,
medi=yes,
fina=yes,
isol=yes,
calt=yes,
rlig=yes,
tlig=yes,
trep=yes,
curs=yes,
kern=yes,
mark=yes
]

\starttypescript [serif] [notonaskharabic]
\definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
\stoptypescript

\starttypescript [serif] [notonaskharabic]
\usetypescript[serif][fallback]
\definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
\definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
\definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
\definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
\stoptypescript

\starttypescript [notonaskharabic]
\definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
\stoptypescript

\usetypescript[notonaskharabic]
\setupbodyfont [RomanFont]

\starttext
\startMPcode
picture p[];
path bb; %bounding box

z0 = (0,0);
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);
z4 = (30,50);
z5 = (90,70);
z6 = (-10,70);

path A; A = z0..z1..z2..z3..z4 ;
pair AStartPoint; AStartPoint = point 0 of A;
pair AEndPoint; AEndPoint = point 4 of A;
path B; B = z5..z6;
pair BStartPoint; BStartPoint = point 0 of B;
pair BEndPoint; BEndPoint = point 1 of B;
path C; C = AStartPoint..AEndPoint;

% drawing steps:
p1:=image(
draw A withcolor red;
);

p2:=image(
label(textext("\JapaneseFont 日本語"), AEndPoint);
);

p3:=image(
label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, AStartPoint);
);

p4:=image(
label(textext("\KoreanFont 한국어"), BStartPoint);
);

p5:=image(
label(textext("\RomanFont bāng"), BEndPoint);
draw C withcolor green;
);

p6:=image(
draw B withcolor blue;
);

beginfig(0); %% the whole picture for the common bbox
for k=1 upto 6: draw p[k]; endfor
bb:=bbox(currentpicture);
endfig;

for $=1 upto 6:
beginfig($);
for k=1 upto $: draw p[k]; endfor
setbounds currentpicture to bb;
endfig;
endfor

\stopMPcode
\stoptext


[-- Attachment #1.2: Type: text/html, Size: 6725 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

             reply	other threads:[~2023-11-27 18:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 18:49 Emanuel Han via ntg-context [this message]
2023-11-27 19:56 ` [NTG-context] " Fabrice L
2023-11-27 22:25   ` Aditya Mahajan
2023-11-29 11:25     ` Emanuel Han via ntg-context
2023-12-02 11:22       ` Emanuel Han via ntg-context
2023-12-02 11:54         ` fv leung
2023-12-02 16:22           ` Mikael Sundqvist
2023-12-02 17:08             ` Emanuel Han via ntg-context
2023-12-02 18:46               ` Mikael Sundqvist
2023-12-02 22:51                 ` Emanuel Han via ntg-context
2024-01-06 16:33                 ` Emanuel Han via ntg-context
2023-12-04 16:35               ` Fabrice L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F8C14B66-CDFB-4783-A640-D91D997FE1B0@getmailspring.com \
    --to=ntg-context@ntg.nl \
    --cc=emanuel@labonneheure.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).