[NTG-context] \framed[align=] with a 'maxwidth' instead of a width? Or get the size of a \frame returned to lua without typesetting it in a document?

2020-04-26 Thread Gerben Wierda
Setup:

TeX file
Contains ctxlua{} call
lua function reads XML file and calls context() statements, it 
puts out a
\startMPpage
METAPOST statements
Of which some are textext(\framed[align, so 
vbox, width defined by lua]{}, the whole TeX string for textext is created in 
lua and passed whole on to METAPOST as METAPOST is pretty limited on string 
manipulation compared to lua)
\stopMPpage

I am running into the following conundrum:

If I do give it a width (say a maximum) it will also be that wide when it is 
mostly empty if there is little text, this interferes with optimal placing
If I don’t give a width to the \framed command it may grow far too wide if 
there is a lot of text instead of wrapping around.

The typeset text is rather unpredictable. It may be three very short 
single-word lines with \\ at the end but it may also be a large paragraph.

So, I would like to find a way to let the \framed become a box as narrow as 
possible, but not growing wider than a pre-set width.

This is way too difficult for my meagre skills. What I could do (but I think is 
clumsy) is pass two \framed commands to METAPOST, have both by typeset with 
textext() and if the one without a width becomes too wide, take the one with 
the width set.

But I would like a neater option. E.g. call TeX (no need for METAPOST in 
between) from lua to typeset the \framed without actually typesetting it to the 
document and getting the dimensions back to lua so I can decide there what to 
do. Or a \specialframed command where I don’t give it a ‘width', but a 
‘maxwidth’

Is one of these doable? If not, I’ll have to implement the ‘clumsy’ route.

Preferably (the what is now thought of as ideal solution) I would be able in 
lua to give a piece of TeX code to TeX and ask it to produce a box and give me 
the dimensions of that box. That alone would give me an option, e.g.

- trial typeset
- if box surface (w*h) is more than what is available, shrink font size and 
lineheight so the total will be within set limits, then typeset it again with 
the smaller font and max width available
- else, if trial box width is more than the width available, typeset again with 
fixed width
- else use the way the trial box was typeset 

But I’m still puzzling.

G

PS. Why is the bbox of a textext(\framed[]{}) slightly larger than the frame?
___
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] register entries in footnotes

2020-04-26 Thread Hans Hagen

On 4/26/2020 4:35 PM, Thomas A. Schmitz wrote:
A similar question has been asked three years ago, and Rik Kabel posted 
a partial solution, adapted here:


\defineprocessor [Footnote] [right={ n}]

\define[1]
   \fnindex{\index[Footnote->]{#1}}

\starttext

This is a sentence with a term in the index: cat\index{cat}. This 
sentence also has an indexed term, dog\index{dog}, as well as a 
footnote.\footnote{The footnote also contains an indexed term, 
mouse.\fnindex{mouse}}


\page

\placeregister [index]

\stoptext

And about a year ago, Hans made a different suggestion to my own 
question; however, I didn't realize then that it was not what I was 
looking for:


\starttext

   Test1: \index{cat}cat.
\footnote{Test2: \index{mouse}mouse.}
\footnote[note:cat]{Test3: \index[cat]{cat in \in{note}[note:cat]}cat.}

\page

\placeregister [index]
\stoptext

This creates two index entries for cat, which is not the intended result.

My questions are:

1. I would like to have the footnote number appear in the index, so it 
says something like "cat 1 n. 1." Is that possible?


2. Is it necessary to define an extra command for index entries in 
footnotes? Is context clever enough to know that it's processing a 
footnote, so one could write a condition such as (pseudocode):


\define [1]
   \myindex
   {\infinfootnoteelse
     {\index[Footnote]->{#1}}
     {\index{#1}}}

Thanks a lot, have a good Sunday!

You probably know intuitively that there is an answer, don't you?

\unexpanded\def\doifelseinnote
  {\ifconditional\processingnote
 \expandafter\firstoftwoarguments
   \else
 \expandafter\secondoftwoarguments
   \fi}

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] bug in PDF boxes? (was: Re: Trouble setting PDF boxes))

2020-04-26 Thread Jack Steyn
I would like to add though that even if the code you posted did work
properly, Pablo, it wouldn't solve my original problem. It would be good if
cropoffset, trimoffset etc. took two dimensions, one for the x direction
and one for the y direction, instead of one for both. But I appreciate you
changing the subject to increase visibility.

Jack

On Sun, 26 Apr 2020 at 19:47, Pablo Rodriguez  wrote:

> On 4/25/20 2:37 PM, Jack Steyn wrote:
> > Hi,
> >
> > I am having trouble setting the PDF boxes to my desired dimensions.
> > Suppose I have \setuppapersize[/a/][/b/]. I want CropBox = MediaBox
> > =/ //b/. So far, so good: I can just use cropoffset=0mm in \setuplayout.
> > But I want TrimBox = /a/. However, as far as I can see, I can't achieve
> > this using trimoffset in \setuplayout unless (width of /b/) – (width of
> > /a/) = (height of /b/) – (height of /a/), which does not hold in my
> > case. So it looks like I need to find another way to set the TrimBox
> > (and the BleedBox, which I want to be 3mm wider and taller than the
> > TrimBox). Does anyone know how to do this?
>
> Hi Jack,
>
> there seems to be a bug in ConTeXt (both in MkXL and MkIV).
>
> From this code:
>
> \setuplayout
>  [cropoffset=15ex,
>   trimoffset=20ex,
>   bleedoffset=25ex,
>   artoffset=30ex]
>
> \starttext
> \input zapf
> \stoptext
>
> I get the relevant code:
>
>   /CropBox [ 0 0 595.2756 841.8898 ]
>   /MediaBox [ 0 0 595.2756 841.8898 ]
>   /TrimBox [ 0 0 595.2756 841.8898 ]
>
> I think it might be a bug that prevents this from working properly.
> (ArtBox is simply disabled.)
>
> Hans, could you check this? Many thanks for your help.
>
> Pablo
>
> PS: sorry for having changed the subject, Jack. It intends only to
> increase visibility about code that may need to be improved.
> --
> 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
>
> ___
>
___
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] register entries in footnotes

2020-04-26 Thread Thomas A. Schmitz
A similar question has been asked three years ago, and Rik Kabel posted 
a partial solution, adapted here:


\defineprocessor [Footnote] [right={ n}]

\define[1]
  \fnindex{\index[Footnote->]{#1}}

\starttext

This is a sentence with a term in the index: cat\index{cat}. This 
sentence also has an indexed term, dog\index{dog}, as well as a 
footnote.\footnote{The footnote also contains an indexed term, 
mouse.\fnindex{mouse}}


\page

\placeregister [index]

\stoptext

And about a year ago, Hans made a different suggestion to my own 
question; however, I didn't realize then that it was not what I was 
looking for:


\starttext

  Test1: \index{cat}cat.
\footnote{Test2: \index{mouse}mouse.}
\footnote[note:cat]{Test3: \index[cat]{cat in \in{note}[note:cat]}cat.}

\page

\placeregister [index]
\stoptext

This creates two index entries for cat, which is not the intended result.

My questions are:

1. I would like to have the footnote number appear in the index, so it 
says something like "cat 1 n. 1." Is that possible?


2. Is it necessary to define an extra command for index entries in 
footnotes? Is context clever enough to know that it's processing a 
footnote, so one could write a condition such as (pseudocode):


\define [1]
  \myindex
  {\infinfootnoteelse
{\index[Footnote]->{#1}}
{\index{#1}}}

Thanks a lot, have a good Sunday!

Thomas
___
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] Basic font question (Optima, but no bold, no italics). Standalone ConTeXt does not work. TeX Live 2019 works

2020-04-26 Thread Benjamin Buchmuller
The problem seems to be resolved. Thanks to everyone, especially Hans, Taco and 
Wolfgang for the fast fix (offlist)!

After updating to

ConTeXt  ver: 2020.01.30 14:13 MKIV beta  fmt: 2020.4.26

Helvetica Neue works with:
==

\starttypescript [sans] [helvet]
   \setups[font:fallback:sans]
   \definefontsynonym [Sans]   [file:Helvetica Neue.ttc(Helvetica 
Neue)] [features=default]
   \definefontsynonym [SansBold]   [file:Helvetica Neue.ttc(Helvetica Neue 
Bold)]   [features=default]
   \definefontsynonym [SansItalic] [file:Helvetica Neue.ttc(Helvetica Neue 
Italic)]  [features=default]
   \definefontsynonym [SansBoldItalic] [file:Helvetica Neue.ttc(Helvetica Neue 
Bold Italic)] [features=default]
\stoptypescript

\definetypeface [helvet] [ss] [sans] [helvet] [default] 

\setupbodyfont [helvet, 12pt]

Optima works with:
==

\starttypescript [sans] [optima]
  \setups[font:fallback:sans]
  \definefontsynonym [Sans]   [file:Optima.ttc(Optima Regular)] 
[features=default]
  \definefontsynonym [SansBold]   [file:Optima.ttc(Optima Bold)]   
[features=default]
  \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)]  
[features=default]
  \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] 
[features=default]
\stoptypescript

\definetypeface [optima] [ss] [sans] [optima] [default]

\setupbodyfont [optima]

\starttext
\tf Upright,
\bf Bold,
\it Italic,
\bi Bolditalic
\stoptext

Note 1: mtxrun --script fonts --list --all --pattern=helvetica etc. might still 
not display all variants correctly in the first place.

Note 2: There are predefined typescripts for Mac OS in ConTeXt 
(type-imp-osx.mkiv) but the file needs a update/cleanup.

> On 24 Apr 2020, at 12:14, Benjamin Buchmuller  
> wrote:
> 
> Hi Hraban,
> 
> Thanks for the hint (and the proper fontfamily setup), I have forced reload 
> ten times now from various accounts; the issue persists unfortunately. 
> 
> This might confirm Taco‘s notion that there is some bug lmtx. I’m running 
> macOS Catalina too, but as it worked with the standalone of Dec/Jan three 
> days ago, I suspect it is not because of a new feature in the OS, but rather 
> an old feature in mtxrun or elsewhere having disappeared. 
> 
>> On 24. Apr 2020, at 11:35, Henning Hraban Ramm  wrote:
>> 
>> 
>> 
>>> Am 24.04.2020 um 11:13 schrieb Benjamin Buchmuller 
>>> :
>>> 
>>> Although this specific issue might have been solved meanwhile by the 
>>> helpful suggestions of Wolfang, Thomas and others, I would like to point 
>>> out that I have recently also encountered an odd behaviour of the mtxrun 
>>> fontloader in the standalone, in which not all typefaces are 
>>> available/properly identified.
>>> 
>>> (I’m sorry to hijack this thread if this is unrelated.)
>>> 
>>> Basically, when I load “Helvetica Neue”, I get instead of “regular/normal” 
>>> always “light/italic”.
>>> 
>>> I have switched to heros for the meantime, but potentially there is some 
>>> bug behind this. (My documents with the version from Dec/Jan worked fine.)
>>> 
>>> I recite my example from Wed:
>>> 
>>> ConTeXt  ver: 2020.01.30 14:13 MKIV beta  fmt: 2020.4.22 (LuaTeX 1.11.1)
>>> 
>>> and I’m running now into troubles with system font indexing:
>>> 
>>> mtxrun --script fonts --reload
>>> 
>>> locates fonts in macOS directories appropriately (*.afm fonts placed in 
>>> .../tex/texmf-fonts are not found, but at the moment I don’t care too 
>>> much), however it resolves only to a single font variant for *.ttc instead 
>>> of all variants:
>>> 
>>> mtxrun --script fonts --list --all --pattern=helvetica
>>> 
>>> helvetica helvetica
>>> helveticalightoblique /System/Library/Fonts/Helvetica.ttc   
>>>  6
>>> helveticalightoblique helvetica
>>> helveticalightoblique /System/Library/Fonts/Helvetica.ttc   
>>>  6
>>> helveticaneuedeskinterfaceheavy   helveticaneuedeskinterface   
>>> helveticaneuedeskinterfaceheavy   
>>> /System/Library/Fonts/HelveticaNeueDeskInterface.ttc   10
>>> helveticaneuethinitalic   helveticaneue
>>> helveticaneuethinitalic   /System/Library/Fonts/HelveticaNeue.ttc   
>>>  14
>> 
>> If the subfont is not listed, ConTeXt/mtxrun couldn’t find it and won’t find 
>> it regardless of your setup.
>> 
>> Try
>> mtxrun --script fonts --reload --force
>> maybe even twice or thrice and check again.
>> (Unfortunately this is not reliable.)
>> 
>> I get the full list:
>> 
>> identifier   familyname   
>> fontname   filename  
>>  subfont   instances
>> 
>> helveticahelvetica
>> helvetica  
>> /System/Library/Fonts/Helvetica.ttc 

[NTG-context] bug in PDF boxes? (was: Re: Trouble setting PDF boxes))

2020-04-26 Thread Pablo Rodriguez
On 4/25/20 2:37 PM, Jack Steyn wrote:
> Hi,
>
> I am having trouble setting the PDF boxes to my desired dimensions.
> Suppose I have \setuppapersize[/a/][/b/]. I want CropBox = MediaBox
> =/ //b/. So far, so good: I can just use cropoffset=0mm in \setuplayout.
> But I want TrimBox = /a/. However, as far as I can see, I can't achieve
> this using trimoffset in \setuplayout unless (width of /b/) – (width of
> /a/) = (height of /b/) – (height of /a/), which does not hold in my
> case. So it looks like I need to find another way to set the TrimBox
> (and the BleedBox, which I want to be 3mm wider and taller than the
> TrimBox). Does anyone know how to do this?

Hi Jack,

there seems to be a bug in ConTeXt (both in MkXL and MkIV).

From this code:

\setuplayout
 [cropoffset=15ex,
  trimoffset=20ex,
  bleedoffset=25ex,
  artoffset=30ex]

\starttext
\input zapf
\stoptext

I get the relevant code:

  /CropBox [ 0 0 595.2756 841.8898 ]
  /MediaBox [ 0 0 595.2756 841.8898 ]
  /TrimBox [ 0 0 595.2756 841.8898 ]

I think it might be a bug that prevents this from working properly.
(ArtBox is simply disabled.)

Hans, could you check this? Many thanks for your help.

Pablo

PS: sorry for having changed the subject, Jack. It intends only to
increase visibility about code that may need to be improved.
--
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
___