निरंजन
I am currently writing a package for writing acronyms in Marathi. [This](https://topanswers.xyz/tex?q=1104) question helped me for developing the macro for building acronyms. I have a further requirement in the package. It is as follows -
1. Add a package option `foo` which will change the font of the acronyms to another.
@JouleV's solution is as follows.
```
\ProvidesPackage{test}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{fontspec}
\RequirePackage{pgfkeys}
\pgfkeys{
test/.is family,test/.cd,
foo/.code={\setfontfamily\test@acronymfont[Script=Devanagari,Mapping=devanagarinumerals]{#1}},
foo/.value required,
foo=Mukta
}
\def\test@setkey#1{\pgfkeys{test/.cd,#1}}
\DeclareOption*{\expandafter\test@setkey\expandafter{\CurrentOption}}
\ProcessOptions
\RequirePackage[acronym]{glossaries}
\newcommand{\newacro}[2]{%
\newacronym{#1}{\test@acronymfont#1}{#2}%
\expandafter\newcommand\csname#1\endcsname{\acrshort{#1}}%
}%
\makeglossaries
\newacro{abc}{abcd}
\providecommand{\listofacros}{%
\printglossary[type=\acronymtype,title={foobar}]%
}
```
I tested the following MWE with the above package -
```
\documentclass{book}
\usepackage{fontspec}
\setmainfont{CharisSIL} % Replace with a font that you have
\usepackage[foo=Minion]{test} % Also here
\newacro{ab}{Abcd}
\newacro{wx}{Wxyz}
\begin{document}
test.\ab
test.\wx
\end{document}
```
Apparently the is changed for all the text after the use of first acronym. I want to change only the font for acronyms and not for other text. I tried embracing the use of font on line 16 in the braces, but it didn't work.
```#16
\newacronym{#1}{{\test@acronymfont#1}}{#2}%
```
Also I tried embracing the font definition on line 7 like this -
```#7
foo/.code={{\setfontfamily\test@acronymfont[Script=Devanagari,Mapping=devanagarinumerals]{#1}}},
```
This too did not work. Font is changed after the acronym.