Re: [NTG-context] Problem using \scale

2023-02-10 Thread Bruce Horrocks via ntg-context

> On 10 Feb 2023, at 09:20, Hans Hagen via ntg-context  
> wrote:

[snip]

Thank-you Hans, these work great - so well in fact that now I've seen the 
output I've come to the conclusion that the scaled text would be too small and 
what I should really do is flag the one or two addresses in our mailing list 
that have long lines and print them on larger labels in a separate run. :-)

—
Bruce Horrocks
Hampshire, UK

___
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] issue with custom hyphenator

2023-02-10 Thread Pablo Rodriguez via ntg-context
Dear list,

I have just copied this from
https://www.pragma-ade.com/general/manuals/languages-mkiv.pdf#page=23:

  \startluacode
  local subset = {
  a = true,
  e = true,
  i = true,
  o = true,
  u = true,
  y = true,
  }

  languages.hyphenators.traditional.installmethod("test",
  function(dictionary,word,n)
  local t = { }
  for i=1,#word do
  local w = word[i]
  if subset[w] then
  t[i] = {
  before = "<" .. w,
  after  = w .. ">",
  left   = false,
  right  = false,
  }
  else
  t[i] = false
  end
  end
  return t
  end
  )
  \stopluacode

  \definehyphenationfeatures
[demo]
[alternative=test]
  \setuphyphenation[method=traditional]

  \starttext
  %\righthyphenmin=-1
  \sethyphenationfeatures[demo]
  \hsize\zeropoint
  coming anaback
  \stoptext

Using current latest (from 2023.02.07 19:06), I get:

  cing
  anack

I’m missing m and b in the hyphenated words.

I’m afraid that the hyphenator is all Greek to me.

Is there any reason why letters are lost in hyphenation?

I’m afraid (I think) I might have hit a bug.

Many thanks for your help,

Pablo
___
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] setupregister/placeregister

2023-02-10 Thread Alan Braslau via ntg-context
Hello,

The criterium key in setupregister (so placeregister, placeindex, ...)
takes the following values:
criterium   local text current previous all section

all: places all entries of the document
section: (part, chapter, section, ...) places entries associated with
that structure element.

Can someone explain local, text, current, previous
for their scope and perhaps subtle differences are not entirely obvious
to me.

Thank you

Alan
___
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] Chapter title in MetaFun manual.

2023-02-10 Thread Jeong Dal via ntg-context
Dear all,
 
I think that I found the cause.
The page layout of my file is different from that of MetaFun manual.
After borrowing the \setuplayout from MetaFun-000.tex, it works correctly.

I am sorry to give you a wrong example.

Thank you for reading.

Best regards,

Dalyoung


> 2023. 2. 10. 오후 9:05, Jeong Dal via ntg-context  작성:
> 
> Dear all,
> 
> I copied the code of defining chapter command  from metafun-000.tex, and run 
> it.
> But the result is different from that in MetaFun Manual.
> There is a big spaces between the number and the title which yields the 
> number cannot be seen.
> I commented out several lines which seems to be not-related with chapter 
> title.
> And, I changed
> 
>   \def\ChapterCommand#1#2% —> \define[2]\ChapterCommand
> 
> Would you please test the following code to find out what is wrong?
> 
> Thank you for reading.
> 
> Best regards,
> 
> Dalyoung
> 
> 
> \startuseMPgraphic{circled}
>   pickup pencircle scaled 1mm ;
>   drawoptions(withcolor (.6+uniformdeviate.35)*white) ;
>   fill fullcircle xscaled 1.5cm yscaled 1cm ;
>   drawoptions(withcolor .625yellow) ;
>   draw fullcircle xscaled 1.5cm yscaled 1cm ;
> \stopuseMPgraphic
> 
> %\startnotmode[proof]
> %  \defineoverlay[circled][\useMPgraphic{circled}]
> %\stopnotmode
> 
> \define[1]\Circled%
>   {\framed
>  [background=circled,frame=off,offset=overlay]
>  {\color[darkred]{#1}}}
> 
> \setuppagenumbering[location=]
> \setupheadertexts[margin][][\hbox to \hsize{\hss\Circled\pagenumber\hss}]
> 
> \startuniqueMPgraphic{titled}
>   path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ;
>   pickup pencircle scaled 1mm ;
>   drawoptions(withcolor .625yellow) ;
>   draw llcorner p -- lrcorner p ;
>   setbounds currentpicture to p ;
> \stopuniqueMPgraphic
> 
> \defineoverlay[titled][\uniqueMPgraphic{titled}]
> 
> \define[2]\ChapterCommand%
>   {\setbox0=\hbox to \leftmarginwidth{#1\hss}%
>\hskip-\leftmarginwidth
>\hskip-\leftmargindistance
>\framed
>  [background=titled,frame=off,offset=0pt]
>  {\box0
>   \hskip\leftmargindistance
>   #2}}
> 
> \define[2]\TitleCommand%
>   {\framed
>  [background=titled,frame=off,offset=0pt]
>  {#2}}
> 
> \setuphead
>   [chapter]%,section,subsection]
>   [command=\ChapterCommand,
>style=\ss\bf\tfd,
>color=darkred]
> 
> \setuphead
>   [title]%,subject,sububject]
>   [command=\TitleCommand,
>style=\ss\bf\tfd,
>color=darkred]
> 
> 
> \setupbodyfont[bonum,rm,12pt]
> \showframe
> 
> \starttext
> \startchapter[title={Introduction}]
> This is the chapter for introduction.
> \stopchapter
> 
> \startchapter[title={Function}]
> Now, we study the function.
> \stopchapter
> 
> \starttitle[title={References}]
> \startitemize[n]
> \item first
> \item second
> \item third
> \stopitemize
> \stoptitle
> 
> \stoptext
> ___
> 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
___


[NTG-context] Chapter title in MetaFun manual.

2023-02-10 Thread Jeong Dal via ntg-context
Dear all,

I copied the code of defining chapter command  from metafun-000.tex, and run it.
But the result is different from that in MetaFun Manual.
There is a big spaces between the number and the title which yields the number 
cannot be seen.
I commented out several lines which seems to be not-related with chapter title.
And, I changed

\def\ChapterCommand#1#2% —> \define[2]\ChapterCommand

Would you please test the following code to find out what is wrong?

Thank you for reading.

Best regards,

Dalyoung


\startuseMPgraphic{circled}
  pickup pencircle scaled 1mm ;
  drawoptions(withcolor (.6+uniformdeviate.35)*white) ;
  fill fullcircle xscaled 1.5cm yscaled 1cm ;
  drawoptions(withcolor .625yellow) ;
  draw fullcircle xscaled 1.5cm yscaled 1cm ;
\stopuseMPgraphic

%\startnotmode[proof]
%  \defineoverlay[circled][\useMPgraphic{circled}]
%\stopnotmode

\define[1]\Circled%
  {\framed
 [background=circled,frame=off,offset=overlay]
 {\color[darkred]{#1}}}

\setuppagenumbering[location=]
\setupheadertexts[margin][][\hbox to \hsize{\hss\Circled\pagenumber\hss}]

\startuniqueMPgraphic{titled}
  path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ;
  pickup pencircle scaled 1mm ;
  drawoptions(withcolor .625yellow) ;
  draw llcorner p -- lrcorner p ;
  setbounds currentpicture to p ;
\stopuniqueMPgraphic

\defineoverlay[titled][\uniqueMPgraphic{titled}]

\define[2]\ChapterCommand%
  {\setbox0=\hbox to \leftmarginwidth{#1\hss}%
   \hskip-\leftmarginwidth
   \hskip-\leftmargindistance
   \framed
 [background=titled,frame=off,offset=0pt]
 {\box0
  \hskip\leftmargindistance
  #2}}

\define[2]\TitleCommand%
  {\framed
 [background=titled,frame=off,offset=0pt]
 {#2}}

\setuphead
  [chapter]%,section,subsection]
  [command=\ChapterCommand,
   style=\ss\bf\tfd,
   color=darkred]

\setuphead
  [title]%,subject,sububject]
  [command=\TitleCommand,
   style=\ss\bf\tfd,
   color=darkred]


\setupbodyfont[bonum,rm,12pt]
\showframe

\starttext
\startchapter[title={Introduction}]
This is the chapter for introduction.
\stopchapter

\startchapter[title={Function}]
Now, we study the function.
\stopchapter

\starttitle[title={References}]
\startitemize[n]
\item first
\item second
\item third
\stopitemize
\stoptitle

\stoptext___
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] Problem using \scale

2023-02-10 Thread Hans Hagen via ntg-context

On 2/9/2023 10:42 PM, Bruce Horrocks via ntg-context wrote:

I'm printing address labels. Sometimes an address has a long line that is too 
long to fit on the label with the result that it wraps. Instead of wrapping, I 
thought it would be nice to try and auto-scale the label and shrink it so that 
the long line just fits.

I'm using \crlf to break the address into lines and this doesn't play well with 
the \scale command, see MWE below, where the second frame is just one long line 
as the \crlf's seem to be ignored.

Is there a simple solution that allows \crlf and also scale?

\starttext
\startbuffer[address]
Name \crlf
Address 1 \crlf
A long line that wraps \crlf
Town \crlf
Postcode
\stopbuffer
\framed[width=3cm,align=flushleft]{\getbuffer[address]}
\framed[width=3cm,align=flushleft]{\scale[factor=fit]{\getbuffer[address]}}
\stoptext

\starttext

\startbuffer[address]
Name
Address 1
A long line that wraps
Town
Postcode
\stopbuffer

\framed
  [align=flushleft,strut=no]
  {\startlines[before=,after=]
   \getbuffer[address]
   \stoplines}

\scale
  [width=3cm]
  {\framed
 [align=flushleft,strut=no]
 {\startlines[before=,after=]
  \getbuffer[address]
  \stoplines}}

\stoptext

You can of course adapt the font size instead but as it's just stickers 
the above is probably good enough, but you can do this:


\begingroup
\doloop {
\setbox\scratchbox\hbox\bgroup\framed
  [align={flushleft},strut=no]
  {\startlines[before=,after=]
   \getbuffer[address]
   \stoplines}
\egroup
\ifdim\wd\scratchbox>3cm
  \advance\glyphscale by -50
\else
  \box\scratchbox
  \exitloop
\fi
}
\endgroup

to get more consistent stepwise scaling or even this:

\begingroup
\doloop {
\setbox\scratchbox\hbox\bgroup\framed
  [align={flushleft},strut=no]
  {\startlines[before=,after=]
   \getbuffer[address]
   \stoplines}
\egroup
\ifdim\wd\scratchbox>3cm
  \advance\glyphxscale by -50
\else
  \framed
[align={flushleft},strut=no,width=3cm]
{\startlines[before=,after=]
 \getbuffer[address]
 \stoplines}
  \exitloop
\fi
}
\endgroup

which is what i might choose eventually (i'll add it to the test suite)

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
___