[Tex/LaTex] LuaLaTeX protrusion problem with Negative value

fontspecitalicluaotfloadluatexprotrusion

Please see the following screen shots.

enter image description here

As you can see there are two "overfull" hbox there. However, LaTeX does not produced any overfull box warning at all. I tried to produce a minimal working example but without exactly the same layout, and fonts, and line breaks, it cannot be reproduced. So sorry that I cannot include a MWE in this question. (edit: please find an MWE further down).

However I tried to diagnose the problem. Since LaTeX does not see these as overfull box, it could be protrusion problem I guess. I setup the Minion fonts with fontspec (LuaLaTeX) as following,

\setmainfont[
UprightFeatures    = {RawFeature = {protrusion = mnr}},
BoldFeatures       = {RawFeature = {protrusion = mnr}},
ItalicFeatures     = {RawFeature = {protrusion = mni}},
BoldItalicFeatures = {RawFeature = {protrusion = mni}},
RawFeature = {expansion  = default},
Ligatures = {Required, Common, Contextual, TeX},
Numbers = {OldStyle, Proportional},
SizeFeatures = {
  {Size =      -8.41,  OpticalSize = 8},
  {Size =  8.41-13.01, OpticalSize = 11},
  {Size = 13.01-19.91, OpticalSize = 19},
  {Size = 19.91-,      OpticalSize = 72}},
]{Minion Pro}

Ignoring the other things (for example the SizeFeatures is used to work around the problem that fontspec/luaotfload cannot select the right optical sizes). The problems appeared to the line

ItalicFeatures = {RawFeature = {protrusion = mmi}},

Where protrusion is turned on before the fonts setup by \pdfprotrudechars2 and mni is the protrusion setting for Minion Pro Italic. I translated the setting in MinionPro package to be used with LuaLaTeX (as the official release of microtype do not support LuaTeX with opentype fonts loaded by fontspec yet). A portion of the Lua file that setup the protrusion can be found below,

fonts                    = fonts                    or { }
fonts.protrusions        = fonts.protrusions        or { }
fonts.protrusions.setups = fonts.protrusions.setups or { }

--omitted codes--

fonts.protrusions.setups["mni"] = { -- Minion Pro Italic

      factor = 1, left = 1, right = 1,

  -- omitted code--
  [0x0067] = {-0.070, -0.070}, -- g
  [0x0069] = { 0.000, -0.110}, -- i
  [0x006A] = {-0.090, -0.150}, -- j
  [0x0070] = {-0.040,  0.000}, -- p
  [0x0072] = { 0.000,  0.080}, -- r
  -- omitted --
}

I I change the protrusion factor of letter g and p, which are the breaking points in the picture above, then the problem solved.

Can anyone explain the problem? Is there something wrong with my fonts setup (the use RawFeatures) or the protrusion setup file (the codes omitted in the above code snipes are just setting for other letters, which I assume should be independent from each other)?

It seems that whenever a linebreak happens at a italic character and protrusion is activated for that character, then the problems always happen. This does not happen for roman fonts.

Edits: Further experiments showing that assigning positive values instead of negative values to the protrusion factors does not cause any problem for the italic fonts. I guess the problem is not with Italic font, but with the negative value of protrusion factors. The reason no such problem for roman fonts is that there are no negative values assigned for any roman characters. But some italic characters has negative protrusion values so that they don't reach out the boundary too much.

Latest Edit: Here's a minimal document that triggers the issue.

\documentclass[a4paper]{article}
\usepackage{microtype}
\usepackage{amsthm}
\newtheorem{proposition}{Proposition}
\usepackage{lipsum}
\begin{document}
\begin{proposition}
  \lipsum
\end{proposition}
\end{document}

With lualatex (showcases the bug):lualatex

With pdflatex (perfectly fine):pdflatex

Best Answer

This could be related to a bug with negative protrusion values that I reported a year ago and which is obviously still open. Which luatex version are you using?