I was looking at Problem with hyphen in URL when using fancyvrb with hyperref but cannot quite understand the solution so cannot apply it to my problem.
I am getting an unwanted ligature in verbatim text that I colored using the work-around in fancyvrb alternate commandchars and \textcolor because I couldn't use brackets as the command characters.
Here is the minimal example, which shows the unwanted ligature "fi" at the beginning of the colored text:
% !TEX TS-program = xelatex
\documentclass{article}
% -- fonts:
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle} % applies to all fonts
\setmonofont[Scale=0.9,Numbers={Lining,Monospaced}]{TeX Gyre Cursor}
% -- custom verbatim env for typesetting code:
\usepackage{fancyvrb,xcolor}
\definecolor{purple}{rgb}{0.5,0.1,0.3}
\DefineVerbatimEnvironment{CodeVerbatim}{Verbatim}{commandchars=\#^\~}
\newcommand*{\fvtextcolor}[2]{\textcolor{#1}{#2}}
\begin{document}
\begin{CodeVerbatim}
@echo #fvtextcolor^purple~^"file uses ligature"~
\end{CodeVerbatim}
\end{document}
This results in the following PDF:
Now my question: how can I break the ligature "fi" in file when handing text over to the \textcolor
command (via the macro \fvtextcolor
in between)?