latex3 / fontspec

Font selection in LaTeX for XeTeX and LuaTeX
http://latex3.github.io/fontspec/
LaTeX Project Public License v1.3c
276 stars 33 forks source link

Def of \EncodingCommand needs one more optional argument #383

Closed muzimuzhi closed 4 years ago

muzimuzhi commented 5 years ago

Description

Definition of \EncodingCommand misses one optional argument, hence does not match the doc and underlying \DeclareTextCommand.

Check/indicate

Further details

\EncodingCommand is documented as having two optional arguments, see https://github.com/wspr/fontspec/blob/c1fdf6d52c75017656c4d99ca5b4711353da125d/fontspec-doc-enc.tex#L189 But this command is defined as accepting only one optional argument, see https://github.com/wspr/fontspec/blob/c1fdf6d52c75017656c4d99ca5b4711353da125d/fontspec-code-enc.dtx#L28-L33

Since the underlying \DeclareTextCommand accepts two optional arguments, \EncodingCommand should accept two optional, too. https://github.com/wspr/fontspec/blob/c1fdf6d52c75017656c4d99ca5b4711353da125d/fontspec-doc-enc.tex#L178

Possible solution

Changing the definition of \EncodingCommand to the following will do the work.

\DeclareDocumentCommand \EncodingCommand { m O{} O{} m }
  {
    \bool_if:NF \l_@@_defining_encoding_bool
      { \@@_error:nn {only-inside-encdef} \EncodingCommand }
    \DeclareTextCommand{#1}{\UnicodeEncodingName}[#2][#3]{#4}
  }
muzimuzhi commented 4 years ago

fixed in https://github.com/wspr/fontspec/commit/72a8b67d685756c4830c13a208fe129a242814de