
Am Sun, 13 Apr 2025 04:51:00 -0600 schrieb Max Chernoff:
Hi Ulrike,
On Sun, 2025-04-13 at 12:15 +0200, Ulrike Fischer wrote:
And I didn't find yet examples or a documentation how to define a callback that "decorates" the tfm.
I think that this would be the "define_font" callback. You should be able to take the example from ยง6.3.3 and replace "v.commands = <...>" with "v.tounicode = {
}" (the documentation says that this needs to be a UTF-16 string, but a table of integer codepoints works too). Luaotfload already hooks into the "define_font" callback, so you should only need to override "fonts.readers.tfm". Actually, there's already a function "fonts.mappings.addtounicode", so you could either replace that with your own function, or add a manipulator that runs before/after that.
It is not really luaotfload that does that, but the font loader which is imported from context. And it is quite unclear if (and how) that can be used to overwrite the tounicode values without disturbing settings done with \pdfglyphtounicode. The actual question came from the maintainer of the adforn package who tried to improve the tounicode values (and so accessibility) of the chars. I will tell her to ask a question on tex.sx and then you can tell her how to do it in LaTeX without disturbing other fonts and packages and in a way that can be extended to other similar fonts. I would be very happy if that is possible, as I have a number of chess fonts where the tounicode values are wrong too. -- Ulrike Fischer http://www.troubleshooting-tex.de/