From 49858100f7513db7dcf366fe874bb10eee977f4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E0=A4=A8=E0=A4=BF=E0=A4=B0=E0=A4=82=E0=A4=9C=E0=A4=A8?=
 <hi.niranjan@pm.me>
Date: Thu, 20 Jan 2022 01:15:42 +0530
Subject: [PATCH 5/5] conditional-warning

---
 tipauni/tipauni.dtx | 103 +++++++++++++++++++++++---------------------
 1 file changed, 55 insertions(+), 48 deletions(-)

diff --git a/tipauni/tipauni.dtx b/tipauni/tipauni.dtx
index f6b158c..2e4a536 100644
--- a/tipauni/tipauni.dtx
+++ b/tipauni/tipauni.dtx
@@ -463,72 +463,79 @@ Unicode characters with TIPA commands]
 % Package options are provided using the package \pkg{xkeyval}. The following
 % commands provide the option \verb|documentfont|.
 %    \begin{macrocode}
-\newif\iffontspecoptionswarning
-\fontspecoptionswarningfalse
-\newif\iffontpreservation
-\newif\ifnocharis
-\fontpreservationfalse
+\newif\ifcharissil
+\newif\ifpreservefont
+\newif\ifdocumentfont
+\newif\iffontoptions
+\newif\ifnontipaignore
+\charissiltrue
+\documentfontfalse
 \let\tipauni@font@options\@empty
-\DeclareOptionX{preservefont}{%
-  \fontpreservationtrue
-  \fontspecoptionswarningfalse
+\DeclareOptionX{preservefont}{% 
+  \documentfontfalse
+  \charissilfalse
+  \preservefonttrue
 }
 \DeclareOptionX{fontspecoptions}{%
   \edef\tipauni@font@options{#1}%
-  \ifx\tipauni@font@options\@empty
-    \fontspecoptionswarningfalse
-  \else
-    \iffontpreservation
-      \fontspecoptionswarningtrue
-    \else
-      \fontspecoptionswarningfalse
-    \fi
-  \fi
+  \fontoptionstrue
 }
 \DeclareOptionX{resetfontspecoptions}{%
   \let\tipauni@font@options\@empty
-  \fontspecoptionswarningfalse
+  \fontoptionsfalse
+  \preservefontfalse
 }
 \DeclareOptionX{documentfont}{%
-  \fontspecoptionswarningfalse
-  \nocharistrue
-  \fontpreservationfalse
-  \edef\tipauni@font{#1}
-  \ifx\tipauni@font\@empty
-    \PackageError{tipauni}%
-    {The `documentfont' option has an empty value}%
-    {Please specify a valid font-name for the `documentfont' option.}
-    \nocharisfalse
+  \def\tipauni@temp{#1}
+  \ifx\tipauni@temp\@empty
+    \PackageWarningNoLine{tipauni}{%
+      The `documentfont' option has an empty value. Please\MessageBreak
+      specify a valid font-name to the `documentfont'\MessageBreak
+      option. Right now loading the default font of the\MessageBreak
+      tipauni package. i.e. Charis SIL%
+    }%
+    \documentfontfalse
   \else
-    \nocharistrue
+    \edef\tipauni@font{#1}
+    \documentfonttrue
+    \charissilfalse
   \fi
 }
-\newif\ifnontipaignore
 \DeclareOptionX{incompatible}{\nontipaignoretrue}
 \ProcessOptionsX\relax
-\iffontspecoptionswarning
-  \PackageWarningNoLine{tipauni}%
-  {%
-    Either you haven't loaded the `documentfont' option\MessageBreak
-    or the `preservefont' option has cleared the value\MessageBreak
-    of the `documentfont' loaded prior to it. An active\MessageBreak
-    `documentfont' is necessary for `fontspecoptions'\MessageBreak
-    to take effect. Please use a documentfont or remove\MessageBreak
-    the `preservefont' option loaded after it. Currently\MessageBreak
-    the ignored fontpsec-options are:\MessageBreak
-    \tipauni@font@options
-   }
-\fi
-\iffontpreservation
+\ifcharissil
+  \def\tipauni@font{CharisSIL}%% https://ctan.org/pkg/charissil
 \else
-  \ifnocharis
+  \ifdocumentfont
   \else
-    \def\tipauni@font{CharisSIL}%% https://ctan.org/pkg/charissil
+    \iffontoptions
+      \PackageWarningNoLine{tipauni}{%
+        The `preservefont' option has made the `documentfont'\MessageBreak
+        option or the default Charis SIL font ineffective.\MessageBreak
+        An active font loaded with package fontspec is\MessageBreak
+        necessary for `fontspecoptions' to take effect.\MessageBreak
+        Please use the documentfont option or remove the\MessageBreak
+        `preservefont' option to make `fontpecoptions'\MessageBreak
+        effective. Currently the ignored fontpsec option(s)\MessageBreak
+        is (are) as follows:\MessageBreak
+        \tipauni@font@options
+      }%
+    \fi
   \fi
-  \expandafter\setmainfont\expandafter
-  [\expandafter{\tipauni@font@options}]%
-  {\tipauni@font}
 \fi
+\ifpreservefont
+\else
+  \expandafter\setmainfont\expandafter[\expandafter{\tipauni@font@options}]{\tipauni@font}
+\fi
+% \ifx\tipauni@font@options\@empty
+%   \fontspecoptionswarningfalse
+% \else
+%   \iffontpreservation
+%     \fontspecoptionswarningtrue
+%   \else
+%     \fontspecoptionswarningfalse
+%   \fi
+% \fi
 %    \end{macrocode}
 % The following commands were kindly suggested by Phelype Oleinik for developing
 % a conditional which is always global.
-- 
2.20.1

