
Hi Patrick, On Wed, 2025-04-09 at 11:45 +0200, Patrick Gundlach wrote:
Do you know (does anyone know) how to activate this callback?
I do
callback.register("glyph_stream_provider",function () assert(false) end)
but this never gets called.
This is the shortest document that I was able to get to work: \directlua{ callback.register("glyph_stream_provider",function(font_id, char_index, mode) texio.write_nl("") print("glyph_stream_provider", font_id, char_index, mode) if mode == 1 or mode == 2 then return "" elseif mode == 3 then return 0, 0, 0, 0 else error() end end) local characters = {} for _, code in utf8.codes("Hello, world!") do characters[code] = { index = code, } end local otf = font.define { name = "texgyreheros-regular.otf", characters = characters, streamprovider = 1, format = "opentype", filename = "texgyreheros-regular.otf", } token.set_char("otf", otf) local ttf = font.define { name = "NotoSans-Regular.ttf", characters = characters, streamprovider = 3, format = "truetype", filename = "NotoSans-Regular.ttf", } token.set_char("ttf", ttf) } {\setfontid\otf Hello, world! \vfill\eject} {\setfontid\ttf Hello, world! \vfill\eject} \bye On Wed, 2025-04-09 at 12:37 +0200, Patrick Gundlach wrote:
Sadly, this is (as the name suggests) only the code for each glyph. I wish I could pass a complete font program to a callback and subset everything by myself (or rather: the harfbuzz subsetting library
You should be able to write out the subsetted font directly to the PDF, then make a virtual font with commands something like commands = { { "pdf", "direct", "/yourfontname 10 Tf (yourcharacter)" }, } although that is kinda ugly. But the LaTeX additions to luaotfload support variable fonts via HarfBuzz, so you should probably look at what they're doing there. Thanks, -- Max