Closed niruvt closed 2 months ago
I'm not sure there is anything specific to unicode-math
, it is a general feature of most key-value parsers that they do not expand while parsing the keyval list. you would see the same with \includegraphics
for example.
You could use
\expanded{
\noexpand\setmainfont[%
\ifmyexpext
Extension = {.\myext}%
\fi
]{KpRoman-Regular}
}
Oh, okay. I didn't know this. I started with fontspec
and it worked there, so it set an unfair expectation :P Thanks for the solution. I will close this, but a side question: would it be safer to use \expanded
for just \ifmyexpext
and \fi
? Can there be parts in this list which should not be expanded as a rule?
Can there be parts in this list which should not be expanded as a rule?
well of course that's the tricky part to answer. In general "it depends" which is why the generic parsers try to avoid expanding anything. But actually here since all (almost all?) the keys and their values end up being strings passed to the font machinery it's probably safe enough to expand everything.
Okay thanks for the clarification, there are more keys too in the actual use-case, I showed a minimal example in this issue. I will better go with the safer method of expanding only the desired macros since this is going to be a public release.
Description
Conditionals inside font-options work only when empty.
Add info or delete as appropriate:
Minimal example demonstrating the issue
Further details
The MWE fails if the conditionals are uncommented. It works in
fontspec
as demonstrated. Strangely they don't produce any errors if there is no content inside.