Re: [NTG-context] How to check if buffer or block has content

2021-08-03 Thread Benjamin Buchmuller via ntg-context
Wow, that's powerful!

I'll add the wiki entries later tonight. 

Thanks a lot!

> On Aug 3, 2021, at 17:02, Hans Hagen  wrote:
> 
> On 8/2/2021 8:54 PM, Benjamin Buchmuller via ntg-context wrote:
>> That's great, I wikified a Note for testing if a buffer exists or has 
>> content (using the \getbuffer[…] approach for the moment).
>> If I was asked, I'd opt for \doifelseemptybuffer (doifemptyelse?) since one 
>> could think of similar commands that test for empty "objects".
>> Is there an option for testing blocks? (I actually use blocks quite 
>> frequently …)
>> I just realized they are probably handled very differently during the 
>> typesetting. Basically I would just need to test if during the first run any 
>> of \beginBLOCK … \endBLOCK was invoked (but if one gets a test for some 
>> content in-between that's even better).
>> As an alternative solution, is there a way to add content to buffers? 
>> Unfortunately, I can't use \getbuffer[first,second], but 
>> \startbuffer[first][add=yes] … \stopbuffer would be nice.
> just for fun I made this:
> 
> \starttext
> 
> \startbuffer[test]
>test
> \stopbuffer
> 
> \startbuffer[oeps]
>oeps
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \startbuffer[test = * + test]
>prepend
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \startbuffer[test = test + *]
>append
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \startbuffer[test = * +++ test]
>before
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \startbuffer[test = test +++ *]
>after
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \startbuffer[test = * + oeps + test + oeps + * ]
>DONE
> \stopbuffer
> 
> \typebuffer[test] \getbuffer[test]
> 
> \stoptext
> 
> which results in
> 
> test
> test
> prependtest
> prependtest
> prependtestappend
> prependtestappend
> before
> prependtestappend
> before
> prependtestappend
> before
> prependtestappend
> after
> before
> prependtestappend
> after
> DONEoepsbefore
> prependtestappend
> afteroepsDONE
> DONEoepsbefore
> prependtestappend
> afteroepsDONE
> 
> so basically one can combine buffers any way
> 
> +   : nothing in between
> ++  : space in between
> +++ : empty line in between
> 
> 
> -
>  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] issue with signature fields in Acrobat

2021-08-03 Thread Pablo Rodriguez via ntg-context
Hi Hans,

I have the following sample:

  \setupinteraction[state=start]
  \starttext
  \startTEXpage[offset=2em]
  \setupfield[ShortLine][horizontal][width=5cm,height=5em]
  \definefield [Email] [signature] [ShortLine]
  \field [Email] [your email]
  \stopTEXpage
  \stoptext

If I sign it with Acrobat Reader, Times New Roman is used instead of
MyriadPro (which is the default font used by Acrobat for signing).

Line 945 from lpdf-fld.lmt contains:

  if #collected > 0 then
  local acroform = pdfdictionary {
  NeedAppearances = pdfmajorversion() == 1 or nil,
  Fields  = pdfreference(pdfflushobject(collected)),
  CO  = fieldsetlist(calculationset),
  }
  if sometext or somefont then
  checkpdfdocencoding()
  if sometext then
  usedfonts.tttf = fontnames.tt.tf
  acroform.DA = "/tttf 12 Tf 0 g"
  end
  acroform.DR = pdfdictionary {
  Font = registerfonts(),
  Encoding = pdfdocencodingcapsule,
  }
  end
  lpdf.addtocatalog("AcroForm",pdfreference(pdfflushobject(acroform)))
  end

Would it be possible that the second conditional ("if sometext or
somefont") could be only applied if Fields doesn’t refer to signatures?

Otherwise, Acrobat will use the font specified in the dictionary. Among
other things, this breaks PDF/A documents, since the font for the
signature isn’t embedded.

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] How to check if buffer or block has content

2021-08-03 Thread Hans Hagen via ntg-context

On 8/2/2021 8:54 PM, Benjamin Buchmuller via ntg-context wrote:

That's great, I wikified a Note for testing if a buffer exists or has content 
(using the \getbuffer[…] approach for the moment).

If I was asked, I'd opt for \doifelseemptybuffer (doifemptyelse?) since one could think 
of similar commands that test for empty "objects".

Is there an option for testing blocks? (I actually use blocks quite frequently 
…)

I just realized they are probably handled very differently during the 
typesetting. Basically I would just need to test if during the first run any of 
\beginBLOCK … \endBLOCK was invoked (but if one gets a test for some content 
in-between that's even better).

As an alternative solution, is there a way to add content to buffers? 
Unfortunately, I can't use \getbuffer[first,second], but 
\startbuffer[first][add=yes] … \stopbuffer would be nice.

just for fun I made this:

\starttext

\startbuffer[test]
test
\stopbuffer

\startbuffer[oeps]
oeps
\stopbuffer

\typebuffer[test] \getbuffer[test]

\startbuffer[test = * + test]
prepend
\stopbuffer

\typebuffer[test] \getbuffer[test]

\startbuffer[test = test + *]
append
\stopbuffer

\typebuffer[test] \getbuffer[test]

\startbuffer[test = * +++ test]
before
\stopbuffer

\typebuffer[test] \getbuffer[test]

\startbuffer[test = test +++ *]
after
\stopbuffer

\typebuffer[test] \getbuffer[test]

\startbuffer[test = * + oeps + test + oeps + * ]
DONE
\stopbuffer

\typebuffer[test] \getbuffer[test]

\stoptext

which results in

test
test
prependtest
prependtest
prependtestappend
prependtestappend
before
prependtestappend
before
prependtestappend
before
prependtestappend
after
before
prependtestappend
after
DONEoepsbefore
prependtestappend
afteroepsDONE
DONEoepsbefore
prependtestappend
afteroepsDONE

so basically one can combine buffers any way

+   : nothing in between
++  : space in between
+++ : empty line in between


-
  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] How to check if buffer or block has content

2021-08-03 Thread Hans Hagen via ntg-context

On 8/2/2021 8:54 PM, Benjamin Buchmuller via ntg-context wrote:

That's great, I wikified a Note for testing if a buffer exists or has content 
(using the \getbuffer[…] approach for the moment).

If I was asked, I'd opt for \doifelseemptybuffer (doifemptyelse?) since one could think 
of similar commands that test for empty "objects".

Is there an option for testing blocks? (I actually use blocks quite frequently 
…)

I just realized they are probably handled very differently during the 
typesetting. Basically I would just need to test if during the first run any of 
\beginBLOCK … \endBLOCK was invoked (but if one gets a test for some content 
in-between that's even better)


indeed, multiple axis ... so then we need three arguments instead of one 
for the test


\defineblock[testa]
\defineblock[testb]

\starttext

\begintesta
oeps
\endtesta

\doifelseblocksempty {testa}{}{} {YES} {NOP} % {name}{tag}{criterium}
\doifelseblocksempty {testb}{}{} {YES} {NOP} % {name}{tag}{criterium}

\stoptext

but you have to wikify it

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] How to check if buffer or block has content

2021-08-03 Thread Hans Hagen via ntg-context

On 8/2/2021 6:31 PM, Wolfgang Schuster via ntg-context wrote:


\doifelsebufferempty


i go for that one (mkiv and lmtx0 ; btw, \doifelsebuffer is expandable 
but the empty test not)


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
___