Open zauguin opened 4 years ago
are the patch_font callbacks something that we want to "officially" support as interface? I know that it is used (I have done it myself) but I always wondered if it is "hackish" or not and what would happen if it is used more widely.
If yes, what sort of patches are actually possible in harf mode? And would it make sense to move the callback(s) to the luaotfload.aux- or fonts.handlers-namespace?
are the patch_font callbacks something that we want to "officially" support as interface? I know that it is used (I have done it myself) but I always wondered if it is "hackish" or not and what would happen if it is used more widely.
I agree that it is hackish but it is documented, so it is more or less official.
If yes, what sort of patches are actually possible in harf mode?
Pretty much all the things currently done in the patch_font
callbacks in luaotfload-auxiliary.lua
could also be done in harf mode (so e.g. adjusting font names, font dimensions etc.) Also it could be used to add TeX-level ligatures and modify the features which HarfBuzz will use.
Pretty much all use-cases for this would be better handled as virtual font features, but that is even more true for node
fonts.
And would it make sense to move the callback(s) to the luaotfload.aux- or fonts.handlers-namespace?
I don't think we should move anything into fonts.*
because that is the fontloader namespace and these callbacks are pretty luaotfload specific. I don't have any opinion if it should be .aux
or not, if we rename them anyway we can move them wherever you think the should belong.
We have two callbacks for patching fonts:
luaotfload.patch_font
andluaotfload.patch_font
and.patch_font_unsafe
. Currently.patch_font
handles allnode
fonts and.patch_font_unsafe
everything else. This leads to the question howharf
fonts should be patched: The original idea was that_unsafe
was for TFM fonts because patching them easily breaks the code and lots of fields are ignored there anyway. So it could be argued that.patch_font
should getharf
fonts too but that would probably break most existing callbacks.Maybe we need a new callback
.patch_font_harf
? If we do this we might want to reconsider the naming of the existing ones (e.g..patch_font
->.patch_font_node
and.patch_font_unsafe
to.patch_font_tfm
)? Of course, we would probably have to keep the old names too for compatibility.