texlive[74671] Build/source/texk/web2c: LuaTeX: final solution for

commits+lscarso at tug.org commits+lscarso at tug.org
Mon Mar 17 20:07:25 CET 2025


Revision: 74671
          https://tug.org/svn/texlive?view=revision&revision=74671
Author:   lscarso
Date:     2025-03-17 20:07:25 +0100 (Mon, 17 Mar 2025)
Log Message:
-----------
LuaTeX: final solution for italic (H.Hagen). Updated luatex.pdf

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/doc/luatex/luatex-math.tex
    trunk/Build/source/texk/web2c/doc/luatex/luatex.pdf
    trunk/Build/source/texk/web2c/luatexdir/ChangeLog
    trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
    trunk/Build/source/texk/web2c/luatexdir/tex/commands.c
    trunk/Build/source/texk/web2c/luatexdir/tex/commands.h
    trunk/Build/source/texk/web2c/luatexdir/tex/equivalents.h
    trunk/Build/source/texk/web2c/luatexdir/tex/maincontrol.c
    trunk/Build/source/texk/web2c/luatexdir/tex/mlist.c

Modified: trunk/Build/source/texk/web2c/doc/luatex/luatex-math.tex
===================================================================
--- trunk/Build/source/texk/web2c/doc/luatex/luatex-math.tex	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/doc/luatex/luatex-math.tex	2025-03-17 19:07:25 UTC (rev 74671)
@@ -773,120 +773,120 @@
 hacks that users came up with but when you set \lpr {matheqdirmode} to a positive
 value direction will be taken into account.
 
-\subsection {Nolimit correction}
+% \subsection {Nolimit correction}
+%
+% \topicindex {math+limits}
+%
+% There are two extra math parameters \lpr {Umathnolimitsupfactor} and \lpr
+% {Umathnolimitsubfactor} that were added to provide some control over how limits
+% are spaced (for example the position of super and subscripts after integral
+% operators). They relate to an extra parameter \lpr {mathnolimitsmode}. The half
+% corrections are what happens when scripts are placed above and below. The
+% problem with italic corrections is that officially that correction italic is used
+% for above|/|below placement while advanced kerns are used for placement at the
+% right end. The question is: how often is this implemented, and if so, do the
+% kerns assume correction too. Anyway, with this parameter one can control it.
 
-\topicindex {math+limits}
+% \starttabulate[|l|ck1|ck1|ck1|ck1|ck1|ck1|]
+%     \NC % probably not ok, we need a raw int here
+%         \NC \mathnolimitsmode0    $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%         \NC \mathnolimitsmode1    $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%         \NC \mathnolimitsmode2    $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%         \NC \mathnolimitsmode3    $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%         \NC \mathnolimitsmode4    $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%         \NC \mathnolimitsmode8000 $\displaystyle\mathop{\normalint}\nolimits^0_1$
+%     \NC \NR
+%     \TB
+%     \BC mode
+%         \NC \tttf 0
+%         \NC \tttf 1
+%         \NC \tttf 2
+%         \NC \tttf 3
+%         \NC \tttf 4
+%         \NC \tttf 8000
+%     \NC \NR
+%     \BC superscript
+%         \NC 0
+%         \NC font
+%         \NC 0
+%         \NC 0
+%         \NC +ic/2
+%         \NC 0
+%     \NC \NR
+%     \BC subscript
+%         \NC -ic
+%         \NC font
+%         \NC 0
+%         \NC -ic/2
+%         \NC -ic/2
+%         \NC 8000ic/1000
+%     \NC \NR
+% \stoptabulate
+%
+% When the mode is set to one, the math parameters are used. This way a macro
+% package writer can decide what looks best. Given the current state of fonts in
+% \CONTEXT\ we currently use mode 1 with factor 0 for the superscript and 750 for
+% the subscripts. Positive values are used for both parameters but the subscript
+% shifts to the left. A \lpr {mathnolimitsmode} larger that 15 is considered to
+% be a factor for the subscript correction. This feature can be handy when
+% experimenting.
 
-There are two extra math parameters \lpr {Umathnolimitsupfactor} and \lpr
-{Umathnolimitsubfactor} that were added to provide some control over how limits
-are spaced (for example the position of super and subscripts after integral
-operators). They relate to an extra parameter \lpr {mathnolimitsmode}. The half
-corrections are what happens when scripts are placed above and below. The
-problem with italic corrections is that officially that correction italic is used
-for above|/|below placement while advanced kerns are used for placement at the
-right end. The question is: how often is this implemented, and if so, do the
-kerns assume correction too. Anyway, with this parameter one can control it.
-
-\starttabulate[|l|ck1|ck1|ck1|ck1|ck1|ck1|]
-    \NC % probably not ok, we need a raw int here
-        \NC \mathnolimitsmode0    $\displaystyle\mathop{\normalint}\nolimits^0_1$
-        \NC \mathnolimitsmode1    $\displaystyle\mathop{\normalint}\nolimits^0_1$
-        \NC \mathnolimitsmode2    $\displaystyle\mathop{\normalint}\nolimits^0_1$
-        \NC \mathnolimitsmode3    $\displaystyle\mathop{\normalint}\nolimits^0_1$
-        \NC \mathnolimitsmode4    $\displaystyle\mathop{\normalint}\nolimits^0_1$
-        \NC \mathnolimitsmode8000 $\displaystyle\mathop{\normalint}\nolimits^0_1$
-    \NC \NR
-    \TB
-    \BC mode
-        \NC \tttf 0
-        \NC \tttf 1
-        \NC \tttf 2
-        \NC \tttf 3
-        \NC \tttf 4
-        \NC \tttf 8000
-    \NC \NR
-    \BC superscript
-        \NC 0
-        \NC font
-        \NC 0
-        \NC 0
-        \NC +ic/2
-        \NC 0
-    \NC \NR
-    \BC subscript
-        \NC -ic
-        \NC font
-        \NC 0
-        \NC -ic/2
-        \NC -ic/2
-        \NC 8000ic/1000
-    \NC \NR
-\stoptabulate
-
-When the mode is set to one, the math parameters are used. This way a macro
-package writer can decide what looks best. Given the current state of fonts in
-\CONTEXT\ we currently use mode 1 with factor 0 for the superscript and 750 for
-the subscripts. Positive values are used for both parameters but the subscript
-shifts to the left. A \lpr {mathnolimitsmode} larger that 15 is considered to
-be a factor for the subscript correction. This feature can be handy when
-experimenting.
-
-\subsection {Math italic mess}
-
-\topicindex {math+italics}
-
-The \lpr {mathitalicsmode} parameter was introduced to deal with the difference
-in applying italic correction in traditional and \OPENTYPE\ math fonts. There are
-\OPENTYPE\ fonts out there that have italic correction and assume them to be
-applied like traditional \TEX\ fonts. This parameter takes several values:
-
-When set to zero, you get what was decided when the two code paths (traditional
-and \OPENTYPE) were introduced.
-
-Values larger than zero will add the italic correction between simple noads (it
-checks some classes so you might pay attention to for instance punctuation
-classes assigned).
-
-When set to zero or one, italics are independent, so we separate width from
-italic, while values larger than one combine both in the width but later
-selectively has to get rid of it (depending on code path).
-
-A value larger than two will backtrack italics for large operators, because there
-italic correction is used for anchoring scripts (limits and no limits). In fact,
-\OPENTYPE\ uses italics either between characters or for this purpose but as
-mentioned fonts are sort of messy here.
-
-We tested our version of plain \TEX\ and recommend to use the value of three to
-get the best average results. More about this italic correction dilemma in
-rendering math can be found in articles (in for instance \TUGBOAT) and various
-documents in the \CONTEXT\ distribution, especially those that discuss the
-upgraded math engine in \LUAMETATEX.
-
-% The \lpr {mathitalicsmode} parameter can be set to~1 to force italic correction
-% before noads that represent some more complex structure (read: everything that is
-% not an ord, bin, rel, open, close, punct or inner). A value of~2 will enforce the
-% old school font code path for all italics. We show a Cambria example.
+% \subsection {Math italic mess}
 %
-% \starttexdefinition Whatever #1
-%     \NC \type{\mathitalicsmode = #1}
-%     \NC \mathitalicsmode#1\ruledhbox{$\left|T^1\right|$}
-%     \NC \mathitalicsmode#1\ruledhbox{$\left|T\right|$}
-%     \NC \mathitalicsmode#1\ruledhbox{$T+1$}
-%     \NC \mathitalicsmode#1\ruledhbox{$T{1\over2}$}
-%     \NC \mathitalicsmode#1\ruledhbox{$T\sqrt{1}$}
-%     \NC \NR
-% \stoptexdefinition
+% \topicindex {math+italics}
 %
-% \start
-%     \switchtobodyfont[cambria]
-%     \starttabulate[|c|c|c|c|c|c|]
-%         \Whatever{0}%
-%         \Whatever{1}%
-%     \stoptabulate
-% \stop
+% The \lpr {mathitalicsmode} parameter was introduced to deal with the difference
+% in applying italic correction in traditional and \OPENTYPE\ math fonts. There are
+% \OPENTYPE\ fonts out there that have italic correction and assume them to be
+% applied like traditional \TEX\ fonts. This parameter takes several values:
 %
-% This kind of parameters relate to the fact that italic correction in \OPENTYPE\
-% math is bound to fuzzy rules. So, control is the solution.
+% When set to zero, you get what was decided when the two code paths (traditional
+% and \OPENTYPE) were introduced.
+%
+% Values larger than zero will add the italic correction between simple noads (it
+% checks some classes so you might pay attention to for instance punctuation
+% classes assigned).
+%
+% When set to zero or one, italics are independent, so we separate width from
+% italic, while values larger than one combine both in the width but later
+% selectively has to get rid of it (depending on code path).
+%
+% A value larger than two will backtrack italics for large operators, because there
+% italic correction is used for anchoring scripts (limits and no limits). In fact,
+% \OPENTYPE\ uses italics either between characters or for this purpose but as
+% mentioned fonts are sort of messy here.
+%
+% We tested our version of plain \TEX\ and recommend to use the value of three to
+% get the best average results. More about this italic correction dilemma in
+% rendering math can be found in articles (in for instance \TUGBOAT) and various
+% documents in the \CONTEXT\ distribution, especially those that discuss the
+% upgraded math engine in \LUAMETATEX.
+%
+% % The \lpr {mathitalicsmode} parameter can be set to~1 to force italic correction
+% % before noads that represent some more complex structure (read: everything that is
+% % not an ord, bin, rel, open, close, punct or inner). A value of~2 will enforce the
+% % old school font code path for all italics. We show a Cambria example.
+% %
+% % \starttexdefinition Whatever #1
+% %     \NC \type{\mathitalicsmode = #1}
+% %     \NC \mathitalicsmode#1\ruledhbox{$\left|T^1\right|$}
+% %     \NC \mathitalicsmode#1\ruledhbox{$\left|T\right|$}
+% %     \NC \mathitalicsmode#1\ruledhbox{$T+1$}
+% %     \NC \mathitalicsmode#1\ruledhbox{$T{1\over2}$}
+% %     \NC \mathitalicsmode#1\ruledhbox{$T\sqrt{1}$}
+% %     \NC \NR
+% % \stoptexdefinition
+% %
+% % \start
+% %     \switchtobodyfont[cambria]
+% %     \starttabulate[|c|c|c|c|c|c|]
+% %         \Whatever{0}%
+% %         \Whatever{1}%
+% %     \stoptabulate
+% % \stop
+% %
+% % This kind of parameters relate to the fact that italic correction in \OPENTYPE\
+% % math is bound to fuzzy rules. So, control is the solution.
 
 \subsection {Script and kerning}
 

Modified: trunk/Build/source/texk/web2c/doc/luatex/luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Build/source/texk/web2c/luatexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2025-03-17 19:07:25 UTC (rev 74671)
@@ -1,10 +1,21 @@
+2025-03-17 Luigi Scarso  <luigi.scarso at gmail.com>
+	*  final solution for italic (H.Hagen)
+
+
+2025-03-16 Luigi Scarso  <luigi.scarso at gmail.com>
+	* always use old school tex logic (also for opentype) wrt italics
+	  with exception for large operators in opentyep fonts (no mixed font
+          usage); all related control modes removed (H.Hagen)
+
+
 2025-03-15 Luigi Scarso  <luigi.scarso at gmail.com>
-	* : italicsmode fix for eight bit fonts (H.Hagen)
+	* italicsmode fix for eight bit fonts (H.Hagen)
 
+	
 2025-03-13 Luigi Scarso  <luigi.scarso at gmail.com>
 	* extra italicsmode (large operator italic spacing) (H.Hagen)
 
-
+	
 2025-02-28  Akira Kakuto  <kakuto at jcom.zaq.ne.jp>
 	* luatex.c: Remove problematic lines for windows
 

Modified: trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2025-03-17 19:07:25 UTC (rev 74671)
@@ -1,4 +1,4 @@
 #ifndef luatex_svn_revision_h
 #define luatex_svn_revision_h
-#define luatex_svn_revision 7672
+#define luatex_svn_revision 7674
 #endif

Modified: trunk/Build/source/texk/web2c/luatexdir/tex/commands.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/tex/commands.c	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/tex/commands.c	2025-03-17 19:07:25 UTC (rev 74671)
@@ -746,7 +746,6 @@
     primitive_luatex("pdfextension", extension_cmd, pdf_extension_code, 0);
     primitive_luatex("pdffeedback", feedback_cmd, pdf_feedback_code, 0);
     primitive_luatex("pdfvariable", variable_cmd, pdf_variable_code, 0);
-    primitive_luatex("mathoption", option_cmd, 0, 0);
 
     primitive_luatex("luacopyinputnodes", assign_int_cmd, int_base + copy_lua_input_nodes_code, int_base);
 
@@ -800,13 +799,19 @@
     primitive_luatex("matheqnogapstep", assign_int_cmd, int_base + math_eqno_gap_step_code, int_base);
     primitive_luatex("mathdisplayskipmode", assign_int_cmd, int_base + math_display_skip_mode_code, int_base);
     primitive_luatex("mathscriptsmode", assign_int_cmd, int_base + math_scripts_mode_code, int_base);
-    primitive_luatex("mathnolimitsmode", assign_int_cmd, int_base + math_nolimits_mode_code, int_base);
-    primitive_luatex("mathitalicsmode", assign_int_cmd, int_base + math_italics_mode_code, int_base);
     primitive_luatex("mathrulesmode", assign_int_cmd, int_base + math_rules_mode_code, int_base);
     primitive_luatex("matheqdirmode", assign_int_cmd, int_base + math_eq_dir_mode_code, int_base);
     primitive_luatex("mathrulesfam", assign_int_cmd, int_base + math_rules_fam_code, int_base);
     primitive_luatex("synctex", assign_int_cmd, int_base + synctex_code, int_base);
 
+    /* obsolete: */
+
+    primitive_luatex("mathoption", option_cmd, 0, 0);
+    primitive_luatex("mathitalicsmode", assign_int_cmd, int_base + math_italics_mode_code, int_base);
+    primitive_luatex("mathnolimitsmode", assign_int_cmd, int_base + math_nolimits_mode_code, int_base);
+
+    /* */
+
     primitive_etex("currentgrouplevel", last_item_cmd, current_group_level_code, 0);
     primitive_etex("currentgrouptype", last_item_cmd, current_group_type_code, 0);
 

Modified: trunk/Build/source/texk/web2c/luatexdir/tex/commands.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/tex/commands.h	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/tex/commands.h	2025-03-17 19:07:25 UTC (rev 74671)
@@ -135,7 +135,7 @@
     message_cmd,                          /* send to user ( \.{\\message}, \.{\\errmessage} ) */
     normal_cmd,                           /* general extensions to \TeX\ that don't fit into a category */
     extension_cmd,                        /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
-    option_cmd,
+    option_cmd,                           /* obsolete */
     lua_function_call_cmd,
     lua_bytecode_call_cmd,
     lua_call_cmd,

Modified: trunk/Build/source/texk/web2c/luatexdir/tex/equivalents.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/tex/equivalents.h	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/tex/equivalents.h	2025-03-17 19:07:25 UTC (rev 74671)
@@ -278,10 +278,10 @@
 #  define math_eqno_gap_step_code 87                                    /* factor/1000 used for distance between eq and eqno */
 #  define math_display_skip_mode_code 88
 #  define math_scripts_mode_code 89
-#  define math_nolimits_mode_code 90
+#  define math_nolimits_mode_code 90 /* obsolete */
 #  define math_rules_mode_code 91
 #  define math_rules_fam_code 92
-#  define math_italics_mode_code 93
+#  define math_italics_mode_code 93 /* obsolete */
 #  define synctex_code 94                                               /* is synctex file generation enabled ?  */
 #  define shape_mode_code 95
 #  define first_valid_language_code 96
@@ -672,8 +672,6 @@
 #define disable_kern_par                   int_par(disable_kern_code)
 #define disable_space_par                  int_par(disable_space_code)
 #define math_scripts_mode_par              int_par(math_scripts_mode_code)
-#define math_nolimits_mode_par             int_par(math_nolimits_mode_code)
-#define math_italics_mode_par              int_par(math_italics_mode_code)
 #define math_rules_mode_par                int_par(math_rules_mode_code)
 #define math_rules_fam_par                 int_par(math_rules_fam_code)
 

Modified: trunk/Build/source/texk/web2c/luatexdir/tex/maincontrol.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/tex/maincontrol.c	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/tex/maincontrol.c	2025-03-17 19:07:25 UTC (rev 74671)
@@ -706,7 +706,7 @@
 /*tex
 
 This is experimental and not used for production, only for testing and writing
-macros (some options stay). It's now obsolete. We keep the cmd_code because it 
+macros (some options stay). It's now obsolete. We keep the cmd_code becuase it 
 looks like hard coded numbers are used in macro packages. 
 
 */
@@ -980,7 +980,7 @@
     any_mode(xray_cmd, show_whatever);
     any_mode(normal_cmd, run_normal);
     any_mode(extension_cmd, run_extension);
-    any_mode(option_cmd, run_option);
+    any_mode(option_cmd, run_option); /* obsolete */
 
     any_mode(lua_function_call_cmd, lua_function_call);
     any_mode(lua_bytecode_call_cmd, lua_bytecode_call);

Modified: trunk/Build/source/texk/web2c/luatexdir/tex/mlist.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/tex/mlist.c	2025-03-17 16:51:14 UTC (rev 74670)
+++ trunk/Build/source/texk/web2c/luatexdir/tex/mlist.c	2025-03-17 19:07:25 UTC (rev 74671)
@@ -19,6 +19,20 @@
 
 /*tex
 
+    These are now obsolete:
+
+    \starttyping
+    \Umathnolimitsupfactor
+    \Umathnolimitsubfactor
+    \mathnolimitsmode
+    \mathitalicssmode
+    \mathoption
+    \stoptyping
+
+*/
+
+/*tex
+
     In traditional \TeX\ the italic correction is added to the width of the
     glyph. This is part of the engine design and related font design. In opentype
     math this is different. There the italic correction had more explicit usage.
@@ -61,28 +75,72 @@
 */
 
 /*tex
+
+    This is the state per early 2025:
+
+    When we started with \OPENTYPE\ math (2005) there was only cambria. The only
+    way to test with e.g. Computer Modern was to make a virtual font. One of the
+    complications we ran into is italic correction and because the specification
+    explicitly binds italic correction to (1) a sequence of text (!) glyphs and
+    (2) anchoring limits (as there's only a top anchor and no bttom anchor
+    field), we ended up with a split code path. This is also due to the fact that
+    when Latin Modern showed up, we wanted to make sure that it rendered okay.
+
+    However, when the \TEX\ Gyre fonts were introduced, and other fonts used
+    those as template, the heuristics for Latin Modern were sub optimal so we
+    introduced ways to control the distance between super and subscript as well
+    as limit anchoring for large operators (these cannot really be identified).
+    Keep in mind that the italic correction in large operators is not used as
+    correction but for anchoring while the \TEX\ machinery always adds italic
+    correction to the width and selectively removes it. There is also the fact
+    that we don't know to what extend users mix \OPENTYPE\ fonts with traditional
+    ones.
+
+    In the end we decided to just drop that control, and assume that \OPENTYPE\
+    math fonts are expected to behave like traditional \TEX\ fonts, or: just
+    forget about what the specification says about italic correction. As a side
+    note: in \CONTEXT\ we already moved on and started treating fonts (in the
+    \LUAMETATEX\ default setup) as glyph providers and forget about italic
+    correction and the on the average unreliable and often wrong staircase kerns.
+    There we take whatever information fits our purpose and assume fonts to be a
+    mixed bag.
+
+    The result is that math renders similar to traditional (eight bit) rendering
+    but that Latin Modern can look kind of bad but as (non \CONTEXT) users are
+    accustomed to correcting spacing manually (with |\,| and |\!| etc.) that is
+    what is expected. We just fix the fonts runtime.
+
+    So, we ditched the control options, went for a hard coded traditional font
+    approach and likely will never look back: this is what one gets,
+    irrespectable of the specification. A side effect is that in some cases
+    \CONTEXT\ users will get worse results but because most already switched to
+    \LUAMETATEX\ the impact is not that large.
+
+    In 2005 and following years no one could have predicted that the majority of
+    math fonts would be designed as traditional \TEX\ fonts and less like the
+    reference Cambria font and that anchoring scripts would therefore be italic
+    correction driven (also for non italic shapes). So, in retrospect one can
+    argue that following the specification was a waste of time although it
+    eventually lead to detailed control over these things in the follow up
+    engine. However, there we might eventually completely remove all traces of
+    italic correction because we don't need it, but that's another story and
+    only relevant for \CONTEXT\ \LMTX.
+
+*/
+
+/*tex
+
     These macros are used to determine if we need to pick up parameters from the
     opentype table or the traditional parameter array. We noticed that some macro
     packages set both tables so we cannot use that for determining if we have a new
     or old font. It's a bit guesswork especially when it comes to italics.
+
 */
 
-# define trace_italics 0
-
-//      is_new_mathfont(A)   ((font_math_params(A) > 0) && (math_old_par == 0))
-//      is_old_mathfont(A,B) ((font_math_params(A) == 0) && (font_params(A) >= (B)))
-//      do_new_math(A)       ((font_math_params(A) > 0) && (font_oldmath(A) == 0) && (math_old_par == 0))
-
 #define is_new_mathfont(A)   ((font_math_params(A) > 0))
 #define is_old_mathfont(A,B) ((font_math_params(A) == 0) && (font_params(A) >= (B)))
 #define assume_new_math(A)   ((font_math_params(A) > 0) && (font_oldmath(A) == 0))
 
-//      do_new_math_but_not(A) (math_italics_mode_par > 1 ? 0 : do_new_math(A))
-
-#define math_italics_between_simple(A)     (math_italics_mode_par > 0) // 1 and higher
-#define math_italics_independent_italic(A) (math_italics_mode_par > 1 ? 0 : assume_new_math(A))
-#define math_italics_backtrack_operator(A) (math_italics_mode_par > 2 ? assume_new_math(A) : 0) // 3 or more
-
 #define protect_glyph(A) subtype(A) = 256
 
 #include "ptexlib.h"
@@ -397,14 +455,14 @@
     return a;
 }
 
-static scaled do_get_math_param_or_zero(int var, int param, const char *name)
-{
-    scaled a = get_math_param(param, var);
-    if (a == undefined_math_parameter) {
-        a = 0;
-    }
-    return a;
-}
+// static scaled do_get_math_param_or_zero(int var, int param, const char *name)
+// {
+//     scaled a = get_math_param(param, var);
+//     if (a == undefined_math_parameter) {
+//         a = 0;
+//     }
+//     return a;
+// }
 
 /*tex
 
@@ -1161,14 +1219,7 @@
     /*tex The new box and its character node. */
     pointer b, p;
     b = new_null_box();
-    if (math_italics_independent_italic(f)) {
-# if trace_italics
-    printf("[math italics independent italic 1]\n");
-# endif
-        width(b) = char_width(f, c);
-    } else {
-        width(b) = char_width(f, c) + char_italic(f, c);
-    }
+    width(b) = char_width(f, c) + char_italic(f, c);
     height(b) = char_height(f, c);
     depth(b) = char_depth(f, c);
     subtype(b) = math_char_list ;
@@ -2747,15 +2798,9 @@
             delta = delta + height(x) - h;
             h = height(x);
         }
-    } else if ((vlink(q) != null) && (type(nucleus(q)) == math_char_node)) {
-        /*tex only pure math char nodes */
-        internal_font_number f = fam_fnt(math_fam(nucleus(q)),cur_size);
-        if (math_italics_independent_italic(f)) {
-# if trace_italics
-    printf("[math italics independent italic 2]\n");
-# endif
-            ic = char_italic(f,math_character(nucleus(q)));
-        }
+//    } else if ((vlink(q) != null) && (type(nucleus(q)) == math_char_node)) {
+//        /*tex only pure math char nodes */
+//        internal_font_number f = fam_fnt(math_fam(nucleus(q)),cur_size);
     }
     /*tex the top accents of both characters are aligned */
     if (s_is_absolute) {
@@ -3117,14 +3162,14 @@
 {
     /*tex offset between subscript and superscript */
     scaled delta = 0;
-    scaled dummy = 0;
     /*tex temporary registers for box construction */
-    pointer p, v, x, y, z, n;
+    pointer p, v, x, y, z;
     /*tex register for character examination */
     int c;
     /*tex dimensions for box calculation */
     scaled shift_up, shift_down;
     boolean axis_shift = false;
+    int opentype = 0;
     scaled ok_size;
     if ((subtype(q) == op_noad_type_normal) && (cur_style < text_style)) {
         subtype(q) = op_noad_type_limits;
@@ -3142,21 +3187,8 @@
                 small_char(y) = math_character(nucleus(q));
                 x = do_delimiter(q, y, text_size, ok_size, false, cur_style, true, NULL, &delta, NULL);
                 if (delta != 0) {
-                    if (math_italics_backtrack_operator(cur_f)) {
-                        width(x) -= delta;
-# if trace_italics
-    printf("[math italics backtrack operator 1]\n");
-# endif
-                    } else if (math_italics_independent_italic(cur_f)) {
+                    if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
                         /*tex
-                            As we never added italic correction we don't need to compensate. The ic
-                            is stored in a special field of the node and applied in some occasions.
-                        */
-# if trace_italics
-    printf("[math italics independent italic 3]\n");
-# endif
-                    } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
-                        /*tex
                             Here we (selectively) remove the italic correction that always gets added
                             in a traditional font. See (**). In \OPENTYPE\ mode we insert italic kerns,
                             but in traditional mode it's width manipulation. This actually makes sense
@@ -3178,17 +3210,7 @@
                 delta = char_italic(cur_f, cur_c);
                 x = clean_box(nucleus(q), cur_style, cur_style, math_nucleus_list);
                 if (delta != 0) {
-                    if (math_italics_backtrack_operator(cur_f)) {
-                        width(x) -= delta;
-# if trace_italics
-    printf("[math italics backtrack operator 2]\n");
-# endif
-                    } else if (math_italics_independent_italic(cur_f)) {
-                        /*tex we never added italic correction */
-# if trace_italics
-    printf("[math italics independent italic 4]\n");
-# endif
-                    } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
+                    if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
                         /*tex remove italic correction */
                         width(x) -= delta;
                     }
@@ -3200,23 +3222,13 @@
             delta = char_italic(cur_f, cur_c);
             x = clean_box(nucleus(q), cur_style, cur_style, math_nucleus_list);
             if (delta != 0) {
-                if (math_italics_backtrack_operator(cur_f)) {
-                    width(x) -= delta;
-# if trace_italics
-    printf("[math italics backtrack operator 3]\n");
-# endif
-                } else if (math_italics_independent_italic(cur_f)) {
-                    /*tex we never added italic correction */
-# if trace_italics
-    printf("[math italics independent italic 5]\n");
-# endif
-                } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
+                if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
                     /*tex remove italic correction */
                     width(x) -= delta;
                 }
             }
             axis_shift = true;
-        }
+            }
         if (axis_shift) {
             /*tex center vertically */
             shift_amount(x) = half(height(x) - depth(x)) - math_axis_size(cur_size);
@@ -3224,82 +3236,18 @@
         type(nucleus(q)) = sub_box_node;
         math_list(nucleus(q)) = x;
     }
+    opentype = assume_new_math(cur_f);
     /*tex we now handle op_nod_type_no_limits here too */
     if (subtype(q) == op_noad_type_no_limits) {
-if (math_italics_backtrack_operator(cur_f)) {
-# if trace_italics
-    printf("[math italics backtrack operator 4]\n");
-# endif
-            /*tex
-                Not:
-
-                \starttyping
-                if (delta != 0) {
-                    delta = half(delta) ;
-                }
-                \stoptyping
-            */
-            p = check_nucleus_complexity(q, &dummy, cur_style, NULL);
-            if ((subscr(q) == null) && (supscr(q) == null)) {
-                assign_new_hlist(q, p);
-            } else {
-                /*tex
-                    Not:
-
-                    \starttyping
-                    make_scripts(q, p, 0, cur_style, delta, -delta);
-                    \stoptyping
-                */
-                int mode = math_nolimits_mode_par; /* wins */
-                /*tex
-
-                    For easy configuration ... fonts are somewhat inconsistent
-                    and the values for italic correction run from 30 to 60\% of.
-                    the width.
-
-                */
-                switch (mode) {
-                    case 0 :
-                        /*tex full bottom correction */
-                        make_scripts(q, p, 0, cur_style, 0, -delta);
-                        break;
-                    case 1 :
-                        /*tex |MathConstants| driven */
-                        make_scripts(q, p, 0, cur_style,
-                             round_xn_over_d(delta, nolimit_sup_factor(cur_style), 1000),
-                            -round_xn_over_d(delta, nolimit_sub_factor(cur_style), 1000));
-                        break ;
-                    case 2 :
-                        /*tex no correction */
-                        make_scripts(q, p, 0, cur_style, 0, 0);
-                        break ;
-                    case 3 :
-                        /*tex half bottom correction */
-                        make_scripts(q, p, 0, cur_style, 0, -half(delta));
-                        break;
-                    case 4 :
-                        /*tex half bottom and top correction */
-                        make_scripts(q, p, 0, cur_style, half(delta), -half(delta));
-                        break;
-                    default :
-                        if (mode > 15) {
-                            /*tex for quickly testing values */
-                            make_scripts(q, p, 0, cur_style, 0, -round_xn_over_d(delta, mode, 1000));
-                        } else {
-                            make_scripts(q, p, 0, cur_style, 0, 0);
-                        }
-                        break;
-                }
-            }
-            delta = 0;
+        /*tex similar code then the caller (before CHECK_DIMENSIONS) */
+        p = check_nucleus_complexity(q, &delta, cur_style, NULL);
+        if (opentype) {
+            width(p) -= delta;
+        }
+        if ((subscr(q) == null) && (supscr(q) == null)) {
+            assign_new_hlist(q, p);
         } else {
-            /*tex similar code then the caller (before CHECK_DIMENSIONS) */
-            p = check_nucleus_complexity(q, &delta, cur_style, NULL);
-            if ((subscr(q) == null) && (supscr(q) == null)) {
-                assign_new_hlist(q, p);
-            } else {
-                make_scripts(q, p, delta, cur_style, 0, 0);
-            }
+            make_scripts(q, p, delta, cur_style, 0, 0);
         }
     } else if (subtype(q) == op_noad_type_limits) {
         /*tex
@@ -3316,57 +3264,26 @@
         reset_attributes(v, node_attr(q));
         type(v) = vlist_node;
         subtype(v) = math_limits_list;
-        if (math_italics_independent_italic(cur_f)) {
-# if trace_italics
-    printf("[math italics independent italic 6]\n");
-# endif
-            n = nucleus(q);
-            if (n != null) {
-                if ((type(n) == sub_mlist_node) || (type(n) == sub_box_node)) {
-                    n = math_list(n);
-                    if (n != null) {
-                        if (type(n) == hlist_node) {
-                            /*tex just a not scaled char */
-                            n = list_ptr(n);
-                            while (n != null) {
-                                if (type(n) == glyph_node) {
-                                    delta = char_italic(font(n),character(n));
-                                }
-                                n = vlink(n);
-                            }
-                        } else {
-                            while (n != null) {
-                                if (type(n) == fence_noad) {
-                                    if (delimiteritalic(n) > delta) {
-                                        /*tex we can have dummies, the period ones */
-                                        delta = delimiteritalic(n);
-                                    }
-                                }
-                                n = vlink(n);
-                            }
-                        }
-                    }
-                } else {
-                    n = nucleus(q);
-                    if (type(n) == math_char_node) {
-                        delta = char_italic(fam_fnt(math_fam(n),cur_size),math_character(n));
-                    }
-                }
-            }
-        }
         width(v) = width(y);
-        if (width(x) > width(v))
+        /* rebox fixes the width and ignores italic */
+        if (width(x) > width(v)) {
             width(v) = width(x);
-        if (width(z) > width(v))
+        }
+        if (width(z) > width(v)) {
             width(v) = width(z);
+        }
         x = rebox(x, width(v));
         y = rebox(y, width(v));
         z = rebox(z, width(v));
-        shift_amount(x) = half(delta);
-        shift_amount(z) = -shift_amount(x);
+        shift_amount(x) = half(delta);      /* sup */
+        shift_amount(z) = -shift_amount(x); /* sub */
         /*tex v is the still empty target */
         height(v) = height(y);
         depth(v) = depth(y);
+        if (opentype) {
+            width(v) -= delta;
+         // delta = 0;
+        }
         /*tex
 
             Attach the limits to |y| and adjust |height(v)|, |depth(v)| to
@@ -3426,12 +3343,6 @@
             supscr(q) = null;
         }
         assign_new_hlist(q, v);
-        if (math_italics_independent_italic(cur_f)) {
-# if trace_italics
-    printf("[math italics independent italic 7]\n");
-# endif
-            delta = 0;
-        }
     }
     return delta;
 }
@@ -3477,19 +3388,6 @@
             type(nucleus(q)) = math_text_char_node;
             fetch(nucleus(q));
             a = cur_c;
-            /*tex add italic correction */
-            if (math_italics_independent_italic(cur_f) && (char_italic(cur_f,math_character(nucleus(q))) != 0)) {
-# if trace_italics
-    printf("[math italics independent italic 8]\n");
-# endif
-
-                p = new_kern(char_italic(cur_f,math_character(nucleus(q))));
-                subtype(p) = italic_kern;
-                reset_attributes(p, node_attr(q));
-                couple_nodes(p,vlink(q));
-                couple_nodes(q,p);
-                return;
-            }
             /*tex construct ligatures, quite unlikely in new math fonts */
             if ((has_kern(cur_f, a)) || (has_lig(cur_f, a))) {
                 cur_c = math_character(nucleus(p));
@@ -4352,7 +4250,7 @@
 {
     pointer p = null;
     pointer t = null;
-    if (same != NULL) {
+    if (same) {
         *same = 0;
     }
     switch (type(nucleus(q))) {
@@ -4361,37 +4259,14 @@
             fetch(nucleus(q));
             if (char_exists(cur_f, cur_c)) {
                 /*tex we could look at neighbours */
-                if (math_italics_independent_italic(cur_f)) {
-                    /*tex cf spec only the last one */
-# if trace_italics
-    printf("[math italics independent italic 9]\n");
-# endif
-                    *delta = 0 ;
-                } else {
-                    *delta = char_italic(cur_f, cur_c);
-                }
+                *delta = char_italic(cur_f, cur_c);
                 p = new_glyph(cur_f, cur_c);
                 protect_glyph(p);
                 reset_attributes(p, node_attr(nucleus(q)));
-                if (math_italics_backtrack_operator(cur_f)) {
-# if trace_italics
-    printf("[math italics backtrack operator 5]\n");
-# endif
-                    /* do nothing */
-                } else if (math_italics_independent_italic(cur_f)) {
-# if trace_italics
-    printf("[math italics independent italic 10]\n");
-# endif
-                    if (get_char_cat_code(cur_c) == 11) {
-                        /*tex no italic correction in mid-word of text font */
-                        *delta = 0;
-                    }
-                } else {
-                    /*tex no italic correction in mid-word of text font */
-                    if (((type(nucleus(q))) == math_text_char_node) && (space(cur_f) != 0)) {
-                        *delta = 0;
-                    }
-                }
+             // /*tex no italic correction in mid-word of text font */
+             // if (((type(nucleus(q))) == math_text_char_node) && (space(cur_f) != 0)) {
+             //     *delta = 0;
+             // }
                 /*tex so we only add italic correction when we have no scripts */
                 if ((subscr(q) == null) && (supscr(q) == null) && (*delta != 0)) {
                     pointer x = new_kern(*delta);
@@ -4399,13 +4274,6 @@
                     reset_attributes(x, node_attr(nucleus(q)));
                     couple_nodes(p,x);
                     *delta = 0;
-                } else if (math_italics_independent_italic(cur_f)) {
-                    /*tex Needs checking but looks ok. It must be more selective. */
-# if trace_italics
-    printf("[math italics independent italic 11]\n");
-# endif
-
-                    *delta = char_italic(cur_f, cur_c);
                 }
             }
             break;
@@ -4455,7 +4323,6 @@
     pointer p = null;
     pointer pp = null;
     pointer z = null;
-    halfword nxt ;
     int same = 0;
     /*tex a penalty to be inserted */
     int pen;
@@ -4491,7 +4358,6 @@
         */
       RESWITCH:
         delta = 0;
-        nxt = vlink(q);
         switch (type(q)) {
             case simple_noad:
                 switch (subtype(q)) {
@@ -4703,43 +4569,6 @@
                 the scripts so if it's optional here it also should be there.
 
             */
-            if (nxt && math_italics_between_simple(null) && (delta != 0)) {
-# if trace_italics
-    printf("[math italics between simple 1]\n");
-# endif
-                if (type(nxt) == simple_noad) {
-                    switch (subtype(nxt)) {
-                        case ord_noad_type:
-                        case bin_noad_type:
-                        case rel_noad_type:
-                        case open_noad_type:
-                        case close_noad_type:
-                        case punct_noad_type:
-                            delta = 0;
-                            break;
-                        case inner_noad_type:
-                            if (! delimitermodeitalics) {
-                                delta = 0;
-                            }
-                            break;
-                        case op_noad_type_normal:
-                        case op_noad_type_limits:
-                        case op_noad_type_no_limits:
-                        case under_noad_type:
-                        case over_noad_type:
-                        case vcenter_noad_type:
-                            break;
-                        default:
-                            break;
-                    }
-                }
-                if (delta != 0) {
-                    pointer d = new_kern(delta);
-                    subtype(d) = italic_kern;
-                    reset_attributes(d, node_attr(q));
-                    couple_nodes(p,d);
-                }
-            }
             assign_new_hlist(q, p);
         } else {
             /*tex top, bottom */



More information about the tex-live-commits mailing list.