Re: [NTG-context] LuaTeX incompatible with Lua

2019-11-20 Thread Henri Menke

Below I include a suggestion on how to do this sort of version agnostic.

Cheers, Henri

Live example on Wandbox:

https://wandbox.org/permlink/jEn9kNnPB0t5rwjP

---

#include 
#include 
#include 

#include 
#include 

static int (*lua_os_execute)(lua_State *L) = NULL;

static int os_execute(lua_State *L) {
// Do whatever
printf("Hello Hans!\n");

// Safeguard
assert(lua_os_execute != NULL);

// Return wrapped
return lua_os_execute(L);
}

LUAMOD_API int luaopen_oslibext(lua_State *L) {
lua_getglobal(L, "os");

// Get the address of the original function
if (lua_os_execute == NULL) {
lua_getfield(L, -1, "execute");
lua_os_execute = lua_tocfunction(L, -1);
lua_pop(L, 1);
}

// Push the new function to overwrite the old one
lua_pushcfunction(L, os_execute);
lua_setfield(L, -2, "execute");
return 1;
}

int main(void) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
luaopen_oslibext(L);

if (luaL_dostring(L, "os.execute([[date]])") != 0) {
fprintf(stderr, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
}

lua_close(L);
}

On 11/21/19 8:17 PM, Henri Menke wrote:

Dear list,

The following Lua script behaves differently when executed in Lua vs.
LuaTeX.

  print(os.execute("date"))

It seems that the definition of os_execute in loslibext.c was copied
over from Lua 5.1 and not adapted to newer versions.

  $ lua5.1 test.lua
  0
  $ lua5.2 test.lua
  true  exit0
  $ lua5.3 test.lua
  true  exit0
  $ texlua test.lua
  0
  $ luajit test.lua
  0
  $ texluajit test.lua
  0

As you can see from the example, this comes with the additional
complication that LuaJIT has Lua 5.1 behaviour and should also retain
that.

Cheers, Henri


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

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


[NTG-context] LuaTeX incompatible with Lua

2019-11-20 Thread Henri Menke

Dear list,

The following Lua script behaves differently when executed in Lua vs.
LuaTeX.

print(os.execute("date"))

It seems that the definition of os_execute in loslibext.c was copied
over from Lua 5.1 and not adapted to newer versions.

$ lua5.1 test.lua
0
$ lua5.2 test.lua
trueexit0
$ lua5.3 test.lua
trueexit0
$ texlua test.lua
0
$ luajit test.lua
0
$ texluajit test.lua
0

As you can see from the example, this comes with the additional
complication that LuaJIT has Lua 5.1 behaviour and should also retain
that.

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

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


Re: [NTG-context] ConTeXt as a service

2019-11-20 Thread Hans Hagen

On 11/20/2019 6:10 PM, Henning Hraban Ramm wrote:


You probably need to set a few environment variables: I find HOME, PATH, 
TEXROOT and TEXMFOS in my setup. I don’t know if you really need all of them, 
it’s already running for several years…
Also your web server process might only run binaries that belong to some 
user/group like wwwrun.


normally you can run with the full path, so, here we do

/data/site/context/tex/texmf-linux-64/bin/mtxrun ..script context .

and the /data/site/context/tex/ root will be used then

(usually we have a resource and dodument sourse tree on an nfs share; 
there are documents in the distribution that explain how to deal with 
using trees and locating resources in there withput the need to scan the 
whole tree each time)


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


[NTG-context] setup according to total numbers

2019-11-20 Thread Pablo Rodriguez
Hi Hans,

this is related to a previous message
(https://mailman.ntg.nl/pipermail/ntg-context/2019/096253.html).

I don’t know how hard could to implement them, but it would be useful to
be able to setup xtables and lists based on the total number of columns,
rows and items.

Some cases would be:

- Set a different width in list if their total number of items is more
than 9 and another one if items are more than 19.

- List iwith alphabetic numbering when it contains fewer items than 5
and with digits in other case.

- Stretch xtable to width, if it contains more than 4 columns.

- Stretch xtable to height, if it contains more than 10 rows.

Sure, there may be plenty of other cases in which being able to setup
xtables and list based on the total number of their elements would be handy.

I wonder whether it would be possible to have commands that provide the
number of these elements to be used to set them up.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


[NTG-context] two issues with inmargin attachments

2019-11-20 Thread Pablo Rodriguez
Hi Hans,

I have the following sample, using latest beta from 2019.11.14 17:07:

\setuppapersize[A5]
\showframe
\setupinteraction[state=start]
\setupinteractionscreen[option=attachment]
\starttext
a\attachment[file=xml-mkiv.pdf]
b\attachment[file=mkiv-publications.pdf]
c\attachment[file=onandon.pdf, location=inmargin]
d\attachment[file=notnow.pdf, location=inmargin]
e\attachment[file=about.pdf, location=text]
f\attachment[file=i-context.pdf, location=text]
\stoptext

The default location seems to be "text", but when specified as option it
prevents the attachment. The general configuration for location may be
different, but in that case it seems impossible to use "text" for a
single attachment.

"location=inmargin" seems to place all /FileAttachment annotations on
the same place (when from the same line, they have the same /Rect), as
shown in the excerpt:

21 0 obj
<<
  /Type /Annot
  /NM (attachment:3)
  /Subtype /FileAttachment
  /Rect [ 35.54572 493.13349 41.52002 499.1078 ]
>>
endobj

22 0 obj
<<
  /Type /Annot
  /NM (attachment:4)
  /Subtype /FileAttachment
  /Rect [ 35.54572 493.13349 41.52002 499.1078 ]
>>
endobj

Would it be possible that inmargin attachments allow more than one from
the same line?

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] ConTeXt as a service

2019-11-20 Thread Henning Hraban Ramm
Hi!

I’m running ConTeXt on my web server e.g. to generate shipping forms for a 
customer.

As Hans said, it makes sense to use an asynchronous setup; in my case it’s 
celery/RabbitMQ behind Django.

You probably need to set a few environment variables: I find HOME, PATH, 
TEXROOT and TEXMFOS in my setup. I don’t know if you really need all of them, 
it’s already running for several years…
Also your web server process might only run binaries that belong to some 
user/group like wwwrun.

It won’t work in shared hosting, because you can’t install your own programs.

Otherwise: What kind of documentation do you need? Installing ConTeXt on a 
(web) server is not different from any other Linux system. Calling ConTeXt from 
a web application is not different from calling any other external program. The 
rest depends on your setup and web frameworks.

Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD


> Am 2019-11-20 um 17:07 schrieb Denis Maier :
> 
> Hi everyone,
> Is it possible to run ConTeXt as a service on a server? If yes, is there 
> documentation about this?
> Background: I'm currently on the PKP conference, and we are discussing OJS 
> plugins for automated PDF production. I was wondering if ConTeXt could be an 
> option...
> Best, 
> Denis
> 
> P.S.: I'll be giving here a brief introduction to XML typesetting with 
> ConTeXt to spread the word... just to let you know.
> 
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___


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

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


Re: [NTG-context] Exchangeing content of variables between luacode and context

2019-11-20 Thread Rudolf Bahr
On Wed, Nov 20, 2019 at 09:24:44AM +0100, Hans Hagen wrote:
> you can store info in the tuc file (there are examplex on the wiki and in
> the test suite) or you cam create a table, save it at the end of the run and
> load it at the start
> 
> (assuming that you cannot just recalculate the values each run, but i assume
> that you have a reason for not doing that)



Hraban and Hans, I thank you for your answers!

Recalculating the results of invoked Luacode functions might be the best
and simplest choice, because finding a good hash key for a lua table which
must be created by the ConTeXt/Luacode program page itself could become rather
difficult (one could get into devil's kitchen, as we say). On the other side
one single lua table only for the current run, similar to .tuc files, is helpful
and necessary to have a look onto the results of the used luacode functions.
Sometimes they are the only help in error finding.

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

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


Re: [NTG-context] ConTeXt as a service

2019-11-20 Thread Hans Hagen

On 11/20/2019 5:07 PM, Denis Maier wrote:

Hi everyone,
Is it possible to run ConTeXt as a service on a server? If yes, is there 
documentation about this?
Background: I'm currently on the PKP conference, and we are discussing 
OJS plugins for automated PDF production. I was wondering if ConTeXt 
could be an option...

Best,
Denis

P.S.: I'll be giving here a brief introduction to XML typesetting with 
ConTeXt to spread the word... just to let you know.
Running tex on demand is not really a problem but when it has to happen 
after clicking a button there is the problem of preventing a (web) 
server locking due to such aprocess as a tex run normally takes some 
time ... can be a second for some simple document but mayb eminutes for 
a 500 page document with images on each page and some 4 runs needed to 
get all cross references and lists right


so, one ends up with some independent service with a cue and a way to 
query the state of a run


there is actually code in the distribution (or can be added) that can be 
used but i never came to document it in detail (it makes no sense if 
only i use it) .. it boils down to delegating to one or more vm running 
a service that runs and reports status


among the aspects to take into account are:

- are resources needed (can be some mount)
- how long does the result needs to be kept
- when is stuff cleaned up
- how to keep things secure (no problem with xml)

etc

anyway, we have some of such workflows and once they work they do so 
forever


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


[NTG-context] ConTeXt as a service

2019-11-20 Thread Denis Maier
Hi everyone,
Is it possible to run ConTeXt as a service on a server? If yes, is there
documentation about this?
Background: I'm currently on the PKP conference, and we are discussing OJS
plugins for automated PDF production. I was wondering if ConTeXt could be
an option...
Best,
Denis

P.S.: I'll be giving here a brief introduction to XML typesetting with
ConTeXt to spread the word... just to let you know.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


[NTG-context] [updating LMTX]

2019-11-20 Thread Floris van Manen
when updating lmtx using the install.sh script, it seems to be unable to
find among others, the web2c . It looks everywhere, except the location
where it was put by that script in the first place.
/home/vm/data/context/tex/texmf/web2c

the $PATH contains
/home/vm/data/context/tex/texmf-linux-64/bin

I have no clue as how to interpret the log.
Should i define $TEXMF ?

.F


...

mtxrun  | forcing cache reload
resolvers   | resolving | looking for regular 'texmfcnf.lua' on
given path '/home/vm/texmf/web2c' from specification 'home:texmf/web2c'
resolvers   | resolving | looking for regular 'texmfcnf.lua' on
given path '/home/vm/data/texmf-local/web2c' from specification
'selfautoparent:/texmf-local/web2c'
resolvers   | resolving | looking for regular 'texmfcnf.lua' on
given path '/home/vm/data/texmf-context/web2c' from specification
'selfautoparent:/texmf-context/web2c'
resolvers   | resolving | looking for regular 'texmfcnf.lua' on
given path '/home/vm/data/texmf-dist/web2c' from specification
'selfautoparent:/texmf-dist/web2c'
resolvers   | resolving | looking for regular 'texmfcnf.lua' on
given path '/home/vm/data/texmf/web2c' from specification
'selfautoparent:/texmf/web2c'
resolvers   | resolving | looking for fallback 'contextcnf.lua' on
given path '/home/vm/texmf/web2c' from specification 'home:texmf/web2c'
resolvers   | resolving | looking for fallback 'contextcnf.lua' on
given path '/home/vm/data/texmf-local/web2c' from specification
'selfautoparent:/texmf-local/web2c'
resolvers   | resolving | looking for fallback 'contextcnf.lua' on
given path '/home/vm/data/texmf-context/web2c' from specification
'selfautoparent:/texmf-context/web2c'
resolvers   | resolving | looking for fallback 'contextcnf.lua' on
given path '/home/vm/data/texmf-dist/web2c' from specification
'selfautoparent:/texmf-dist/web2c'
resolvers   | resolving | looking for fallback 'contextcnf.lua' on
given path '/home/vm/data/texmf/web2c' from specification
'selfautoparent:/texmf/web2c'
resolvers   | resolving |
resolvers   | resolving | warning: no lua configuration files found
resolvers   | resolving | no texmf paths are defined (using TEXMF)

...

mtxrun  | unknown script 'cache.lua' or 'mtx-cache.lua'

...


pEpkey.asc
Description: application/pgp-keys
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] eqalign

2019-11-20 Thread Otared Kavian
Hi,

Indeed in ConTeXt one has better to use \startalign. Please see the excellent 
explanations by Aditya 

http://dl.contextgarden.net/myway/mathalign.pdf

Best regards: OK

> On 20 Nov 2019, at 09:01, no...@posteo.org wrote:
> 
> Dear All,
> 
> The command \eqalign does not work as described under:
>  https://wiki.contextgarden.net/Math_with_newmat
> as the ampersands are typeset (and the equal signs unaligned).
> 
> The following minimal example shows the issue:
> -
> \usemodule[newmat]
> 
> \starttext
> 
> \startformula
> \eqalign{
> A & = x\cr
>   & = y\cr}
> \stopformula
> 
> \stoptext
> -
> 
> (Issue showing up in context 2019.11.14 17:07.)
> 
> Best regards.
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___

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

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


[NTG-context] eqalign

2019-11-20 Thread nohop

Dear All,

The command \eqalign does not work as described under:
  https://wiki.contextgarden.net/Math_with_newmat
as the ampersands are typeset (and the equal signs unaligned).

The following minimal example shows the issue:
-
\usemodule[newmat]

\starttext

\startformula
\eqalign{
 A & = x\cr
   & = y\cr}
\stopformula

\stoptext
-

(Issue showing up in context 2019.11.14 17:07.)

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

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


Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Hans Hagen

On 11/20/2019 10:08 AM, Krešimir Cindrić wrote:

Thank you for the reply.

I was aware that I can install fonts in ` tex/texmf-fonts `. However, 
the idea behind my odd request was the need to have the entire project 
contained in a single directory. which I can share with people and 
compile on any computer with a working TeX Live, without them having to 
install any fonts or dependencies.


I tried setting the RUNTIMEFONTS env variable, and it does exactly what 
I want. The fact that it leaves garbage in the cache that can influence 
other, unrelated projects, is a bit unsettling, I guess I'll just have 
to remember to tell people to clean the cache.

you can rename a font to a unique name, like

myproject-myfont-it.otf

also, you can have:

texmf-fonts/fonts/data/myproject/...
texmf-project/tex/context/user/myproject/...

and such .. these are never overwritten when you update context

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


Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Krešimir Cindrić
Thank you for the reply.

I was aware that I can install fonts in ` tex/texmf-fonts `. However, the
idea behind my odd request was the need to have the entire project
contained in a single directory. which I can share with people and compile
on any computer with a working TeX Live, without them having to install any
fonts or dependencies.

I tried setting the RUNTIMEFONTS env variable, and it does exactly what I
want. The fact that it leaves garbage in the cache that can influence
other, unrelated projects, is a bit unsettling, I guess I'll just have to
remember to tell people to clean the cache.

Thanks again,

Krešimir

On Wed, 20 Nov 2019 at 09:49, Hans Hagen  wrote:

> On 11/19/2019 10:50 AM, Krešimir Cindrić wrote:
> > I'm /very/ new to ConTeXt, so please excuse the newbie question. I'm
> > trying to load a font from a file. The |.otf| files are stored in a
> > directory named |fonts/| which is in the directory of the |.tex| file
> > I'm trying to compile.
> >
> > This code does not work, and reverts to the default font:
> >
> > |\definefontfamily[mainface][serif][My Font][tf=file:./fonts/MyFont.otf,
> > it=file:./fonts/MyFont-It.otf, bf=file:./fonts/MyFont-Bd.otf,
> >
> bi=file:./fonts/MyFont-BdIt.otf]\setupbodyfont[mainface]\starttext\title{Hello,
>
> > world!}Hello World! \emph{Hi!}\stoptext|
> >
> > However, if I copy the |.otf| files into the same directory as the
> > |.tex| file, and write |tf=file:MyFont.otf| etc, then everything works
> > fine.
> >
> > How do I specify a relative path to the font, inside the |.tex| file?
> >
> > In LaTeX, I would use |fontspec| package and do the following:
> >
> > |\setmainfont{MyFont.otf}[Path =./fonts/, ItalicFont =MyFont-It.otf]|
> >
> > However, I couldn't find the equivalent syntax for |\definefontfamily|
> > in ConTeXt.
> >
> > Just to mention, I am using ConTeXt version: 2019.03.21 21:39 as part of
> > TeX Live, on Manjaro Linux.
> It is normally a bad idea to have fonts in such a place. You never know
> how it will clash with other fonts (versions, similar names, etc).
>
> In context, we have
>
> tex/texmf-fonts
>
> so best is to use:
>
> tex/texmf-fonts/data/MyFont-It.otf
>
> etc, them run mtxrun --generate and let the system sort it out.
>
> Another option is to set the RUNTIMEFONTS environment variable.
>
> Like:
>
> \starttext
>
>% \ctxlua{fonts.names.addruntimepath("./myfonts")}
>  \ctxlua{os.setenv("RUNTIMEFONTS","./myfonts")}
>
>  Hello World!
>
>  \definefont[myfont][file:myfont.otf]
>
>  {\myfont Hello World!}
>
> \stoptext
>
> But .. you need tio wipe such a font from the cache when you move it and
> other projects using a different font with the same name can be in
> trobles. Fonts are best managed very careful as they are responsible for
> long term inconsistencies.
>
> There is no official interface from tex this (maybe WS has a suggestion
> that fits into the definefontfamily subsystem)
>
> 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Hans Hagen

On 11/19/2019 10:50 AM, Krešimir Cindrić wrote:
I'm /very/ new to ConTeXt, so please excuse the newbie question. I'm 
trying to load a font from a file. The |.otf| files are stored in a 
directory named |fonts/| which is in the directory of the |.tex| file 
I'm trying to compile.


This code does not work, and reverts to the default font:

|\definefontfamily[mainface][serif][My Font][tf=file:./fonts/MyFont.otf, 
it=file:./fonts/MyFont-It.otf, bf=file:./fonts/MyFont-Bd.otf, 
bi=file:./fonts/MyFont-BdIt.otf]\setupbodyfont[mainface]\starttext\title{Hello, 
world!}Hello World! \emph{Hi!}\stoptext|


However, if I copy the |.otf| files into the same directory as the 
|.tex| file, and write |tf=file:MyFont.otf| etc, then everything works 
fine.


How do I specify a relative path to the font, inside the |.tex| file?

In LaTeX, I would use |fontspec| package and do the following:

|\setmainfont{MyFont.otf}[Path =./fonts/, ItalicFont =MyFont-It.otf]|

However, I couldn't find the equivalent syntax for |\definefontfamily| 
in ConTeXt.


Just to mention, I am using ConTeXt version: 2019.03.21 21:39 as part of 
TeX Live, on Manjaro Linux.
It is normally a bad idea to have fonts in such a place. You never know 
how it will clash with other fonts (versions, similar names, etc).


In context, we have

tex/texmf-fonts

so best is to use:

tex/texmf-fonts/data/MyFont-It.otf

etc, them run mtxrun --generate and let the system sort it out.

Another option is to set the RUNTIMEFONTS environment variable.

Like:

\starttext

  % \ctxlua{fonts.names.addruntimepath("./myfonts")}
\ctxlua{os.setenv("RUNTIMEFONTS","./myfonts")}

Hello World!

\definefont[myfont][file:myfont.otf]

{\myfont Hello World!}

\stoptext

But .. you need tio wipe such a font from the cache when you move it and 
other projects using a different font with the same name can be in 
trobles. Fonts are best managed very careful as they are responsible for 
long term inconsistencies.


There is no official interface from tex this (maybe WS has a suggestion 
that fits into the definefontfamily subsystem)


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


Re: [NTG-context] context command line interface documentation?

2019-11-20 Thread Hans Hagen

On 11/19/2019 8:10 PM, Philipp A. wrote:
That’s pretty cool, overriding that hook allows to build a ConTeXt 
language server for editors like VS Code! 
https://microsoft.github.io/language-server-protocol/


i looked at that a while ago but imo the whole server model is pretty 
complex (maintaince and compatibility hell) for something as simple as 
an edit-run-cycle .. i wait till vscode has a simple filetype related 
hit-this-key-and-run feature (last time i checked it was global for all 
file types)


Sadly I’m still a bit lost: When calling `context file_with_error.tex`, 
I see “This is LuaTeX, Version 1.10 … tex error on line … ?” and it 
waits for input.
You said that context stops when encountering an error which isn’t the 
case for me. Any ideas why?


i'm talking lmtx

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


Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Henning Hraban Ramm
In my typescripts it works with file:fonts/MyFont.otf
HTH HR

> Am 2019-11-19 um 10:50 schrieb Krešimir Cindrić :
> 
> I'm very new to ConTeXt, so please excuse the newbie question. I'm trying to 
> load a font from a file. The .otf files are stored in a directory named 
> fonts/ which is in the directory of the .tex file I'm trying to compile.
> 
> This code does not work, and reverts to the default font:
> 
> \definefontfamily [mainface][serif] [My Font]
> 
>   
> [tf=
> file:./fonts/MyFont.otf,
>it
> =
> file:./fonts/MyFont-It.otf,
>bf
> =
> file:./fonts/MyFont-Bd.otf,
>bi
> =file:./fonts/MyFont-BdIt.otf]
> 

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

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


Re: [NTG-context] Exchangeing content of variables between luacode and context

2019-11-20 Thread Hans Hagen

On 11/19/2019 8:34 PM, Rudolf Bahr wrote:


My 'actual problem' is more or less a design problem: Should in a book project
ConTeXt be the master and Luacode the slave or vice versa? Both seems possible.


nearly always context is th emaster (it is anyway as it manages the 
process)



The task to solve is to set a photo album with say 300 DIN A4 landscape pages.
On every page there should be 1 to 4 columns filled with photos and texts mostly
defined in layers.

Up to now I made all in ConTeXt manually by trying, for instance::
- To estimate the width of layers, if neighboured layers should contain photos 
of
   same height with respect to center horizontally all columns at end of page.


can be done in tex of lua


- To complete abbreviations of long picture names; it's rather annoying doing
   this by copy and paste with hundreds of photo names; instead I'd like to type
   a short code and Luacode should complete it to the full name.


that can be done runtime ...


- To estimate the shift amount of all columns together in order to horizontally
   get them centered on the page.


can be done by tex or lua


All of these tasks can be made best by Luacode functions. And I'd like to save
their results in the ConTeXt program permanently. With 'tokens.setters.macro()'
it's possible only in the same, Luacode calling ConTeXt run. In the following
run, the macro shows its original value again and the Luacode program must be
called again to alter it.


you can store info in the tuc file (there are examplex on the wiki and 
in the test suite) or you cam create a table, save it at the end of the 
run and load it at the start


(assuming that you cannot just recalculate the values each run, but i 
assume that you have a reason for not doing that)



So I've to think about making Luacode the master and ConTeXt the slave. Then 
it'd
be possible to embody Luacode's results permanently in the ConTeXt code. Vice 
versa
a solution could be to store Luacode's results in a flattened Lua table on disc.
But the perfect relating to their ConTeXt page remains difficult when inserting
or deleting of pages in an ensemble of 300 pages should become necessary. 
Another
much simpler solution would be the proposal above, namely, to copy the ConTeXt
program step by step and page by page to another file and introducing the 
Luacode
results simultaneously.


if each page can be recognized you can make a hash of its properties and 
store the page specific data using that hash



In [1] there is a chapter with "stepper" commands, but I didn't understand that,
so I can't say, whether they are suitable for this issue.


unrelated

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