after having had used STIX2 which looks good but a little too heavy/bold for my taste, I had a dream yesterday night. It was the solution. By using a hack with manual kerning and creation of the fj
ligature and \extraligfj
command and with LuaLaTeX
on-the-fly text-replacement I have created a seamless solution.
\ProvidesPackage{extralig}
\usepackage{xcolor}
\usepackage{luacode}
\newcommand{\extraligfj}{fi\llap{\textcolor{white}{\rule[-0.05em]{0.252em}{0.55em}}}\kern-0.01em\llap{\j}\kern-0.05em\relax}
\begin{luacode}
local function vartosrcvar ( line )
return string.gsub(line, "fj" , "\\extraligfj{}")
end
luatexbase.add_to_callback( "process_input_buffer", vartosrcvar, "var_to_srcvar")
\end{luacode}
By saving this code as extralig.sty
in your .tex
file directory and calling it with \usepackage{extralig}
it will work perfectly!
Obviously because of the Lua code you must compile this with LuaLaTeX
You are not required to use this as a package, simply copy everything into your document in corresponding places and it will work fine too but its much cleaner to have it as a seperate package.
How does this work?
- I define
\extraligfj
, a hack where the i
in fi
is replaced with a j
, making a perfect fj
ligature with some manual kerning. (Thanks to this TeX.SX post!)
- With LuaLaTeX, I use code which replaces all instances of
fj
with \extraligfj
, which we defined before.
- This is all placed neatly inside of
extralig.sty
and ready to be seamlessly loaded into our document as a package.
TL;DR Save the code snippet as extralig.sty
and place it the same directory as your .tex
file and load it with \usepackage{extralig}
. use LuaLaTeX. This is only guaranteed to work with Computer Modern, no other fonts (they will need manual kerning adjustment). Doing this then fj will automagically be ligatured.
Pros:
- I was expecting there to be some really weird glitches with linebreaks due to the nature of the hacked glyph, but to my surprise, it works perfectly even when broken in lines at
f
and j
- Only need to compile once because LuaTeX runs it on the fly, which is why its fully seamless, no slowdowns.
f
+j
->f
+\j
andff
+j
toff
+\j
it doesn't appear that this can be done outside editing font metrics though.