diff options
Diffstat (limited to 'source/luametatex/source/tex')
-rw-r--r-- | source/luametatex/source/tex/texcommands.c | 2 | ||||
-rw-r--r-- | source/luametatex/source/tex/texmath.c | 39 | ||||
-rw-r--r-- | source/luametatex/source/tex/texmlist.c | 60 | ||||
-rw-r--r-- | source/luametatex/source/tex/texnodes.c | 21 | ||||
-rw-r--r-- | source/luametatex/source/tex/texnodes.h | 11 | ||||
-rw-r--r-- | source/luametatex/source/tex/texrules.c | 19 |
6 files changed, 100 insertions, 52 deletions
diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c index 03bcc34d1..13357a141 100644 --- a/source/luametatex/source/tex/texcommands.c +++ b/source/luametatex/source/tex/texcommands.c @@ -495,10 +495,12 @@ void tex_initialize_commands(void) tex_primitive(tex_command, "vrule", vrule_cmd, normal_rule_code, 0); tex_primitive(luatex_command, "novrule", vrule_cmd, empty_rule_code, 0); + tex_primitive(luatex_command, "virtualvrule", vrule_cmd, virtual_rule_code, 0); tex_primitive(luatex_command, "srule", vrule_cmd, strut_rule_code, 0); tex_primitive(tex_command, "hrule", hrule_cmd, normal_rule_code, 0); tex_primitive(luatex_command, "nohrule", hrule_cmd, empty_rule_code, 0); + tex_primitive(luatex_command, "virtualhrule", hrule_cmd, virtual_rule_code, 0); tex_primitive(tex_command, "count", register_cmd, int_val_level, 0); tex_primitive(luatex_command, "attribute", register_cmd, attr_val_level, 0); diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c index a9f1a3ed9..4979c1a23 100644 --- a/source/luametatex/source/tex/texmath.c +++ b/source/luametatex/source/tex/texmath.c @@ -1691,20 +1691,27 @@ int tex_check_active_math_char(int character) case alignment_tab_cmd: case superscript_cmd: case subscript_cmd: - cur_cmd = code; - cur_chr = character; - cur_tok = token_val(cur_cmd, cur_chr); - if (tracing_commands_par >= 4) { - tex_aux_report_active(4, "control", code, character); - } - return 1; case letter_cmd: case other_char_cmd: + case active_char_cmd: cur_cmd = code; cur_chr = character; cur_tok = token_val(cur_cmd, cur_chr); if (tracing_commands_par >= 4) { - tex_aux_report_active(4, "inject", code, character); + switch (code) { + case alignment_tab_cmd: + case superscript_cmd: + case subscript_cmd: + tex_aux_report_active(4, "control", code, character); + break; + case letter_cmd: + case other_char_cmd: + tex_aux_report_active(4, "inject", code, character); + break; + case active_char_cmd: + tex_aux_report_active(4, "active", code, character); + break; + } } return 1; default: @@ -1754,6 +1761,21 @@ static int tex_aux_scan_active_math_char(mathcodeval *mval, int where) tex_aux_report_active(where, "inject", code, character); } return 0; + case active_char_cmd: + /*tex + We reset the code so that we don't get a loop, whuich means that the macro that + gets invoked has to set the amcode again if needed. + */ + tex_set_am_code(character, other_char_cmd, 0); + cur_cs = tex_active_to_cs(cur_chr, 1); + cur_cmd = eq_type(cur_cs); + cur_chr = eq_value(cur_cs); + tex_x_token(); + tex_back_input(cur_tok); + if (tracing_commands_par >= 4) { + tex_aux_report_active(where, "active", code, character); + } + return 1; default: if (tracing_commands_par >= 4) { tex_aux_report_active(where, "ignore", code, character); @@ -1761,6 +1783,7 @@ static int tex_aux_scan_active_math_char(mathcodeval *mval, int where) return 1; } } else if (mval->class_value == active_math_class_value) { + /*tex We might eventually drop tthis feature in favor of the amcode. */ cur_cs = tex_active_to_cs(cur_chr, 1); cur_cmd = eq_type(cur_cs); cur_chr = eq_value(cur_cs); diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c index 79ab490e7..b3f8cf294 100644 --- a/source/luametatex/source/tex/texmlist.c +++ b/source/luametatex/source/tex/texmlist.c @@ -1326,14 +1326,14 @@ static halfword register_extensible(halfword fnt, halfword chr, int size, halfwo { int callback_id = lmt_callback_defined(register_extensible_callback); if (callback_id > 0) { - halfword b = null; - lmt_run_callback(lmt_lua_state.lua_instance, callback_id, "dddN->N", fnt, chr, size, result, &b); - if (b) { - switch (node_type(b)) { + halfword boxed = null; + lmt_run_callback(lmt_lua_state.lua_instance, callback_id, "dddN->N", fnt, chr, size, result, &boxed); + if (boxed) { + switch (node_type(boxed)) { case hlist_node: case vlist_node: - tex_attach_attribute_list_attribute(b, att); - return b; + tex_attach_attribute_list_attribute(boxed, att); /* yes or no */ + return boxed; default: tex_formatted_error("fonts", "invalid extensible character %U registered for font %F, [h|v]list expected", chr, fnt); break; @@ -1425,10 +1425,12 @@ static halfword tex_aux_make_delimiter(halfword target, halfword delimiter, int goto FOUND; } } - if (tex_char_has_tag_from_font(curfnt, curchr, extensible_tag)) { - fnt = curfnt; - chr = curchr; - do_parts = 1; + if (tex_char_has_tag_from_font(curfnt, curchr, extensible_tag)) { + if (flat ? tex_char_has_tag_from_font(curfnt, curchr, horizontal_tag) : tex_char_has_tag_from_font(curfnt, curchr, vertical_tag)) { + fnt = curfnt; + chr = curchr; + do_parts = 1; + } goto FOUND; } else if (count > 1000) { tex_formatted_warning("fonts", "endless loop in extensible character %U of font %F", curchr, curfnt); @@ -2142,7 +2144,6 @@ static void tex_aux_make_over(halfword target, halfword style, halfword size, ha extensibles. The order is: kern, rule, gap, content. */ - halfword result; scaled thickness = tex_get_math_y_parameter_checked(style, math_parameter_overbar_rule); scaled vgap = tex_get_math_y_parameter_checked(style, math_parameter_overbar_vgap); scaled kern = tex_get_math_y_parameter_checked(style, math_parameter_overbar_kern); @@ -2152,14 +2153,16 @@ static void tex_aux_make_over(halfword target, halfword style, halfword size, ha thickness = t; } } - result = tex_aux_overbar( - tex_aux_clean_box(noad_nucleus(target), tex_math_style_variant(style, math_parameter_over_line_variant), style, math_nucleus_list, 0, NULL), - vgap, thickness, kern, - get_attribute_list(noad_nucleus(target)), math_over_rule_subtype, size, fam - ); - node_subtype(result) = math_over_list; - kernel_math_list(noad_nucleus(target)) = result; - node_type(noad_nucleus(target)) = sub_box_node; + { + halfword result = tex_aux_overbar( + tex_aux_clean_box(noad_nucleus(target), tex_math_style_variant(style, math_parameter_over_line_variant), style, math_nucleus_list, 0, NULL), + vgap, thickness, kern, + get_attribute_list(noad_nucleus(target)), math_over_rule_subtype, size, fam + ); + node_subtype(result) = math_over_list; + kernel_math_list(noad_nucleus(target)) = result; + node_type(noad_nucleus(target)) = sub_box_node; + } } static void tex_aux_make_under(halfword target, halfword style, halfword size, halfword fam) @@ -2171,7 +2174,6 @@ static void tex_aux_make_under(halfword target, halfword style, halfword size, h rule, kern. */ - halfword result; scaled thickness = tex_get_math_y_parameter_checked(style, math_parameter_underbar_rule); scaled vgap = tex_get_math_y_parameter_checked(style, math_parameter_underbar_vgap); scaled kern = tex_get_math_y_parameter_checked(style, math_parameter_underbar_kern); @@ -2181,14 +2183,16 @@ static void tex_aux_make_under(halfword target, halfword style, halfword size, h thickness = t; } } - result = tex_aux_underbar( - tex_aux_clean_box(noad_nucleus(target), tex_math_style_variant(style, math_parameter_under_line_variant), style, math_nucleus_list, 0, NULL), - vgap, thickness, kern, - get_attribute_list(noad_nucleus(target)), math_under_rule_subtype, size, fam - ); - node_subtype(result) = math_over_list; - kernel_math_list(noad_nucleus(target)) = result; - node_type(noad_nucleus(target)) = sub_box_node; + { + halfword result = tex_aux_underbar( + tex_aux_clean_box(noad_nucleus(target), tex_math_style_variant(style, math_parameter_under_line_variant), style, math_nucleus_list, 0, NULL), + vgap, thickness, kern, + get_attribute_list(noad_nucleus(target)), math_under_rule_subtype, size, fam + ); + node_subtype(result) = math_over_list; + kernel_math_list(noad_nucleus(target)) = result; + node_type(noad_nucleus(target)) = sub_box_node; + } } /*tex diff --git a/source/luametatex/source/tex/texnodes.c b/source/luametatex/source/tex/texnodes.c index 27b9520e3..625a4346b 100644 --- a/source/luametatex/source/tex/texnodes.c +++ b/source/luametatex/source/tex/texnodes.c @@ -204,6 +204,7 @@ void lmt_nodelib_initialize(void) { set_value_entry_key(subtypes_rule, math_radical_rule_subtype, radical) set_value_entry_key(subtypes_rule, box_rule_subtype, box) set_value_entry_key(subtypes_rule, image_rule_subtype, image) + set_value_entry_key(subtypes_rule, virtual_rule_subtype, virtual) subtypes_glyph = lmt_aux_allocate_value_info(glyph_math_accent_subtype); @@ -212,13 +213,13 @@ void lmt_nodelib_initialize(void) { set_value_entry_key(subtypes_glyph, glyph_ligature_subtype, ligature) set_value_entry_key(subtypes_glyph, glyph_math_delimiter_subtype, delimiter); set_value_entry_key(subtypes_glyph, glyph_math_extensible_subtype, extensible); - set_value_entry_key(subtypes_glyph, glyph_math_ordinary_subtype, ord); - set_value_entry_key(subtypes_glyph, glyph_math_operator_subtype, op); - set_value_entry_key(subtypes_glyph, glyph_math_binary_subtype, bin); - set_value_entry_key(subtypes_glyph, glyph_math_relation_subtype, rel); + set_value_entry_key(subtypes_glyph, glyph_math_ordinary_subtype, ordinary); + set_value_entry_key(subtypes_glyph, glyph_math_operator_subtype, operator); + set_value_entry_key(subtypes_glyph, glyph_math_binary_subtype, binary); + set_value_entry_key(subtypes_glyph, glyph_math_relation_subtype, relation); set_value_entry_key(subtypes_glyph, glyph_math_open_subtype, open); set_value_entry_key(subtypes_glyph, glyph_math_close_subtype, close); - set_value_entry_key(subtypes_glyph, glyph_math_punctuation_subtype, punct); + set_value_entry_key(subtypes_glyph, glyph_math_punctuation_subtype, punctuation); set_value_entry_key(subtypes_glyph, glyph_math_variable_subtype, variable); set_value_entry_key(subtypes_glyph, glyph_math_active_subtype, active); set_value_entry_key(subtypes_glyph, glyph_math_inner_subtype, inner); @@ -307,13 +308,13 @@ void lmt_nodelib_initialize(void) { subtypes_noad = lmt_aux_allocate_value_info(vcenter_noad_subtype); // last_noad_subtype - set_value_entry_key(subtypes_noad, ordinary_noad_subtype, ord) - set_value_entry_key(subtypes_noad, operator_noad_subtype, op) - set_value_entry_key(subtypes_noad, binary_noad_subtype, bin) - set_value_entry_key(subtypes_noad, relation_noad_subtype, rel) + set_value_entry_key(subtypes_noad, ordinary_noad_subtype, ordinary) + set_value_entry_key(subtypes_noad, operator_noad_subtype, operator) + set_value_entry_key(subtypes_noad, binary_noad_subtype, binary) + set_value_entry_key(subtypes_noad, relation_noad_subtype, relation) set_value_entry_key(subtypes_noad, open_noad_subtype, open) set_value_entry_key(subtypes_noad, close_noad_subtype, close) - set_value_entry_key(subtypes_noad, punctuation_noad_subtype, punct) + set_value_entry_key(subtypes_noad, punctuation_noad_subtype, punctuation) set_value_entry_key(subtypes_noad, variable_noad_subtype, variable) set_value_entry_key(subtypes_noad, active_noad_subtype, active) set_value_entry_key(subtypes_noad, inner_noad_subtype, inner) diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h index 093978c4e..113de8f40 100644 --- a/source/luametatex/source/tex/texnodes.h +++ b/source/luametatex/source/tex/texnodes.h @@ -79,6 +79,13 @@ - radical - boundary + Before we went on with \LUAMETATEX\ already quite a bit was added to \LUATEX\ (granularity in + subtypes, more of them, etc.) but here we add more. Some day I might make a list of difference + just for historic reasons. Don't assume equivalence: some in \LUATEX\ was sort of experimental + and improved over time and maybe should not have been added to \LUATEX\ at all and been delayed + for \LUAMETATEX\ instead (as it's probably not used), so that core \LUATEX\ stayed closer the + other engines. + */ typedef enum node_types { @@ -966,6 +973,7 @@ typedef enum rule_subtypes { empty_rule_subtype, strut_rule_subtype, outline_rule_subtype, + virtual_rule_subtype, user_rule_subtype, math_over_rule_subtype, math_under_rule_subtype, @@ -978,7 +986,8 @@ typedef enum rule_subtypes { typedef enum rule_codes { normal_rule_code, empty_rule_code, - strut_rule_code, + virtual_rule_code, + strut_rule_code } rule_codes; # define last_rule_subtype image_rule_subtype diff --git a/source/luametatex/source/tex/texrules.c b/source/luametatex/source/tex/texrules.c index b3d069ad3..db993585b 100644 --- a/source/luametatex/source/tex/texrules.c +++ b/source/luametatex/source/tex/texrules.c @@ -4,19 +4,19 @@ # include "luametatex.h" -halfword tex_aux_scan_rule_spec(rule_types t, halfword s) +halfword tex_aux_scan_rule_spec(rule_types type, halfword code) { /*tex |width|, |depth|, and |height| all equal |null_flag| now */ - halfword rule = tex_new_rule_node((quarterword) s); + halfword rule = tex_new_rule_node((quarterword) code); halfword attr = node_attr(rule); - switch (t) { + switch (type) { case h_rule_type: rule_height(rule) = default_rule; rule_depth(rule) = 0; break; case v_rule_type: case m_rule_type: - if (s == strut_rule_code) { + if (code == strut_rule_code) { rule_width(rule) = 0; node_subtype(rule) = strut_rule_subtype; } else { @@ -124,9 +124,18 @@ halfword tex_aux_scan_rule_spec(rule_types t, halfword s) } DONE: node_attr(rule) = attr; - if (t == v_rule_type && s == strut_rule_code) { + if (type == v_rule_type && code == strut_rule_code) { tex_aux_check_text_strut_rule(rule, text_style); } + if (code == virtual_rule_code) { + rule_data(rule) = rule_width(rule); + rule_left(rule) = rule_height(rule); + rule_right(rule) = rule_depth(rule); + rule_width(rule) = 0; + rule_height(rule) = 0; + rule_depth(rule) = 0; + node_subtype(rule) = virtual_rule_subtype; + } return rule; } |