Hi, the new `glyph_info` callback is called in two pretty different cases: in `short_display(_n)` where a pretty short representation of the actual output characters is required, and in `print_font_and_char`, which creates the representation for `print_node_list`. Here, more details can be useful, e.g.: Which variant of a character is used, are displacements applied etc. These could be added through `glyph_info`, but then these additional fields are also printed in `short_display`, leading to significantly worse overfull warnings etc. This could be improved if `glyph_info` could return different values in different situations.
So I suggest to add an additional parameter to the `glyph_info` callback which states if the current context could handle longer output. A possible implementation is attached. Best regards, Marcel
>From f69873a377d6db6e6c669f23374bb3f85af743af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= <t...@2krueger.de> Date: Tue, 22 Oct 2019 16:26:18 +0200 Subject: [PATCH] Add long parameter to `glyph_info`. --- manual/luatex-callbacks.tex | 4 +++- source/texk/web2c/luatexdir/tex/printing.c | 10 +++++----- source/texk/web2c/luatexdir/tex/printing.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manual/luatex-callbacks.tex b/manual/luatex-callbacks.tex index 9be3e3635..9f266a28e 100644 --- a/manual/luatex-callbacks.tex +++ b/manual/luatex-callbacks.tex @@ -1148,7 +1148,7 @@ The \type {glyph_info} callback can be set to report a useful representation of glyph. \startfunctioncall -function(<node> g) +function(<node> g, <boolean> long) -- return a string or nil end \stopfunctioncall @@ -1157,6 +1157,8 @@ When \type {nil} is returned the character code is printed, otherwise the returned string is used. By default the \UTF\ representation is shown which is not always that useful, especially when there is no real representation. Keep in mind that setting this callback can change the log in an incompatible way. +The second parameter indicates if a particularly short representation is +required for inline use of if more details can be added. \stopsection diff --git a/source/texk/web2c/luatexdir/tex/printing.c b/source/texk/web2c/luatexdir/tex/printing.c index c85a6a532..81faf6d9c 100644 --- a/source/texk/web2c/luatexdir/tex/printing.c +++ b/source/texk/web2c/luatexdir/tex/printing.c @@ -1013,12 +1013,12 @@ void print_font_identifier(internal_font_number f) number itself. */ -void print_character_info(halfword p) +void print_character_info(halfword p, boolean is_long) { int callback_id = callback_defined(glyph_info_callback); if (callback_id) { char* str = NULL; - run_callback(callback_id, "N->R", p, &str); + run_callback(callback_id, "Nb->R", p, is_long, &str); if (str == NULL) { print_qhex(character(p)); } else { @@ -1050,7 +1050,7 @@ void short_display(int p) print_char(' '); font_in_short_display = font(p); } - print_character_info(p); + print_character_info(p, false); } } else { /*tex Print a short indication of the contents of node |p| */ @@ -1081,7 +1081,7 @@ void print_font_and_char(int p) else print_font_identifier(font(p)); print_char(' '); - print_character_info(p); + print_character_info(p, true); } /*tex @@ -1179,7 +1179,7 @@ void short_display_n(int p, int m) print_char(' '); font_in_short_display = font(p); } - print_character_info(p); + print_character_info(p, false); } } else { if ( (type(p) == glue_node) || diff --git a/source/texk/web2c/luatexdir/tex/printing.h b/source/texk/web2c/luatexdir/tex/printing.h index e54186a27..10054f847 100644 --- a/source/texk/web2c/luatexdir/tex/printing.h +++ b/source/texk/web2c/luatexdir/tex/printing.h @@ -127,6 +127,6 @@ extern void begin_diagnostic(void); extern void end_diagnostic(boolean blank_line); extern int global_old_setting; -extern void print_character_info(halfword p); +extern void print_character_info(halfword p, boolean is_long); #endif -- 2.23.0
_______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex