From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/112974 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jairo A. del Rio via ntg-context" Newsgroups: gmane.comp.tex.context Subject: Metafun's utflen not working in certain contexts Date: Sun, 3 Oct 2021 14:28:38 -0500 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6264405968551954457==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39868"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Jairo A. del Rio" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Oct 03 21:29:29 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mX7Av-000AD9-J9 for gctc-ntg-context-518@m.gmane-mx.org; Sun, 03 Oct 2021 21:29:29 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3BCD0282813; Sun, 3 Oct 2021 21:28:55 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Vjva7QoRo3W; Sun, 3 Oct 2021 21:28:53 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7C62D287D2E; Sun, 3 Oct 2021 21:28:53 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 21D17287D2E for ; Sun, 3 Oct 2021 21:28:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eUj_stB81NTy for ; Sun, 3 Oct 2021 21:28:50 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.48; helo=mail-wr1-f48.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id E333F282813 for ; Sun, 3 Oct 2021 21:28:49 +0200 (CEST) Original-Received: by mail-wr1-f48.google.com with SMTP id o20so8383449wro.3 for ; Sun, 03 Oct 2021 12:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=lEWHPj9ZIjvNNtaeH2ujJIWscjrlccXGgytIraVJMQE=; b=lFO0W99X7xbxHbqkY5psgTVXUrP6BFAiu1hp7icIdwDdqX1gi4AhiVW6id2RJC3DHN TU2aP/g7/xHy2E7TLeszwVXb1ktaprU00M6V8nheAVlKfxndvigXa2f+gHC32yXXzrQf CbWy7BwS9NTKDyWTkmhPEsGp4lDYwDJ8cSo6Qsi/N/vWZC1zUWF8QewssuIq5DbZrl7y 3bHEw/5R7f5yyEigGE9Fxnaw4H3vJQOMnqRo0oGsbySFrk1mvu0jdsW4i4p0HissqIvT /RcyIEclDUvtT1wWQzX6Ju9qQNs1kTRR5/FSz8cvsQuEoRz5ExvYnNIEGqbYn7m+cFuX ffXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lEWHPj9ZIjvNNtaeH2ujJIWscjrlccXGgytIraVJMQE=; b=BJegsOyy/KyI3FGKgrlbwNwwVaXELyVTz3FhwXtOeAxskWPl48K3N3aBPXI1qI7UxZ blw5MXBS4QfvTtOje+m4sxb6oMJD9HpiohN+VAFHppRAhxNxYxdHIOgt4p8qDl7IvNlY 7sJB+m4+7gsKVy/6/vt/xROh+jT9H2pCSlwF3qExkPA4tXYUwwGfLcN6plLB9q9ASQXS 5ms7jZGkovd3QUTY/UuMgHi0IQUPIGdwSiUvxZg0xB6UdQA+hyxLPpoxObENi8snwFcZ WAZ5ChhnCA5Uad3bqOhPJ1FOlR26l//rdjbT9b1o1mgw8U17eAJQpKZuqoZs+QliJrGR PpTw== X-Gm-Message-State: AOAM531xbh8Nke8eaAGUvfh/fTmT1Cx7mIFpectAhgmCotYcCzLAMVsL /lHC0/eYOlMw8Ywu4xL+7kaVYtyz+MjqqtWPOZ0jPNqM37wcgA== X-Google-Smtp-Source: ABdhPJxYqqEGS4ZvdEu0c1+MGybp0MLR0voyR7b9f9/wBhkQG3zg4GC/VUjQhhpHxoz+yVLk6JDgLeaQRZe9ntGiI3E= X-Received: by 2002:a05:6000:2cd:: with SMTP id o13mr9770232wry.193.1633289329466; Sun, 03 Oct 2021 12:28:49 -0700 (PDT) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:112974 Archived-At: --===============6264405968551954457== Content-Type: multipart/alternative; boundary="0000000000004c5f8505cd77ce6c" --0000000000004c5f8505cd77ce6c Content-Type: text/plain; charset="UTF-8" Hi, list. The following works for MkIV, but not LMTX (adapted from here: https://tex.stackexchange.com/questions/617597/how-can-i-use-luas-string-len-inside-a-metapost-function ): \startMPinclusions vardef MotMystere(expr taille, speciale, index) = save avant,apres,case; numeric avant,apres; path case; case := fullsquare scaled 13; avant := speciale-1; %For Unicode, use "utflen" instead apres := utflen(taille) - speciale; if avant >= 1: for j=1 upto avant: draw (case rotated 180 cutafter point 3 of case rotated 180) shifted (-13j,-13*index); endfor; fi; label.lft (index,point 3.5 of case shifted (-13*avant,-13*index)); draw case yshifted (-13*index); fill case yshifted (-13*index) withcolor \MPcolor{gray-8}; if apres > 0: for j=1 upto apres: draw (case cutafter point 3 of case) shifted (13j,-13*index); endfor; fi; enddef; \stopMPinclusions \starttext An example with "enigma" \startMPcode MotMystere("enigma",4,1) \stopMPcode \stoptext --0000000000004c5f8505cd77ce6c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, list. The following works for MkIV, but not LMTX (adap= ted from here: https://tex.stackex= change.com/questions/617597/how-can-i-use-luas-string-len-inside-a-metapost= -function):

\startMPinclus= ions

vardef MotMyst= ere(expr taille, speciale, index) =3D

save avant,ap= res,case;

numeric avant= ,apres;

path case;

case :=3D f= ullsquare scaled 13;

avant :=3D sp= eciale-1;

%For Unicode,= use "utflen" instead

apres :=3D ut= flen(taille) - speciale;

if avant &g= t;=3D 1:

for j=3D1 up= to avant:

draw (case = rotated 180

cutafter po= int 3 of case rotated 180)

shifted (-1= 3j,-13*index);

endfor;<= /p>

fi;

label.lft (in= dex,point 3.5 of

case shifted = (-13*avant,-13*index));

draw case ysh= ifted (-13*index);

fill case ysh= ifted (-13*index)

withcolor \M= Pcolor{gray-8};

if apres >= 0:

for j=3D1 up= to apres:

draw (case = cutafter point 3 of case)

shifted (1= 3j,-13*index);

endfor;

fi;

enddef;

\stopMPinclusi= ons

\starttext

An example wit= h "enigma"


\startMPcode

MotMystere(&qu= ot;enigma",4,1)

\stopMPcode

\stoptext

<= /div> --0000000000004c5f8505cd77ce6c-- --===============6264405968551954457== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============6264405968551954457==--