Re: [NTG-context] LMTX: reimplementing texquotes as OTF feature

2022-11-11 Thread Hans Hagen via ntg-context

On 11/11/2022 10:19 PM, Leah Neukirchen via ntg-context wrote:

Hi,

as Hans recommended in the last video meeting, I tried to implement
the texquotes feature using OTF features, and hit two problems:

1) To support German quotes as well, I have two ligatures that end
up as the same glyph:
   `` -> “
   "' -> “
This can't be in the same ligature feature, as it will overwrite
the table entry with a duplicate key.

After some fiddling, I decided to map "' to a Unicode PUA symbol
and then add a second feature that maps this symbol to “ using
the substitute feature.  This works for TeX Gyre Schola.
But perhaps someone knows a nicer way.

2) This approach doesn't work for lmodern or palatino, I still
get "' as inch-sign/quote there... anything else I need to tweak
for these fonts?


\startluacode
 fonts.handlers.otf.addfeature {
 name = "texlig",
 type = "ligature",
 data = {
 ['“'] = { "`", "`" },
 ['”'] = { "'", "'" },
 ['„'] = { '"', "`" },
 [''] = { '"', "'" },
 ['‘'] = { "`" },
 ['’'] = { "'" }
 }
 }
 fonts.handlers.otf.addfeature {
 name = "texsub",
 type = "substitute",
 data = {
 [''] = '“',
 }
 }
\stopluacode

% with lmodern or palatino it breaks
\setupbodyfont[schola]

\definefontfeature[ltest][texlig=yes,texsub=yes,trep=no]
\addff{ltest}

\starttext

``foo'' `foo' "`foo"' 19" rack

\stoptext

can you show what is wrong and what it should be with

fonts.handlers.otf.addfeature {
name = "germantexlig",
type = "ligature",
data = {
['“'] = { "`", "`" },
['”'] = { "'", "'" },
['„'] = { '"', "`" },
['“'] = { '"', "'" },
['‘'] = { "`" },
['’'] = { "'" }
}
}

best not use an existign feature because we accumulate ... features come 
in order (you can force order if needed as you probably saw in one of 
the test files)


\definefontfeature[ltest][germantexlig=yes,trep=no] \addff{ltest}


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


[NTG-context] LMTX: reimplementing texquotes as OTF feature

2022-11-11 Thread Leah Neukirchen via ntg-context
Hi,

as Hans recommended in the last video meeting, I tried to implement
the texquotes feature using OTF features, and hit two problems:

1) To support German quotes as well, I have two ligatures that end
   up as the same glyph:
  `` -> “
  "' -> “
   This can't be in the same ligature feature, as it will overwrite
   the table entry with a duplicate key.

   After some fiddling, I decided to map "' to a Unicode PUA symbol
   and then add a second feature that maps this symbol to “ using
   the substitute feature.  This works for TeX Gyre Schola.
   But perhaps someone knows a nicer way.

2) This approach doesn't work for lmodern or palatino, I still
   get "' as inch-sign/quote there... anything else I need to tweak
   for these fonts?


\startluacode
fonts.handlers.otf.addfeature {
name = "texlig",
type = "ligature",
data = {
['“'] = { "`", "`" },
['”'] = { "'", "'" },
['„'] = { '"', "`" },
[''] = { '"', "'" },
['‘'] = { "`" },
['’'] = { "'" }
}
}
fonts.handlers.otf.addfeature {
name = "texsub",
type = "substitute",
data = {
[''] = '“',
}
}
\stopluacode

% with lmodern or palatino it breaks
\setupbodyfont[schola]

\definefontfeature[ltest][texlig=yes,texsub=yes,trep=no]
\addff{ltest}

\starttext

``foo'' `foo' "`foo"' 19" rack

\stoptext


Thanks,
-- 
Leah Neukirchenhttps://leahneukirchen.org/
___
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] Page break with placement of a figure at the bottom of the page

2022-11-11 Thread Bruce Horrocks via ntg-context

> On 10 Nov 2022, at 17:06, Fabrice Couvreur via ntg-context 
>  wrote:
> 
> Hi,
> Sorry to come back to you, but it seems to me that there is enough space here.
> Fabrice

For some reason your PNG images came through in extremely low resolution. 
Without having the ConTeXt source it's hard to say for sure what's happening - 
for example, I would have expected the text on the second page to be at the 
bottom of the first even if there wasn't room for the image - because that was 
what was happening in your first example. 

—
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
___


Re: [NTG-context] how to simulate \hss in luametatex?

2022-11-11 Thread 黄复雄 via ntg-context
Hans,
thank you.
By your and Max's answers, I understand that
there must be box.glueset for the glues in the box.list to actually work.

Best regards

Huang Fusyong(黄复雄)

Hans Hagen via ntg-context  于2022年11月11日周五 18:52写道:
>
> On 11/11/2022 10:53 AM, Max Chernoff via ntg-context wrote:
> > Hi,
> >
> >> I want to  simulate \hss  in lua end in ConTeXt/luametatex environment.
> >> For example,
> >>
> >> ```ConTeXt
> >> a{\raise 1.5ex\hbox to 0pt{\hss b}}c
> >> ```
> >
> >> And in lua, I do as follows(part of my app seen in attachment):
> >
> > Your code doesn't compile as is. I think that this is the same thing
> > though:
> >
> > \starttext
> > \startluacode
> > local a = node.new"glyph"
> > a.char = string.byte("a")
> > a.font = font.current()
> >
> > local b = node.new"glyph"
> > b.char = string.byte("b")
> > b.font = font.current()
> >
> > local c = node.new"glyph"
> > c.char = string.byte("c")
> > c.font = font.current()
> >
> > local hss = node.new("glue")
> > hss.stretch = 65536
> > hss.stretchorder = 2
> > hss.shrink = 65536
> > hss.shrinkorder = 2
> > hss.width = 0
> > b = node.insertbefore(b, b, hss)
> >
> > local box = node.new("hlist", "box")
> > box.head = b
> > box.width = 0
> > box.shift = -tex.sp("1ex")
> >
> > tex.forcehmode()
> > node.write(a + box + c)
> > \stopluacode
> > \stoptext
> >
> >> And got 'b' on top of 'c' in pdf as follows:
> >>
> >> ```pdf
> >>b
> >> ac
> >> ```
> >
> > The \hss isn't the problem here. The problem is actually with the box.
> > When you manually make the \hbox like that, I think (although I could be
> > wrong) that you're bypassing all of TeX's glue calculations. You should
> > probably use "node.hpack" instead:
> >
> > \starttext
> > \startluacode
> > local a = node.new"glyph"
> > a.char = string.byte("a")
> > a.font = font.current()
> >
> > local b = node.new"glyph"
> > b.char = string.byte("b")
> > b.font = font.current()
> >
> > local c = node.new"glyph"
> > c.char = string.byte("c")
> > c.font = font.current()
> >
> > local hss = node.new("glue")
> > hss.stretch = 65536
> > hss.stretchorder = 2
> > hss.shrink = 65536
> > hss.shrinkorder = 2
> > hss.width = 0
> >
> > local box = node.hpack(hss + b, "exactly", 0)
> > box.shift = -tex.sp("1ex")
> >
> > tex.forcehmode()
> > a.next = box
> > box.next = c
> > node.write(a)
> > \stopluacode
> > \stoptext
> indeed, an dafter that you can check it
>
>   box.glueorder  : 2
>   box.glueset: 6.6683349609375
>   box.gluesign   : 2
>
> which will be applied (in the backend) to glues
>
> 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
> ___
___
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] how to simulate \hss in luametatex?

2022-11-11 Thread 黄复雄 via ntg-context
Dear Max,
I am very grateful that you took the time to tweak and test my
non-running code snippet
and found the problem.

 > local box = node.hpack(hss + b, "exactly", 0)

You are absolutely right, the cause of the problem was that I wasn't
using node.hpack().
Actually, I tried to use it, but used it wrong, as follows:

local box, _ = node_hpack(list)
box.width = 0
box.shift = -tex_sp("1ex")

My app works fine now. Also, I learned a lot from your code, like
font.current(), hss + b
and tex.forcehmode() - I immediately used the last one to set
box.shift, making it relative.

Best regards

Huang Fusyong(黄复雄)

Max Chernoff via ntg-context  于2022年11月11日周五 17:55写道:
>
> Hi,
>
> > I want to  simulate \hss  in lua end in ConTeXt/luametatex environment.
> > For example,
> >
> > ```ConTeXt
> > a{\raise 1.5ex\hbox to 0pt{\hss b}}c
> > ```
>
> > And in lua, I do as follows(part of my app seen in attachment):
>
> Your code doesn't compile as is. I think that this is the same thing
> though:
>
>\starttext
>\startluacode
>local a = node.new"glyph"
>a.char = string.byte("a")
>a.font = font.current()
>
>local b = node.new"glyph"
>b.char = string.byte("b")
>b.font = font.current()
>
>local c = node.new"glyph"
>c.char = string.byte("c")
>c.font = font.current()
>
>local hss = node.new("glue")
>hss.stretch = 65536
>hss.stretchorder = 2
>hss.shrink = 65536
>hss.shrinkorder = 2
>hss.width = 0
>b = node.insertbefore(b, b, hss)
>
>local box = node.new("hlist", "box")
>box.head = b
>box.width = 0
>box.shift = -tex.sp("1ex")
>
>tex.forcehmode()
>node.write(a + box + c)
>\stopluacode
>\stoptext
>
> > And got 'b' on top of 'c' in pdf as follows:
> >
> > ```pdf
> >   b
> > ac
> > ```
>
> The \hss isn't the problem here. The problem is actually with the box.
> When you manually make the \hbox like that, I think (although I could be
> wrong) that you're bypassing all of TeX's glue calculations. You should
> probably use "node.hpack" instead:
>
>\starttext
>\startluacode
>local a = node.new"glyph"
>a.char = string.byte("a")
>a.font = font.current()
>
>local b = node.new"glyph"
>b.char = string.byte("b")
>b.font = font.current()
>
>local c = node.new"glyph"
>c.char = string.byte("c")
>c.font = font.current()
>
>local hss = node.new("glue")
>hss.stretch = 65536
>hss.stretchorder = 2
>hss.shrink = 65536
>hss.shrinkorder = 2
>hss.width = 0
>
>local box = node.hpack(hss + b, "exactly", 0)
>box.shift = -tex.sp("1ex")
>
>tex.forcehmode()
>a.next = box
>box.next = c
>node.write(a)
>\stopluacode
>\stoptext
>
> -- Max
>
> ___
> 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
___


Re: [NTG-context] how to simulate \hss in luametatex?

2022-11-11 Thread Hans Hagen via ntg-context

On 11/11/2022 10:53 AM, Max Chernoff via ntg-context wrote:

Hi,


I want to  simulate \hss  in lua end in ConTeXt/luametatex environment.
For example,

```ConTeXt
a{\raise 1.5ex\hbox to 0pt{\hss b}}c
```



And in lua, I do as follows(part of my app seen in attachment):


Your code doesn't compile as is. I think that this is the same thing
though:

\starttext
\startluacode
local a = node.new"glyph"
a.char = string.byte("a")
a.font = font.current()

local b = node.new"glyph"

b.char = string.byte("b")
b.font = font.current()

local c = node.new"glyph"

c.char = string.byte("c")
c.font = font.current()

local hss = node.new("glue")

hss.stretch = 65536
hss.stretchorder = 2
hss.shrink = 65536
hss.shrinkorder = 2
hss.width = 0
b = node.insertbefore(b, b, hss)

local box = node.new("hlist", "box")

box.head = b
box.width = 0
box.shift = -tex.sp("1ex")

tex.forcehmode()

node.write(a + box + c)
\stopluacode
\stoptext


And got 'b' on top of 'c' in pdf as follows:

```pdf
   b
ac
```


The \hss isn't the problem here. The problem is actually with the box.
When you manually make the \hbox like that, I think (although I could be
wrong) that you're bypassing all of TeX's glue calculations. You should
probably use "node.hpack" instead:

\starttext
\startluacode
local a = node.new"glyph"
a.char = string.byte("a")
a.font = font.current()

local b = node.new"glyph"

b.char = string.byte("b")
b.font = font.current()

local c = node.new"glyph"

c.char = string.byte("c")
c.font = font.current()

local hss = node.new("glue")

hss.stretch = 65536
hss.stretchorder = 2
hss.shrink = 65536
hss.shrinkorder = 2
hss.width = 0

local box = node.hpack(hss + b, "exactly", 0)

box.shift = -tex.sp("1ex")

tex.forcehmode()

a.next = box
box.next = c
node.write(a)
\stopluacode
\stoptext

indeed, an dafter that you can check it

 box.glueorder  : 2
 box.glueset: 6.6683349609375
 box.gluesign   : 2

which will be applied (in the backend) to glues

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
___


Re: [NTG-context] how to simulate \hss in luametatex?

2022-11-11 Thread Max Chernoff via ntg-context
Hi,

> I want to  simulate \hss  in lua end in ConTeXt/luametatex environment.
> For example,
> 
> ```ConTeXt
> a{\raise 1.5ex\hbox to 0pt{\hss b}}c
> ```

> And in lua, I do as follows(part of my app seen in attachment):

Your code doesn't compile as is. I think that this is the same thing
though:

   \starttext
   \startluacode
   local a = node.new"glyph"
   a.char = string.byte("a")
   a.font = font.current()
   
   local b = node.new"glyph"
   b.char = string.byte("b")
   b.font = font.current()
   
   local c = node.new"glyph"
   c.char = string.byte("c")
   c.font = font.current()
   
   local hss = node.new("glue")
   hss.stretch = 65536
   hss.stretchorder = 2
   hss.shrink = 65536
   hss.shrinkorder = 2
   hss.width = 0
   b = node.insertbefore(b, b, hss)
   
   local box = node.new("hlist", "box")
   box.head = b
   box.width = 0
   box.shift = -tex.sp("1ex")
   
   tex.forcehmode()
   node.write(a + box + c)
   \stopluacode
   \stoptext

> And got 'b' on top of 'c' in pdf as follows:
> 
> ```pdf
>   b
> ac
> ```

The \hss isn't the problem here. The problem is actually with the box.
When you manually make the \hbox like that, I think (although I could be
wrong) that you're bypassing all of TeX's glue calculations. You should
probably use "node.hpack" instead:

   \starttext
   \startluacode
   local a = node.new"glyph"
   a.char = string.byte("a")
   a.font = font.current()
   
   local b = node.new"glyph"
   b.char = string.byte("b")
   b.font = font.current()
   
   local c = node.new"glyph"
   c.char = string.byte("c")
   c.font = font.current()
   
   local hss = node.new("glue")
   hss.stretch = 65536
   hss.stretchorder = 2
   hss.shrink = 65536
   hss.shrinkorder = 2
   hss.width = 0
   
   local box = node.hpack(hss + b, "exactly", 0)
   box.shift = -tex.sp("1ex")
   
   tex.forcehmode()
   a.next = box
   box.next = c
   node.write(a)
   \stopluacode
   \stoptext

-- Max

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