Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-13 Thread Hans Hagen via luatex

On 1/13/2026 1:30 PM, Vítek Starý Novotný wrote:


Thank you, Hans, this is very helpful for isolating the cause of the
issue. Setting `\automatichyphenmode = 1` or `\automatichyphenmode = 2`
resolves the problem for the minimal working example(s) discussed in
this thread.

(I am still seeing protrusion-related issues in the original document
that prompted this investigation, and those are not fixed by changing
the value of `\automatichyphenmode`. This suggests that my format may
also be doing something with hyphenation in the background [1], but I
have not yet managed to isolate a minimal working example.)

> > More generally, I wonder how much sense it makes to suppress protrusion

in the presence of discretionary nodes. From a typographic perspective,
wouldn't we want margin protrusion to apply regardless of whether a
hyphen is discretionary or not? Is this primarily a technical
limitation? Because from the typographic standpoint, I do not quite
understand the rationale.

  [1]: https://github.com/schlcht/microtype/issues/61#issuecomment-3743992442


It's not only about what is or should be possible or limitations in the 
engine. If in context one sets the lefthyphenchar to - as well as left 
protrusion on the - (which we don't do by default) one gets hanging left 
hyphens, assuming protrusion is enabled (so test-test-test can break and 
have left and right -) I have no cleu what other macro packages do or 
set up or what interferences might happen.


In luametatex a leading - also works but there we have more granular 
control anyway and i'm not going to backport any of that (so 
-test-test-test can break and have left and right - but i admit that i 
have no clue what a user actually expects).


Starting with a - and expecting it to protrude is a kind of weird 
situation anyway, so one can then as well llap that hyphen in the 
specific case where it is needed. Like expansion, protrusion is to be 
used in controlled situations; it doesn't always give nicer results.


Whatever trickery we add to luatex, it will eventually (maybe after 
years) result in some complaint or additional control request and we 
can't even be sure if it concerns just some experiment or a realistic 
situation, or it even being applied or well tested.


Sometimes one just as to accept a limitation (40 years of tex probably 
force accepting limitations anyway) ... it happens all over life.


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
-


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-13 Thread Vítek Starý Novotný
On Tue, Jan 13, 2026 at 10:26:04AM +0100, Hans Hagen via luatex wrote:
> On 1/13/2026 8:25 AM, luigi scarso wrote:
> > 
> > 
> > On Tue, 13 Jan 2026 at 01:51, Robert via luatex  > > wrote:
> > 
> > On 12.01.26 15:58, luigi scarso wrote:
> >  >
> >  > Do you have the same with the luatex-plain format ?
> >  >
> > 
> > Here is a MWE for -ini mode, which also only yields two protruded
> > hyphens instead of three (with luatex or luahbtex 1.21 from TL25), so
> > maybe it's something that the luatex-plain format (which I can't test
> > right now) fixes, not something that the vanilla plain format breaks?
> > 
> > \catcode`\{=1
> > \catcode`\}=2
> > \input luatexconfig.tex    % enable luatex primitives
> > \input luatexiniconfig.tex
> > \outputmode=1
> > \hsize=10cm
> > \vsize=10cm
> > \def\\{\hfil\penalty-1}
> > \font\x=cmr10 \x
> > \baselineskip=12pt
> > \parfillskip=0pt plus 1fil
> > \protrudechars2
> > \lpcode\font`-=500
> > 
> > \noindent
> > \vrule width 4cm height 1mm\\
> > -\\
> > -foo\\
> > -\kern0pt foo\\
> > \vrule width 4cm height 1mm
> > \end
> > 
> > Best,
> > 
> > 
> > It doesn't seem like a critical bug -- if it is, maybe we can call it a
> > feature.
> > I'll leave it to Vitek to investigate.
> > 
> > In case, we can add \tracingall and see the trace.
> > 
> > \input luatexconfig.tex    % enable luatex primitives
> > \input luatexiniconfig.tex
> > \def\tracingall{%
> >       \tracingonline=1
> >       \tracingcommands=3
> >       \tracingstats=2
> >       \tracingpages=1
> >       \tracingoutput=1
> >       \tracinglostchars=2
> >       \tracingmacros=2
> >       \tracingparagraphs=1
> >       \tracingrestores=1
> >       \showboxbreadth=65535
> >       \showboxdepth=65535
> >       \errorstopmode
> >       \tracinggroups=1
> >       \tracingifs=1
> >       \tracingscantokens=1
> >       \tracingnesting=1
> >       \tracingassigns=2
> >       }
> > \tracingall
> > 
> >   --
> > luigi
> 
> Indeed. And tracing shows this:
> 
> \hbox(6.9+0.0)x284.52756, glue set 272.86084fil, direction TLT
> ..\kern-5.2 (left margin)
> ..\x -
> 
> 
> .\hbox(6.9+0.0)x284.52756, glue set 267.86084fil, direction TLT
> ..\discretionary (penalty 0)
> ...< \x -
> ...= \x -
> 
> where the difference is in setting
> 
> \automatichyphenmode = 1
> 
> Which is what we do in luatex-plain.tex indeed. There are various conditions
> checked for what makes a left or right edge and that mode avoids creating a
> discretionary node that hides the hyphen. There have been plenty discussions
> about hyphens in the past and this was one of the solutions to accomodate
> various scenarios.
> 
> Hans

Thank you, Hans, this is very helpful for isolating the cause of the
issue. Setting `\automatichyphenmode = 1` or `\automatichyphenmode = 2`
resolves the problem for the minimal working example(s) discussed in
this thread.

(I am still seeing protrusion-related issues in the original document
that prompted this investigation, and those are not fixed by changing
the value of `\automatichyphenmode`. This suggests that my format may
also be doing something with hyphenation in the background [1], but I
have not yet managed to isolate a minimal working example.)

More generally, I wonder how much sense it makes to suppress protrusion
in the presence of discretionary nodes. From a typographic perspective,
wouldn't we want margin protrusion to apply regardless of whether a
hyphen is discretionary or not? Is this primarily a technical
limitation? Because from the typographic standpoint, I do not quite
understand the rationale.

 [1]: https://github.com/schlcht/microtype/issues/61#issuecomment-3743992442

Vitek


signature.asc
Description: PGP signature


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-13 Thread Hans Hagen via luatex

On 1/13/2026 8:25 AM, luigi scarso wrote:



On Tue, 13 Jan 2026 at 01:51, Robert via luatex > wrote:


On 12.01.26 15:58, luigi scarso wrote:
 >
 > Do you have the same with the luatex-plain format ?
 >

Here is a MWE for -ini mode, which also only yields two protruded
hyphens instead of three (with luatex or luahbtex 1.21 from TL25), so
maybe it's something that the luatex-plain format (which I can't test
right now) fixes, not something that the vanilla plain format breaks?

\catcode`\{=1
\catcode`\}=2
\input luatexconfig.tex    % enable luatex primitives
\input luatexiniconfig.tex
\outputmode=1
\hsize=10cm
\vsize=10cm
\def\\{\hfil\penalty-1}
\font\x=cmr10 \x
\baselineskip=12pt
\parfillskip=0pt plus 1fil
\protrudechars2
\lpcode\font`-=500

\noindent
\vrule width 4cm height 1mm\\
-\\
-foo\\
-\kern0pt foo\\
\vrule width 4cm height 1mm
\end

Best,


It doesn't seem like a critical bug -- if it is, maybe we can call it a 
feature.

I'll leave it to Vitek to investigate.

In case, we can add \tracingall and see the trace.

\input luatexconfig.tex    % enable luatex primitives
\input luatexiniconfig.tex
\def\tracingall{%
      \tracingonline=1
      \tracingcommands=3
      \tracingstats=2
      \tracingpages=1
      \tracingoutput=1
      \tracinglostchars=2
      \tracingmacros=2
      \tracingparagraphs=1
      \tracingrestores=1
      \showboxbreadth=65535
      \showboxdepth=65535
      \errorstopmode
      \tracinggroups=1
      \tracingifs=1
      \tracingscantokens=1
      \tracingnesting=1
      \tracingassigns=2
      }
\tracingall

  --
luigi


Indeed. And tracing shows this:

\hbox(6.9+0.0)x284.52756, glue set 272.86084fil, direction TLT
..\kern-5.2 (left margin)
..\x -


.\hbox(6.9+0.0)x284.52756, glue set 267.86084fil, direction TLT
..\discretionary (penalty 0)
...< \x -
...= \x -

where the difference is in setting

\automatichyphenmode = 1

Which is what we do in luatex-plain.tex indeed. There are various 
conditions checked for what makes a left or right edge and that mode 
avoids creating a discretionary node that hides the hyphen. There have 
been plenty discussions about hyphens in the past and this was one of 
the solutions to accomodate various scenarios.


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
-


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread luigi scarso
On Tue, 13 Jan 2026 at 01:51, Robert via luatex  wrote:

> On 12.01.26 15:58, luigi scarso wrote:
> >
> > Do you have the same with the luatex-plain format ?
> >
>
> Here is a MWE for -ini mode, which also only yields two protruded
> hyphens instead of three (with luatex or luahbtex 1.21 from TL25), so
> maybe it's something that the luatex-plain format (which I can't test
> right now) fixes, not something that the vanilla plain format breaks?
>
> \catcode`\{=1
> \catcode`\}=2
> \input luatexconfig.tex% enable luatex primitives
> \input luatexiniconfig.tex
> \outputmode=1
> \hsize=10cm
> \vsize=10cm
> \def\\{\hfil\penalty-1}
> \font\x=cmr10 \x
> \baselineskip=12pt
> \parfillskip=0pt plus 1fil
> \protrudechars2
> \lpcode\font`-=500
>
> \noindent
> \vrule width 4cm height 1mm\\
> -\\
> -foo\\
> -\kern0pt foo\\
> \vrule width 4cm height 1mm
> \end
>
> Best,
>

It doesn't seem like a critical bug -- if it is, maybe we can call it a
feature.
I'll leave it to Vitek to investigate.

In case, we can add \tracingall and see the trace.

\input luatexconfig.tex% enable luatex primitives
\input luatexiniconfig.tex
\def\tracingall{%
 \tracingonline=1
 \tracingcommands=3
 \tracingstats=2
 \tracingpages=1
 \tracingoutput=1
 \tracinglostchars=2
 \tracingmacros=2
 \tracingparagraphs=1
 \tracingrestores=1
 \showboxbreadth=65535
 \showboxdepth=65535
 \errorstopmode
 \tracinggroups=1
 \tracingifs=1
 \tracingscantokens=1
 \tracingnesting=1
 \tracingassigns=2
 }
\tracingall

 --
luigi


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread Robert via luatex

On 12.01.26 15:58, luigi scarso wrote:


Do you have the same with the luatex-plain format ?



Here is a MWE for -ini mode, which also only yields two protruded 
hyphens instead of three (with luatex or luahbtex 1.21 from TL25), so 
maybe it's something that the luatex-plain format (which I can't test 
right now) fixes, not something that the vanilla plain format breaks?


\catcode`\{=1
\catcode`\}=2
\input luatexconfig.tex% enable luatex primitives
\input luatexiniconfig.tex
\outputmode=1
\hsize=10cm
\vsize=10cm
\def\\{\hfil\penalty-1}
\font\x=cmr10 \x
\baselineskip=12pt
\parfillskip=0pt plus 1fil
\protrudechars2
\lpcode\font`-=500

\noindent
\vrule width 4cm height 1mm\\
-\\
-foo\\
-\kern0pt foo\\
\vrule width 4cm height 1mm
\end

Best,
--
 Robert




Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread Vítek Starý Novotný
On Mon, Jan 12, 2026 at 03:58:29PM +0100, luigi scarso wrote:
> On Sat, 10 Jan 2026 at 07:35, luigi scarso  wrote:
> 
> >
> >
> > On Mon, 5 Jan 2026 at 14:40, Vítek Starý Novotný  wrote:
> >
> >> Consider the following minimal working example [1]:
> >>
> >> \protrudechars2
> >> \lpcode\font`-=500
> >> % OR:
> >> %\input luaotfload.sty
> >> %\directlua{fonts.protrusions.setups["test"] = {[0x002D] = { 1, 1 }}}
> >> %\font\x=LatinModernRoman:protrusion=test; \x
> >> \noindent
> >> -\hfil\break
> >> -foo\hfil\break
> >> -\kern0pt foo
> >> \bye
> >>
> >> With LuaTeX 1.04 from TeX Live 2017, three protruded lines are produced,
> >> as expected. Since LuaTeX 1.07 from TeX Live 2018, the second line
> >> (`-foo\hfil\break`) is not protruded for some reason.
> >>
> >>  [1]:
> >> https://github.com/schlcht/microtype/issues/61#issuecomment-3690602014
> >>
> >> What do you think?
> >>
> >
> > I will check this weekend.
> >
> 
> 
> Do you have the same with the luatex-plain format ?
> 
> $>mtxrun --script plain --make
> 
> and compare
> $>luatex  test.tex
> vs
> $>luatex --fmt=luatex-plain  test.tex

No, using `luatex --fmt=luatex-plain test.tex` fixes the issue even with
LuaTeX 1.22.0.


signature.asc
Description: PGP signature


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread luigi scarso
On Sat, 10 Jan 2026 at 07:35, luigi scarso  wrote:

>
>
> On Mon, 5 Jan 2026 at 14:40, Vítek Starý Novotný  wrote:
>
>> Consider the following minimal working example [1]:
>>
>> \protrudechars2
>> \lpcode\font`-=500
>> % OR:
>> %\input luaotfload.sty
>> %\directlua{fonts.protrusions.setups["test"] = {[0x002D] = { 1, 1 }}}
>> %\font\x=LatinModernRoman:protrusion=test; \x
>> \noindent
>> -\hfil\break
>> -foo\hfil\break
>> -\kern0pt foo
>> \bye
>>
>> With LuaTeX 1.04 from TeX Live 2017, three protruded lines are produced,
>> as expected. Since LuaTeX 1.07 from TeX Live 2018, the second line
>> (`-foo\hfil\break`) is not protruded for some reason.
>>
>>  [1]:
>> https://github.com/schlcht/microtype/issues/61#issuecomment-3690602014
>>
>> What do you think?
>>
>
> I will check this weekend.
>


Do you have the same with the luatex-plain format ?

$>mtxrun --script plain --make

and compare
$>luatex  test.tex
vs
$>luatex --fmt=luatex-plain  test.tex


--
luigi


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread Hans Hagen via luatex

On 1/12/2026 1:21 PM, Vítek Starý Novotný wrote:

On Sat, Jan 10, 2026 at 12:11:25PM +0100, Hans Hagen via luatex wrote:

On 1/10/2026 7:35 AM, luigi scarso wrote:

[...]


it seems to work ok here with luatex 1.23.3

\protrudechars2
\lpcode\font`-=500

\noindent\vrule width 4cm height 1mm

\noindent
-\hfil\break
-foo\hfil\break
-\kern0pt foo

\noindent\vrule width 4cm height 1mm

\end

I see three - moved into the left margin.


I see only two with LuaTeX 1.22.0 from TeX Live 2025.

 $ docker run --rm -it -v "$PWD"/workdir:/workdir -w /workdir 
texlive/texlive
 root@c15069e992dc:/workdir# luatex example.tex
 This is LuaTeX, Version 1.22.0 (TeX Live 2025)
  restricted system commands enabled.
 (./example.tex 
[1{/usr/local/texlive/2025/texmf-var/fonts/map/pdftex/updmap/pdf
 
tex.map}])
 Output written on example.pdf (1 page, 10644 bytes).
 Transcript written on example.log.

See also the attached file `example.pdf`.

I wonder if this could be related to TeX Live somehow, since an
unintentional fix almost ten years since it has become broken in
TeX Live 2017 seems exceedingly unlikely.


You could test that by updating that docker thing. Also, who knows what 
specific kind of plain format is used and how that sets up the 
machinery. We're already in the code freeze months so nothing will 
change in the engine anyway.


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
-


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-12 Thread Vítek Starý Novotný
On Sat, Jan 10, 2026 at 12:11:25PM +0100, Hans Hagen via luatex wrote:
> On 1/10/2026 7:35 AM, luigi scarso wrote:
> > [...]
> 
> it seems to work ok here with luatex 1.23.3
> 
> \protrudechars2
> \lpcode\font`-=500
> 
> \noindent\vrule width 4cm height 1mm
> 
> \noindent
> -\hfil\break
> -foo\hfil\break
> -\kern0pt foo
> 
> \noindent\vrule width 4cm height 1mm
> 
> \end
> 
> I see three - moved into the left margin.

I see only two with LuaTeX 1.22.0 from TeX Live 2025.

$ docker run --rm -it -v "$PWD"/workdir:/workdir -w /workdir texlive/texlive
root@c15069e992dc:/workdir# luatex example.tex
This is LuaTeX, Version 1.22.0 (TeX Live 2025) 
 restricted system commands enabled.
(./example.tex 
[1{/usr/local/texlive/2025/texmf-var/fonts/map/pdftex/updmap/pdf

tex.map}])
Output written on example.pdf (1 page, 10644 bytes).
Transcript written on example.log.

See also the attached file `example.pdf`.

I wonder if this could be related to TeX Live somehow, since an
unintentional fix almost ten years since it has become broken in
TeX Live 2017 seems exceedingly unlikely.


signature.asc
Description: PGP signature


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-10 Thread Hans Hagen via luatex

On 1/10/2026 7:35 AM, luigi scarso wrote:



On Mon, 5 Jan 2026 at 14:40, Vítek Starý Novotný > wrote:


Consider the following minimal working example [1]:

     \protrudechars2
     \lpcode\font`-=500
     % OR:
     %\input luaotfload.sty
     %\directlua{fonts.protrusions.setups["test"] = {[0x002D] = { 1,
1 }}}
     %\font\x=LatinModernRoman:protrusion=test; \x
     \noindent
     -\hfil\break
     -foo\hfil\break
     -\kern0pt foo
     \bye

With LuaTeX 1.04 from TeX Live 2017, three protruded lines are produced,
as expected. Since LuaTeX 1.07 from TeX Live 2018, the second line
(`-foo\hfil\break`) is not protruded for some reason.

  [1]: https://github.com/schlcht/microtype/
issues/61#issuecomment-3690602014 

What do you think?


I will check this weekend.


it seems to work ok here with luatex 1.23.3

\protrudechars2
\lpcode\font`-=500

\noindent\vrule width 4cm height 1mm

\noindent
-\hfil\break
-foo\hfil\break
-\kern0pt foo

\noindent\vrule width 4cm height 1mm

\end

I see three - moved into the left margin.

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
-


Re: [luatex] A hyphen followed by a word fails to protrude the left margin

2026-01-09 Thread luigi scarso
On Mon, 5 Jan 2026 at 14:40, Vítek Starý Novotný  wrote:

> Consider the following minimal working example [1]:
>
> \protrudechars2
> \lpcode\font`-=500
> % OR:
> %\input luaotfload.sty
> %\directlua{fonts.protrusions.setups["test"] = {[0x002D] = { 1, 1 }}}
> %\font\x=LatinModernRoman:protrusion=test; \x
> \noindent
> -\hfil\break
> -foo\hfil\break
> -\kern0pt foo
> \bye
>
> With LuaTeX 1.04 from TeX Live 2017, three protruded lines are produced,
> as expected. Since LuaTeX 1.07 from TeX Live 2018, the second line
> (`-foo\hfil\break`) is not protruded for some reason.
>
>  [1]:
> https://github.com/schlcht/microtype/issues/61#issuecomment-3690602014
>
> What do you think?
>

I will check this weekend.

--
luigi