[NTG-context] Mathematical MetaFun Mania

2022-12-14 Thread Gavin via ntg-context
Hello MetaFun Math Lovers,

I am using MetaFun to attach diagrams to formulas. Both the physics and the 
typesetting are going great! I attached a sample below, to give a taste of what 
I am trying to do. This page of actual calculations has examples of almost 
everything I need. It’s a lot, but it is all working. Right now the interface 
is terrible, but effective. Thanks to Hans and Mikael for many helpful hints!

I am still using \hpos and \setMPpositiongraphic, because I haven't figured out 
how to pass information from \mathboxanchored and \connectboxanchors to my 
MetaPost code. Here is the code for the connectors:

\startMPpositiongraphic{mypos:contract}
  path pa, pb, pab ; numeric na, nb ; string ta, tb, hand, product ;
  ta := mpvars("from") ;
  tb := mpvars("to") ;
  stemshiftfrom := (EmWidth/8)*mpvarn("startstem") ;
  stemshiftto   := (EmWidth/8)*mpvarn("stopstem") ;
  hand := mpvars("hand") ;
  product := mpvars("product") ;
  delta := mpvard("distance") ;
  na := positionpage(ta) ; % page number of a
  nb := positionpage(tb) ; % page number of b
  pa := positionbox(ta) ;  % box of a
  pb := positionbox(tb) ;  % box of b
  if hand = "right" :
 z1 = 0.5[llcorner pa,lrcorner pa] shifted (stemshiftfrom, -ExHeight/4) ;
 z2 = 0.5[llcorner pb,lrcorner pb] shifted (stemshiftto,   -ExHeight/4) ;
 y3 = min(y1,y2) - ExHeight/2 -delta; 
  else :
z1 = 0.5[ulcorner pa,urcorner pa] shifted (stemshiftfrom,  ExHeight/4) ;
z2 = 0.5[ulcorner pb,urcorner pb] shifted (stemshiftto,ExHeight/4) ;
y3 = max(y1,y2) + ExHeight/2 +delta; 
  fi ;
  if na = nb : % Check that positions are on the same page
pickup pencircle scaled 0.6pt ;
if product = "sym" :
  draw z1 -- (x1,y3+ExHeight/2) ;
  draw z2 -- (x2,y3+ExHeight/2) ;
  pickup pencircle scaled 1.2pt ;
  draw (x1-EmWidth/8,y3) -- (x2+EmWidth/8,y3) ;
else :
  pab := z1 -- (x1,y3) -- (x2,y3) -- z2{down} ;
  draw pab ;
fi ;
positioninregion ;
  fi ;
\stopMPpositiongraphic

A connector command might look something like this:

\setMPpositiongraphic{X-1}{mypos:contract}{to=X-2,product=sym,startstem=-2,stopstem=2,distance=0.5ex}

All of the key=value pairs in the last argument of \setMPpositiongraphic pop 
right up in my MetaPost code with mpvar(“key”). I haven’t been able to follow 
this with \mathboxanchored and \connectboxanchors. My two questions are:

1) Can I use \setMPpositiongraphic with \mathboxanchored? That would allow me 
to go straight to my MetaPost code without the \connectboxanchors interface

2) Can I tell \connectboxanchors to use my MetaPost code and pass key=value 
pairs like I do with \setMPpositiongraphic?

Thanks for any hints!
Gavin




hposQuestion.pdf
Description: Adobe PDF document

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Cron /var/www/aanhet.net/context/bin/cron/context-mirror

2022-12-14 Thread Cron Daemon via ntg-context
rsync: failed to connect to rsync.pragma-ade.nl (213.125.29.165): Connection 
timed out (110)
rsync error: error in socket IO (code 10) at clientserver.c(125) 
[Receiver=3.1.2]
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Radial and linear gradients

2022-12-14 Thread Hans Hagen via ntg-context

On 12/14/2022 9:45 PM, Thangalin via ntg-context wrote:

Inkscape can export the gradients to PDF.

I was hoping to eliminate Inkscape as an extra piece of software users
have to download to make sure their SVG images are rendered correctly.
By containerizing ConTeXt, MetaPost can be swapped for Inkscape, so
users won't even know. It is, however, a minor duplication to have two
programs that can convert SVG to PDF. (And Inkscape will bloat the
container size.)

For my images, at least, gradients are one of the last features needed
to render them correctly using MetaPost. The other is font rendering
in some cases will be incorrect (e.g., try using Roboto with weight
100). If we have to use Inkscape to ensure tat all SVG images are


Also in the latest?


rendered correctly, then we'd only want to use MetaPost if we know
that the images don't contain gradients, or would you recommend
avoiding MetaPost altogether for SVG conversion?
dunno, but that gradient is somewhat special so it then needs to be 
intercepted ... i'm currently not in svg mode so ... (variable color 
fonts have even wierder ones).


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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Radial and linear gradients

2022-12-14 Thread Thangalin via ntg-context
Inkscape can export the gradients to PDF.

I was hoping to eliminate Inkscape as an extra piece of software users
have to download to make sure their SVG images are rendered correctly.
By containerizing ConTeXt, MetaPost can be swapped for Inkscape, so
users won't even know. It is, however, a minor duplication to have two
programs that can convert SVG to PDF. (And Inkscape will bloat the
container size.)

For my images, at least, gradients are one of the last features needed
to render them correctly using MetaPost. The other is font rendering
in some cases will be incorrect (e.g., try using Roboto with weight
100). If we have to use Inkscape to ensure tat all SVG images are
rendered correctly, then we'd only want to use MetaPost if we know
that the images don't contain gradients, or would you recommend
avoiding MetaPost altogether for SVG conversion?

Thank you!

On Wed, Dec 14, 2022 at 12:46 AM Hans Hagen via ntg-context
 wrote:
>
> On 12/14/2022 5:46 AM, Thangalin via ntg-context wrote:
> > Hi there!
> >
> > Any thoughts on implementing SVG gradients in MetaPost?
> >
> > % SOF
> > \startbuffer[csvg]
> > http://www.w3.org/2000/svg;
> > xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="0 0 115.669
> > 115.669"> > cy="167.114" r="57.834" fx="124.515" fy="167.114"
> > gradientTransform="translate(-17.77 -18.4)"
> > gradientUnits="userSpaceOnUse"/> > offset="0"/> > stop-opacity="0"/> > transform="translate(-48.91 -90.879)"> > fill-opacity=".5" d="M48.769 90.936H164.64V206.96H48.769z"/> > cx="106.745" cy="148.713" r="57.834" fill="url(#b)"
> > fill-rule="evenodd"/>
> > \stopbuffer
> >
> > \starttext
> >\placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
> > \stoptext
> > % EOF
> >
> > See attached a comparison of the PDF generated using ConTeXt and the
> > PNG file generated by exporting from Inkscape.
> these gradients definitions get crazier by the day ... does inkscape
> output a bitmap or vector pdf
>
> given what we do with context i'm not sure we should support everything
> that pops up (mapping all onto mp and then pdf ...)
>
> 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://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___


inkscape-gradient.pdf
Description: Adobe PDF document
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Non-standard font alternatives

2022-12-14 Thread Wolfgang Schuster via ntg-context

Matthew McCabe via ntg-context schrieb am 13.12.2022 um 09:15:

Hi list,

I'm looking to import a font with medium and light weights (in this case 
Roboto) and define font alternatives so one can quickly switch to light 
text just as one would switch to bold text. There is a stackexchange 
answer from Wolfgang 
(https://tex.stackexchange.com/questions/303648/context-font-weights) 
which details a solution to this problem for ConTeXt MkIV but despite my 
best efforts I haven't been able to get things to work for me. There is 
the Roboto typescript example on ConTeXt garden but it isn't exactly 
what I'm looking for as for the document I'm making I would prefer to be 
able to treat the font weights as alternatives rather than separate 
families since I will be switching often.


One can download the exact set of fonts I am using from 
https://fonts.google.com/specimen/Roboto


Here is my code:

[...]

\starttypescript [sans] [roboto]
   \definebodyfont [default] [rm]


Replace [rm] with [ss]:

\definebodyfont [default] [ss]


      [lf=SansLight sa 1,
       li=SansLightItalic sa 1,
       tf=Sans sa 1,
       it=SansItalic sa 1,
       md=SansMedium sa 1,
       mi=SansMediumItalic sa 1,
       bf=SansBold sa 1,
       bi=SansBoldItalic sa 1,
       sc=SansCaps sa 1]
\stoptypescript

\definetypeface[roboto][rm][sans][roboto][default]


Replace [rm] with [ss]:

\definetypeface [roboto] [ss] [sans] [roboto] [default]

Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Containerized ConTeXt

2022-12-14 Thread Henri Menke via ntg-context
The Island of TeX builds Docker images for ConTeXt weekly.

https://gitlab.com/islandoftex/images/context

registry.gitlab.com/islandoftex/images/context:lmtx

Cheers, Henri

On Tue, 2022-12-13 at 20:56 -0800, Thangalin via ntg-context wrote:
> Hi again,
> 
> I've added the start of a podman container for invoking ConTeXt that
> may be of interest:
> 
> https://github.com/DaveJarvis/keenwrite/tree/main/container
> 
> The Containerfile sets up ConTeXt to work with my themes:
> 
> https://github.com/DaveJarvis/keenwrite-themes
> 
> The manage.sh shell script is a wrapper around the podman command to
> help build, save, and load the container, as well as connect and run
> commands. It's a work-in-progress.
> 
> My goal is to simplify the setup and configuration of ConTeXt as well
> as make the instructions "cross platform" owing to containerization.
> From there, I want to call out to the container from KeenWrite to
> typeset PDF documents using one of the themes. Further, I'd like to
> have KeenWrite download and install ConTeXt automatically using
> podman. I believe this will make it easier for people to generate
> high-quality PDFs from (R) Markdown documents because they'd only
> have
> to download KeenWrite, then ask KeenWrite to download/configure
> ConTeXt automatically, in a cross-platform fashion.
> 
> Thoughts? Suggestions for improvement?
> _
> __
> If your question is of interest to others as well, please add an
> entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> _
> __

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Containerized ConTeXt

2022-12-14 Thread Leah Neukirchen via ntg-context
Thangalin via ntg-context  writes:

> Thoughts? Suggestions for improvement?

If you are looking for technical suggestions, every RUN line will
create a layer even if you delete files later.  I'd suggest making the
final image by copying the root directory of a multistage container,
e.g. https://adriancitu.com/2022/03/11/7-ways-to-build-lighter-linux-containers/

Alternatively, do all the steps before installing ConTeXt in a
multistage container, and run all shell commands that install ConTeXt
in one action, then you get two layers and the lower one only changes
if a font changes (or alpine:latest).

-- 
Leah Neukirchenhttps://leahneukirchen.org/
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Non-standard font alternatives

2022-12-14 Thread Matthew McCabe via ntg-context
> On 13 Dec 2022, at 7:53 pm, Hans Hagen via ntg-context  
> wrote:
> 
> On 12/13/2022 9:15 AM, Matthew McCabe via ntg-context wrote:
>> Hi list,
>> I'm looking to import a font with medium and light weights (in this case 
>> Roboto) and define font alternatives so one can quickly switch to light text 
>> just as one would switch to bold text. There is a stackexchange answer from 
>> Wolfgang 
>> (https://tex.stackexchange.com/questions/303648/context-font-weights 
>> ) which 
>> details a solution to this problem for ConTeXt MkIV but despite my best 
>> efforts I haven't been able to get things to work for me. There is the 
>> Roboto typescript example on ConTeXt garden but it isn't exactly what I'm 
>> looking for as for the document I'm making I would prefer to be able to 
>> treat the font weights as alternatives rather than separate families since I 
>> will be switching often.
> take a look at type-imp-plex.mkiv (just remove the \s! in your case)
> 
> basically you define two typefaces: normal and light and then just switch 
> between these, as in:
> 
> at the top of your document you say
> 
> \usebodyfont[plex]   % preloads
> \usebodyfont[plex-light] % preloads
> 
> \setupbodyfont[plex] % enables main font
> 
> and after that
> 
> {\switchtobodyfont[plex-light]  }
> 
> will do a consistent switch
> 
> 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://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___

Thanks for the reply and your help Hans, ok so if I understand correctly the 
canonical way to integrate light weight font is to define two typefaces. I 
wrote up a typescript for (Sans) Roboto based on the example typescript from 
ConTeXt garden using only the Sans variants and it’s working well.

For anyone else looking to do something similar, since the typescript is just a 
tex file it seems if one places it in one’s local directory it will be 
accessible when ConTeXt generates the pdf. I saved it as type-imp-roboto.tex in 
my local directory and used ‘\usebodyfont[roboto]’ and 
‘\usebodyfont[roboto-light]’ to preload the fonts as recommended 
(\usetypescriptfile didn’t seem to be required).

Here is my typescript, for the Sans Roboto font, pretty much picked out of the 
context garden example typescript for Roboto:

\definefontfeature[robotofeatures][
  mode=node,
  ccmp=yes, % character composition
  liga=yes, tlig=yes, % ligatures
  pnum=yes,
  cpsp=yes, % capital spacing
  kern=yes,
  language=dflt,
  protrusion=quality,
  expansion=quality,
]

\definefontfeature[smallcaps][ % use with \addff
  smcp=yes, % smallcaps
  % c2sc=yes, % caps to smallcaps
]

\starttypescript[sans][roboto,robotosans]
  \definefontsynonym[Roboto-Regular][name:robotoregular]
  \definefontsynonym[Roboto-Black][name:robotoblack]
  \definefontsynonym[Roboto-BlackItalic][name:robotoblackitalic]
  \definefontsynonym[Roboto-Bold][name:robotobold]
  \definefontsynonym[Roboto-BoldItalic][name:robotobolditalic]
  \definefontsynonym[Roboto-Italic][name:robotoitalic]
  \definefontsynonym[Roboto-Light][name:robotolight]
  \definefontsynonym[Roboto-LightItalic][name:robotolightitalic]
  \definefontsynonym[Roboto-Medium][name:robotomedium]
  \definefontsynonym[Roboto-MediumItalic][name:robotomediumitalic]
  \definefontsynonym[Roboto-Italic][name:robotoitalic]
  \definefontsynonym[Roboto-Regular][name:robotoregular]
  \definefontsynonym[Roboto-Thin][name:robotothin]
  \definefontsynonym[Roboto-ThinItalic][name:robotothinitalic]
\stoptypescript

\starttypescript[sans][roboto,robotosans][name]
  \definefontsynonym [SansThin] [Roboto-Thin]
[features=robotofeatures]
  \definefontsynonym [SansThinItalic]   [Roboto-ThinItalic]  
[features=robotofeatures]
  \definefontsynonym [SansThinSlanted]  [Roboto-ThinItalic]  
[features=robotofeatures]
  \definefontsynonym [SansLight][Roboto-Light]   
[features=robotofeatures]
  \definefontsynonym [SansLightItalic]  [Roboto-LightItalic] 
[features=robotofeatures]
  \definefontsynonym [SansLightSlanted] [Roboto-LightItalic] 
[features=robotofeatures]
  \definefontsynonym [Sans] [Roboto-Regular] 
[features=robotofeatures]
  

Re: [NTG-context] Radial and linear gradients

2022-12-14 Thread Hans Hagen via ntg-context

On 12/14/2022 5:46 AM, Thangalin via ntg-context wrote:

Hi there!

Any thoughts on implementing SVG gradients in MetaPost?

% SOF
\startbuffer[csvg]
http://www.w3.org/2000/svg;
xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="0 0 115.669
115.669">
\stopbuffer

\starttext
   \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
\stoptext
% EOF

See attached a comparison of the PDF generated using ConTeXt and the
PNG file generated by exporting from Inkscape.
these gradients definitions get crazier by the day ... does inkscape 
output a bitmap or vector pdf


given what we do with context i'm not sure we should support everything 
that pops up (mapping all onto mp and then pdf ...)


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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___