[NTG-context] Getting dimensions in Lua

2021-01-17 Thread Jairo A. del Rio
Hi, list.

I want to get some dimensions in Lua. See, for instance

\starttext

\the\dimexpr\availablehsize\relax %say, 426pt

\stoptext

Is there an equivalent in ConTeXt for Lua, i.e. without passing values from
TeX or, at least, using only Lua commands? Thank you in advance.

Best wishes,

Jairo
___
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] expansion of xml userdata

2021-01-17 Thread Jano Kula
On Sun, 17 Jan 2021 at 21:27, Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> wrote:

> > Do you know how to force expansion of userdata?
>
> You can drop "expansion=yes" when you use
>
> \normalexpanded{\startsection[..,..=..,..][..,..=..,..]}
>
> Wolfgang
>

Wow, this was fater then filling my glass. And it works even for userdata.
Thank you, Wolfgang.
Added to wiki \setuphead  and
Interaction .

To finish the story of expansion parameter, what is expansion=xml good for?

Jano
___
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] LMTX isn't typesetting math correctly with Pagella

2021-01-17 Thread Hans Hagen

On 1/16/2021 12:33 AM, Hans Hagen wrote:

On 1/15/2021 1:33 PM, Jack Hill wrote:

Hi,

I've been having some trouble with ConTeXt not typesetting math 
correctly when using the Pagella font (I do not know if the same issue 
occurs with other fonts as I haven't tested them).


If I compile with LMTX, the spacing between letters becomes very small 
so that when I type "|f|", for example, the second "|" intersects the 
f and looks rather ugly. However, compiling with the --luatex switch 
fixes these issues and the math looks nice again.


Can anybody else replicate this issue, and does anybody know why it is 
happening?


This the code I used to test:

|\setupbodyfont[pagella] \starttext \startformula |f| = \sqrt{\int_0^1 
|f(t)|^2 \text{d}t} \stopformula \stoptext |||
I'll check it ... smells like some interference between newer and older 
corrections (these gyre fonts need some special treatment).

I uploaded lmtx.

Here is the story about math:

- there is traditional math, the 8 bit fonts (from Don Knuth)
- and there is opentype math (originating at Microsoft)

the eight bit fonts are all modelled after the cmr fonts so they have 
the same set of parameters, the same assumptions about family 2 and 3, 
use the same width/height/depth trickery


one thing is that they lie about the width: the italic correction is 
subtracted from the width and the engine always adds it when a glyph is 
dealt with but then removes in some cases afterwards


in opentype we also have italic correction but that is applied in 
specific cases; there the shapes have a real width


(there are tricks to make fonts seen as opentype be treated as old 
school which work ok for virtual constructs that only use those 8 bit 
fonts but often fail for gyre fonts)


now, the gust foundation fonts are a mix: they are opentype, have its 
parameters and properties but have the wrong width and assume the italic 
hackery


the microsoft cambria font is the reference for opentype math (and to 
some extend microsoft word also is)


afaik xetex uses the old tex approach also for opentype so that is why 
probably the old width approach works ok there but i never looked into 
it; cambria is an opentype font but probably seldom used so side effects 
will go unnoticed, also, texies often have no problem blaming microsoft, 
even when they got it right; of course we have to admit that 'moving 
forward wrt math fonts' didn't come from our community so we just have 
to follow


now, when we move on (with context + luametatex) to a variants font 
scaling model, i need to adapt the math machinery to deal with that ... 
this can have side effects as you noticed but these will be dealt with 
(or fixed when something is wrong)


in context we have font goodies that can handle this (widths, kerns etc) 
and we do so for at least the 'f' which also has a strange left offset 
... i now adapted that to also serve the new (compact context font) 
model and also make sure that the smaller sizes for mkiv are handled; we 
can add more in those files, but that's also a (math) user effort


to be decided is of we use the feature setting "mathkerns=yes" (this was 
a directive but i made it just a feature)


Now, ideally:

   \enableexperiments[fonts.compact] % for the definitions

should give nearly similar results (but less mem usage, less fonts 
loaded and possibly some performance gain)


I also updated some test features:

   \definefontfeature[mathextra][staircase=yes,boundingbox=frame]

as part of the general lmtx upgrading process. Only cambria (and lucida) 
have these staircase kerns and e.g. pagella and friends have a few 
defined in the font goodies but one has to do something liek this:



\definefontfeature[mathextra][mathkerns=yes,staircase=yes,boundingbox=frame]

more such tracers will be added in due time (and some old ones will go 
away as they lost their purpose).


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] expansion of xml userdata

2021-01-17 Thread Wolfgang Schuster

Jano Kula schrieb am 17.01.2021 um 21:22:

Hello to everybody!

\setuphead[section][expansion=yes] expands xml reference to the actual 
content in TUC file:


\xmlatt {xml:name::4}{title} → First section

for titles & bookmarks. The same is not true for userdata (mkiv & mkxl). 
Do you know how to force expansion of userdata?



You can drop "expansion=yes" when you use

\normalexpanded{\startsection[..,..=..,..][..,..=..,..]}

Wolfgang
___
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] expansion of xml userdata

2021-01-17 Thread Jano Kula
Hello to everybody!

\setuphead[section][expansion=yes] expands xml reference to the actual
content in TUC file:

\xmlatt {xml:name::4}{title} → First section

for titles & bookmarks. The same is not true for userdata (mkiv & mkxl). Do
you know how to force expansion of userdata?

MWE attached.

Thank you,
Jano

\startbuffer[doc]



text


text


\stopbuffer

\setuphead[section][expansion=yes]
\setuplist[section][alternative=command,
command=\SectionListCommand]

\define[3]\SectionListCommand{%
   {\bf#1\par
   title: #2\par
   usertitle: \structurelistuservariable{usertitle}}\par
   \blank
   \endgraf}

\startxmlsetups xml:name
\xmlsetsetup{\xmldocument}{document|section}{xml:name:*}
\stopxmlsetups
\xmlregistersetup{xml:name}

\startxmlsetups xml:name:document
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:name:section
\startsection[title=\xmlatt{#1}{title}]
 [usertitle=\xmlatt{#1}{title}]
\stopsection
\stopxmlsetups

\starttext
\placelist[section]
\xmlprocessbuffer{xml:name}{doc}{}
\stoptext


xml-one-file-head-toc.tex
Description: Binary data
___
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] question about vardef variables

2021-01-17 Thread Jeong Dal
Dear Damien Thiriet,

If you change ‘vardef’ to ‘def’, you will get the figure.
There is a difference between ‘vardef’ and ‘def’.
AFAIK, vardef returns the value of the last statement in the macro.
Please see  the examples in Metafun manual from page 32 ~ .
I hope that you find your answer there.

I am sorry that I am not good enough to explain the variables.

Best regards,

Dalyoung

> 2021. 1. 17. 오후 8:00, ntg-context-requ...@ntg.nl 작성:
> 
> \starttext
> \startMPpage
> 
> vardef Test (expr ab,cd)=
>   %numeric ab;
>   %numeric cd;
>   draw unitsquare scaled 10 xshifted ab;
>   draw unitsquare scaled 10 yshifted cd;
> enddef;
> 
> Test (50,100);
> \stopMPpage
> \stoptext

___
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] question about vardef variables

2021-01-17 Thread Damien Thiriet
Hi,


I have some troubles with understanding metafun's macro mechanism.

Given this MWE:

\starttext
\startMPpage

vardef Test (expr ab,cd)=
   %numeric ab;
   %numeric cd;
   draw unitsquare scaled 10 xshifted ab;
   draw unitsquare scaled 10 yshifted cd;
enddef;

Test (50,100);
\stopMPpage
\stoptext

Uncommenting the two declarations makes me run intro a silent error. I was 
lucky enough yesterday to get an explicit error message with a more 
complex macro.  It made me figure out where my problems came from.

So here are my two questions:
- Why shouldn't we tell metafun if expr is a path, a pair or so on?
- Would it be possible to issue an error message each time this wrong
declaration is made?

Thanks,


Damien Thiriet 
___
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
___