For some reason, I'm really struggling to articulate my question, so let me apologise in advance. I may not be approaching this from the right angle.
I'm working in XeTeX (and it's far too late to change to LuaTeX). The font I've chosen has the problem with ligatures displaying properly, but containing garbage when copy-and-pasted from the resulting PDF. This also makes the PDF much less searchable, since, e.g., "flow" won't be found because of the "fl" ligature.
After a significant amount of googling, it appears to me that there is no proper solution to address this yet. One less-than-ideal option is to use the accsupp
package, and to provide XeTeX and the PDF with different strings. For example, this works:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Minion Pro}
\usepackage{accsupp}
\newcommand\ligfl{\BeginAccSupp{method=escape,ActualText=fl}fl\EndAccSupp{}}
\begin{document}
flow vs. {\ligfl}ow
\end{document}
(Before anyone suggests it, I'm not actually using Minion Pro, so \usepackage{MinionPro}
is not the way to go for me.)
One option would be to do a find-and-replace on "fi", "ffi", "fl", and "ffl" to change them to commands like the \ligfl
above. This is doable, and I may have to resort to it, but before I do, is there a more flexible, elegant way to do it than the hard-coding above?
What I would ideally like to do is either:
make the "ligaturisable" character pairs or triplets active, and have, e.g., each
fl
automatically interpreted as{\ligfl}
. I may have been searching incorrectly, but there appears to be no way to do this; oruse some sort of pre-processor or similar which would change all
fl
s to{\ligfl}
s just before the document is built. (Realistically, though, I think I'd struggle with this option as I'm working in LyX.)
or, of course, a third option I haven't thought of.
Any help would be greatly appreciated.
\footnote
. It should be fairly simple in any editor with regular expressions to change every instance of fl not in a command name by \ligfl