@@ -61,31 +61,27 @@ LuaTeX; if not, see <http://www.gnu.org/licenses/>.
61
61
*/
62
62
63
63
/*tex
64
- These two are used to determine if we need to pick up parameters from the
64
+ These macros are used to determine if we need to pick up parameters from the
65
65
opentype table or the traditional parameter array. We noticed that some macro
66
66
packages set both tables so we cannot use that for determining if we have a new
67
- or old font.
67
+ or old font. It's a bit guesswork especially when it comes to italics.
68
68
*/
69
69
70
- #define is_new_mathfont (A ) ((font_math_params(A) > 0))
71
- #define is_old_mathfont (A ,B ) ((font_math_params(A) == 0) && (font_params(A) >= (B)))
72
-
73
- /*tex
74
- This is a bit of a guess.
75
- */
70
+ # define trace_italics 0
76
71
77
- #define assume_new_math (A ) ((font_math_params(A) > 0) && (font_oldmath(A) == 0))
72
+ // is_new_mathfont(A) ((font_math_params(A) > 0) && (math_old_par == 0))
73
+ // is_old_mathfont(A,B) ((font_math_params(A) == 0) && (font_params(A) >= (B)))
74
+ // do_new_math(A) ((font_math_params(A) > 0) && (font_oldmath(A) == 0) && (math_old_par == 0))
78
75
79
- /*tex
80
- So we no longer use that test here.
81
- */
76
+ #define is_new_mathfont ( A ) ((font_math_params(A) > 0))
77
+ #define is_old_mathfont ( A , B ) ((font_math_params(A) == 0) && (font_params(A) >= (B)))
78
+ #define assume_new_math ( A ) ((font_math_params(A) > 0) && (font_oldmath(A) == 0))
82
79
83
80
// do_new_math_but_not(A) (math_italics_mode_par > 1 ? 0 : do_new_math(A))
84
- // do_new_math_but_not(A) (math_italics_mode_par <= 1)
85
81
86
- #define math_italics_between_simple (math_italics_mode_par > 0) // 1 and higher
87
- #define math_italics_independent_italic (math_italics_mode_par <= 1 )
88
- #define math_italics_backtrack_operator (math_italics_mode_par > 2 ) // 3 or more
82
+ #define math_italics_between_simple ( A ) (math_italics_mode_par > 0) // 1 and higher
83
+ #define math_italics_independent_italic ( A ) (math_italics_mode_par > 1 ? 0 : assume_new_math(A) )
84
+ #define math_italics_backtrack_operator ( A ) (math_italics_mode_par > 2 ? assume_new_math(A) : 0 ) // 3 or more
89
85
90
86
#define protect_glyph (A ) subtype(A) = 256
91
87
@@ -1165,10 +1161,14 @@ static pointer char_box(internal_font_number f, int c, pointer bb)
1165
1161
/*tex The new box and its character node. */
1166
1162
pointer b , p ;
1167
1163
b = new_null_box ();
1168
- if (math_italics_independent_italic )
1164
+ if (math_italics_independent_italic (f )) {
1165
+ # if trace_italics
1166
+ printf ("[math italics independent italic 1]\n" );
1167
+ # endif
1169
1168
width (b ) = char_width (f , c );
1170
- else
1169
+ } else {
1171
1170
width (b ) = char_width (f , c ) + char_italic (f , c );
1171
+ }
1172
1172
height (b ) = char_height (f , c );
1173
1173
depth (b ) = char_depth (f , c );
1174
1174
subtype (b ) = math_char_list ;
@@ -2750,7 +2750,10 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl
2750
2750
} else if ((vlink (q ) != null ) && (type (nucleus (q )) == math_char_node )) {
2751
2751
/*tex only pure math char nodes */
2752
2752
internal_font_number f = fam_fnt (math_fam (nucleus (q )),cur_size );
2753
- if (math_italics_independent_italic ) {
2753
+ if (math_italics_independent_italic (f )) {
2754
+ # if trace_italics
2755
+ printf ("[math italics independent italic 2]\n" );
2756
+ # endif
2754
2757
ic = char_italic (f ,math_character (nucleus (q )));
2755
2758
}
2756
2759
}
@@ -3139,13 +3142,19 @@ static scaled make_op(pointer q, int cur_style)
3139
3142
small_char (y ) = math_character (nucleus (q ));
3140
3143
x = do_delimiter (q , y , text_size , ok_size , false, cur_style , true, NULL , & delta , NULL );
3141
3144
if (delta != 0 ) {
3142
- if (math_italics_backtrack_operator ) {
3145
+ if (math_italics_backtrack_operator ( cur_f ) ) {
3143
3146
width (x ) -= delta ;
3144
- } else if (math_italics_independent_italic ) {
3147
+ # if trace_italics
3148
+ printf ("[math italics backtrack operator 1]\n" );
3149
+ # endif
3150
+ } else if (math_italics_independent_italic (cur_f )) {
3145
3151
/*tex
3146
3152
As we never added italic correction we don't need to compensate. The ic
3147
3153
is stored in a special field of the node and applied in some occasions.
3148
3154
*/
3155
+ # if trace_italics
3156
+ printf ("[math italics independent italic 3]\n" );
3157
+ # endif
3149
3158
} else if ((subscr (q ) != null ) && (subtype (q ) != op_noad_type_limits )) {
3150
3159
/*tex
3151
3160
Here we (selectively) remove the italic correction that always gets added
@@ -3169,10 +3178,16 @@ static scaled make_op(pointer q, int cur_style)
3169
3178
delta = char_italic (cur_f , cur_c );
3170
3179
x = clean_box (nucleus (q ), cur_style , cur_style , math_nucleus_list );
3171
3180
if (delta != 0 ) {
3172
- if (math_italics_backtrack_operator ) {
3181
+ if (math_italics_backtrack_operator ( cur_f ) ) {
3173
3182
width (x ) -= delta ;
3174
- } else if (math_italics_independent_italic ) {
3183
+ # if trace_italics
3184
+ printf ("[math italics backtrack operator 2]\n" );
3185
+ # endif
3186
+ } else if (math_italics_independent_italic (cur_f )) {
3175
3187
/*tex we never added italic correction */
3188
+ # if trace_italics
3189
+ printf ("[math italics independent italic 4]\n" );
3190
+ # endif
3176
3191
} else if ((subscr (q ) != null ) && (subtype (q ) != op_noad_type_limits )) {
3177
3192
/*tex remove italic correction */
3178
3193
width (x ) -= delta ;
@@ -3185,12 +3200,16 @@ static scaled make_op(pointer q, int cur_style)
3185
3200
delta = char_italic (cur_f , cur_c );
3186
3201
x = clean_box (nucleus (q ), cur_style , cur_style , math_nucleus_list );
3187
3202
if (delta != 0 ) {
3188
- /* if (math_italics_backtrack_operator) {
3189
- } else */
3190
- if (math_italics_backtrack_operator ) {
3203
+ if (math_italics_backtrack_operator (cur_f )) {
3191
3204
width (x ) -= delta ;
3192
- } else if (math_italics_independent_italic ) {
3205
+ # if trace_italics
3206
+ printf ("[math italics backtrack operator 3]\n" );
3207
+ # endif
3208
+ } else if (math_italics_independent_italic (cur_f )) {
3193
3209
/*tex we never added italic correction */
3210
+ # if trace_italics
3211
+ printf ("[math italics independent italic 5]\n" );
3212
+ # endif
3194
3213
} else if ((subscr (q ) != null ) && (subtype (q ) != op_noad_type_limits )) {
3195
3214
/*tex remove italic correction */
3196
3215
width (x ) -= delta ;
@@ -3207,7 +3226,10 @@ static scaled make_op(pointer q, int cur_style)
3207
3226
}
3208
3227
/*tex we now handle op_nod_type_no_limits here too */
3209
3228
if (subtype (q ) == op_noad_type_no_limits ) {
3210
- if (math_italics_backtrack_operator ) {
3229
+ if (math_italics_backtrack_operator (cur_f )) {
3230
+ # if trace_italics
3231
+ printf ("[math italics backtrack operator 4]\n" );
3232
+ # endif
3211
3233
/*tex
3212
3234
Not:
3213
3235
@@ -3294,7 +3316,10 @@ if (math_italics_backtrack_operator) {
3294
3316
reset_attributes (v , node_attr (q ));
3295
3317
type (v ) = vlist_node ;
3296
3318
subtype (v ) = math_limits_list ;
3297
- if (math_italics_independent_italic ) {
3319
+ if (math_italics_independent_italic (cur_f )) {
3320
+ # if trace_italics
3321
+ printf ("[math italics independent italic 6]\n" );
3322
+ # endif
3298
3323
n = nucleus (q );
3299
3324
if (n != null ) {
3300
3325
if ((type (n ) == sub_mlist_node ) || (type (n ) == sub_box_node )) {
@@ -3401,7 +3426,10 @@ if (math_italics_backtrack_operator) {
3401
3426
supscr (q ) = null ;
3402
3427
}
3403
3428
assign_new_hlist (q , v );
3404
- if (math_italics_independent_italic ) {
3429
+ if (math_italics_independent_italic (cur_f )) {
3430
+ # if trace_italics
3431
+ printf ("[math italics independent italic 7]\n" );
3432
+ # endif
3405
3433
delta = 0 ;
3406
3434
}
3407
3435
}
@@ -3450,7 +3478,11 @@ static void make_ord(pointer q)
3450
3478
fetch (nucleus (q ));
3451
3479
a = cur_c ;
3452
3480
/*tex add italic correction */
3453
- if (math_italics_independent_italic && (char_italic (cur_f ,math_character (nucleus (q ))) != 0 )) {
3481
+ if (math_italics_independent_italic (cur_f ) && (char_italic (cur_f ,math_character (nucleus (q ))) != 0 )) {
3482
+ # if trace_italics
3483
+ printf ("[math italics independent italic 8]\n" );
3484
+ # endif
3485
+
3454
3486
p = new_kern (char_italic (cur_f ,math_character (nucleus (q ))));
3455
3487
subtype (p ) = italic_kern ;
3456
3488
reset_attributes (p , node_attr (q ));
@@ -4329,18 +4361,27 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_styl
4329
4361
fetch (nucleus (q ));
4330
4362
if (char_exists (cur_f , cur_c )) {
4331
4363
/*tex we could look at neighbours */
4332
- if (math_italics_independent_italic ) {
4364
+ if (math_italics_independent_italic ( cur_f ) ) {
4333
4365
/*tex cf spec only the last one */
4366
+ # if trace_italics
4367
+ printf ("[math italics independent italic 9]\n" );
4368
+ # endif
4334
4369
* delta = 0 ;
4335
4370
} else {
4336
4371
* delta = char_italic (cur_f , cur_c );
4337
4372
}
4338
4373
p = new_glyph (cur_f , cur_c );
4339
4374
protect_glyph (p );
4340
4375
reset_attributes (p , node_attr (nucleus (q )));
4341
- if (math_italics_backtrack_operator ) {
4376
+ if (math_italics_backtrack_operator (cur_f )) {
4377
+ # if trace_italics
4378
+ printf ("[math italics backtrack operator 5]\n" );
4379
+ # endif
4342
4380
/* do nothing */
4343
- } else if (math_italics_independent_italic ) {
4381
+ } else if (math_italics_independent_italic (cur_f )) {
4382
+ # if trace_italics
4383
+ printf ("[math italics independent italic 10]\n" );
4384
+ # endif
4344
4385
if (get_char_cat_code (cur_c ) == 11 ) {
4345
4386
/*tex no italic correction in mid-word of text font */
4346
4387
* delta = 0 ;
@@ -4358,8 +4399,12 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_styl
4358
4399
reset_attributes (x , node_attr (nucleus (q )));
4359
4400
couple_nodes (p ,x );
4360
4401
* delta = 0 ;
4361
- } else if (math_italics_independent_italic ) {
4402
+ } else if (math_italics_independent_italic ( cur_f ) ) {
4362
4403
/*tex Needs checking but looks ok. It must be more selective. */
4404
+ # if trace_italics
4405
+ printf ("[math italics independent italic 11]\n" );
4406
+ # endif
4407
+
4363
4408
* delta = char_italic (cur_f , cur_c );
4364
4409
}
4365
4410
}
@@ -4658,7 +4703,10 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
4658
4703
the scripts so if it's optional here it also should be there.
4659
4704
4660
4705
*/
4661
- if (nxt && math_italics_between_simple && (delta != 0 )) {
4706
+ if (nxt && math_italics_between_simple (null ) && (delta != 0 )) {
4707
+ # if trace_italics
4708
+ printf ("[math italics between simple 1]\n" );
4709
+ # endif
4662
4710
if (type (nxt ) == simple_noad ) {
4663
4711
switch (subtype (nxt )) {
4664
4712
case ord_noad_type :
0 commit comments