निरंजन
I must be missing something trivial, but I am not able to expand the `\fontspec` macro inside `\AddToHook`. How to escape this issue?
```
\begin{filecontents}[overwrite]{duck.cls}
\ProvidesClass{duck}
\LoadClass{article}
\RequirePackage{expkv-def,expkv-opt}
\RequirePackage{fontspec}
\ekvdefinekeys{quack}{%
store duckfont = {\duckfont},%
initial duckfont = {\normalfont}%
}
\AddToHook{begindocument}{%
\fontspec{\duckfont}%
quack%
}
\end{filecontents}
\documentclass[duckfont={KpRoman-Regular.otf}]{duck}
\begin{document}
\end{document}
```
Top Answer
निरंजन
I forgot to process options! The solution was quite easy.
```
\begin{filecontents}[overwrite]{duck.cls}
\ProvidesClass{duck}
\LoadClass{article}
\RequirePackage{expkv-def,expkv-opt}
\RequirePackage{fontspec}
\ekvdefinekeys{quack}{%
store duckfont = {\duckfont},%
initial duckfont = {\normalfont}%
}
\ekvoProcessLocalOptions{quack}
\AddToHook{begindocument}{%
\fontspec{\duckfont}%
quack%
}
\end{filecontents}
\documentclass[duckfont={KpRoman-Regular.otf}]{duck}
\begin{document}
\end{document}
```