निरंजन
```
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Shobhika}%% https://ctan.org/pkg/shobhika
\begin{filecontents}[overwrite]{bar.sty}
\RequirePackage{xkeyval}
\RequirePackage{fontspec}
\newif\iffontpreserving
\DeclareOptionX{preservefont}{\fontpreservingtrue}
\iffontpreserving\relax
\else
\setmainfont{CharisSIL}%% https://ctan.org/pkg/charissil
\fi
\ProcessOptionsX
\end{filecontents}
\usepackage[preservefont]{bar}
\begin{document}
अआइई
abcd
\end{document}
```
I want the `\setmainfont{CharisSIL}` command to be loaded **only** when the option `preservefont` is not loaded. I wonder what's wrong with the code I have so far written.
Top Answer
samcarter
Before you can test for `\iffontpreserving` you have to process the package options:
```
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Shobhika}%% https://ctan.org/pkg/shobhika
\begin{filecontents}[overwrite]{bar.sty}
\RequirePackage{xkeyval}
\RequirePackage{fontspec}
\newif\iffontpreserving
\DeclareOptionX{preservefont}{\fontpreservingtrue}
\ProcessOptionsX
\iffontpreserving\relax
\else
\setmainfont{CharisSIL}%% https://ctan.org/pkg/charissil
\fi
\end{filecontents}
\usepackage[
preservefont
]{bar}
\begin{document}
अआइई
abcd
\end{document}
```