add tag
निरंजन
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}
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.