summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fontspec
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/fontspec
Initial commit
Diffstat (limited to 'macros/latex/contrib/fontspec')
-rw-r--r--macros/latex/contrib/fontspec/CHANGES.md429
-rw-r--r--macros/latex/contrib/fontspec/LICENSE416
-rw-r--r--macros/latex/contrib/fontspec/README.md83
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-api.dtx390
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-closing.dtx44
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-enc.dtx173
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-feat-aat.dtx242
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-feat-opentype.dtx582
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-fontload.dtx136
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-graphite.dtx128
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-interfaces.dtx296
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-internal.dtx1196
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-keyval.dtx903
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-lang.dtx419
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-load.dtx72
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-math.dtx260
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-msg.dtx285
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-opening.dtx213
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-opentype.dtx478
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-patches.dtx182
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-scripts.dtx184
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-user.dtx540
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-vars.dtx332
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code-xfss.dtx290
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code.ltx42
-rw-r--r--macros/latex/contrib/fontspec/fontspec-code.pdfbin0 -> 637164 bytes
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-api.tex344
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-enc.tex216
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-featset.tex622
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-fontsel.tex639
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-intro.tex247
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-luatex.tex94
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-opentype.tex1476
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-style.sty290
-rw-r--r--macros/latex/contrib/fontspec/fontspec-doc-xetex.tex380
-rw-r--r--macros/latex/contrib/fontspec/fontspec-example.tex48
-rw-r--r--macros/latex/contrib/fontspec/fontspec-lua.dtx101
-rw-r--r--macros/latex/contrib/fontspec/fontspec.cfg22
-rw-r--r--macros/latex/contrib/fontspec/fontspec.dtx117
-rw-r--r--macros/latex/contrib/fontspec/fontspec.ins60
-rw-r--r--macros/latex/contrib/fontspec/fontspec.ltx40
-rw-r--r--macros/latex/contrib/fontspec/fontspec.pdfbin0 -> 690085 bytes
42 files changed, 13011 insertions, 0 deletions
diff --git a/macros/latex/contrib/fontspec/CHANGES.md b/macros/latex/contrib/fontspec/CHANGES.md
new file mode 100644
index 0000000000..4fc699d0be
--- /dev/null
+++ b/macros/latex/contrib/fontspec/CHANGES.md
@@ -0,0 +1,429 @@
+Change history
+==============
+
+## v2.7c (2019/03/15)
+
+ * Two optimisations reduce time for font definitions with a large number of
+ `FontFace` options. Thanks to Bob Tennent for the test file and bringing
+ the problem to my attention.
+
+
+## v2.7b (2019/02/12)
+
+ * Fix regression in loading `Language=Turkish`. This now allows users to define more
+ than one OpenType tag when defining a language name, where the first tag found is
+ the one selected for the font. E.g.,
+
+ \newfontlanguage{Turkish}{TRK,TUR}
+
+ when selected, this first checks for the existance of the TRK language tag, and if
+ not found then checks for the TUR language tag to use if available.
+
+ * Add new `Renderer` options for LuaTeX that enable the Harfbuzz engine. These only
+ work running under `luahbtex` and are currently experimental. The new options are
+ `Harfbuzz`, `OpenType`, `AAT`, and `Graphite`.
+
+ * Always try to remove ‘clashing’ font features inside `\addfontfeatures` even in
+ cases when the requested font feature doesn't exist. E.g., now if a font is loaded
+ with `Numbers=OldStyle` and *doesn't have* `Numbers=Lining`, requesting the latter
+ will still reset the former.
+
+ * Add `pxfonts`, `txfonts`, `newpxmath`, `newtxmath`, `mtpro2` to the list
+ of packages that automatically invoke `no-math`.
+
+ * Add `\providefontfamily`, `\setfontface`, `\renewfontface`, and `\providefontface`.
+
+ * Add local/global distinction with `\fontspec_(g)set_family:Nnn` and `\fontspec_(g)set_fontface:NNnn`.
+
+
+## v2.7a (2019/01/25)
+
+ * One last (?!) fix for recent regression (!!). I am not getting enough sleep at the moment and it is too hot.
+ * Add `LocalForms=On/Off/Reset` to control the `locl` OpenType tag.
+ * Reorganise some documentation.
+ * Remove redundant redefinition of `\-` which is nowadays defined correctly by the LaTeX2e kernel.
+ * Add code to remove the patching of verbatim commands and environments when the new
+ `\verbvisiblespace` command is defined in a future version of LaTeX2e.
+
+
+## v2.7 (2019/01/24)
+
+ * Add new `ScaleAgain` feature for compounding scale factors.
+ (This is largely to support `unicode-math` but may be useful by others.)
+ * `\oldstylenums` no longer overwritten if `textcomp` loaded after `fontspec`.
+ * More fixes for recent regressions (sorry!).
+
+
+## v2.6l (2019/01/18)
+
+ * REALLY fix crash when loading fonts that are missing a requested script.
+ * Lots of internal logic changes for what should have been an easy fix :(
+
+
+## v2.6k (2019/01/16)
+
+ * Fix crash when loading fonts that are missing a requested script.
+
+
+## v2.6j (2019/01/10)
+
+ * Re-sync with `expl3` for deprecated commands.
+ * Added support for `\hbar` if anyone is relying on `fontspec` to emulate legacy maths.
+
+
+## v2.6i (2018/08/02)
+
+ * Emergency bug-fix -- a one-char typo broke loading of bold fonts!
+ * Some minor updates to the docs regarding “family names” of fonts.
+ * Using `\defaultfontfeatures` to specify a font face by a custom name can now use
+ `Font=` to specify the filename.
+
+
+## v2.6h (2018/07/30)
+
+ * `expl3` internals updated so loading `expl3` with the `check-declarations` option will run without error.
+ * Fix bug with `FontFace` in which spaces weren't being ignored.
+
+
+## v2.6g (2017-11-09)
+
+ * Bugfix for clash introduced with last version. When loading `babel`
+ before `fontspec` the following error arose:
+
+ ! Control sequence \latinencoding already defined.
+
+
+## v2.6f (2017-11-05)
+
+ * Fix loading of Graphite fonts and add a little documentation (a better interface is needed, though)
+ * Correct and simplify some internal code that fixes a bug in the way some fonts are displayed in `\tracingoutput` mode.
+ * This also fixes an obscure bug using the API in which a query for a selected font feature
+ would test against the upright font in the current family regardless of the face/shape actually in use.
+ * This package now complies with the `expl3` option `check-declarations`.
+
+
+## v2.6e (2017/09/22)
+
+ * Re-enable use of `HyphenChar=None` in LuaLaTeX. (Hyphenation and font choice are
+ decoupled in LuaTeX, except for this one setting.)
+ * Some internal changes needed by `unicode-math` to fix some cross-over code.
+
+
+## v2.6d (2017/08/14)
+
+ * Update Scripts to Unicode 1.8.2 (thanks Werner)
+ * Remove `HyphenChar` feature when running LuaTeX — use `\prehyphenchar` LuaTeX primitive instead.
+ * Rewrite test suite so that automated testing actually functions correctly and automatically. Thanks to Joseph for introducing me to Travis CI.
+
+
+## v2.6c (2017/07/23)
+
+ * Emergency bug-fix.
+
+
+## v2.6b (2017/07/16)
+
+ * Fix conflict with Polyglossia and `Scale=MatchLowercase`.
+ * New feature `IgnoreFontspecFile` to avoid loading the `.fontspec` file for a font.
+ * Fix regression with `\fontspec_if_feature:nTF`
+ (which broke `realscripts`, oops — must improve my test suite)
+
+
+## v2.6a (2017/03/31)
+
+ * Fix crashing bug with `..Reset` and `ResetAll` keys.
+ * Fix crashing bug with `\newfontface`.
+
+## v2.6 (2017/02/12)
+
+ * Change the new behaviour of `\emph` (and `\emfontdeclare`) to act only on the NFSS font shape; using the series as well was too fragile.
+ * Add `\strong` as the "weight" analogy to `\emph`. This will need some extra syntactic sugar from `fontspec` before it becomes truly useful.
+ * Add `Numbers=Tabular` alias for `Numbers=Monospaced`.
+ * Fix occasional bug with "chained" keyval choices such as `Numbers={Lining,Proportional}` in which only the first choice would be recognised.
+ * Fix interaction with `RawFeature` and "proper" `fontspec` features.
+ * Fix regression in which `C:\...` file paths in Windows couldn't be used.
+ * Fix regression in XeTeX in which `Ligatures=TeX` overrode `Mapping=..` regardless of where the former was declared in the feature list.
+ * Fix bug (sorry!) in `\newopentypefeature`.
+ * Improve monospace font in documentation.
+
+ * N.B. There is currently a known issue with TTC fonts and LuaTeX; currently they cannot be loaded through the `fontspec` interface, but this issue should soon be addressed by the `luaotfload` package.
+
+## v2.5d (2017/01/24) "oops"
+
+ * Add `\fontspec_if_small_caps:TF`
+ * Fix bug in `\emph` (!!)
+
+## v2.5c (2017/01/20) "Christmas 2016 release"
+
+ * `TU` font encoding now default, with encoding files provided by the kernel.
+ * Experimental interface added for customising encodings.
+ * Add feature `Ornament=`*n* corresponding to OpenType feature `+ornm=`*n*.
+ * Add feature `FontIndex=`*n* to support TrueType Collection (TTC) files.
+ * Nested `\emph` is now much smarter and will cleverly nest even if manual font changes are made.
+ * Tries to resolve situations when font features clash.
+ E.g., `Numbers={Uppercase,Lowercase}` will define only `+onum` rather than the previous behaviour of `+lnum;+onum` to let the engine sort things out. Coverage may still be preliminary.
+ * Add API function `\fontspec_if_current_feature:nTF` for querying selected features based on their OpenType tag.
+ * Add user function `\IfFontFeatureActiveTF` for querying selected features based on their `fontspec` specification.
+ * All "tag-based" OpenType features are now provided in `Feat`/`FeatOff`/`FeatReset` forms to disable and reset them.
+ * `ResetAll` provided for all "tag-based" OpenType feature keys. (E.g., `Ligatures=ResetAll`.)
+ * Big table of OpenType feature tags to help cross-reference which fontspec feature (if any) corresponds to which OpenType feature.
+ * Bug fixed for `Script` selection.
+
+## v2.5b (2016/05/14) "More bugs" (somehow never released)
+
+ * Fixed bug with garbage text printed in certain "verbatim" situations under LuaTeX.
+ * Improve interaction between optical sizes and small caps.
+ * Remove documentation for `FeatureFile`, since this is no longer supported under LuaLaTeX
+ (there are other methods to perform the same thing, but no "easy" user interface that `fontspec` can provide at this stage).
+ * Fix regression causing an error message if `fontspec` loaded before `\documentclass'.
+
+## v2.5a (2016/02/01) "Bugs fixed"
+
+ * Rather embarrassing bug fix! (`unicode-math` was broken.)
+ * Remember to add the `fontspec.cfg` file to the distribution.
+ * Remove `+trep` from `Ligatures=TeX` (no longer necessary).
+ * Add some basic tests using `l3build`; more to come.
+ * Simplify some internal Lua code and package loading code.
+
+## v2.5 (2016/01/30) "TL2016 release"
+
+ * Provide a new Unicode font encoding ("TU") to replace EU1/EU2 and xunicode.
+ * Activate with package option `[tuenc]'; once it becomes the default (later this year), `[euenc]` option will revert to the old behaviour.
+ * New command `\emfontdeclare` for defining font shapes when arbitrarily nesting the `\emph` command.
+ * Allow slanted small caps and better internal methods for "combining" font shapes; this fixes a few bugs.
+ * Incorporate "new" font script tags for Indic fonts. E.g., when selecting `Script=Bengali`, fontspec will first query the font for the `bng2` OpenType script, and if not found select `beng`.
+ * Restrict some font features from being able to be used within `\addfontfeatures` that were causing some font-loading confusion.
+ * Fixed behaviour in which `\baselineskip` and `\f@size` would (possibly) change values after loading the packge.
+ * Remove copy of `fixltx2e`'s code for footnote symbols; handled by LaTeX2e now.
+ * Deprecate `ExternalLocation` for the simpler (and identical) `Path` option.
+ * Improvement to some warnings/info messages.
+ * Improve structure of code.
+
+## v2.4e (2015/09/24)
+
+ * Allow `[Path=...]` to be specified for individual font faces.
+ * Continue to normalise naming with expl3. (Ongoing.)
+
+## v2.4d (2015/07/22)
+
+ * Rename an internal expl3 function or two.
+
+## v2.4c (2015/03/14)
+
+ * v2.4b was never released, sorry!
+ * This time *really* fix `\@fnsymbol` and avoid overwriting it if already fixed.
+ * Fix "`Renderer=Graphite`" (off-by-one error).
+ * Fix some edge cases for `\aliasfontfeature`.
+
+## v2.4b (2014/08/23)
+
+ * Improve backwards compatibility w.r.t. recent argument order change;
+ specifically, if an optional argument is presented before the font name
+ then avoid looking for one afterwards.
+ * Fix \@fnsymbol; it was defined as a \protected macro, where in fact its internal text-or-math switch needed to be instead.
+ * No longer lowercase fontnames internally; this fixes a bug with loading
+ mixed-case ".fontspec" files.
+ * Fixed some documentation typos/inconsistencies related to recent changes.
+
+## v2.4a (2014/06/21)
+
+ * No longer load fixltx2e.sty -- this package should really be loaded before \documentclass.
+ * Avoid deprecated l3fp code.
+ * A couple of bugs introduced with v2.4 fixed.
+
+## v2.4 (2014/06/01)
+
+ * Significant change to the user interface: instead of `\setmainfont[features]{font}`, you now write `\setmainfont{font}[features]`.
+ Backwards compatibility is of course preserved.
+
+ The reason for this change is to improve the visual comprehension of the font loading syntax with large numbers of font features.
+
+ * Defaults for symbolic font families like this can now be specified with
+
+ \defaultfontfeatures[\rmfamily]{...}
+
+ or
+
+ \defaultfontfeatures[\headingsfont]{...}
+ \newfontfamily\headingsfont{...}
+
+ * New `PunctuationSpace=WordSpace` and `PunctuationSpace=TwiceWordSpace` settings, intended for monospaced fonts; these force the space after a period to be exactly one or two spaces wide, respectively, which preserves character alignment across lines.
+
+ * The features above now allow changes to the default settings:
+
+ * `Ligatures=TeX` is enabled by default with `\setmainfont` and `\setsansfont`.
+ * `WordSpace={1,0,0}` and `PunctuationSpace=WordSpace` are now enabled by default for `\setmonofont` to produce better monospaced results.
+ * (These can be adjusted by created your own `fontspec.cfg` file.)
+
+ * `SizeFeatures` can now be nested inside `ItalicFeatures` (etc.) and behaves correctly. This has been a very long overdue bug!
+
+ * New feature `NFSSFamily=ABC` to set the NFSS family of a font to “`ABC`”. Useful
+ when other packages use the `\fontfamily{ABC}\selectfont` interface.
+
+ * New feature `FontFace = {series}{shape}{font}` allows a font face to be loaded with a specific NFSS font series and font shape.
+ A more verbose syntax allows arbitrary font features as well (and this also plays nicely with `SizeFeatures`):
+
+ \fontspec{myfont.otf}[
+ FontFace = {b}{ui}{Font = myfont-bui.otf, <features>} ,
+ ]
+
+ The code above, for example, will allow a bold upright italic font to be selected using the standard NFSS interface: `\fontseries{b}\fontshape{ui}\selectfont`.
+
+ * `\defaultfontfeatures+` (note the `+`) can now be used to append to the default font feature set.
+
+ * Setting the `SmallCapsFont` using the `*`-replacement notation has been improved/fixed.
+
+## v2.3c (2013/05/20)
+
+ * Compatbility with luaotfload 2013/05/20 2.2c, support for older version
+ removed.
+
+## v2.3b (2013/05/12)
+
+ * Compatibility with new (and future) version of luaotfload
+
+## v2.3a (2013/03/16)
+
+ * Bug fix update to retain compatibility with new expl3
+
+## v2.3 (2013/02/25)
+
+ * Add support for per-font options in `\defaultfontfeatures`
+ * Add support for `<fontname>.fontspec` per-font configuration files
+ * Keep up-to-date with expl3 changes
+
+## v2.2b (2012/05/06) "TL2012 version"
+
+ * Fix error with AutoFakeSlant/Bold (#113) and when used with external fonts (#128)
+ * Add warning when using FakeBold in LuaLaTeX, where it's not supported
+ * Fix slshape misassignment introduced in v2.2
+ * Allow fontspec to be loaded before \documentclass
+ (or rather fix the regression that broke this)
+ * Avoid using the calc package now that it's no longer loaded by expl3
+ * Allow multiple values to StylisticSet and Alternate font options
+
+## v2.2a (2011/09/14)
+
+ * Bug fix: improve backwards compatibility for packages that use old
+ fontspec internals such as mathspec.
+
+## v2.2 (2011/09/13)
+
+ * Support alternate selections in CharacterVariant (cvxx in OpenType)
+ using new syntax `[CharacterVariant=5:2]`.
+ * Add `fontspec`-compatible `\oldstylenums` and `\liningnums` commands.
+ * New programmer's function `\fontspec_set_fontface:NNnn` (for use when
+ `\zf@basefont` might previously have been queried).
+ * Log file output is slightly tidier.
+ * Some old lingering bugs squashed:
+ - Small caps font selection was broken in some cases.
+ (Thanks Enrico Gregorio.)
+ - Fonts loaded by filename with under-specified shapes threw an error
+ (e.g., asking explicitly for bold but not italic).
+ (Thanks Vafa Khalighi.)
+ * Documentation improvements largely due to Markus Böhning.
+ * Many internal changes, among which:
+ - `xkeyval` package no longer used for option processing;
+ `expl3`'s `l3keys` used instead.
+ This allows `fontspec` to be loaded before `\documentclass`
+ (thanks Heiko Oberdiek for reporting the issue)
+ and fixes a potential conflict with the `preview` package
+ (thanks again Vafa).
+ - Internal names changed; avoid "\zf@basefont", "\zf@family", etc.
+ from now on -- there are public interfaces now to get access to the
+ same information
+ - Update `expl3` support to latest CTAN version.
+
+## v2.1g (2011/08/02)
+
+ * No longer uses the binhex package, avoiding some name clashes with TIPA
+
+## v2.1f (2011/02/26)
+
+ * Finally add a real error message when a font cannot be found!
+ * Add "Letters=Random" feature.
+ * Fix bug in which "Unknown feature `'..." warnings
+ were shown in the log file.
+ * Some small documentation improvements.
+
+## v2.1e (2010/11/17)
+
+ * Internal changes for luatexbase v0.3.
+
+## v2.1d (2010/11/07)
+
+ * Bug fix when \itdefault is "sl" rather than "it".
+ E.g., when using the "slides" class.
+ * Minor internal changes, including merging some code from unicode-math.
+
+## v2.1c (2010/10/13)
+
+ * New documentation for defining custom kerning and ligatures
+ when using LuaLaTeX.
+ * Fix bug when defining bold italic fonts by filename.
+ * Avoid infinite loop when the Latin script is requested for a font
+ that does not contain it. TODO: a suitable fallback script should be
+ chosen; right now we just ignore the script selection.
+
+## v2.1b (2010/09/29)
+
+ * Fix for bug introduced in the last release:
+ small caps weren't being automatically selected correctly
+
+## v2.1a (2010/09/27)
+
+ * Fix for colours bug introduced in the last update
+ * Fix for for bad interaction with LuaLaTeX and fallback fonts
+ (such as using \slshape when no slanted font specified)
+ * Behaviour/messaging improvement when scripts/languages are requested
+ that do not exist in the font
+ * Fix bug with detecting font features/scripts in some cases with:
+
+ - `\fontspec_if_feature:n(TF)`
+ - `\fontspec_if_language:n(TF)`
+ - `\fontspec_if_current_script:n(TF)`
+ - `\fontspec_if_current_language:n(TF)`
+
+ * Some messages in the log file are improved
+ * Code for "visible space" fixed for LuaLaTeX use
+ * Lots of internal changes to bring the implementation closer
+ to being "native expl3".
+
+## v2.1 (2010/09/19)
+
+ * Now load xunicode internally for consistent behaviour in
+ XeLaTeX and LuaLaTeX.
+ * Font commands now include \fontencoding internally, easing their
+ use together with legacy TeX fonts.
+ * Colour & Opacity now behave a little better.
+ * Nested emphasis with \emph now also occurs inside a "slanted" shape.
+ * Some compatibility commands/options added that were removed.
+ in the transition to v2.
+ * Bug fix for a problem triggered after counters got too high.
+
+## v2.0c (2010/08/01)
+ Bug fix and documentation tune-up.
+
+ * Significant bug fix reported simultaneously by Enrico Gregorio and
+ Don Hosek.
+ * Many documentation improvements and additions due to David Perry.
+ * Documentation typo thanks to John McChesney-Young
+
+## v2.0b (2010/07/14)
+ *Actually* the final release before TeX Live 2010.
+
+ * Improved examples in the documentation, with fewer proprietary fonts
+ * All font examples are included as separate images on CTAN, so the
+ manual can be compiled (with pdfLaTeX) by anyone, anywhere
+ * LuaLaTeX fixes for the StylisticSet and Annotation features
+ * New OpenType feature `CharacterVariant` now supported
+ * Minor change: `Ligatures=Historical` is now `Ligatures=Historic` for consistency
+
+## v2.0a (2010/07/11)
+ Final release before TeX Live 2010.
+
+ * Bug fix for the Language setting being ignored
+ * Add programmer's command `\fontspec_glyph_if_exist:NnTF`
+ * Many documentation improvements, especially for LuaTeX features
+ `FeatureFile=...` and `Numbers=Arabic`.
+ * Add `Parsi` and `Persian` synonyms for `Language=Farsi`
diff --git a/macros/latex/contrib/fontspec/LICENSE b/macros/latex/contrib/fontspec/LICENSE
new file mode 100644
index 0000000000..2244313901
--- /dev/null
+++ b/macros/latex/contrib/fontspec/LICENSE
@@ -0,0 +1,416 @@
+The LaTeX Project Public License
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+LPPL Version 1.3c 2008-05-04
+
+Copyright 1999 2002-2008 LaTeX3 Project
+ Everyone is allowed to distribute verbatim copies of this
+ license document, but modification of it is not allowed.
+
+
+PREAMBLE
+========
+
+The LaTeX Project Public License (LPPL) is the primary license under
+which the LaTeX kernel and the base LaTeX packages are distributed.
+
+You may use this license for any work of which you hold the copyright
+and which you wish to distribute. This license may be particularly
+suitable if your work is TeX-related (such as a LaTeX package), but
+it is written in such a way that you can use it even if your work is
+unrelated to TeX.
+
+The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE',
+below, gives instructions, examples, and recommendations for authors
+who are considering distributing their works under this license.
+
+This license gives conditions under which a work may be distributed
+and modified, as well as conditions under which modified versions of
+that work may be distributed.
+
+We, the LaTeX3 Project, believe that the conditions below give you
+the freedom to make and distribute modified versions of your work
+that conform with whatever technical specifications you wish while
+maintaining the availability, integrity, and reliability of
+that work. If you do not see how to achieve your goal while
+meeting these conditions, then read the document `cfgguide.tex'
+and `modguide.tex' in the base LaTeX distribution for suggestions.
+
+
+DEFINITIONS
+===========
+
+In this license document the following terms are used:
+
+ `Work'
+ Any work being distributed under this License.
+
+ `Derived Work'
+ Any work that under any applicable law is derived from the Work.
+
+ `Modification'
+ Any procedure that produces a Derived Work under any applicable
+ law -- for example, the production of a file containing an
+ original file associated with the Work or a significant portion of
+ such a file, either verbatim or with modifications and/or
+ translated into another language.
+
+ `Modify'
+ To apply any procedure that produces a Derived Work under any
+ applicable law.
+
+ `Distribution'
+ Making copies of the Work available from one person to another, in
+ whole or in part. Distribution includes (but is not limited to)
+ making any electronic components of the Work accessible by
+ file transfer protocols such as FTP or HTTP or by shared file
+ systems such as Sun's Network File System (NFS).
+
+ `Compiled Work'
+ A version of the Work that has been processed into a form where it
+ is directly usable on a computer system. This processing may
+ include using installation facilities provided by the Work,
+ transformations of the Work, copying of components of the Work, or
+ other activities. Note that modification of any installation
+ facilities provided by the Work constitutes modification of the Work.
+
+ `Current Maintainer'
+ A person or persons nominated as such within the Work. If there is
+ no such explicit nomination then it is the `Copyright Holder' under
+ any applicable law.
+
+ `Base Interpreter'
+ A program or process that is normally needed for running or
+ interpreting a part or the whole of the Work.
+
+ A Base Interpreter may depend on external components but these
+ are not considered part of the Base Interpreter provided that each
+ external component clearly identifies itself whenever it is used
+ interactively. Unless explicitly specified when applying the
+ license to the Work, the only applicable Base Interpreter is a
+ `LaTeX-Format' or in the case of files belonging to the
+ `LaTeX-format' a program implementing the `TeX language'.
+
+
+
+CONDITIONS ON DISTRIBUTION AND MODIFICATION
+===========================================
+
+1. Activities other than distribution and/or modification of the Work
+are not covered by this license; they are outside its scope. In
+particular, the act of running the Work is not restricted and no
+requirements are made concerning any offers of support for the Work.
+
+2. You may distribute a complete, unmodified copy of the Work as you
+received it. Distribution of only part of the Work is considered
+modification of the Work, and no right to distribute such a Derived
+Work may be assumed under the terms of this clause.
+
+3. You may distribute a Compiled Work that has been generated from a
+complete, unmodified copy of the Work as distributed under Clause 2
+above, as long as that Compiled Work is distributed in such a way that
+the recipients may install the Compiled Work on their system exactly
+as it would have been installed if they generated a Compiled Work
+directly from the Work.
+
+4. If you are the Current Maintainer of the Work, you may, without
+restriction, modify the Work, thus creating a Derived Work. You may
+also distribute the Derived Work without restriction, including
+Compiled Works generated from the Derived Work. Derived Works
+distributed in this manner by the Current Maintainer are considered to
+be updated versions of the Work.
+
+5. If you are not the Current Maintainer of the Work, you may modify
+your copy of the Work, thus creating a Derived Work based on the Work,
+and compile this Derived Work, thus creating a Compiled Work based on
+the Derived Work.
+
+6. If you are not the Current Maintainer of the Work, you may
+distribute a Derived Work provided the following conditions are met
+for every component of the Work unless that component clearly states
+in the copyright notice that it is exempt from that condition. Only
+the Current Maintainer is allowed to add such statements of exemption
+to a component of the Work.
+
+ a. If a component of this Derived Work can be a direct replacement
+ for a component of the Work when that component is used with the
+ Base Interpreter, then, wherever this component of the Work
+ identifies itself to the user when used interactively with that
+ Base Interpreter, the replacement component of this Derived Work
+ clearly and unambiguously identifies itself as a modified version
+ of this component to the user when used interactively with that
+ Base Interpreter.
+
+ b. Every component of the Derived Work contains prominent notices
+ detailing the nature of the changes to that component, or a
+ prominent reference to another file that is distributed as part
+ of the Derived Work and that contains a complete and accurate log
+ of the changes.
+
+ c. No information in the Derived Work implies that any persons,
+ including (but not limited to) the authors of the original version
+ of the Work, provide any support, including (but not limited to)
+ the reporting and handling of errors, to recipients of the
+ Derived Work unless those persons have stated explicitly that
+ they do provide such support for the Derived Work.
+
+ d. You distribute at least one of the following with the Derived Work:
+
+ 1. A complete, unmodified copy of the Work;
+ if your distribution of a modified component is made by
+ offering access to copy the modified component from a
+ designated place, then offering equivalent access to copy
+ the Work from the same or some similar place meets this
+ condition, even though third parties are not compelled to
+ copy the Work along with the modified component;
+
+ 2. Information that is sufficient to obtain a complete,
+ unmodified copy of the Work.
+
+7. If you are not the Current Maintainer of the Work, you may
+distribute a Compiled Work generated from a Derived Work, as long as
+the Derived Work is distributed to all recipients of the Compiled
+Work, and as long as the conditions of Clause 6, above, are met with
+regard to the Derived Work.
+
+8. The conditions above are not intended to prohibit, and hence do not
+apply to, the modification, by any method, of any component so that it
+becomes identical to an updated version of that component of the Work as
+it is distributed by the Current Maintainer under Clause 4, above.
+
+9. Distribution of the Work or any Derived Work in an alternative
+format, where the Work or that Derived Work (in whole or in part) is
+then produced by applying some process to that format, does not relax or
+nullify any sections of this license as they pertain to the results of
+applying that process.
+
+10. a. A Derived Work may be distributed under a different license
+ provided that license itself honors the conditions listed in
+ Clause 6 above, in regard to the Work, though it does not have
+ to honor the rest of the conditions in this license.
+
+ b. If a Derived Work is distributed under a different license, that
+ Derived Work must provide sufficient documentation as part of
+ itself to allow each recipient of that Derived Work to honor the
+ restrictions in Clause 6 above, concerning changes from the Work.
+
+11. This license places no restrictions on works that are unrelated to
+the Work, nor does this license place any restrictions on aggregating
+such works with the Work by any means.
+
+12. Nothing in this license is intended to, or may be used to, prevent
+complete compliance by all parties with all applicable laws.
+
+
+NO WARRANTY
+===========
+
+There is no warranty for the Work. Except when otherwise stated in
+writing, the Copyright Holder provides the Work `as is', without
+warranty of any kind, either expressed or implied, including, but not
+limited to, the implied warranties of merchantability and fitness for a
+particular purpose. The entire risk as to the quality and performance
+of the Work is with you. Should the Work prove defective, you assume
+the cost of all necessary servicing, repair, or correction.
+
+In no event unless required by applicable law or agreed to in writing
+will The Copyright Holder, or any author named in the components of the
+Work, or any other party who may distribute and/or modify the Work as
+permitted above, be liable to you for damages, including any general,
+special, incidental or consequential damages arising out of any use of
+the Work or out of inability to use the Work (including, but not limited
+to, loss of data, data being rendered inaccurate, or losses sustained by
+anyone as a result of any failure of the Work to operate with any other
+programs), even if the Copyright Holder or said author or said other
+party has been advised of the possibility of such damages.
+
+
+MAINTENANCE OF THE WORK
+=======================
+
+The Work has the status `author-maintained' if the Copyright Holder
+explicitly and prominently states near the primary copyright notice in
+the Work that the Work can only be maintained by the Copyright Holder
+or simply that it is `author-maintained'.
+
+The Work has the status `maintained' if there is a Current Maintainer
+who has indicated in the Work that they are willing to receive error
+reports for the Work (for example, by supplying a valid e-mail
+address). It is not required for the Current Maintainer to acknowledge
+or act upon these error reports.
+
+The Work changes from status `maintained' to `unmaintained' if there
+is no Current Maintainer, or the person stated to be Current
+Maintainer of the work cannot be reached through the indicated means
+of communication for a period of six months, and there are no other
+significant signs of active maintenance.
+
+You can become the Current Maintainer of the Work by agreement with
+any existing Current Maintainer to take over this role.
+
+If the Work is unmaintained, you can become the Current Maintainer of
+the Work through the following steps:
+
+ 1. Make a reasonable attempt to trace the Current Maintainer (and
+ the Copyright Holder, if the two differ) through the means of
+ an Internet or similar search.
+
+ 2. If this search is successful, then enquire whether the Work
+ is still maintained.
+
+ a. If it is being maintained, then ask the Current Maintainer
+ to update their communication data within one month.
+
+ b. If the search is unsuccessful or no action to resume active
+ maintenance is taken by the Current Maintainer, then announce
+ within the pertinent community your intention to take over
+ maintenance. (If the Work is a LaTeX work, this could be
+ done, for example, by posting to comp.text.tex.)
+
+ 3a. If the Current Maintainer is reachable and agrees to pass
+ maintenance of the Work to you, then this takes effect
+ immediately upon announcement.
+
+ b. If the Current Maintainer is not reachable and the Copyright
+ Holder agrees that maintenance of the Work be passed to you,
+ then this takes effect immediately upon announcement.
+
+ 4. If you make an `intention announcement' as described in 2b. above
+ and after three months your intention is challenged neither by
+ the Current Maintainer nor by the Copyright Holder nor by other
+ people, then you may arrange for the Work to be changed so as
+ to name you as the (new) Current Maintainer.
+
+ 5. If the previously unreachable Current Maintainer becomes
+ reachable once more within three months of a change completed
+ under the terms of 3b) or 4), then that Current Maintainer must
+ become or remain the Current Maintainer upon request provided
+ they then update their communication data within one month.
+
+A change in the Current Maintainer does not, of itself, alter the fact
+that the Work is distributed under the LPPL license.
+
+If you become the Current Maintainer of the Work, you should
+immediately provide, within the Work, a prominent and unambiguous
+statement of your status as Current Maintainer. You should also
+announce your new status to the same pertinent community as
+in 2b) above.
+
+
+WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE
+======================================================
+
+This section contains important instructions, examples, and
+recommendations for authors who are considering distributing their
+works under this license. These authors are addressed as `you' in
+this section.
+
+Choosing This License or Another License
+----------------------------------------
+
+If for any part of your work you want or need to use *distribution*
+conditions that differ significantly from those in this license, then
+do not refer to this license anywhere in your work but, instead,
+distribute your work under a different license. You may use the text
+of this license as a model for your own license, but your license
+should not refer to the LPPL or otherwise give the impression that
+your work is distributed under the LPPL.
+
+The document `modguide.tex' in the base LaTeX distribution explains
+the motivation behind the conditions of this license. It explains,
+for example, why distributing LaTeX under the GNU General Public
+License (GPL) was considered inappropriate. Even if your work is
+unrelated to LaTeX, the discussion in `modguide.tex' may still be
+relevant, and authors intending to distribute their works under any
+license are encouraged to read it.
+
+A Recommendation on Modification Without Distribution
+-----------------------------------------------------
+
+It is wise never to modify a component of the Work, even for your own
+personal use, without also meeting the above conditions for
+distributing the modified component. While you might intend that such
+modifications will never be distributed, often this will happen by
+accident -- you may forget that you have modified that component; or
+it may not occur to you when allowing others to access the modified
+version that you are thus distributing it and violating the conditions
+of this license in ways that could have legal implications and, worse,
+cause problems for the community. It is therefore usually in your
+best interest to keep your copy of the Work identical with the public
+one. Many works provide ways to control the behavior of that work
+without altering any of its licensed components.
+
+How to Use This License
+-----------------------
+
+To use this license, place in each of the components of your work both
+an explicit copyright notice including your name and the year the work
+was authored and/or last substantially modified. Include also a
+statement that the distribution and/or modification of that
+component is constrained by the conditions in this license.
+
+Here is an example of such a notice and statement:
+
+ %% pig.dtx
+ %% Copyright 2005 M. Y. Name
+ %
+ % This work may be distributed and/or modified under the
+ % conditions of the LaTeX Project Public License, either version 1.3
+ % of this license or (at your option) any later version.
+ % The latest version of this license is in
+ % http://www.latex-project.org/lppl.txt
+ % and version 1.3 or later is part of all distributions of LaTeX
+ % version 2005/12/01 or later.
+ %
+ % This work has the LPPL maintenance status `maintained'.
+ %
+ % The Current Maintainer of this work is M. Y. Name.
+ %
+ % This work consists of the files pig.dtx and pig.ins
+ % and the derived file pig.sty.
+
+Given such a notice and statement in a file, the conditions
+given in this license document would apply, with the `Work' referring
+to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being
+generated from `pig.dtx' using `pig.ins'), the `Base Interpreter'
+referring to any `LaTeX-Format', and both `Copyright Holder' and
+`Current Maintainer' referring to the person `M. Y. Name'.
+
+If you do not want the Maintenance section of LPPL to apply to your
+Work, change `maintained' above into `author-maintained'.
+However, we recommend that you use `maintained', as the Maintenance
+section was added in order to ensure that your Work remains useful to
+the community even when you can no longer maintain and support it
+yourself.
+
+Derived Works That Are Not Replacements
+---------------------------------------
+
+Several clauses of the LPPL specify means to provide reliability and
+stability for the user community. They therefore concern themselves
+with the case that a Derived Work is intended to be used as a
+(compatible or incompatible) replacement of the original Work. If
+this is not the case (e.g., if a few lines of code are reused for a
+completely different task), then clauses 6b and 6d shall not apply.
+
+
+Important Recommendations
+-------------------------
+
+ Defining What Constitutes the Work
+
+ The LPPL requires that distributions of the Work contain all the
+ files of the Work. It is therefore important that you provide a
+ way for the licensee to determine which files constitute the Work.
+ This could, for example, be achieved by explicitly listing all the
+ files of the Work near the copyright notice of each file or by
+ using a line such as:
+
+ % This work consists of all files listed in manifest.txt.
+
+ in that place. In the absence of an unequivocal list it might be
+ impossible for the licensee to determine what is considered by you
+ to comprise the Work and, in such a case, the licensee would be
+ entitled to make reasonable conjectures as to which files comprise
+ the Work.
+
diff --git a/macros/latex/contrib/fontspec/README.md b/macros/latex/contrib/fontspec/README.md
new file mode 100644
index 0000000000..cd01b539d8
--- /dev/null
+++ b/macros/latex/contrib/fontspec/README.md
@@ -0,0 +1,83 @@
+The FONTSPEC package
+====================
+
+The `fontspec` package provides an automatic and unified interface for loading
+fonts in LaTeX. XeTeX and LuaTeX (the latter through the `luaotfload` package)
+allows a direct interface to fonts which may be loaded by their name or filename,
+so no manual font installation is required.
+
+This package also provides access to the large number of font features
+available with OpenType (and other) fonts, including upper and lower case numbers,
+proportional and monospaced numbers, swash letters, ligature control, and many
+many others.
+
+See the documentation `fontspec.pdf` for full information.
+
+
+Summary of user commands
+------------------------
+
+To define commands for selecting fonts efficiently through a document:
+
+ \newfontfamily\<font switch>{<font name>}[<font options>]
+ \newfontface \<font switch>{<font name>}[<font options>]
+
+To select the default document fonts:
+
+ \setmainfont{<font name>}[<font options>]
+ \setsansfont{<font name>}[<font options>]
+ \setmonofont{<font name>}[<font options>]
+
+To define an ad hoc font family individually:
+
+ \fontspec{<font name>}[<font options>]
+
+To specify features to be used for every subsequently defined font:
+
+ \defaultfontfeatures{<default font options>}
+ \defaultfontfeatures+{<add to default font options>}
+
+To specify features to be used for specific fonts:
+
+ \defaultfontfeatures[<font name or switch>]{<default font options>}
+ \defaultfontfeatures+[<font name or switch>]{<add to defaults>}
+
+To add features to the font family currently in use:
+
+ \addfontfeatures{<font options to add>}
+
+
+Package details
+---------------
+
+Release versions of fontspec are available from CTAN:
+ <http://www.ctan.org/pkg/fontspec>
+
+Development and historical versions are available from Github:
+ <http://github.com/wspr/fontspec>
+
+Please offer suggestions and file bug reports in the issue tracker:
+ <http://github.com/wspr/fontspec/issues>
+
+If you are running TeX Live, you can update to the latest version of this package by running
+
+ tlmgr install fontspec
+
+If you wish to manually download the latest release version from CTAN, get the pre-built TDS package and extract it into your local texmf tree:
+
+ http://mirror.ctan.org/install/macros/latex/contrib/fontspec.tds.zip
+
+If you wish to use the latest development version from Github, either use git to obtain the bleeding edge version with
+
+ git clone git://github.com/wspr/fontspec.git
+
+(For bleeding edge versions, see the `working` branch.)
+Having obtained the package from Github, install the package code by running
+
+ texlua build.lua install
+
+This will compile the documentation and install all necessary files in your
+local texmf tree. Depending how your TeX distribution is configured
+you may then need to update the filename database with `texhash`.
+
+
diff --git a/macros/latex/contrib/fontspec/fontspec-code-api.dtx b/macros/latex/contrib/fontspec/fontspec-code-api.dtx
new file mode 100644
index 0000000000..09340f273f
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-api.dtx
@@ -0,0 +1,390 @@
+%%^^A%% fontspec-code-api.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Programmer's interface}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+%
+%
+% These functions are not used directly by fontspec when defining fonts;
+% they are designed to be used by other packages who wish to do font-related
+% things on top of fontspec itself.
+%
+% Because I haven't fully explored how these functions will behave in
+% practise, I am not giving them user-level names. As it becomes more clear
+% which of these should be accessible by document writers, I'll open them up
+% a little more.
+%
+% All functions are defined assuming that the font to be queried is
+% currently selected as a fontspec font. (I.e., via \verb|\fontspec| or
+% from a \verb|\newfontfamily| macro or from \verb|\setmainfont| and so on.)
+%
+% \begin{macro}{\fontspec_if_fontspec_font:TF}
+% Test whether the currently selected font has been loaded by fontspec.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_fontspec_font: {TF,T,F}
+ {
+ \cs_if_exist:cTF {g_@@_fontinfo_ \f@family _prop} \prg_return_true: \prg_return_false:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fontspec_if_aat_feature:nnTF}
+% Conditional to test if the currently selected font contains the \AAT\
+% feature (|#1|,|#2|).
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_aat_feature:nn {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_atsui_bool
+ {
+ \@@_make_AAT_feature_string:NnnTF \font {#1} {#2}
+ \prg_return_true: \prg_return_false:
+ }
+ {
+ \prg_return_false:
+ }
+ }
+ {
+ \prg_return_false:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fontspec_if_opentype:TF}
+% Test whether the currently selected font is an OpenType font.
+% Always true for LuaTeX fonts.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_opentype: {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool \prg_return_true: \prg_return_false:
+ }
+ {
+ \prg_return_false:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_feature:nTF}
+% Test whether the currently selected font contains the raw OpenType
+% feature |#1|. E.g.: |\fontspec_if_feature:nTF {pnum} {True} {False}|
+% Returns false if the font is not loaded by fontspec or is not an OpenType
+% font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_feature:n {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {script-num} \l_@@_tmp_tl
+ \int_set:Nn \l_@@_script_int {\l_@@_tmp_tl}
+
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {lang-num} \l_@@_tmp_tl
+ \int_set:Nn \l_@@_language_int {\l_@@_tmp_tl}
+
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {script-tag} \l_@@_script_tl
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {lang-tag} \l_@@_lang_tl
+
+ \@@_check_ot_feat:NnTF \font {#1} {\prg_return_true:} {\prg_return_false:}
+ }
+ {
+ \prg_return_false:
+ }
+ }
+ {
+ \prg_return_false:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_feature:nnnTF}
+% Test whether the currently selected font with raw OpenType script tag |#1| and
+% raw OpenType language tag |#2| contains the raw OpenType feature tag |#3|.
+% E.g.:\\ | \fontspec_if_feature:nTF {latn} {ROM} {pnum} {True} {False}|
+% Returns false if the font is not loaded by fontspec or is not an OpenType
+% font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_feature:nnn {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \@@_check_ot_feat:NnnnTF \font {#3} {#2} {#1} \prg_return_true: \prg_return_false:
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_script:nTF}
+% Test whether the currently selected font contains the raw OpenType
+% script |#1|. E.g.: |\fontspec_if_script:nTF {latn} {True} {False}|
+% Returns false if the font is not loaded by fontspec or is not an OpenType
+% font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_script:n {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \@@_check_script:NnTF \font {#1} \prg_return_true: \prg_return_false:
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_language:nTF}
+% Test whether the currently selected font contains the raw OpenType language
+% tag |#1|. E.g.: |\fontspec_if_language:nTF {ROM} {True} {False}|.
+% Returns false if the font is not loaded by fontspec or is not an OpenType
+% font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_language:n {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {script-num} \l_@@_tmp_tl
+ \int_set:Nn \l_@@_script_int {\l_@@_tmp_tl}
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {script-tag} \l_@@_script_tl
+
+ \@@_check_lang:NnTF \font {#1} \prg_return_true: \prg_return_false:
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_language:nnTF}
+% Test whether the currently selected font contains the raw OpenType language
+% tag |#2| in script |#1|. E.g.: |\fontspec_if_language:nnTF {cyrl} {SRB} {True} {False}|.
+% Returns false if the font is not loaded by fontspec or is not an OpenType
+% font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_language:nn {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \@@_check_lang:NnnTF \font {#2} {#1} \prg_return_true: \prg_return_false:
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fontspec_if_current_script:nTF}
+% Test whether the currently loaded font is using the specified raw
+% OpenType script tag |#1|.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_current_script:n {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {script-tag} \l_@@_tmp_tl
+ \str_if_eq:nVTF {#1} \l_@@_tmp_tl
+ {\prg_return_true:} {\prg_return_false:}
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_current_language:nTF}
+% Test whether the currently loaded font is using the specified raw
+% OpenType language tag |#1|.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_current_language:n {TF,T,F}
+ {
+ \fontspec_if_fontspec_font:TF
+ {
+ \@@_set_font_type:N \font
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {lang-tag} \l_@@_tmp_tl
+ \str_if_eq:nVTF {#1} \l_@@_tmp_tl
+ {\prg_return_true:} {\prg_return_false:}
+ }
+ { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fontspec_set_family:Nnn}
+% \darg{family}
+% \darg{fontspec features}
+% \darg{font name}
+% Defines a new font family from given \meta{features} and \meta{font},
+% and stores the name in the variable \meta{family}.
+% See the standard \pkg{fontspec} user commands for applications of this
+% function.
+%
+% We want to store the actual name of the font family within the \meta{family}
+% variable because the actual \LaTeX\ family name is automatically generated
+% by fontspec and it's easier to keep it that way.
+% \begin{macrocode}
+\cs_new:Nn \@@_tl_new_if_free:N { \tl_if_exist:NF #1 { \tl_new:N #1 } }
+\cs_new:Nn \@@_set_family:NnnN
+ {
+ \tl_set:Nn \l_@@_fontface_cs_tl {\l_fontspec_font} % reset
+ \tl_set:Nn \l_@@_family_label_tl {#1}
+ \@@_select_font_family:nn {#2} {#3}
+ \@@_tl_new_if_free:N #1
+ #4 #1 \l_fontspec_family_tl
+ \tl_set:Nn \l_@@_fontface_cs_tl {\l_fontspec_font} % reset
+ }
+\cs_new:Nn \fontspec_gset_family:Nnn { \@@_set_family:NnnN #1 {#2} {#3} \tl_gset_eq:NN }
+\cs_new:Nn \fontspec_set_family:Nnn { \@@_set_family:NnnN #1 {#2} {#3} \tl_set_eq:NN }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_generate_variant:Nn \fontspec_set_family:Nnn {c}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fontspec_set_fontface:NNnn}
+% TODO: the round-about approach of using \cs{fontname}
+% means that settings such as fontdimens will be lost.
+% (Discovered in unicode-math.) Investigate!
+% \begin{macrocode}
+\tl_new:N \l_@@_fontface_cs_tl
+\tl_set:Nn \l_@@_fontface_cs_tl {\l_fontspec_font}
+\cs_new:Nn \@@_set_fontface:NNnnN
+ {
+ \tl_set:Nn \l_@@_fontface_cs_tl {#1}
+ \tl_set:Nn \l_@@_family_label_tl {#2}
+ \@@_select_font_family:nn {#3} {#4}
+ #5 #2 \l_fontspec_family_tl
+ \tl_set:Nn \l_@@_fontface_cs_tl {\l_fontspec_font} % reset
+ }
+\cs_new:Nn \fontspec_gset_fontface:NNnn { \@@_set_fontface:NNnnN #1 #2 {#3} {#4} \tl_gset_eq:NN }
+\cs_new:Nn \fontspec_set_fontface:NNnn { \@@_set_fontface:NNnnN #1 #2 {#3} {#4} \tl_set_eq:NN }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\fontspec_font_if_exist:n}
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_font_if_exist:n {TF,T,F}
+ {
+ \group_begin:
+ \@@_init:
+ \@@_if_detect_external:nT {#1} { \@@_font_is_file: }
+ \@@_primitive_font_if_exist:nTF { \@@_construct_font_call:nn {#1} {} }
+ { \group_end: \prg_return_true: }
+ { \group_end: \prg_return_false: }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set_eq:NN \IfFontExistsTF \fontspec_font_if_exist:nTF
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\fontspec_if_current_feature:nTF}
+% Test whether the currently loaded font is using the specified raw
+% OpenType feature tag |#1|.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_current_feature:n {TF,T,F}
+ {
+%<debug>\typeout{::~fontspec_if_current_feature:n~{#1}}
+%<debug>\typeout{::::~primitive_font_current_name:~=~\@@_primitive_font_current_name:}
+ \exp_args:Nxx \tl_if_in:nnTF
+ { \@@_primitive_font_current_name: } { \tl_to_str:n {#1} }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_if_small_caps:TF}
+% \begin{macrocode}
+\prg_new_conditional:Nnn \fontspec_if_small_caps: {TF,T,F}
+ {
+ \@@_if_merge_shape:nTF {sc}
+ {
+ \tl_set_eq:Nc \l_@@_smcp_shape_tl { \@@_shape_merge:nn {\f@shape} {sc} }
+ }
+ {
+ \tl_set:Nn \l_@@_smcp_shape_tl {sc}
+ }
+
+ \cs_if_exist:cTF { \f@encoding/\f@family/\f@series/\l_@@_smcp_shape_tl }
+ {
+ \tl_if_eq:ccTF
+ { \f@encoding/\f@family/\f@series/\l_@@_smcp_shape_tl }
+ { \f@encoding/\f@family/\f@series/\updefault }
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-closing.dtx b/macros/latex/contrib/fontspec/fontspec-code-closing.dtx
new file mode 100644
index 0000000000..17fb823eef
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-closing.dtx
@@ -0,0 +1,44 @@
+%%^^A%% fontspec-code-closing.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Closing code}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \subsection{Finishing up}
+% Now we just want to set up loading the \texttt{.cfg} file, if it exists.
+% \begin{macrocode}
+\bool_if:NT \g_@@_cfg_bool
+ {
+ \InputIfFileExists{fontspec.cfg}
+ {}
+ { \typeout{No~ fontspec.cfg~ file~ found;~ no~ configuration~ loaded.} }
+ }
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-enc.dtx b/macros/latex/contrib/fontspec/fontspec-code-enc.dtx
new file mode 100644
index 0000000000..fef5d81549
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-enc.dtx
@@ -0,0 +1,173 @@
+%%^^A%% fontspec-code-enc.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Extended font encodings}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% To be removed after the 2017 release of LaTeX2e:
+% \begin{macrocode}
+\providecommand\UnicodeFontFile[2]{"[#1]:#2"}
+\providecommand\UnicodeFontName[2]{"#1:#2"}
+%<XE>\providecommand\UnicodeFontTeXLigatures{mapping=tex-text;}
+%<LU>\providecommand\UnicodeFontTeXLigatures{+tlig;}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\providecommand\add@unicode@accent[2]{#2\char#1\relax}
+\providecommand\DeclareUnicodeAccent[3]{%
+ \DeclareTextCommand{#1}{#2}{\add@unicode@accent{#3}}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\EncodingCommand}
+% \begin{macrocode}
+\DeclareDocumentCommand \EncodingCommand {mO{}m}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \EncodingCommand }
+ \DeclareTextCommand{#1}{\UnicodeEncodingName}[#2]{#3}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EncodingAccent}
+% \begin{macrocode}
+\DeclareDocumentCommand \EncodingAccent {mm}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \EncodingAccent }
+ \DeclareTextCommand{#1}{\UnicodeEncodingName}{\add@unicode@accent{#2}}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EncodingSymbol}
+% \begin{macrocode}
+\DeclareDocumentCommand \EncodingSymbol {mm}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \EncodingSymbol }
+ \DeclareTextSymbol{#1}{\UnicodeEncodingName}{#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EncodingComposite}
+% \begin{macrocode}
+\DeclareDocumentCommand \EncodingComposite {mmm}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \EncodingComposite }
+ \DeclareTextComposite{#1}{\UnicodeEncodingName}{#2}{#3}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EncodingCompositeCommand}
+% \begin{macrocode}
+\DeclareDocumentCommand \EncodingCompositeCommand {mmm}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \EncodingCompositeCommand }
+ \DeclareTextCompositeCommand{#1}{\UnicodeEncodingName}{#2}{#3}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareUnicodeEncoding}
+% \begin{macrocode}
+\DeclareDocumentCommand \DeclareUnicodeEncoding {mm}
+ {
+ \DeclareFontEncoding{#1}{}{}
+ \DeclareErrorFont{#1}{lmr}{m}{n}{10}
+ \DeclareFontSubstitution{#1}{lmr}{m}{n}
+ \DeclareFontFamily{#1}{lmr}{}
+
+ \DeclareFontShape{#1}{lmr}{m}{n}
+ {<->\UnicodeFontFile{lmroman10-regular}{\UnicodeFontTeXLigatures}}{}
+ \DeclareFontShape{#1}{lmr}{m}{it}
+ {<->\UnicodeFontFile{lmroman10-italic}{\UnicodeFontTeXLigatures}}{}
+ \DeclareFontShape{#1}{lmr}{m}{sc}
+ {<->\UnicodeFontFile{lmromancaps10-regular}{\UnicodeFontTeXLigatures}}{}
+ \DeclareFontShape{#1}{lmr}{bx}{n}
+ {<->\UnicodeFontFile{lmroman10-bold}{\UnicodeFontTeXLigatures}}{}
+ \DeclareFontShape{#1}{lmr}{bx}{it}
+ {<->\UnicodeFontFile{lmroman10-bolditalic}{\UnicodeFontTeXLigatures}}{}
+
+ \tl_set_eq:NN \l_@@_prev_unicode_name_tl \UnicodeEncodingName
+ \tl_set:Nn \UnicodeEncodingName {#1}
+ \bool_set_true:N \l_@@_defining_encoding_bool
+ #2
+ \bool_set_false:N \l_@@_defining_encoding_bool
+ \tl_set_eq:NN \UnicodeEncodingName \l_@@_prev_unicode_name_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\UndeclareSymbol}
+% \begin{macro}{\UndeclareAccent}
+% \begin{macro}{\UndeclareCommand}
+% Synonyms for each other but all included for completeness.
+% \begin{macrocode}
+\DeclareDocumentCommand \UndeclareSymbol {m}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \UndeclareSymbol }
+ \UndeclareTextCommand {#1} {\UnicodeEncodingName}
+ }
+\DeclareDocumentCommand \UndeclareAccent {m}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \UndeclareAccent }
+ \UndeclareTextCommand {#1} {\UnicodeEncodingName}
+ }
+\DeclareDocumentCommand \UndeclareCommand {m}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \UndeclareCommand }
+ \UndeclareTextCommand {#1} {\UnicodeEncodingName}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\UndeclareComposite}
+% \begin{macrocode}
+\DeclareDocumentCommand \UndeclareComposite {mm}
+ {
+ \bool_if:NF \l_@@_defining_encoding_bool
+ { \@@_error:nn {only-inside-encdef} \UndeclareComposite }
+ \cs_undefine:c
+ { \c_backslash_str \UnicodeEncodingName \token_to_str:N #1 - \tl_to_str:n {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-feat-aat.dtx b/macros/latex/contrib/fontspec/fontspec-code-feat-aat.dtx
new file mode 100644
index 0000000000..7fc1e382b7
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-feat-aat.dtx
@@ -0,0 +1,242 @@
+%%^^A%% fontspec-code-feat-aat.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{AAT feature definitions}
+%
+% These are only defined for \XeTeX.
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec&XE>
+% \end{macrocode}
+% \fi
+
+% \subsection{Ligatures}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Ligatures}
+\@@_define_aat_feature:nnnn {Ligatures} {Required} {1} {0}
+\@@_define_aat_feature:nnnn {Ligatures} {NoRequired} {1} {1}
+\@@_define_aat_feature:nnnn {Ligatures} {Common} {1} {2}
+\@@_define_aat_feature:nnnn {Ligatures} {NoCommon} {1} {3}
+\@@_define_aat_feature:nnnn {Ligatures} {Rare} {1} {4}
+\@@_define_aat_feature:nnnn {Ligatures} {NoRare} {1} {5}
+\@@_define_aat_feature:nnnn {Ligatures} {Discretionary} {1} {4}
+\@@_define_aat_feature:nnnn {Ligatures} {NoDiscretionary} {1} {5}
+\@@_define_aat_feature:nnnn {Ligatures} {Logos} {1} {6}
+\@@_define_aat_feature:nnnn {Ligatures} {NoLogos} {1} {7}
+\@@_define_aat_feature:nnnn {Ligatures} {Rebus} {1} {8}
+\@@_define_aat_feature:nnnn {Ligatures} {NoRebus} {1} {9}
+\@@_define_aat_feature:nnnn {Ligatures} {Diphthong} {1} {10}
+\@@_define_aat_feature:nnnn {Ligatures} {NoDiphthong} {1} {11}
+\@@_define_aat_feature:nnnn {Ligatures} {Squared} {1} {12}
+\@@_define_aat_feature:nnnn {Ligatures} {NoSquared} {1} {13}
+\@@_define_aat_feature:nnnn {Ligatures} {AbbrevSquared} {1} {14}
+\@@_define_aat_feature:nnnn {Ligatures} {NoAbbrevSquared} {1} {15}
+\@@_define_aat_feature:nnnn {Ligatures} {Icelandic} {1} {32}
+\@@_define_aat_feature:nnnn {Ligatures} {NoIcelandic} {1} {33}
+% \end{macrocode}
+% Emulate CM extra ligatures.
+% \begin{macrocode}
+\keys_define:nn {fontspec-aat}
+ {
+ Ligatures / TeX .code:n =
+ {
+ \tl_set:Nn \l_@@_mapping_tl { tex-text }
+ }
+ }
+% \end{macrocode}
+%
+% \subsection{Letters}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Letters}
+\@@_define_aat_feature:nnnn {Letters} {Normal} {3} {0}
+\@@_define_aat_feature:nnnn {Letters} {Uppercase} {3} {1}
+\@@_define_aat_feature:nnnn {Letters} {Lowercase} {3} {2}
+\@@_define_aat_feature:nnnn {Letters} {SmallCaps} {3} {3}
+\@@_define_aat_feature:nnnn {Letters} {InitialCaps} {3} {4}
+% \end{macrocode}
+%
+% \subsection{Numbers}
+%
+% These were originally separated into \feat{NumberCase} and
+% \feat{NumberSpacing} following \AAT, but it makes more sense to
+% combine them.
+%
+% Both naming conventions are offered to select the number case.
+%
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Numbers}
+\@@_define_aat_feature:nnnn {Numbers} {Monospaced} {6} {0}
+\@@_define_aat_feature:nnnn {Numbers} {Proportional} {6} {1}
+\@@_define_aat_feature:nnnn {Numbers} {Lowercase} {21} {0}
+\@@_define_aat_feature:nnnn {Numbers} {OldStyle} {21} {0}
+\@@_define_aat_feature:nnnn {Numbers} {Uppercase} {21} {1}
+\@@_define_aat_feature:nnnn {Numbers} {Lining} {21} {1}
+\@@_define_aat_feature:nnnn {Numbers} {SlashedZero} {14} {5}
+\@@_define_aat_feature:nnnn {Numbers} {NoSlashedZero} {14} {4}
+% \end{macrocode}
+%
+% \subsection{Contextuals}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Contextuals}
+\@@_define_aat_feature:nnnn {Contextuals} {WordInitial} {8} {0}
+\@@_define_aat_feature:nnnn {Contextuals} {NoWordInitial} {8} {1}
+\@@_define_aat_feature:nnnn {Contextuals} {WordFinal} {8} {2}
+\@@_define_aat_feature:nnnn {Contextuals} {NoWordFinal} {8} {3}
+\@@_define_aat_feature:nnnn {Contextuals} {LineInitial} {8} {4}
+\@@_define_aat_feature:nnnn {Contextuals} {NoLineInitial} {8} {5}
+\@@_define_aat_feature:nnnn {Contextuals} {LineFinal} {8} {6}
+\@@_define_aat_feature:nnnn {Contextuals} {NoLineFinal} {8} {7}
+\@@_define_aat_feature:nnnn {Contextuals} {Inner} {8} {8}
+\@@_define_aat_feature:nnnn {Contextuals} {NoInner} {8} {9}
+% \end{macrocode}
+%
+% \subsection{Diacritics}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Diacritics}
+\@@_define_aat_feature:nnnn {Diacritics} {Show} {9} {0}
+\@@_define_aat_feature:nnnn {Diacritics} {Hide} {9} {1}
+\@@_define_aat_feature:nnnn {Diacritics} {Decompose} {9} {2}
+% \end{macrocode}
+%
+%
+% \subsection{Vertical position}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {VerticalPosition}
+\@@_define_aat_feature:nnnn {VerticalPosition} {Normal} {10} {0}
+\@@_define_aat_feature:nnnn {VerticalPosition} {Superior} {10} {1}
+\@@_define_aat_feature:nnnn {VerticalPosition} {Inferior} {10} {2}
+\@@_define_aat_feature:nnnn {VerticalPosition} {Ordinal} {10} {3}
+% \end{macrocode}
+%
+% \subsection{Fractions}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Fractions}
+\@@_define_aat_feature:nnnn {Fractions} {On} {11} {1}
+\@@_define_aat_feature:nnnn {Fractions} {Off} {11} {0}
+\@@_define_aat_feature:nnnn {Fractions} {Diagonal} {11} {2}
+% \end{macrocode}
+%
+% \subsection{Alternate}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n { Alternate }
+\keys_define:nn {fontspec-aat}
+ {
+ Alternate .default:n = {0} ,
+ Alternate / unknown .code:n =
+ {
+ \clist_map_inline:nn {#1}
+ {
+ \@@_make_AAT_feature:nn {17}{##1}
+ }
+ }
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Variant / StylisticSet}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Variant}
+\keys_define:nn {fontspec-aat}
+ {
+ Variant .default:n = {0} ,
+ Variant / unknown .code:n =
+ {
+ \clist_map_inline:nn {#1}
+ { \@@_make_AAT_feature:nn {18}{##1} }
+ }
+ }
+\aliasfontfeature{Variant}{StylisticSet}
+% \end{macrocode}
+%
+%
+%
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Vertical}
+\keys_define:nn {fontspec-aat}
+ {
+ Vertical .choice: ,
+ Vertical / RotatedGlyphs .code:n =
+ {
+ \__fontspec_update_featstr:n {vertical}
+ }
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Style}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Style}
+\@@_define_aat_feature:nnnn {Style} {Italic} {32} {2}
+\@@_define_aat_feature:nnnn {Style} {Ruby} {28} {2}
+\@@_define_aat_feature:nnnn {Style} {Display} {19} {1}
+\@@_define_aat_feature:nnnn {Style} {Engraved} {19} {2}
+\@@_define_aat_feature:nnnn {Style} {TitlingCaps} {19} {4}
+\@@_define_aat_feature:nnnn {Style} {TallCaps} {19} {5}
+% \end{macrocode}
+%
+% \subsection{CJK shape}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {CJKShape}
+\@@_define_aat_feature:nnnn {CJKShape} {Traditional} {20} {0}
+\@@_define_aat_feature:nnnn {CJKShape} {Simplified} {20} {1}
+\@@_define_aat_feature:nnnn {CJKShape} {JIS1978} {20} {2}
+\@@_define_aat_feature:nnnn {CJKShape} {JIS1983} {20} {3}
+\@@_define_aat_feature:nnnn {CJKShape} {JIS1990} {20} {4}
+\@@_define_aat_feature:nnnn {CJKShape} {Expert} {20} {10}
+\@@_define_aat_feature:nnnn {CJKShape} {NLC} {20} {13}
+% \end{macrocode}
+%
+% \subsection{Character width}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {CharacterWidth}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Proportional} {22} {0}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Full} {22} {1}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Half} {22} {2}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Third} {22} {3}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Quarter} {22} {4}
+\@@_define_aat_feature:nnnn {CharacterWidth} {AlternateProportional} {22} {5}
+\@@_define_aat_feature:nnnn {CharacterWidth} {AlternateHalf} {22} {6}
+\@@_define_aat_feature:nnnn {CharacterWidth} {Default} {22} {7}
+% \end{macrocode}
+%
+% \subsection{Annotation}
+% \begin{macrocode}
+\@@_define_aat_feature_group:n {Annotation}
+\@@_define_aat_feature:nnnn {Annotation} {Off} {24} {0}
+\@@_define_aat_feature:nnnn {Annotation} {Box} {24} {1}
+\@@_define_aat_feature:nnnn {Annotation} {RoundedBox} {24} {2}
+\@@_define_aat_feature:nnnn {Annotation} {Circle} {24} {3}
+\@@_define_aat_feature:nnnn {Annotation} {BlackCircle} {24} {4}
+\@@_define_aat_feature:nnnn {Annotation} {Parenthesis} {24} {5}
+\@@_define_aat_feature:nnnn {Annotation} {Period} {24} {6}
+\@@_define_aat_feature:nnnn {Annotation} {RomanNumerals} {24} {7}
+\@@_define_aat_feature:nnnn {Annotation} {Diamond} {24} {8}
+\@@_define_aat_feature:nnnn {Annotation} {BlackSquare} {24} {9}
+\@@_define_aat_feature:nnnn {Annotation} {BlackRoundSquare} {24} {10}
+\@@_define_aat_feature:nnnn {Annotation} {DoubleCircle} {24} {11}
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec&XE>
+% \end{macrocode}
+% \fi
+
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-feat-opentype.dtx b/macros/latex/contrib/fontspec/fontspec-code-feat-opentype.dtx
new file mode 100644
index 0000000000..aaba25c293
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-feat-opentype.dtx
@@ -0,0 +1,582 @@
+%%^^A%% fontspec-code-feat-opentype.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{OpenType feature definitions}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+%
+% \begin{macrocode}
+\@@_feat_prop_add:nn {salt} { Alternate\,=\,$N$ }
+\@@_feat_prop_add:nn {nalt} { Annotation\,=\,$N$ }
+\@@_feat_prop_add:nn {ornm} { Ornament\,=\,$N$ }
+\@@_feat_prop_add:nn {cvNN} { CharacterVariant\,=\,$N$:$M$ }
+\@@_feat_prop_add:nn {ssNN} { StylisticSet\,=\,$N$ }
+% \end{macrocode}
+%
+% \section{Regular key=val / tag definitions}
+%
+% \subsection{Ligatures}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Ligatures}
+\@@_define_opentype_feature:nnnnn {Ligatures} {ResetAll} {} {}
+ {
+ +dlig,-dlig,+rlig,-rlig,+liga,-liga,+dlig,-dlig,+clig,-clig,+hlig,-hlig,
+%<XE> mapping = tex-text
+%<LU> +tlig,-tlig
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Required} {rlig} {rlig} {}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Common} {liga} {liga} {}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Rare} {dlig} {dlig} {}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Discretionary} {dlig} {dlig} {}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Contextual} {clig} {clig} {}
+\@@_define_opentype_onoffreset:nnnnn {Ligatures} {Historic} {hlig} {hlig} {}
+% \end{macrocode}
+% Emulate CM extra ligatures.
+% \begin{macrocode}
+%<*XE>
+\keys_define:nn {fontspec-opentype}
+ {
+ Ligatures / TeX .code:n = { \tl_set:Nn \l_@@_mapping_tl {tex-text} },
+ Ligatures / TeX .groups:n = {opentype},
+ Ligatures / TeXReset .code:n = { \tl_clear:N \l_@@_mapping_tl },
+ Ligatures / TeXReset .groups:n = {opentype},
+ }
+%</XE>
+%<LU>\@@_define_opentype_onreset:nnnnn {Ligatures} {TeX} {} { +tlig } {}
+% \end{macrocode}
+%
+% \subsection{Letters}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Letters}
+\@@_define_opentype_feature:nnnnn {Letters} {ResetAll} {} {}
+ {
+ +case,+smcp,+pcap,+c2sc,+c2pc,+unic,+rand,
+ -case,-smcp,-pcap,-c2sc,-c2pc,-unic,-rand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {Uppercase} {case} {case} {+smcp,+pcap,+c2sc,+c2pc,+unic,+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {SmallCaps} {smcp} {smcp} {+pcap,+unic,+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {PetiteCaps} {pcap} {pcap} {+smcp,+unic,+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {UppercaseSmallCaps} {c2sc} {c2sc} {+c2pc,+unic,+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {UppercasePetiteCaps} {c2pc} {c2pc} {+c2sc,+unic,+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {Unicase} {unic} {unic} {+rand}
+\@@_define_opentype_onoffreset:nnnnn {Letters} {Random} {rand} {rand} {+unic}
+% \end{macrocode}
+%
+% \subsection{Numbers}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Numbers}
+\@@_define_opentype_feature:nnnnn {Numbers} {ResetAll} {} {}
+ {
+ +tnum,-tnum,
+ +pnum,-pnum,
+ +onum,-onum,
+ +lnum,-lnum,
+ +zero,-zero,
+ +anum,-anum,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Numbers} {Monospaced} {tnum} {tnum} {+pnum,-pnum}
+\@@_define_opentype_onoffreset:nnnnn {Numbers} {Proportional} {pnum} {pnum} {+tnum,-tnum}
+\@@_define_opentype_onoffreset:nnnnn {Numbers} {Lowercase} {onum} {onum} {+lnum,-lnum}
+\@@_define_opentype_onoffreset:nnnnn {Numbers} {Uppercase} {lnum} {lnum} {+onum,-onum}
+\@@_define_opentype_onoffreset:nnnnn {Numbers} {SlashedZero} {zero} {zero} {}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\aliasfontfeatureoption {Numbers} {Monospaced} {Tabular}
+\aliasfontfeatureoption {Numbers} {Lowercase} {OldStyle}
+\aliasfontfeatureoption {Numbers} {Uppercase} {Lining}
+% \end{macrocode}
+%
+% |luaotload| provides a custom |anum| feature for replacing Latin
+% (AKA Arabic) numbers with Arabic (AKA Indic-Arabic). The same feature
+% maps to Farsi (Persian) numbers if font language is Farsi.
+% \begin{macrocode}
+%<LU> \@@_define_opentype_onoffreset:nnnnn {Numbers} {Arabic} {anum} {anum} {}
+% \end{macrocode}
+%
+% \subsection{Vertical position}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {VerticalPosition}
+\@@_define_opentype_feature:nnnnn {VerticalPosition} {ResetAll} {} {}
+ {
+ +sups,-sups,
+ +subs,-subs,
+ +ordn,-ordn,
+ +numr,-numr,
+ +dnom,-dnom,
+ +sinf,-sinf,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Superior} {sups} {sups} {+subs,+ordn,+numr,+dnom,+sinf}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Inferior} {subs} {subs} {+sups,+ordn,+numr,+dnom,+sinf}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Ordinal} {ordn} {ordn} {+sups,+subs,+numr,+dnom,+sinf}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Numerator} {numr} {numr} {+sups,+subs,+ordn,+dnom,+sinf}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Denominator} {dnom} {dnom} {+sups,+subs,+ordn,+numr,+sinf}
+\@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {ScientificInferior} {sinf} {sinf} {+sups,+subs,+ordn,+numr,+dnom}
+% \end{macrocode}
+%
+% \subsection{Contextuals}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Contextuals}
+\@@_define_opentype_feature:nnnnn {Contextuals} {ResetAll} {} {}
+ {
+ +cswh,-cswh,
+ +calt,-calt,
+ +init,-init,
+ +fina,-fina,
+ +falt,-falt,
+ +medi,-medi,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {Swash} {cswh} {cswh} {}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {Alternate} {calt} {calt} {}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {WordInitial} {init} {init} {}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {WordFinal} {fina} {fina} {}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {LineFinal} {falt} {falt} {}
+\@@_define_opentype_onoffreset:nnnnn {Contextuals} {Inner} {medi} {medi} {}
+% \end{macrocode}
+%
+% \subsection{Diacritics}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Diacritics}
+\@@_define_opentype_feature:nnnnn {Diacritics} {ResetAll} {} {}
+ {
+ +mark,-mark,
+ +mkmk,-mkmk,
+ +abvm,-abvm,
+ +blwm,-blwm,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Diacritics} {MarkToBase} {mark} {mark} {}
+\@@_define_opentype_onoffreset:nnnnn {Diacritics} {MarkToMark} {mkmk} {mkmk} {}
+\@@_define_opentype_onoffreset:nnnnn {Diacritics} {AboveBase} {abvm} {abvm} {}
+\@@_define_opentype_onoffreset:nnnnn {Diacritics} {BelowBase} {blwm} {blwm} {}
+% \end{macrocode}
+%
+% \subsection{Kerning}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Kerning}
+\@@_define_opentype_feature:nnnnn {Kerning} {ResetAll} {} {}
+ {
+ +cpsp,-cpsp,
+ +kern,-kern,
+ }
+\@@_define_opentype_onoffreset:nnnnn {Kerning} {Uppercase} {cpsp} {cpsp} {}
+\@@_define_opentype_feature:nnnnn {Kerning} {On} {kern} {+kern} {-kern}
+\@@_define_opentype_feature:nnnnn {Kerning} {Off} {kern} {-kern} {+kern}
+\@@_define_opentype_feature:nnnnn {Kerning} {Reset} {} {} {+kern,-kern}
+% \end{macrocode}
+%
+% \subsection{Fractions}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Fractions}
+\@@_define_opentype_feature:nnnnn {Fractions} {ResetAll} {} {}
+ {
+ +frac,-frac,
+ +afrc,-afrc,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_feature:nnnnn {Fractions} {On} {frac} {+frac} {}
+\@@_define_opentype_feature:nnnnn {Fractions} {Off} {frac} {-frac} {}
+\@@_define_opentype_feature:nnnnn {Fractions} {Reset} {} {} {+frac,-frac}
+\@@_define_opentype_onoffreset:nnnnn {Fractions} {Alternate} {afrc} {afrc} {-frac}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {LocalForms}
+\@@_define_opentype_feature:nnnnn {LocalForms} {On} {locl} {+locl} {}
+\@@_define_opentype_feature:nnnnn {LocalForms} {Off} {locl} {-locl} {}
+\@@_define_opentype_feature:nnnnn {LocalForms} {Reset} {} {} {+locl,-locl}
+% \end{macrocode}
+%
+
+% \subsection{Style}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Style}
+\@@_define_opentype_feature:nnnnn {Style} {ResetAll} {} {}
+ {
+ +salt,-salt,
+ +ital,-ital,
+ +ruby,-ruby,
+ +swsh,-swsh,
+ +hist,-hist,
+ +titl,-titl,
+ +hkna,-hkna,
+ +vkna,-vkna,
+ +ssty=0,-ssty=0,
+ +ssty=1,-ssty=1,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Alternate} {salt} {salt} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Italic} {ital} {ital} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Ruby} {ruby} {ruby} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Swash} {swsh} {swsh} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Cursive} {swsh} {curs} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {Historic} {hist} {hist} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {TitlingCaps} {titl} {titl} {}
+\@@_define_opentype_onoffreset:nnnnn {Style} {HorizontalKana} {hkna} {hkna} {+vkna,+pkna}
+\@@_define_opentype_onoffreset:nnnnn {Style} {VerticalKana} {vkna} {vkna} {+hkna,+pkna}
+\@@_define_opentype_onoffreset:nnnnn {Style} {ProportionalKana} {pkna} {pkna} {+vkna,+hkna}
+\@@_define_opentype_feature:nnnnn {Style} {MathScript} {ssty} {+ssty=0} {+ssty=1}
+\@@_define_opentype_feature:nnnnn {Style} {MathScriptScript} {ssty} {+ssty=1} {+ssty=0}
+% \end{macrocode}
+%
+% \subsection{CJK shape}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {CJKShape}
+\@@_define_opentype_feature:nnnnn {CJKShape} {ResetAll} {} {}
+ {
+ +trad,-trad,
+ +smpl,-smpl,
+ +jp78,-jp78,
+ +jp83,-jp83,
+ +jp90,-jp90,
+ +jp04,-jp04,
+ +expt,-expt,
+ +nlck,-nlck,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {Traditional} {trad} {trad} {+smpl,+jp78,+jp83,+jp90,+jp04,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {Simplified} {smpl} {smpl} {+trad,+jp78,+jp83,+jp90,+jp04,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1978} {jp78} {jp78} {+trad,+smpl,+jp83,+jp90,+jp04,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1983} {jp83} {jp83} {+trad,+smpl,+jp78,+jp90,+jp04,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1990} {jp90} {jp90} {+trad,+smpl,+jp78,+jp83,+jp04,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS2004} {jp04} {jp04} {+trad,+smpl,+jp78,+jp83,+jp90,+expt,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {Expert} {expt} {expt} {+trad,+smpl,+jp78,+jp83,+jp90,+jp04,+nlck}
+\@@_define_opentype_onoffreset:nnnnn {CJKShape} {NLC} {nlck} {nlck} {+trad,+smpl,+jp78,+jp83,+jp90,+jp04,+expt}
+% \end{macrocode}
+%
+% \subsection{Character width}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {CharacterWidth}
+\@@_define_opentype_feature:nnnnn {CharacterWidth} {ResetAll} {} {}
+ {
+ +pwid,-pwid,
+ +fwid,-fwid,
+ +hwid,-hwid,
+ +twid,-twid,
+ +qwid,-qwid,
+ +palt,-palt,
+ +halt,-halt,
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Proportional} {pwid} {pwid} {+fwid,+hwid,+twid,+qwid,+palt,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Full} {fwid} {fwid} {+pwid,+hwid,+twid,+qwid,+palt,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Half} {hwid} {hwid} {+pwid,+fwid,+twid,+qwid,+palt,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Third} {twid} {twid} {+pwid,+fwid,+hwid,+qwid,+palt,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Quarter} {qwid} {qwid} {+pwid,+fwid,+hwid,+twid,+palt,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {AlternateProportional} {palt} {palt} {+pwid,+fwid,+hwid,+twid,+qwid,+halt}
+\@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {AlternateHalf} {halt} {halt} {+pwid,+fwid,+hwid,+twid,+qwid,+palt}
+% \end{macrocode}
+%
+% \subsection{Vertical}
+% According to spec |vkrn| must also activate |vpal| if available but for simplicity we don't do that here (yet?).
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Vertical}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {RotatedGlyphs} {vrt2} {vrt2} {+vrtr,+vert}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {AlternatesForRotation} {vrtr} {vrtr} {+vrt2}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {Alternates} {vert} {vert} {+vrt2}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {KanaAlternates} {vkna} {vkna} {+hkna}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {Kerning} {vkrn} {vkrn} {}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {AlternateMetrics} {valt} {valt} {+vhal,+vpal,+kern}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {HalfMetrics} {vhal} {vhal} {+valt,+vpal,+kern}
+\@@_define_opentype_onoffreset:nnnnn {Vertical} {ProportionalMetrics} {vpal} {vpal} {+valt,+vhal}
+% \end{macrocode}
+%
+%
+%
+%
+% \section{OpenType features that need numbering}
+%
+% \subsection{Alternate}
+%
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Alternate}
+\keys_define:nn {fontspec-opentype}
+ {
+ Alternate .default:n = {0} ,
+ Alternate .groups:n = {opentype},
+ Alternate / unknown .code:n =
+ {
+ \clist_map_inline:nn {#1}
+ { \@@_make_OT_feature:nnn {salt}{ +salt = ##1 }{} }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*LU>
+\keys_define:nn {fontspec-opentype}
+ {
+ Alternate / Random .code:n =
+ { \@@_make_OT_feature:nnn {salt}{ +salt = random }{} } ,
+ }
+%</LU>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\aliasfontfeature{Alternate}{StylisticAlternates}
+% \end{macrocode}
+%
+%
+% \subsection{Variant / StylisticSet}
+%
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Variant}
+\keys_define:nn {fontspec-opentype}
+ {
+ Variant .default:n = {0} ,
+ Variant .groups:n = {opentype} ,
+ Variant / unknown .code:n =
+ {
+ \clist_map_inline:nn {#1}
+ {
+ \@@_make_OT_feature:xxx { ss \two@digits {##1} } { +ss \two@digits {##1} } {}
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\aliasfontfeature{Variant}{StylisticSet}
+% \end{macrocode}
+%
+% \subsection{CharacterVariant}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {CharacterVariant}
+\use:x
+ {
+ \cs_new:Npn \exp_not:N \fontspec_parse_cv:w
+ ##1 \c_colon_str ##2 \c_colon_str ##3 \exp_not:N \q_nil
+ {
+ \@@_make_OT_feature:xxx
+ { cv \exp_not:N \two@digits {##1} }
+ { +cv \exp_not:N \two@digits {##1} = ##2 } {}
+ }
+ \keys_define:nn {fontspec-opentype}
+ {
+ CharacterVariant / unknown .code:n =
+ {
+ \clist_map_inline:nn {##1}
+ {
+ \exp_not:N \fontspec_parse_cv:w
+ ####1 \c_colon_str 0 \c_colon_str \exp_not:N \q_nil
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% Possibilities: \verb|a:0:\q_nil| or \verb|a:b:0:\q_nil|.
+%
+%
+% \subsection{Annotation}
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Annotation}
+\keys_define:nn {fontspec-opentype}
+ {
+ Annotation .default:n = {0} ,
+ Annotation .groups:n = {opentype},
+ Annotation / unknown .code:n =
+ {
+ \@@_make_OT_feature:nnn {nalt} {+nalt=#1} {}
+ }
+ }
+% \end{macrocode}
+%
+% \subsection{Ornament}
+%
+% \begin{macrocode}
+\@@_define_opentype_feature_group:n {Ornament}
+\keys_define:nn {fontspec-opentype}
+ {
+ Ornament .default:n = {0} ,
+ Ornament .groups:n = {opentype},
+ Ornament / unknown .code:n =
+ {
+ \@@_make_OT_feature:nnn {ornm} { +ornm=#1 } {}
+ }
+ }
+% \end{macrocode}
+%
+%
+% \section{Script and Language}
+%
+%
+% \subsection{Script}
+%
+% \begin{macrocode}
+\keys_define:nn {fontspec-opentype}
+ {
+ Script .choice: ,
+ Script .groups:n = {opentype} ,
+ }
+\cs_new:Nn \fontspec_new_script:nn
+ {
+ \keys_define:nn {fontspec-opentype} { Script / #1 .code:n =
+ {
+%<debug>\typeout{Trying~[Script=#1]}
+ \bool_set_false:N \l_@@_scriptlang_exist_bool
+ \clist_map_inline:nn {#2}
+ {
+ \exp_args:No \@@_check_script:NnT \l_@@_fontface_cs_tl {####1}
+ {
+%<debug>\typeout{Script~tag~found:~####1}
+ \tl_set:Nn \l_@@_script_name_tl {#1}
+ \tl_set:Nn \l_@@_script_tl {####1}
+ \int_set:Nn \l_@@_script_int {\l_@@_strnum_int}
+ \bool_set_true:N \l_@@_scriptlang_exist_bool
+ \tl_gset:Nx \g_@@_single_feat_tl { script=####1 }
+ \clist_map_break:
+ }
+ }
+
+ \bool_if:NF \l_@@_scriptlang_exist_bool
+ {
+%<debug>\typeout{Script~not~found!}
+ \bool_if:nF { \str_if_eq_p:ee {#1} {CustomDefault} }
+ {
+ \tl_clear:N \l_@@_script_name_tl
+ \@@_warning:nxx {no-script} {\l_fontspec_fontname_tl} {#1}
+ }
+
+ \bool_if:nF
+ {
+ \str_if_eq_p:ee {#1} {Default} ||
+ \str_if_eq_p:ee {#1} {Latin} ||
+ \str_if_eq_p:ee {#1} {CustomDefault}
+ }
+ {
+ \keys_set:nn {fontspec-opentype} { Script = CustomDefault }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Language}
+%
+% \begin{macrocode}
+\keys_define:nn {fontspec-opentype}
+ {
+ Language .choice: ,
+ Language .groups:n = {opentype} ,
+ }
+\cs_new:Nn \fontspec_new_lang:nn
+ {
+ \keys_define:nn {fontspec-opentype} { Language / #1 .code:n =
+ {
+ \bool_set_false:N \l_@@_scriptlang_exist_bool
+ \clist_map_inline:nn {#2}
+ {
+ \exp_args:No \@@_check_lang:NnTF \l_@@_fontface_cs_tl {####1}
+ {
+ \tl_set:Nn \l_@@_lang_tl {####1}
+ \int_set:Nn \l_@@_language_int {\l_@@_strnum_int}
+ \tl_gset:Nx \g_@@_single_feat_tl { language=####1 }
+ \bool_set_true:N \l_@@_scriptlang_exist_bool
+ \clist_map_break:
+ }
+ }
+ \bool_if:NF \l_@@_scriptlang_exist_bool
+ {
+ \@@_warning:nx {language-not-exist} {#1}
+ \keys_set:nn {fontspec-opentype} { Language = Default }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \paragraph{Language=Default}
+% These are special-cased to avoid the additional logic above.
+% From memory, the OpenType default
+% language is hardcoded to have a zero value,
+% although this might be some \XeTeX-specific thing.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-opentype} { Language / Default }
+ {
+ \tl_set:Nn \l_@@_lang_tl {DFLT}
+ \int_zero:N \l_@@_language_int
+ \tl_gset:Nn \g_@@_single_feat_tl { language=DFLT }
+ }
+% \end{macrocode}
+%
+%
+% \section{Backwards compatibility}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_ot_compat:nn
+ {
+ \aliasfontfeatureoption {#1} {#2Off} {No#2}
+ }
+\@@_ot_compat:nn {Ligatures} {Rare}
+\@@_ot_compat:nn {Ligatures} {Required}
+\@@_ot_compat:nn {Ligatures} {Common}
+\@@_ot_compat:nn {Ligatures} {Discretionary}
+\@@_ot_compat:nn {Ligatures} {Contextual}
+\@@_ot_compat:nn {Ligatures} {Historic}
+\@@_ot_compat:nn {Numbers} {SlashedZero}
+\@@_ot_compat:nn {Contextuals} {Swash}
+\@@_ot_compat:nn {Contextuals} {Alternate}
+\@@_ot_compat:nn {Contextuals} {WordInitial}
+\@@_ot_compat:nn {Contextuals} {WordFinal}
+\@@_ot_compat:nn {Contextuals} {LineFinal}
+\@@_ot_compat:nn {Contextuals} {Inner}
+\@@_ot_compat:nn {Diacritics} {MarkToBase}
+\@@_ot_compat:nn {Diacritics} {MarkToMark}
+\@@_ot_compat:nn {Diacritics} {AboveBase}
+\@@_ot_compat:nn {Diacritics} {BelowBase}
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-fontload.dtx b/macros/latex/contrib/fontspec/fontspec-code-fontload.dtx
new file mode 100644
index 0000000000..88a107896f
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-fontload.dtx
@@ -0,0 +1,136 @@
+%%^^A%% fontspec-code-fontload.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{expl3 interface for primitive font loading}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \begin{macro}{\@@_primitive_font_set:Nnn,\@@_primitive_font_gset:Nnn}
+% \begin{macrocode}
+\cs_set:Npn \@@_primitive_font_set:Nnn #1#2#3
+ {
+ \font #1 = #2 ~at~ \dim_eval:n {#3} \scan_stop:
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_set:Npn \@@_primitive_font_gset:Nnn #1#2#3
+ {
+ \global \font #1 = #2 ~at~ \dim_eval:n {#3} \scan_stop:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_font_suppress_not_found_error:}
+% \begin{macrocode}
+\cs_set:Npn \@@_font_suppress_not_found_error:
+ {
+ \int_set:Nn \suppressfontnotfounderror {1}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[pTF]{\@@_primitive_font_if_null:N}
+% \begin{macrocode}
+\prg_set_conditional:Nnn \@@_primitive_font_if_null:N {p,TF,T,F}
+ {
+ \ifx #1 \nullfont
+ \prg_return_true:
+ \else
+ \prg_return_false:
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[pTF]{\@@_primitive_font_set:NnnTF,\@@_primitive_font_gset:NnnTF}
+% \begin{macrocode}
+\prg_set_conditional:Nnn \@@_primitive_font_set:Nnn {TF,T,F}
+ {
+ \@@_primitive_font_set:Nnn #1 {#2} {#3}
+ \@@_primitive_font_if_null:NTF #1 {\prg_return_false:} {\prg_return_true:}
+ }
+\prg_set_conditional:Nnn \@@_primitive_font_gset:Nnn {TF,T,F}
+ {
+ \@@_primitive_font_gset:Nnn #1 {#2} {#3}
+ \@@_primitive_font_if_null:NTF #1 {\prg_return_false:} {\prg_return_true:}
+ }
+\cs_set:Npn \@@_primitive_font_set:Onn { \exp_last_unbraced:No \@@_primitive_font_set:Nnn }
+\cs_set:Npn \@@_primitive_font_set:OnnF { \exp_last_unbraced:No \@@_primitive_font_set:NnnF }
+\cs_set:Npn \@@_primitive_font_gset:Onn { \exp_last_unbraced:No \@@_primitive_font_gset:Nnn }
+\cs_set:Npn \@@_primitive_font_gset:OnnF { \exp_last_unbraced:No \@@_primitive_font_gset:NnnF }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[TF]{\@@_primitive_font_if_exist:n}
+% \begin{macrocode}
+\prg_set_conditional:Nnn \@@_primitive_font_if_exist:n {TF,T,F}
+ {
+ \group_begin:
+ \@@_font_suppress_not_found_error:
+ \@@_primitive_font_set:Nnn \l_@@_primitive_font {#1} { \f@size pt - 1sp }
+ \@@_primitive_font_if_null:NTF \l_@@_primitive_font
+ { \group_end: \prg_return_false: }
+ { \group_end: \prg_return_true: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_primitive_font_glyph_if_exist:NnTF}
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_primitive_font_glyph_if_exist:Nn {p,TF,T,F}
+ {
+ \tex_iffontchar:D #1 #2 \scan_stop:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_primitive_font_set_hyphenchar:Nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_primitive_font_set_hyphenchar:Nn
+ {
+ \tex_hyphenchar:D #1 = #2 \scan_stop:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_primitive_font_get_name:N}
+% \begin{macro}{\@@_primitive_font_current_name:}
+% \begin{macrocode}
+\cs_new_eq:NN \@@_primitive_font_get_name:N \fontname
+\cs_new:Npn \@@_primitive_font_current_name:
+ {
+ \@@_primitive_font_get_name:N \tex_font:D
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-graphite.dtx b/macros/latex/contrib/fontspec/fontspec-code-graphite.dtx
new file mode 100644
index 0000000000..a39cfe36aa
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-graphite.dtx
@@ -0,0 +1,128 @@
+%%^^A%% fontspec-code-graphite.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Graphite/AAT code}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec&XE>
+% \end{macrocode}
+% \fi
+%
+
+
+% \begin{macro}{\@@_define_aat_feature_group:n}
+% \begin{macrocode}
+\cs_new:Nn \@@_define_aat_feature_group:n
+ {
+ \keys_define:nn {fontspec-aat} { #1 .multichoice: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_define_aat_feature:nnnn}
+% \begin{macrocode}
+\cs_new:Nn \@@_define_aat_feature:nnnn
+ {
+ \keys_define:nn {fontspec-aat}
+ {
+ #1/#2 .code:n = { \@@_make_AAT_feature:nn {#3}{#4} }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\@@_make_AAT_feature:nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_make_AAT_feature:nn
+ {
+ \tl_if_empty:nTF {#1}
+ { \@@_warning:n {aat-feature-not-exist} }
+ {
+ \exp_args:No \@@_make_AAT_feature_string:NnnTF \l_@@_fontface_cs_tl {#1} {#2}
+ {
+ \@@_update_featstr:n {\l_fontspec_feature_string_tl}
+ }
+ {
+ \@@_warning:nx {aat-feature-not-exist-in-font} {#1,#2}
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_make_AAT_feature_string:NnnTF}
+% This macro takes the numerical codes for a font feature and
+% creates a specified macro containing the string required in the
+% font definition to turn that feature on or off. Used primarily in
+% [...], but also used to check if small caps
+% exists in the requested font (see page~\pageref{mac:makesmallcaps}).
+%
+% For exclusive selectors, it's easy; just grab the string:
+% For \emph{non}-exclusive selectors, it's a little more complex.
+% If the selector is even, it corresponds to switching the feature on.
+% If the selector is \emph{odd}, it corresponds to switching the feature off.
+% But \XeTeX\ doesn't return a selector string for this number, since the
+% feature is defined for the `switching on' value. So we need to check the
+% selector of the previous number, and then prefix the feature string with |!|
+% to denote the switch.
+%
+% Finally, save out the complete feature string in \cmd\l_fontspec_feature_string_tl.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_make_AAT_feature_string:Nnn {TF,T,F}
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \XeTeXfeaturename #1 #2 }
+ \tl_if_empty:NTF \l_@@_tmpa_tl
+ { \prg_return_false: }
+ {
+ \int_compare:nTF { \XeTeXisexclusivefeature #1 #2 > 0 }
+ {
+ \tl_set:Nx \l_@@_tmpb_tl {\XeTeXselectorname #1 #2\space #3}
+ }
+ {
+ \int_if_even:nTF {#3}
+ {
+ \tl_set:Nx \l_@@_tmpb_tl {\XeTeXselectorname #1 #2\space #3}
+ }
+ {
+ \tl_set:Nx \l_@@_tmpb_tl
+ {
+ \XeTeXselectorname #1 #2\space \numexpr#3-1\relax
+ }
+ \tl_if_empty:NF \l_@@_tmpb_tl { \tl_put_left:Nn \l_@@_tmpb_tl {!} }
+ }
+ }
+
+ \tl_if_empty:NTF \l_@@_tmpb_tl
+ { \prg_return_false: }
+ {
+ \tl_set:Nx \l_fontspec_feature_string_tl { \l_@@_tmpa_tl = \l_@@_tmpb_tl }
+ \prg_return_true:
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec&XE>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-interfaces.dtx b/macros/latex/contrib/fontspec/fontspec-code-interfaces.dtx
new file mode 100644
index 0000000000..2962d2e49d
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-interfaces.dtx
@@ -0,0 +1,296 @@
+%%^^A%% fontspec-code-interfaces.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{User commands}\label{sec:codeuser}
+%
+% This section contains the definitions of the commands detailed in
+% the user documentation. Only the `top level' definitions of the
+% commands are contained herein; they all use or define macros which
+% are defined or used later on in \vref{sec:codeinternal}.
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \begin{macrocode}
+\NewDocumentCommand \fontspec { O{} m O{} }
+ {
+ \@@_main_fontspec:nn {#1,#3} {#2}
+ \ignorespaces
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setmainfont { O{} m O{} }
+ {
+ \@@_main_setmainfont:nn {#1,#3} {#2}
+ \ignorespaces
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setsansfont { O{} m O{} }
+ {
+ \@@_main_setsansfont:nn {#1,#3} {#2}
+ \ignorespaces
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setmonofont { O{} m O{} }
+ {
+ \@@_main_setmonofont:nn {#1,#3} {#2}
+ \ignorespaces
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setmathrm { O{} m O{} }
+ {
+ \@@_main_setmathrm:nn {#1,#3} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setboldmathrm { O{} m O{} }
+ {
+ \@@_main_setboldmathrm:nn {#1,#3} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setmathsf { O{} m O{} }
+ {
+ \@@_main_setmathsf:nn {#1,#3} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setmathtt { O{} m O{} }
+ {
+ \@@_main_setmathtt:nn {#1,#3} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\setromanfont}
+% This is the old name for \cs{setmainfont}, retained \emph{ad infinitum}
+% for backwards compatibility. It was deprecated in 2010.
+% \begin{macrocode}
+\NewDocumentCommand \setromanfont { O{} m O{} }
+ {
+ \@@_main_setmainfont:nn {#1,#3} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\NewDocumentCommand \newfontfamily { m O{} m O{} }
+ {
+ \@@_main_newfontfamily:NnnN #1 {#2,#4} {#3} \NewDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \renewfontfamily { m O{} m O{} }
+ {
+ \@@_main_newfontfamily:NnnN #1 {#2,#4} {#3} \RenewDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setfontfamily { m O{} m O{} }
+ {
+ \@@_main_newfontfamily:NnnN #1 {#2,#4} {#3} \DeclareDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \providefontfamily { m O{} m O{} }
+ {
+ \@@_main_newfontfamily:NnnN #1 {#2,#4} {#3} \ProvideDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \newfontface { m O{} m O{} }
+ {
+ \@@_main_newfontface:NnnN #1 {#2,#4} {#3} \NewDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \renewfontface { m O{} m O{} }
+ {
+ \@@_main_newfontface:NnnN #1 {#2,#4} {#3} \RenewDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \setfontface { m O{} m O{} }
+ {
+ \@@_main_newfontface:NnnN #1 {#2,#4} {#3} \DeclareDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \providefontface { m O{} m O{} }
+ {
+ \@@_main_newfontface:NnnN #1 {#2,#4} {#3} \ProvideDocumentCommand
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\defaultfontfeatures}
+% This macro takes one argument that consists of all of feature
+% options that will be applied by default to all subsequent \cs{fontspec} commands.
+% \begin{macrocode}
+\NewDocumentCommand \defaultfontfeatures { t+ o m }
+ {
+ \IfNoValueTF {#2}
+ { \@@_set_default_features:nn {#1} {#3} }
+ { \@@_set_font_default_features:nnn {#1} {#2} {#3} }
+ \ignorespaces
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\NewDocumentCommand \addfontfeatures {m}
+ {
+ \@@_main_addfontfeatures:n {#1}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \addfontfeature {m}
+ {
+ \@@_main_addfontfeatures:n {#1}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \newfontfeature {mm}
+ {
+ \@@_main_newfontfeature:nn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \newAATfeature {mmmm}
+ {
+ \@@_main_newAATfeature:nnnn {#1} {#2} {#3} {#4}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \newopentypefeature {mmm}
+ {
+ \@@_main_newopentypefeature:nnn {#1} {#2} {#3}
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\newICUfeature}
+% Deprecated.
+% \begin{macrocode}
+\NewDocumentCommand \newICUfeature {mmm}
+ {
+ \@@_main_newopentypefeature:nnn {#1} {#2} {#3}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\NewDocumentCommand \aliasfontfeature {mm}
+ {
+ \@@_main_aliasfontfeature:nn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \aliasfontfeatureoption {mmm}
+ {
+ \@@_main_aliasfontfeatureoption:nnn {#1} {#2} {#3}
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\newfontscript}
+% Mostly used internally, but also possibly useful for users, to define new OpenType
+% `scripts', mapping logical names to OpenType script tags.
+% \begin{macrocode}
+\NewDocumentCommand \newfontscript {mm}
+ {
+ \fontspec_new_script:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfontlanguage}
+% Mostly used internally, but also possibly useful for users, to define new OpenType
+% `languages', mapping logical names to OpenType language tags.
+% \begin{macrocode}
+\NewDocumentCommand \newfontlanguage {mm}
+ {
+ \fontspec_new_lang:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\NewDocumentCommand \DeclareFontExtensions {m}
+ {
+ \@@_main_DeclareFontExtensions:n {#1}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \IfFontFeatureActiveTF {mmm}
+ {
+ \@@_main_IfFontFeatureActiveTF:nnn {#1} {#2} {#3}
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\oldstylenums}
+% This is performed only after the preamble to overwrite any redefinition by \pkg{textcomp}:
+% \begin{macrocode}
+\AtBeginDocument
+ {
+ \RenewDocumentCommand \oldstylenums {m}
+ {
+ \@@_main_oldstylenums:n {#1}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\liningnums}
+% \begin{macrocode}
+\NewDocumentCommand \liningnums {m}
+ {
+ \@@_main_liningnums:n {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-internal.dtx b/macros/latex/contrib/fontspec/fontspec-code-internal.dtx
new file mode 100644
index 0000000000..50ae7498cd
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-internal.dtx
@@ -0,0 +1,1196 @@
+%%^^A%% fontspec-code-internal.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Internals}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \subsection{The main function for setting fonts}
+%
+% \begin{macro}{\@@_select_font_family:nn}
+% This is the command that defines font families for use, the underlying
+% procedure of all \cmd\fontspec-like commands. Given a
+% list of font features (|#1|) for a requested font (|#2|),
+% it will define an NFSS
+% family for that font and put the family name (globally) into \cs{l_fontspec_family_tl}.
+% The \TeX\ `\cs{font}' command is (globally) stored in \cs{l_fontspec_font}.
+%
+% This macro does its processing inside a group to attempt to restrict the scope of its internal processing.
+% This works to some degree to insulate the internal commands from having to be manually cleared.
+%
+% Some often-used variables to know about:
+% \begin{itemize}
+% \item \cmd{\l_fontspec_fontname_tl} is used as the generic name of the font being defined.
+% \item \cmd{\l_@@_fontid_tl} is the unique identifier of the font with all its features.
+% \item \cmd{\l_@@_fontname_up_tl} is the font specifically to be used as the upright font.
+% \item \cmd{\l_@@_basename_tl} is the (immutable) original argument used for |*|-replacing.
+% \item \cmd{\l_fontspec_font} is the plain \TeX{} font of the upright font requested.
+% \end{itemize}
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_select_font_family:nn
+ {
+%<debug>\typeout{^^J^^J::::::::::::::::::::::::::::::^^J:: fontspec_select:nn~ {#1}~ {#2} }
+ \group_begin:
+ \@@_font_suppress_not_found_error:
+ \@@_init:
+
+ \@@_sanitise_fontname:Nn \l_fontspec_fontname_tl {#2}
+ \@@_sanitise_fontname:Nn \l_@@_fontname_up_tl {#2}
+ \@@_sanitise_fontname:Nn \l_@@_basename_tl {#2}
+
+ \@@_if_detect_external:nT {#2}
+ { \keys_set:nn {fontspec-preparse-external} {Path} }
+
+ \keys_set_known:nn {fontspec-preparse-cfg} {#1}
+
+ \@@_init_ttc:n {#2}
+ \@@_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#2}
+
+ \@@_extract_all_features:n {#1}
+ \tl_set:Nx \l_@@_fontid_tl { \tl_to_str:N \l_fontspec_fontname_tl-:-\tl_to_str:N \l_@@_all_features_clist }
+
+%<debug>\typeout{fontid: \l_@@_fontid_tl}
+
+ \@@_preparse_features:
+ \@@_load_font:
+ \@@_set_scriptlang:
+ \@@_get_features:n {}
+ \bool_set_false:N \l_@@_firsttime_bool
+
+ \@@_save_family_needed:nTF {#2}
+ {
+ \@@_save_family:nn {#1} {#2}
+%<debug>\@@_warning:nxx {defining-font} {#1} {#2}
+ }
+ {
+%<debug>\typeout{Font~ family~ already~ defined.}
+ }
+ \group_end:
+
+ \tl_set_eq:NN \l_fontspec_family_tl \g_@@_nfss_family_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_select:nn}
+% This old name has been used by 3rd party packages so for compatibility:
+% \begin{macrocode}
+\cs_set_eq:NN \fontspec_select:nn \@@_select_font_family:nn %% deprecated, for compatibility only
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_sanitise_fontname:Nn}
+% Assigns font name |#2| to token list variable |#1| and strips extension(s) from it in the case of an external font.
+% We strip spaces for luatex for consistency with luaotfload, although I'm not sure this is necessary any more.
+% At one stage this also lowercased the name, but this step has been removed unless someone can remind me why it was necessary.
+% \begin{macrocode}
+\cs_new:Nn \@@_sanitise_fontname:Nn
+ {
+ \tl_set:Nx #1 {#2}
+%<LU> \tl_remove_all:Nn #1 {~}
+ \clist_map_inline:Nn \l_@@_extensions_clist
+ {
+ \tl_if_in:NnT #1 {##1}
+ {
+ \tl_remove_once:Nn #1 {##1}
+ \tl_set:Nn \l_@@_extension_tl {##1}
+ \clist_map_break:
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_if_detect_external:nT}
+% Check if either the fontname ends with a known font extension.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_if_detect_external:n {T}
+ {
+%<debug> \typeout{:: @@_if_detect_external:n { \exp_not:n {#1} } }
+ \clist_map_inline:Nn \l_@@_extensions_clist
+ {
+ \bool_set_false:N \l_@@_tmpa_bool
+ \exp_args:Nx % <- this should be handled earlier
+ \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string}
+ { \bool_set_true:N \l_@@_tmpa_bool \clist_map_break: }
+ }
+ \bool_if:NTF \l_@@_tmpa_bool \prg_return_true: \prg_return_false:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_init_ttc:n}
+% For TTC fonts we assume they will be loading the italic/bold fonts from the same file,
+% so prepopulate the fontnames to avoid needing to do it manually.
+% \begin{macrocode}
+\cs_new:Nn \@@_init_ttc:n
+ {
+ \str_if_eq:eeT { \str_lower_case:f {\l_@@_extension_tl} } {.ttc}
+ {
+ \@@_sanitise_fontname:Nn \l_@@_fontname_it_tl {#1}
+ \@@_sanitise_fontname:Nn \l_@@_fontname_bf_tl {#1}
+ \@@_sanitise_fontname:Nn \l_@@_fontname_bfit_tl {#1}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_load_external_fontoptions:Nn}
+% Load a possible \texttt{.fontspec} font configuration file.
+% This file could set font-specific options for the font about to be loaded.
+% \begin{macrocode}
+\cs_new:Nn \@@_load_external_fontoptions:Nn
+ {
+ \bool_if:NT \l_@@_fontcfg_bool
+ {
+%<debug> \typeout{:: @@_load_external_fontoptions:Nn \exp_not:N #1 {#2} }
+ \@@_sanitise_fontname:Nn #1 {#2}
+ \tl_set:Nx \l_@@_ext_filename_tl {#1.fontspec}
+ \tl_remove_all:Nn \l_@@_ext_filename_tl {~}
+ \prop_if_in:NVF \g_@@_fontopts_prop #1
+ {
+ \exp_args:No \file_if_exist:nT { \l_@@_ext_filename_tl }
+ { \file_input:n { \l_@@_ext_filename_tl } }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_extract_all_features:}
+% \begin{macrocode}
+\cs_new:Nn \@@_extract_all_features:n
+ {
+%<debug> \typeout{:: @@_extract_all_features:n { \unexpanded {#1} } }
+ \bool_if:NTF \l_@@_disable_defaults_bool
+ {
+ \clist_set:Nx \l_@@_all_features_clist {#1}
+ }
+ {
+ \prop_get:NVNF \g_@@_fontopts_prop \l_fontspec_fontname_tl \l_@@_fontopts_clist
+ { \clist_clear:N \l_@@_fontopts_clist }
+
+ \prop_get:NVNF \g_@@_fontopts_prop \l_@@_family_label_tl \l_@@_family_fontopts_clist
+ { \clist_clear:N \l_@@_family_fontopts_clist }
+ \tl_clear:N \l_@@_family_label_tl
+
+ \clist_set:Nx \l_@@_all_features_clist
+ {
+ \g_@@_default_fontopts_clist,
+ \l_@@_family_fontopts_clist,
+ \l_@@_fontopts_clist,
+ #1
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_preparse_features:}
+% \darg{feature options}
+% \darg{font name}
+% Perform the (multi-step) feature parsing process.
+%
+% Convert the requested features to font definition
+% strings. First the features are parsed for information about font
+% loading (whether it's a named font or external font, etc.), and then
+% information is extracted for the names of the other shape fonts.
+% \begin{macrocode}
+\cs_new:Nn \@@_preparse_features:
+ {
+%<debug> \typeout{:: @@_preparse_features:}
+% \end{macrocode}
+% Detect if external fonts are to be used, possibly automatically, and
+% parse fontspec features for bold/italic fonts and their features.
+% \begin{macrocode}
+
+ \@@_keys_set_known:nxN {fontspec-preparse-external}
+ { \l_@@_all_features_clist }
+ \l_@@_keys_leftover_clist
+
+% \end{macrocode}
+% When \cmd{\l_fontspec_fontname_tl} is augmented with a prefix or whatever to create
+% the name of the upright font (\cmd{\l_@@_fontname_up_tl}), this latter is the new `general
+% font name' to use.
+% \begin{macrocode}
+ \tl_set_eq:NN \l_fontspec_fontname_tl \l_@@_fontname_up_tl
+ \@@_keys_set_known:nxN {fontspec-renderer} {\l_@@_keys_leftover_clist}
+ \l_@@_keys_leftover_clist
+ \@@_keys_set_known:nxN {fontspec-preparse} {\l_@@_keys_leftover_clist}
+ \l_@@_fontfeat_clist
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_load_font:}
+% \begin{macrocode}
+\cs_new:Nn \@@_load_font:
+ {
+%<debug>\typeout{:: @@_load_font}
+
+%<debug>\typeout{Set~ base~ font~ for~ preliminary~ analysis: \@@_construct_font_call:nn { \l_@@_fontname_up_tl } {} }
+ \@@_primitive_font_set:NnnF \l_@@_test_font
+ { \@@_construct_font_call:nn { \l_@@_fontname_up_tl } {} }
+ { \f@size pt - 2sp }
+ { \@@_error:nx {font-not-found} {\l_@@_fontname_up_tl} }
+
+%<debug>\typeout{Set~ base~ font~ properly: \@@_construct_font_call:nn { \l_@@_fontname_up_tl } {} }
+ \@@_set_font_type:N \l_@@_test_font
+ \@@_primitive_font_gset:Onn \l_@@_fontface_cs_tl
+ { \@@_construct_font_call:nn { \l_@@_fontname_up_tl } {} }
+ { \f@size pt }
+
+ \l_@@_fontface_cs_tl % this is necessary for LuaLaTeX to check the scripts properly
+
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_construct_font_call:nn}
+% Constructs the complete font invocation.
+% \darg{Base name}
+% \darg{Extension}
+% \darg{TTC Index}
+% \darg{Renderer}
+% \darg{Optical size}
+% \darg{Font features}
+% We check if \meta{Font features} are empty and if so don't add in the separator colon.
+% \begin{macrocode}
+\cs_new:Nn \@@_construct_font_call:nnnnnn
+ {
+%<XE> " \@@_fontname_wrap:n { #1 #2 #3 }
+%<LU> " \@@_fontname_wrap:n { #1 #2 } #3
+ #4 #5
+ \str_if_eq:eeF {#6}{} {:#6} "
+ }
+% \end{macrocode}
+% In practice, we don't use the six-argument version, since most arguments are constructed on-the-fly:
+% \begin{macrocode}
+\cs_new:Nn \@@_construct_font_call:nn
+ {
+ \@@_construct_font_call:nnnnnn
+ {#1}
+ \l_@@_extension_tl
+ \l_@@_ttc_index_tl
+ \l_@@_renderer_tl
+ \l_@@_optical_size_tl
+ {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_font_is_file:,\@@_font_is_name:}
+% The \cs{@@_fontname_wrap:n} command takes the font name and either passes it through unchanged or wraps it in the syntax for loading a font `by filename'.
+% \XeTeX's syntax is followed since \pkg{luaotfload} provides compatibility.
+% \begin{macrocode}
+\cs_new:Nn \@@_font_is_name:
+ {
+ \cs_set_eq:NN \@@_fontname_wrap:n \use:n
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_font_is_file:
+ {
+ \cs_set:Npn \@@_fontname_wrap:n ##1 { [ \l_@@_font_path_tl ##1 ] }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_set_scriptlang:}
+% Only necessary for OpenType fonts.
+% First check if the font supports scripts, then apply defaults if
+% none are explicitly requested. Similarly with the language settings.
+% \begin{macrocode}
+\cs_new:Nn \@@_set_scriptlang:
+ {
+%<debug> \typeout{:: _set_scriptlang:}
+ \bool_if:NT \l_@@_firsttime_bool
+ {
+ \tl_if_empty:NF \l_@@_script_name_tl
+ {
+%<debug> \typeout{:::: Script=\l_@@_script_name_tl, Language=\l_@@_lang_name_tl}
+ \keys_set:nx {fontspec-opentype} {Script=\l_@@_script_name_tl}
+ \keys_set:nx {fontspec-opentype} {Language=\l_@@_lang_name_tl}
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_get_features:Nn}
+% This macro is a wrapper for |\keys_set:nn| which expands and adds a
+% default specification to the original passed options. It begins by
+% initialising the commands used to hold font-feature specific
+% strings.
+% Its argument is any additional features to prepend to the default.
+%
+% Do not set the colour if not explicitly spec'd else \verb|\color| (using
+% specials) will not work.
+% \begin{macrocode}
+\cs_new:Nn \@@_get_features:n
+ {
+%<debug> \typeout{:: @@_get_features:Nn { \exp_not:n {#1} } }
+ \@@_init_fontface:
+ \@@_keys_set_known:nxN {fontspec-renderer} {\l_@@_fontfeat_clist,#1}
+ \l_@@_keys_leftover_clist
+ \@@_keys_set_known:nxN {fontspec} {\l_@@_keys_leftover_clist} \l_@@_keys_leftover_clist
+%<*XE>
+ \bool_if:NTF \l_@@_ot_bool
+ {
+%<debug> \typeout{::: Setting~ keys~ for~ OpenType~ font~ features:~"\l_@@_keys_leftover_clist"}
+ \keys_set:nV {fontspec-opentype} \l_@@_keys_leftover_clist
+ }
+ {
+%<debug> \typeout{::: Setting~ keys~ for~ AAT/Graphite~ font~ features:~"\l_@@_keys_leftover_clist"}
+ \bool_if:nT { \l_@@_atsui_bool || \l_@@_graphite_bool }
+ { \keys_set:nV {fontspec-aat} \l_@@_keys_leftover_clist }
+ }
+%</XE>
+%<*LU>
+%<debug> \typeout{::: Setting~ keys~ for~ OpenType~ font~ features:~"\l_@@_keys_leftover_clist"}
+ \keys_set:nV {fontspec-opentype} \l_@@_keys_leftover_clist
+%</LU>
+
+ \tl_if_empty:NF \l_@@_mapping_tl
+ { \@@_update_featstr:n { mapping = \l_@@_mapping_tl } }
+
+ \str_if_eq:eeF { \l_@@_hexcol_tl \l_@@_opacity_tl }
+ { \c_@@_hexcol_tl \c_@@_opacity_tl }
+ { \@@_update_featstr:n { color = \l_@@_hexcol_tl\l_@@_opacity_tl } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_save_family_needed:nTF}
+% Check if the family is unique and, if so, save its information.
+% (\cs{addfontfeature} and other macros use this data.)
+% Then the font family and its shapes are defined in the NFSS.
+%
+% Now we have a unique (in fact, too unique!) string that contains
+% the family name and every option in abbreviated form. This is used
+% with a counter to create a simple NFSS family name for the font we're
+% selecting.
+%
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_save_family_needed:n { TF }
+ {
+
+%<debug> \typeout{save~ family:~ #1}
+%<debug> \typeout{== fontid_tl: "\l_@@_fontid_tl".}
+
+ \tl_if_empty:NTF \l_@@_nfss_fam_tl
+ {
+ \prop_get:NVNTF \g_@@_fontid_family_prop \l_@@_fontid_tl \l_@@_tmp_tl
+ {
+ \tl_gset_eq:NN \g_@@_nfss_family_tl \l_@@_tmp_tl
+ \prg_return_false:
+ }
+ {
+ \tl_set:Nx \l_@@_tmp_tl {#1}
+ \tl_remove_all:Nn \l_@@_tmp_tl { ~ }
+ \@@_save_fontid_family:VV \l_@@_fontid_tl \l_@@_tmp_tl
+ \prg_return_true:
+ }
+ }
+ {
+ \tl_gset_eq:NN \g_@@_nfss_family_tl \l_@@_nfss_fam_tl
+ \cs_undefine:c { g_@@_fontinfo_ \g_@@_nfss_family_tl _prop }
+ \prg_return_true:
+ }
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Nn \@@_save_fontid_family:nn
+ {
+ \prop_get:NnNTF \g_@@_family_int_prop {#2} \l_@@_tmp_tl
+ {
+ \tl_set:Nx \l_@@_tmp_tl
+ { \int_eval:n { \l_@@_tmp_tl + 1 } }
+ }
+ { \tl_set:Nn \l_@@_tmp_tl { 0 } }
+ \prop_gput:NnV \g_@@_family_int_prop {#2} \l_@@_tmp_tl
+ \tl_gset:Nx \g_@@_nfss_family_tl { #2 ( \l_@@_tmp_tl ) }
+ \prop_gput:NnV \g_@@_fontid_family_prop {#1} \g_@@_nfss_family_tl
+ }
+\cs_generate_variant:Nn \@@_save_fontid_family:nn { VV }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_save_family:nn}
+% Saves the relevant font information for future processing.
+% \begin{macrocode}
+\cs_new:Nn \@@_save_family:nn
+ {
+ \@@_save_fontinfo:n {#2}
+ \@@_find_autofonts:
+ \DeclareFontFamily{\g_@@_nfss_enc_tl}{\g_@@_nfss_family_tl}{}
+ \@@_set_faces:
+ \@@_info:nxx {defining-font} {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_save_fontinfo:n}
+% Saves the relevant font information for future processing.
+% \begin{macrocode}
+\cs_new:Nn \@@_save_fontinfo:n
+ {
+ \prop_new:c {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop}
+ \prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {fontname} { #1 }
+ \prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {options} { \l_@@_all_features_clist }
+ \prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {fontdef}
+ {
+ \@@_construct_font_call:nn {\l_fontspec_fontname_tl}
+ { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist }
+ }
+ \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {script-num} \l_@@_script_int
+ \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {lang-num} \l_@@_language_int
+ \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {script-tag} \l_@@_script_tl
+ \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {lang-tag} \l_@@_lang_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Setting font shapes in a family}
+%
+% All NFSS specifications take their default values, so if any of them
+% are redefined, the shapes will be selected to fit in with the
+% current state. For example, if \cmd\bfdefault\ is redefined to |b|, all
+% bold shapes defined by this package will also be assigned to |b|.
+%
+% The combination shapes are searched first because they use information that may be redefined in the single cases.
+% E.g., if no bold font is specified then |set_autofont| will attempt to set it.
+% This has subtle/small ramifications on the logic of choosing the bold italic font.
+%
+% \begin{macro}{\@@_find_autofonts:}
+% \begin{macrocode}
+\cs_new:Nn \@@_find_autofonts:
+ {
+ \bool_if:nF {\l_@@_noit_bool || \l_@@_nobf_bool}
+ {
+ \@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_@@_fontname_it_tl} {/B}
+ \@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_@@_fontname_bf_tl} {/I}
+ \@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_fontspec_fontname_tl} {/BI}
+ }
+
+ \bool_if:NF \l_@@_nobf_bool
+ {
+ \@@_set_autofont:Nnn \l_@@_fontname_bf_tl {\l_fontspec_fontname_tl} {/B}
+ }
+
+ \bool_if:NF \l_@@_noit_bool
+ {
+ \@@_set_autofont:Nnn \l_@@_fontname_it_tl {\l_fontspec_fontname_tl} {/I}
+ }
+
+ \@@_set_autofont:Nnn \l_@@_fontname_bfsl_tl {\l_@@_fontname_sl_tl} {/B}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_set_faces:}
+% \begin{macrocode}
+\cs_new:Nn \@@_set_faces:
+ {
+ \@@_add_nfssfont:nnnn \mddefault \updefault \l_fontspec_fontname_tl \l_@@_fontfeat_up_clist
+ \@@_add_nfssfont:nnnn \bfdefault \updefault \l_@@_fontname_bf_tl \l_@@_fontfeat_bf_clist
+ \@@_add_nfssfont:nnnn \mddefault \itdefault \l_@@_fontname_it_tl \l_@@_fontfeat_it_clist
+ \@@_add_nfssfont:nnnn \mddefault \sldefault \l_@@_fontname_sl_tl \l_@@_fontfeat_sl_clist
+ \@@_add_nfssfont:nnnn \bfdefault \itdefault \l_@@_fontname_bfit_tl \l_@@_fontfeat_bfit_clist
+ \@@_add_nfssfont:nnnn \bfdefault \sldefault \l_@@_fontname_bfsl_tl \l_@@_fontfeat_bfsl_clist
+
+ \prop_map_inline:Nn \l_@@_nfssfont_prop { \@@_set_faces_aux:nnnnn ##2 }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_set_faces_aux:nnnnn
+ {
+ \fontspec_complete_fontname:Nn \l_@@_curr_fontname_tl {#3}
+ \@@_make_font_shapes:Nnnnn \l_@@_curr_fontname_tl {#1} {#2} {#4} {#5}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_complete_fontname:Nn}
+% This macro defines |#1| as the input with any |*| tokens of its input
+% replaced by the font name. This lets us define supplementary fonts in full
+% (``\texttt{Baskerville Semibold}'') or in abbreviation (``\texttt{* Semibold}'').
+% \begin{macrocode}
+\cs_new:Nn \fontspec_complete_fontname:Nn
+ {
+ \tl_set:Nx #1 {#2}
+ \tl_replace_all:Nnx #1 {*} {\l_@@_basename_tl}
+%<LU> \tl_remove_all:Nn #1 {~}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_add_nfssfont:nnnn}
+% \darg{series}
+% \darg{shape}
+% \darg{fontname}
+% \darg{fontspec features}
+% \begin{macrocode}
+\cs_new:Nn \@@_add_nfssfont:nnnn
+ {
+ \tl_set:Nx \l_@@_this_font_tl {#3}
+
+ \tl_if_empty:xTF {#4}
+ { \clist_set:Nn \l_@@_sizefeat_clist {Size={-}} }
+ { \@@_keys_set_known:nxN {fontspec-preparse-nested} {#4} \l_@@_tmp_tl }
+
+ \tl_if_empty:NF \l_@@_this_font_tl
+ {
+ \prop_put:Nxx \l_@@_nfssfont_prop {#1/#2}
+ { {#1}{#2}{\l_@@_this_font_tl}{#4}{\l_@@_sizefeat_clist} }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Fonts}
+%
+% \begin{macro}{\@@_set_font_type:N}
+% Now check if the font is to be rendered with \ATSUI\ or Harfbuzz. This will either
+% be automatic (based on the font type), or specified by the user via a font feature.
+%
+% This macro sets booleans
+% accordingly depending if the font in \cmd\l_fontspec_test_font\ is an \AAT\
+% font or an OpenType font or a font with feature axes (either \AAT\ or
+% Multiple Master), respectively.
+% \begin{macrocode}
+\cs_new:Nn \@@_set_font_type:N
+ {
+%<debug> \typeout{:: @@_set_font_type:}
+%<*XE>
+ \bool_set_false:N \l_@@_tfm_bool
+ \bool_set_false:N \l_@@_atsui_bool
+ \bool_set_false:N \l_@@_ot_bool
+ \bool_set_false:N \l_@@_mm_bool
+ \bool_set_false:N \l_@@_graphite_bool
+ \ifcase\XeTeXfonttype #1
+%<debug> \typeout{:::: TFM}
+ \bool_set_true:N \l_@@_tfm_bool
+ \or
+%<debug> \typeout{:::: AAT}
+ \bool_set_true:N \l_@@_atsui_bool
+ \tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/AAT} }
+ \ifnum\XeTeXcountvariations #1 > 0\relax
+%<debug> \typeout{:::: MM}
+ \bool_set_true:N \l_@@_mm_bool
+ \fi
+ \or
+%<debug> \typeout{:::: OpenType}
+ \bool_set_true:N \l_@@_ot_bool
+ \tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/OT} }
+ \or
+%<debug> \typeout{:::: Graphite}
+ \bool_set_true:N \l_@@_graphite_bool
+ \tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/GR} }
+ \fi
+%</XE>
+% \end{macrocode}
+% If automatic, the \cmd{\l_@@_renderer_tl} token list will still be
+% empty (other suffices that could be added will be later in the feature
+% processing), and if it is indeed still empty, assign it a value so that the
+% other weights of the font are specifically loaded with the same renderer.
+%
+% LuaTeX only supports one:
+% \begin{macrocode}
+%<*LU>
+ \bool_set_true:N \l_@@_ot_bool
+%</LU>
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_set_autofont:Nnn}
+% \darg{Font name tl}
+% \darg{Base font name}
+% \darg{Font name modifier}
+%
+% This function looks for font with \meta{name} and \meta{modifier} |#2#3|, and if found (i.e., different to font with name |#2|) stores it in tl |#1|. A modifier is something like |/B| to look for a bold font, for example.
+%
+% We can't match external fonts in this way (in \XeTeX\ anyway; todo: test with LuaTeX).
+% If \meta{font name tl} is not empty, then it's already been specified by the user so abort.
+% If \meta{Base font name} is not given, we also abort for obvious reasons.
+%
+% If \meta{font name tl} is empty, then proceed.
+% If not found, \meta{font name tl} remains empty.
+% Otherwise, we have a match.
+% \begin{macrocode}
+\cs_new:Nn \@@_set_autofont:Nnn
+ {
+ \bool_if:NF \l_@@_external_bool
+ {
+ \tl_if_empty:xF {#2}
+ {
+ \tl_if_empty:NT #1
+ {
+ \@@_if_autofont:nnTF {#2} {#3}
+ { \tl_set:Nx #1 {#2#3} }
+ { \@@_info:nx {no-font-shape} {#2#3} }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_if_autofont:nn {T,TF}
+ {
+ \group_begin:
+ \@@_primitive_font_set:Nnn \l_@@_tmpa_font { \@@_construct_font_call:nn {#1} {} } { \f@size pt + 1sp }
+ \@@_primitive_font_set:Nnn \l_@@_tmpb_font { \@@_construct_font_call:nn {#1#2} {} } { \f@size pt + 1sp }
+ \str_if_eq:eeTF { \@@_primitive_font_get_name:N \l_@@_tmpa_font } { \@@_primitive_font_get_name:N \l_@@_tmpb_font }
+ { \group_end: \prg_return_false: }
+ { \group_end: \prg_return_true: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_make_font_shapes:Nnnnn}
+% \darg{Font name}
+% \darg{Font series}
+% \darg{Font shape}
+% \darg{Font features}
+% \darg{Size features}
+% This macro eventually uses \cs{DeclareFontShape} to define the font shape in
+% question.
+% \begin{macrocode}
+\cs_new:Nn \@@_make_font_shapes:Nnnnn
+ {
+ \group_begin:
+ \@@_keys_set_known:nxN {fontspec-preparse-external} { #4 } \l_@@_leftover_clist
+ \@@_load_fontname:Nn \l_fontspec_fontname_tl {#1}
+ \@@_declare_shape:nnxx {#2} {#3} { \l_@@_fontopts_clist, \l_@@_leftover_clist } {#5}
+ \group_end:
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_load_fontname:Nn
+ {
+%<debug> \typeout{:: @@_load_fontname:Nn \exp_not:N #1 (#1) {#2} }
+ \@@_load_external_fontoptions:Nn #1 {#2}
+ \prop_get:NVNF \g_@@_fontopts_prop #1 \l_@@_fontopts_clist
+ { \clist_clear:N \l_@@_fontopts_clist }
+ \keys_set_groups:nnV {fontspec/fontname} {getfontname} \l_@@_fontopts_clist
+ \@@_primitive_font_set:OnnF \l_@@_fontface_cs_tl
+ { \@@_construct_font_call:nn {#1} {} } { \f@size pt }
+ { \@@_error:nx {font-not-found} {#2} }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\keys_define:nn {fontspec/fontname}
+ {
+ Font .tl_set:N = \l_fontspec_fontname_tl ,
+ Font .groups:n = {getfontname} ,
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_declare_shape:nnnn}
+% \darg{Font series}
+% \darg{Font shape}
+% \darg{Font features}
+% \darg{Size features}
+% Wrapper for \cmd\DeclareFontShape.
+% And finally the actual font shape declaration using \cmd\l_@@_nfss_tl\ defined above.
+% \cmd\l_@@_postadjust_tl\ is defined in various places to deal with things like the hyphenation
+% character and interword spacing.
+%
+% The main part is to loop through \feat{SizeFeatures} arguments, which are of the form
+% {\par\centering |SizeFeatures={{<one>},{<two>},{<three>}}|.\par}
+% \begin{macrocode}
+\cs_new:Nn \@@_declare_shape:nnnn
+ {
+%<debug>\typeout{=~ declare_shape:~{\l_fontspec_fontname_tl}~{#1}~{#2}}
+ \tl_build_begin:N \l_@@_nfss_tl
+ \tl_build_begin:N \l_@@_nfss_sc_tl
+ \tl_set_eq:NN \l_@@_saved_fontname_tl \l_fontspec_fontname_tl
+
+ \exp_args:Nx \clist_map_inline:nn {#4} { \@@_setup_single_size:nn {#3} {##1} }
+
+ \tl_build_end:N \l_@@_nfss_tl
+ \tl_build_end:N \l_@@_nfss_sc_tl
+
+ \@@_declare_shapes_normal:nn {#1} {#2}
+ \@@_declare_shapes_smcaps:nn {#1} {#2}
+ \@@_declare_shape_slanted:nn {#1} {#2}
+ \@@_declare_shape_loginfo:nn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_generate_variant:Nn \@@_declare_shape:nnnn {nnxx}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_setup_single_size:nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_setup_single_size:nn
+ {
+ \tl_clear:N \l_@@_size_tl
+ \tl_set_eq:NN \l_@@_sizedfont_tl \l_@@_saved_fontname_tl % in case not spec'ed
+
+ \keys_set_known:nxN {fontspec-sizing} { \exp_after:wN \use:n #2 }
+ \l_@@_sizing_leftover_clist
+ \tl_if_empty:NT \l_@@_size_tl { \@@_error:n {no-size-info} }
+%<debug>\typeout{==~ size:~\l_@@_size_tl}
+
+ % "normal"
+ \@@_load_fontname:Nn \l_fontspec_fontname_tl {\l_@@_sizedfont_tl}
+ \@@_setup_nfss:Nnnn \l_@@_nfss_tl {#1} {\l_@@_sizing_leftover_clist} {}
+%<debug> \typeout{===~ sized~ font:~ \l_@@_sizedfont_tl}
+
+ % small caps
+ \clist_set_eq:NN \l_@@_fontfeat_curr_clist \l_@@_fontfeat_sc_clist
+
+ \bool_if:NF \l_@@_nosc_bool
+ {
+ \tl_if_empty:NTF \l_@@_fontname_sc_tl
+ {
+ \@@_make_smallcaps:TF
+ {
+%<debug>\typeout{====~Small~ caps~ found.}
+ \clist_put_left:Nn \l_@@_fontfeat_curr_clist {Letters=SmallCaps}
+ }
+ {
+%<debug>\typeout{====~Small~ caps~ not~ found.}
+ \bool_set_true:N \l_@@_nosc_bool
+ }
+ }
+ { \@@_load_fontname:Nn \l_fontspec_fontname_tl {\l_@@_fontname_sc_tl} }% local for each size
+ }
+
+ \bool_if:NF \l_@@_nosc_bool
+ {
+ \@@_setup_nfss:Nnnn \l_@@_nfss_sc_tl
+ {#1} {\l_@@_sizing_leftover_clist} {\l_@@_fontfeat_curr_clist}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_setup_nfss:Nnnn}
+% \begin{macrocode}
+\cs_new:Nn \@@_setup_nfss:Nnnn
+ {
+%<debug>\typeout{====~Setup~NFSS~shape:~<\l_@@_size_tl>~\l_fontspec_fontname_tl}
+
+ \@@_get_features:n { #2 , #3 , #4 }
+%<debug>\typeout{====~Gathered~features:~\g_@@_rawfeatures_sclist}
+
+ \tl_if_empty:NF \l_@@_scale_tl
+ {
+ \tl_set:Nx \l_@@_scale_tl { s*[\l_@@_scale_tl] }
+ }
+
+ \tl_build_put_right:Nx #1
+ {
+ <\l_@@_size_tl> \l_@@_scale_tl
+ \@@_construct_font_call:nn { \l_fontspec_fontname_tl }
+ { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_declare_shapes_normal:nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_declare_shapes_normal:nn
+ {
+ \@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl}
+ {#1} {#2} {\l_@@_nfss_tl}{\l_@@_postadjust_tl}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_declare_shapes_smcaps:nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_declare_shapes_smcaps:nn
+ {
+ \tl_if_empty:NF \l_@@_nfss_sc_tl
+ {
+ \@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} {#1}
+ { \@@_combo_sc_shape:n {#2} } {\l_@@_nfss_sc_tl} {\l_@@_postadjust_tl}
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_combo_sc_shape:n
+ {
+ \tl_if_exist:cTF { \@@_shape_merge:nn {#1} {\scdefault} }
+ { \tl_use:c { \@@_shape_merge:nn {#1} {\scdefault} } }
+ { \scdefault }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_DeclareFontShape:nnnnnn}
+% \begin{macrocode}
+\cs_new:Nn \@@_DeclareFontShape:nnnnnn
+ {
+%<debug>\typeout{DeclareFontShape:~{#1}{#2}{#3}{#4}...}
+ \group_begin:
+ \normalsize
+ \cs_undefine:c {#1/#2/#3/#4/\f@size}
+ \group_end:
+ \DeclareFontShape{#1}{#2}{#3}{#4}{#5}{#6}
+ }
+\cs_generate_variant:Nn \@@_DeclareFontShape:nnnnnn {xxxxxx}
+% \end{macrocode}
+%
+% \begin{macro}{\@@_declare_shape_slanted:nn}
+% This extra stuff for the slanted shape substitution is a little bit awkward.
+% We define the slanted shape to be a synonym for it when (a)~we're defining an italic font, but also (b)~when the default slanted shape isn't `it'.
+% (Presumably this turned up once in a test and I realised it caused problems. I doubt this would happen much.)
+%
+% We should test when a slanted font has been specified and not run this code if so, but the \verb|\@@_set_slanted:| code will overwrite this anyway if necessary.
+% \begin{macrocode}
+\cs_new:Nn \@@_declare_shape_slanted:nn
+ {
+ \bool_if:nT
+ {
+ \str_if_eq_p:ee {#2} {\itdefault} &&
+ !(\str_if_eq_p:ee {\itdefault} {\sldefault})
+ }
+ {
+ \@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl}{\g_@@_nfss_family_tl}{#1}{\sldefault}
+ {<->ssub*\g_@@_nfss_family_tl/#1/\itdefault}{\l_@@_postadjust_tl}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_declare_shape_loginfo:nn}
+% Lastly some informative messaging.
+% \begin{macrocode}
+\cs_new:Nn \@@_declare_shape_loginfo:nn
+ {
+ \tl_gput_right:Nx \g_@@_defined_shapes_tl
+ {
+ \exp_not:n { \\ }
+ -~ \exp_not:N \str_case:nn {#1/#2}
+ {
+ {\mddefault/\updefault} {'normal'~}
+ {\bfdefault/\updefault} {'bold'~}
+ {\mddefault/\itdefault} {'italic'~}
+ {\mddefault/\sldefault} {'slanted'~}
+ {\bfdefault/\itdefault} {'bold~ italic'~}
+ {\bfdefault/\sldefault} {'bold~ slanted'~}
+ } (#1/#2)~
+ with~ NFSS~ spec.:~
+ \l_@@_nfss_tl
+ \exp_not:n { \\ }
+ -~ \exp_not:N \str_case:nn { #1 / \@@_combo_sc_shape:n {#2} }
+ {
+ {\mddefault/\scdefault} {'small~ caps'~}
+ {\bfdefault/\scdefault} {'bold~ small~ caps'~}
+ {\mddefault/\itscdefault} {'italic~ small~ caps'~}
+ {\bfdefault/\itscdefault} {'bold~ italic~ small~ caps'~}
+ {\mddefault/\slscdefault} {'slanted~ small~ caps'~}
+ {\bfdefault/\slscdefault} {'bold~ slanted~ small~ caps'~}
+ }~( #1 / \@@_combo_sc_shape:n {#2} )~
+ with~ NFSS~ spec.:~
+ \l_@@_nfss_sc_tl
+ \tl_if_empty:fF {\l_@@_postadjust_tl}
+ {
+ \exp_not:N \\ and~ font~ adjustment~ code:
+ \exp_not:N \\ \l_@@_postadjust_tl
+ }
+ }
+ }
+% \end{macrocode}
+% Maybe |\str_if_eq:eeF| would be better?
+% \end{macro}
+%
+%
+% \subsubsection{Features}
+%
+% \begin{macro}{\l_@@_pre_feat_sclist}
+% These are the features always applied to a font selection before other
+% features.
+% \begin{macrocode}
+\tl_set:Nn \l_@@_pre_feat_sclist
+%<*XE>
+ {
+ \bool_if:NT \l_@@_ot_bool
+ {
+ \tl_if_empty:NF \l_@@_script_tl
+ {
+ script = \l_@@_script_tl ;
+ language = \l_@@_lang_tl ;
+ }
+ }
+ }
+%</XE>
+%<*LU>
+ {
+ mode = \l_@@_mode_tl ;
+ \tl_if_empty:NF \l_@@_shaper_tl
+ {
+ shaper = \l_@@_shaper_tl ;
+ }
+ \tl_if_empty:NF \l_@@_script_tl
+ {
+ script = \l_@@_script_tl ;
+ language = \l_@@_lang_tl ;
+ }
+ }
+%</LU>
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@_make_ot_smallcaps:TF}
+% \label{mac:makesmallcaps}
+% This macro checks if the font contains small caps.
+% \begin{macrocode}
+%<LU>\cs_new:Nn \@@_make_smallcaps:TF
+%<XE>\cs_new:Nn \@@_make_ot_smallcaps:TF
+ {
+ \exp_args:No \@@_check_ot_feat:NnTF \l_@@_fontface_cs_tl {smcp} {#1} {#2}
+ }
+%<*XE>
+\cs_new:Nn \@@_make_smallcaps:TF
+ {
+ \bool_if:NTF \l_@@_ot_bool
+ { \@@_make_ot_smallcaps:TF {#1} {#2} }
+ {
+ \bool_if:NT \l_@@_atsui_bool
+ {
+ \exp_args:No \@@_make_AAT_feature_string:NnnTF
+ \l_@@_fontface_cs_tl {3} {3} {#1} {#2}
+ }
+ }
+ }
+%</XE>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_update_featstr:n}
+% \cmd{\g_@@_rawfeatures_sclist} is the string used to define the list of specific
+% font features. Each time another font feature is requested, this
+% macro is used to add that feature to the list. Font features are
+% separated by semicolons.
+% \begin{macrocode}
+\cs_new:Nn \@@_update_featstr:n
+ {
+%<debug> \typeout{:::: @@_update_featstr:n {#1}}
+ \bool_if:NF \l_@@_firsttime_bool
+ {
+ \tl_gset:Nx \g_@@_single_feat_tl { #1 }
+%<debug> \typeout{::::~ Adding~ feature.}
+ \tl_gput_right:Nx \g_@@_rawfeatures_sclist {#1;}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_remove_clashing_featstr:n}
+% \begin{macrocode}
+\cs_new:Nn \@@_remove_clashing_featstr:n
+ {
+%<debug> \typeout{:::: @@_remove_clashing_featstr:n {#1}}
+ \clist_map_inline:nn {#1}
+ {
+%<debug> \typeout{::::~ Removing~ feature~ "##1;"}
+ \tl_gremove_all:Nn \g_@@_rawfeatures_sclist {##1;}
+ }
+ }
+\cs_generate_variant:Nn \@@_remove_clashing_featstr:n {x}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Initialisation}
+%
+% \begin{macro}{\@@_init:}
+% Initialisations that need to occur once per fontspec font invocation.
+% (Some of these may be redundant.
+% Check whether they're assigned to globally or not.)
+% \begin{macrocode}
+\cs_set:Npn \@@_init:
+ {
+%<debug> \typeout{:: @@_init:}
+ \bool_set_false:N \l_@@_ot_bool
+ \bool_set_true:N \l_@@_firsttime_bool
+ \@@_font_is_name:
+ \tl_clear:N \l_@@_font_path_tl
+ \tl_clear:N \l_@@_optical_size_tl
+ \tl_clear:N \l_@@_ttc_index_tl
+ \tl_clear:N \l_@@_renderer_tl
+ \tl_gclear:N \g_@@_defined_shapes_tl
+ \tl_gclear:N \g_@@_curr_series_tl
+ \tl_gset_eq:NN \g_@@_nfss_enc_tl \g_fontspec_encoding_tl
+%<*LU>
+ \tl_set:Nn \l_@@_mode_tl {node}
+ \int_set:Nn \prehyphenchar { `\- } % fixme
+ \int_zero:N \posthyphenchar % fixme
+ \int_zero:N \preexhyphenchar % fixme
+ \int_zero:N \postexhyphenchar % fixme
+%</LU>
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_init_fontface:}
+% Executed in \cs{@@_get_features:Nn}.
+% \begin{macrocode}
+\cs_new:Nn \@@_init_fontface:
+ {
+ \tl_gclear:N \g_@@_rawfeatures_sclist
+ \tl_clear:N \l_@@_scale_tl
+ \tl_set_eq:NN \l_@@_opacity_tl \c_@@_opacity_tl
+ \tl_set_eq:NN \l_@@_hexcol_tl \c_@@_hexcol_tl
+ \tl_set_eq:NN \l_@@_postadjust_tl \c_@@_postadjust_tl
+ \tl_clear:N \l_@@_wordspace_adjust_tl
+ \tl_clear:N \l_@@_punctspace_adjust_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Miscellaneous}
+%
+% \begin{macro}{\@@_ot_validate_tag:n}
+% This macro takes an OpenType tag and validates it.
+% \begin{macrocode}
+%<*LU>
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_ot_validate_tag:n
+ {
+ \@@_ot_validate_tag:w #1 \q_nil
+ }
+\cs_generate_variant:Nn \@@_ot_validate_tag:n {x}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set:Npn \@@_ot_validate_tag:w #1 #2 \q_nil
+ {
+ \bool_if:nTF { \str_if_eq_p:nn {#1} {+} || \str_if_eq_p:nn {#1} {-} }
+ { \@@_ot_validate_tag_aux:w #2 \c_empty_tl \c_empty_tl \q_nil }
+ { \@@_ot_validate_tag_aux:w #1#2 \c_empty_tl \c_empty_tl \q_nil }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set:Npn \@@_ot_validate_tag_aux:w #1#2#3#4#5 \q_nil
+ {
+ \int_compare:nT { \tl_count:n {#5} > 2 }
+ { \@@_error:nx {ot-tag-too-long} {#1#2#3#4#5} }
+ }
+% \end{macrocode}
+% \begin{macrocode}
+%</LU>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_iv_str_to_num:Nn}
+% This macro takes a four character string and converts it to the
+% numerical representation required for \XeTeX\ OpenType script/language/feature
+% purposes. The output is stored in |#1|.
+%
+% This code is not used in Lua\TeX, as the checking for that engine is done via Lua code
+% provided by \pkg{luaotfload}.
+% \begin{macrocode}
+%<*XE>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_iv_str_to_num:Nn
+ {
+%<debug>\typeout{_iv_str_to_num:~#1~/~#2}
+ \@@_strip_leading_sign:Nw #1#2 \q_nil
+ }
+\cs_generate_variant:Nn \@@_iv_str_to_num:Nn {Nx}
+% \end{macrocode}
+%
+% The input can be of the form of any of these:
+% `|abcd|', `|abc|', `|abc |', `|ab|', `|ab |', \etc.
+% (It is assumed the first two chars are \emph{always} not spaces.) So this macro
+% reads in the string padded with \cmd\@empty s,
+% and anything beyond four chars is snipped. The \cmd\@empty s then are used to reconstruct
+% the spaces in the string to number calculation.
+%
+% For backwards compatibility this code also strips a leading |+| or |-|.
+%
+% \begin{macrocode}
+\cs_set:Npn \@@_strip_leading_sign:Nw #1#2#3 \q_nil
+ {
+ \bool_if:nTF { \str_if_eq_p:nn {#2} {+} || \str_if_eq_p:nn {#2} {-} }
+ { \@@_iv_str_to_num:w #1 \q_nil #3 \c_empty_tl \c_empty_tl \q_nil }
+ { \@@_iv_str_to_num:w #1 \q_nil #2#3 \c_empty_tl \c_empty_tl \q_nil }
+ }
+% \end{macrocode}
+% If input string (after sign is stripped) is more than 4 chars, \verb|#6| will contain
+% `\meta{excess}\cs{c_empty_tl}\cs{c_empty_tl}'. Therefore use \verb|#6| to verify string length.
+% \begin{macrocode}
+\cs_set:Npn \@@_iv_str_to_num:w #1 \q_nil #2#3#4#5#6 \q_nil
+ {
+ \int_compare:nT { \tl_count:n {#6} > 2 }
+ { \@@_error:nx {ot-tag-too-long} {#2#3#4#5#6} }
+
+ \int_set:Nn #1
+ {
+ `#2 * "1000000
+ + `#3 * "10000
+ + \ifx \c_empty_tl #4 32 \else `#4 \fi * "100
+ + \ifx \c_empty_tl #5 32 \else `#5 \fi
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</XE>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_lang_dflt_correct:N}
+% \begin{macrocode}
+%<*XE>
+\cs_new_protected:Nn \@@_lang_dflt_correct:N
+ {
+ \int_compare:nNnT {#1} = {1145457748} % "DFLT"
+ {
+ \int_zero:N #1
+ }
+ }
+%</XE>
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-keyval.dtx b/macros/latex/contrib/fontspec/fontspec-code-keyval.dtx
new file mode 100644
index 0000000000..b68bb8bbde
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-keyval.dtx
@@ -0,0 +1,903 @@
+%%^^A%% fontspec-code-keyval.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Font loading (\pkg{keyval}) definitions}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% This package uses a large number of keyval modules which operate sequentially on keyval
+% input to ensure priority.
+% \begin{macrocode}
+\clist_gset:Nn \g_@@_all_keyval_modules_clist
+ {
+ fontspec, fontspec-opentype, fontspec-aat,
+ fontspec-preparse, fontspec-preparse-cfg, fontspec-preparse-external, fontspec-preparse-nested,
+ fontspec-renderer
+ }
+% \end{macrocode}
+%
+% Wrapper function to save some characters in the source:
+% \begin{macrocode}
+\cs_new:Nn \@@_keys_define_code:nnn
+ {
+ \keys_define:nn {#1} { #2 .code:n = {#3} }
+ }
+% \end{macrocode}
+%
+% For catching features that cannot be used in |\addfontfeatures|:
+% \begin{macrocode}
+\cs_new:Nn \@@_aff_error:n
+ {
+ \@@_keys_define_code:nnn {fontspec-addfeatures} {#1}
+ { \@@_error:nx {not-in-addfontfeatures} {#1} }
+ }
+% \end{macrocode}
+%
+% \subsection{Pre-pre-parsing stages}
+%
+% These features are extracted from the font feature list before all others.
+%
+% \paragraph{Don't load font config file}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-cfg} {IgnoreFontspecFile}
+ {
+ \bool_set_false:N \l_@@_fontcfg_bool
+ }
+\@@_keys_define_code:nnn {fontspec-preparse-external} {IgnoreFontspecFile}
+ {
+ \bool_set_false:N \l_@@_fontcfg_bool
+ }
+% \end{macrocode}
+%
+% \begin{macro}{Path}
+% For fonts that aren't installed in the system. If no argument is given, the font is located
+% with |kpsewhich|; it's either in the current directory or the \TeX\ tree. Otherwise, the
+% argument given defines the file path of the font.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {Path}
+ {
+ \bool_set_true:N \l_@@_nobf_bool
+ \bool_set_true:N \l_@@_noit_bool
+ \bool_set_true:N \l_@@_external_bool
+ \tl_set:Nn \l_@@_font_path_tl {#1}
+ \@@_font_is_file:
+%<*XE>
+ \keys_set:nn {fontspec-renderer} {Renderer=OpenType}
+%</XE>
+ }
+\aliasfontfeature{Path}{ExternalLocation}
+\@@_keys_define_code:nnn {fontspec} {Path} {}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{\feat{Extension}}
+% For fonts that aren't installed in the system. Specifies the font extension
+% to use.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {Extension}
+ {
+ \tl_set:Nn \l_@@_extension_tl {#1}
+ \bool_if:NF \l_@@_external_bool
+ {
+ \keys_set:nn {fontspec-preparse-external} {Path}
+ }
+ }
+\tl_clear:N \l_@@_extension_tl
+\@@_keys_define_code:nnn {fontspec} {Extension} {}
+% \end{macrocode}
+%
+%
+% \paragraph{\feat{Renderer}}
+% This feature must be processed before all others (the other font shape and features
+% options are also pre-parsed for convenience) because the renderer determines the format
+% of the features and whether certain features are available.
+% \begin{macrocode}
+%<*XE>
+\keys_define:nn {fontspec-renderer}
+ {
+ Renderer .choices:nn =
+ {AAT,ICU,OpenType,Graphite,Full,Basic,Node,Base,Harfbuzz}
+ {
+ \int_compare:nTF {\l_keys_choice_int <= 4}
+ {
+ \tl_set:Nx \l_@@_renderer_tl
+ {
+ \int_case:nn \l_keys_choice_int { 1 {/AAT} 2 {/OT} 3 {/OT} 4 {/GR} }
+ }
+%<debug>\typeout{Renderer:~ \l_@@_renderer_tl}
+ \tl_gset:Nx \g_@@_single_feat_tl { \l_@@_renderer_tl }
+ }
+ {
+ \@@_warning:nx {only-luatex-feature} {Renderer=Full/Basic/Node/Base/Harfbuzz}
+ }
+ }
+ }
+%</XE>
+%<*LU>
+\keys_define:nn {fontspec-renderer}
+ {
+ Renderer .choices:nn =
+ {Full,Node,Basic,Base,Harfbuzz,OpenType,AAT,Graphite}
+ {
+ \int_compare:nTF {\l_keys_choice_int >= 5} { \bool_set_true:N \l_@@_harfbuzz_bool }
+
+ \tl_set:Nx \l_@@_mode_tl
+ {
+ \int_case:nn \l_keys_choice_int { 1 {node} 2 {node} 3 {base} 4 {base} 5 {harf} 6 {harf} 7 {harf} 8 {harf} }
+ }
+
+ \tl_set:Nx \l_@@_shaper_tl
+ {
+ \int_case:nn \l_keys_choice_int { 1 {} 2 {} 3 {} 4 {} 5 {} 6 {ot} 7 {coretext_aat} 8 {graphite2} }
+ }
+
+%<debug>\typeout{Mode:~"\l_@@_mode_tl"~/~Shaper:~"\l_@@_shaper_tl"}
+
+ \tl_gset:Nx \g_@@_single_feat_tl
+ {
+ mode=\l_@@_mode_tl ;
+ \tl_if_empty:NF \l_@@_shaper_tl { shaper=\l_@@_shaper_tl}
+ }
+ } ,
+
+ Renderer unknown .code:n =
+ {
+ \bool_set_true:N \l_@@_harfbuzz_bool
+ \@@_warning:nx {unknown-renderer} {#1}
+ \tl_set:Nn \l_@@_mode_tl {harf}
+ \tl_set:Nn \l_@@_shaper_tl {#1}
+ } ,
+ }
+%</LU>
+% \end{macrocode}
+%
+% \subsection{Pre-parsed features}
+%
+% \paragraph{OpenType script/language}
+% See later for the resolutions from \pkg{fontspec} features to OpenType definitions.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {Script}
+ {
+%<XE> \keys_set:nn {fontspec-renderer} {Renderer=OpenType}
+ \tl_set:Nn \l_@@_script_name_tl {#1}
+ }
+% \end{macrocode}
+% Exactly the same:
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {Language}
+ {
+%<XE> \keys_set:nn {fontspec-renderer} {Renderer=OpenType}
+ \tl_set:Nn \l_@@_lang_name_tl {#1}
+ }
+% \end{macrocode}
+%
+%
+% \paragraph{TTC font index}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {FontIndex}
+ {
+ \str_if_eq:eeF { \str_lower_case:f {\l_@@_extension_tl} } {.ttc}
+ { \@@_warning:n {font-index-needs-ttc} }
+%<XE> \tl_set:Nn \l_@@_ttc_index_tl {:#1}
+%<LU> \tl_set:Nn \l_@@_ttc_index_tl {(#1)}
+ }
+\@@_keys_define_code:nnn {fontspec} {FontIndex}
+ {
+%<XE> \tl_set:Nn \l_@@_ttc_index_tl {:#1}
+%<LU> \tl_set:Nn \l_@@_ttc_index_tl {(#1)}
+ }
+% \end{macrocode}
+%
+% \subsection{Font faces}
+%
+% \paragraph{Upright}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {UprightFont}
+ {
+ \fontspec_complete_fontname:Nn \l_@@_fontname_up_tl {#1}
+ }
+% \end{macrocode}
+%
+% \paragraph{Italic and slanted}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {ItalicFont}
+ {
+ \tl_if_empty:nTF {#1}
+ {
+ \bool_set_true:N \l_@@_noit_bool
+ }
+ {
+ \bool_set_false:N \l_@@_noit_bool
+ \fontspec_complete_fontname:Nn \l_@@_fontname_it_tl {#1}
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {SlantedFont}
+ {
+ \fontspec_complete_fontname:Nn \l_@@_fontname_sl_tl {#1}
+ }
+% \end{macrocode}
+%
+%
+% \paragraph{Bold (NFSS) Series}
+% By default, \pkg{fontspec} uses the default bold series, \cs{bfdefault}.
+% We want to be able to make this extensible. This code is not yet functional!
+% \begin{macrocode}
+%\@@_keys_define_code:nnn {fontspec-preparse-external} {BoldSeries}
+% {
+% \tl_gset:Nx \g_@@_curr_series_tl { #1 }
+% \seq_put_right:Nx \l_@@_bf_series_seq { #1 }
+% }
+% \end{macrocode}
+%
+% \paragraph{Bold}
+% This contains some stubb code to allow more than one bold font to be loaded.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {BoldFont}
+ {
+ \tl_if_empty:nTF {#1}
+ {
+ \bool_set_true:N \l_@@_nobf_bool
+ }
+ {
+ \bool_set_false:N \l_@@_nobf_bool
+ \fontspec_complete_fontname:Nn \l_@@_curr_bfname_tl {#1}
+
+ \seq_if_empty:NT \l_@@_bf_series_seq
+ {
+ \tl_gset:Nx \g_@@_curr_series_tl {\bfdefault}
+ \seq_put_right:Nx \l_@@_bf_series_seq {\bfdefault}
+ }
+
+ \tl_if_eq:oxT \g_@@_curr_series_tl {\bfdefault}
+ {
+ \tl_set_eq:NN \l_@@_fontname_bf_tl \l_@@_curr_bfname_tl
+ }
+
+ \prop_put:NxV \l_@@_nfss_prop {BoldFont-\g_@@_curr_series_tl} \l_@@_curr_bfname_tl
+
+%<debug>\typeout{Setting~bold~font~"\l_@@_curr_bfname_tl"~with~series~"\g_@@_curr_series_tl"}
+
+ }
+ }
+% \end{macrocode}
+%
+% \paragraph{Bold italic/slanted}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {BoldItalicFont}
+ {
+ \fontspec_complete_fontname:Nn \l_@@_fontname_bfit_tl {#1}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {BoldSlantedFont}
+ {
+ \fontspec_complete_fontname:Nn \l_@@_fontname_bfsl_tl {#1}
+ }
+% \end{macrocode}
+%
+% \paragraph{Small caps}
+% Small caps isn't pre-parsed because it can vary with others above:
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {SmallCapsFont}
+ {
+ \tl_if_empty:nTF {#1}
+ {
+ \bool_set_true:N \l_@@_nosc_bool
+ }
+ {
+ \bool_set_false:N \l_@@_nosc_bool
+ \fontspec_complete_fontname:Nn \l_@@_fontname_sc_tl {#1}
+ }
+ }
+% \end{macrocode}
+%
+%
+% \subsubsection{Preparsed font features}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {UprightFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_up_clist {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-preparse} {BoldFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_bf_clist {#1}
+
+% \prop_put:NxV \l_@@_nfss_prop
+% {BoldFont-\g_@@_curr_series_tl} \l_@@_curr_bfname_tl
+ }
+\@@_keys_define_code:nnn {fontspec-preparse} {ItalicFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_it_clist {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-preparse} {BoldItalicFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_bfit_clist {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-preparse} {SlantedFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_sl_clist {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-preparse} {BoldSlantedFeatures}
+ {
+ \clist_set:Nn \l_@@_fontfeat_bfsl_clist {#1}
+ }
+% \end{macrocode}
+% Note that small caps features can vary by shape, so these in fact \emph{aren't} pre-parsed.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {SmallCapsFeatures}
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ {
+ \clist_set:Nn \l_@@_fontfeat_sc_clist {#1}
+ }
+ }
+% \end{macrocode}
+%
+% \paragraph{Features varying by size}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {SizeFeatures}
+ {
+ \clist_set:Nn \l_@@_sizefeat_clist {#1}
+ \clist_put_right:Nn \l_@@_fontfeat_up_clist { SizeFeatures = {#1} }
+ }
+\@@_keys_define_code:nnn {fontspec-preparse-nested} {SizeFeatures}
+ {
+ \clist_set:Nn \l_@@_sizefeat_clist {#1}
+ \tl_if_empty:NT \l_@@_this_font_tl
+ { \tl_set:Nn \l_@@_this_font_tl { -- } } % needs to be non-empty as a flag
+ }
+\@@_keys_define_code:nnn {fontspec-preparse-nested} {Font}
+ {
+ \tl_set:Nn \l_@@_this_font_tl {#1}
+ }
+\@@_keys_define_code:nnn {fontspec} {SizeFeatures}
+ {
+ % dummy
+ }
+\@@_keys_define_code:nnn {fontspec} {Font}
+ {
+ % dummy
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-sizing} {Size}
+ {
+ \tl_set:Nn \l_@@_size_tl {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-sizing} {Font}
+ {
+ \fontspec_complete_fontname:Nn \l_@@_sizedfont_tl {#1}
+ }
+% \end{macrocode}
+%
+%
+%
+% \subsection{General font-independent features}
+%
+% These features can be applied to any font.
+%
+% \paragraph{NFSS encoding}
+% For the very brave.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {NFSSEncoding}
+ {
+ \tl_gset:Nx \g_@@_nfss_enc_tl { #1 }
+ }
+% \end{macrocode}
+%
+% \paragraph{NFSS family}
+% Interactions with other packages will sometimes require setting the NFSS family explicitly.
+% (By default \pkg{fontspec} auto-generates one based on the font name.)
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {NFSSFamily}
+ {
+ \tl_set:Nx \l_@@_nfss_fam_tl { #1 }
+ }
+% \end{macrocode}
+%
+% \paragraph{NFSS series/shape}
+% This option looks similar in name but has a very different function.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse} {FontFace}
+ {
+ \tl_clear:N \l_@@_this_font_tl
+ \clist_set:No \l_@@_arg_clist { \use_iii:nnn #1 }
+ \clist_set_eq:NN \l_@@_this_feat_clist \l_@@_arg_clist
+ \int_compare:nT { \clist_count:N \l_@@_arg_clist = 1 }
+ {
+%<debug>\typeout{FontFace~ parsing:~ one~ clist~ item}
+ \tl_if_in:NnF \l_@@_arg_clist {=}
+ {
+%<debug>\typeout{FontFace~ parsing:~ no~ equals~ =>~ font~ name~ only}
+ \tl_set_eq:NN \l_@@_this_font_tl \l_@@_arg_clist
+ \tl_clear:N \l_@@_this_feat_clist
+ }
+ }
+
+ \@@_add_nfssfont:nnnn
+ {\use_i:nnn #1} {\use_ii:nnn #1} {\l_@@_this_font_tl} {\l_@@_this_feat_clist}
+ }
+% \end{macrocode}
+%
+%
+%
+% \paragraph{Scale}
+% If the input isn't one of the pre-defined string options, then
+% it's gotta be numerical. \cs{fontspec_calc_scale:n} does all the work in
+% the auto-scaling cases.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {Scale}
+ {
+ \str_case:nnF {#1}
+ {
+ {MatchLowercase} { \@@_calc_scale:n {5} }
+ {MatchUppercase} { \@@_calc_scale:n {8} }
+ }
+ { \tl_set:Nx \l_@@_scale_tl {#1} }
+ }
+% \end{macrocode}
+%
+% \paragraph{ScaleAgain}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {ScaleAgain}
+ {
+ \tl_if_empty:NT \l_@@_scale_tl { \tl_set:Nn \l_@@_scale_tl {1} }
+ \tl_set:Nx \l_@@_scale_tl { \fp_eval:n { #1 * \l_@@_scale_tl } }
+ \@@_info:n {set-scale}
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\@@_calc_scale:n}
+% This macro calculates the amount of scaling between the default
+% roman font and the (default shape of) the font being selected such
+% that the font dimension that is input is equal for both. The only
+% font dimensions that justify this are 5 (lowercase height)
+% and 8 (uppercase height in \XeTeX).
+%
+% This script is executed for every extra shape, which seems wasteful,
+% but allows alternate italic shapes from a separate font, say, to
+% be loaded and to be auto-scaled correctly. Even if this would be ugly.
+%
+% To begin, change to \cs{rmfamily} but use internal commands in case cs{rmfamily}
+% has been overwritten.
+% (Note that changing \cs{rmfamily} with fontspec resets \cs{encodingdefault}
+% appropriately.)
+% \begin{macrocode}
+\cs_new:Nn \@@_calc_scale:n
+ {
+ \group_begin:
+
+ \fontencoding { \encodingdefault }
+ \fontfamily { \rmdefault }
+ \selectfont
+
+ \@@_set_font_dimen:NnN \l_@@_tmpa_dim {#1} \font
+ \@@_set_font_dimen:NnN \l_@@_tmpb_dim {#1} \l_@@_fontface_cs_tl
+
+ \tl_set:Nx \l_@@_scale_tl
+ {
+ \fp_eval:n { \dim_to_fp:n {\l_@@_tmpa_dim} /
+ \dim_to_fp:n {\l_@@_tmpb_dim} }
+ }
+
+ \@@_info:n {set-scale}
+ \exp_args:NNNx
+ \group_end:
+ \tl_set:Nx \l_@@_scale_tl { \l_@@_scale_tl }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@_set_font_dimen:NnN}
+% This function sets the dimension |#1| (for font |#3|) to `fontdimen' |#2|
+% for either font dimension 5 (x-height) or 8 (cap-height). If, for some
+% reason, these return an incorrect `zero' value (as \cs{fontdimen8} might
+% for a \texttt{.tfm} font), then we cheat and measure the height of a glyph.
+% We assume in this case that the font contains either an `X' or an `x'.
+% \begin{macrocode}
+\cs_new:Nn \@@_set_font_dimen:NnN
+ {
+ \dim_set:Nn #1 { \fontdimen #2 #3 }
+ \dim_compare:nNnT #1 = {0pt}
+ {
+ \settoheight #1
+ {
+ \str_if_eq:nnTF {#3} {\font} \rmfamily #3
+ \int_case:nnF #2
+ {
+ {5} {x} % x-height
+ {8} {X} % cap-height
+ } {?} % "else" clause; never reached.
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \paragraph{Inter-word space}
+% These options set the relevant \cmd\fontdimen s for the
+% font being loaded.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {WordSpace}
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ { \_fontspec_parse_wordspace:w #1,,,\q_stop }
+ }
+\@@_aff_error:n {WordSpace}
+% \end{macrocode}
+%
+% \begin{macro}{\_fontspec_parse_wordspace:w}
+% This macro determines if the input to \feat{WordSpace} is
+% of the form |{X}| or |{X,Y,Z}| and executes the font scaling.
+% If the former input, it executes |{X,X,X}|.
+% \begin{macrocode}
+\cs_set:Npn \_fontspec_parse_wordspace:w #1,#2,#3,#4 \q_stop
+ {
+ \tl_if_empty:nTF {#4}
+ {
+ \tl_set:Nn \l_@@_wordspace_adjust_tl
+ {
+ \fontdimen 2 \font = #1 \fontdimen 2 \font
+ \fontdimen 3 \font = #1 \fontdimen 3 \font
+ \fontdimen 4 \font = #1 \fontdimen 4 \font
+ }
+ }
+ {
+ \tl_set:Nn \l_@@_wordspace_adjust_tl
+ {
+ \fontdimen 2 \font = #1 \fontdimen 2 \font
+ \fontdimen 3 \font = #2 \fontdimen 3 \font
+ \fontdimen 4 \font = #3 \fontdimen 4 \font
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Punctuation space}
+% Scaling factor for the nominal \cmd\fontdimen \#7.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {PunctuationSpace}
+ {
+ \str_case_e:nnF {#1}
+ {
+ {WordSpace}
+ {
+ \tl_set:Nn \l_@@_punctspace_adjust_tl
+ { \fontdimen 7 \font = 0 \fontdimen 2 \font }
+ }
+ {TwiceWordSpace}
+ {
+ \tl_set:Nn \l_@@_punctspace_adjust_tl
+ { \fontdimen 7 \font = 1 \fontdimen 2 \font }
+ }
+ }
+ {
+ \tl_set:Nn \l_@@_punctspace_adjust_tl
+ { \fontdimen 7 \font = #1 \fontdimen 7 \font }
+ }
+ }
+\@@_aff_error:n {PunctuationSpace}
+% \end{macrocode}
+%
+% \paragraph{Secret hook into the font-adjustment code}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {FontAdjustment}
+ {
+ \tl_put_right:Nx \l_@@_postadjust_tl {#1}
+ }
+% \end{macrocode}
+%
+% \paragraph{Letterspacing}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {LetterSpace}
+ {
+ \@@_update_featstr:n {letterspace=#1}
+ }
+% \end{macrocode}
+%
+% \paragraph{Hyphenation character}
+% This feature takes one of three arguments: `\opt{None}',
+% \meta{glyph}, or \meta{slot}. If the input isn't the first,
+% and it's one character, then it's the second; otherwise, it's
+% the third.
+%
+% LuaTeX decouples hyphenation from font settings, so only \verb|HyphenChar=None| works
+% for that engine.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {HyphenChar}
+ {
+ \str_if_eq:nnTF {#1} {None}
+ {
+ \tl_put_right:Nn \l_@@_postadjust_tl
+ { \@@_primitive_font_set_hyphenchar:Nn \font {-1} }
+ }
+ {
+ \@@_warning:nx {only-xetex-feature} {HyphenChar}
+
+ \tl_if_single:nTF {#1}
+ { \tl_set:Nn \l_@@_hyphenchar_tl {`#1} }
+ { \tl_set:Nn \l_@@_hyphenchar_tl { #1} }
+
+ \exp_args:No \@@_primitive_font_glyph_if_exist:NnTF \l_@@_fontface_cs_tl {\l_@@_hyphenchar_tl}
+ {
+ \tl_put_right:Nn \l_@@_postadjust_tl
+ { \@@_primitive_font_set_hyphenchar:Nn \font { \l_@@_hyphenchar_tl } }
+ }
+ { \@@_error:nxx {no-glyph}{\l_fontspec_fontname_tl}{#1} }
+
+ }
+ }
+\@@_aff_error:n {HyphenChar}
+% \end{macrocode}
+%
+% \paragraph{Color}
+% Hooks into pkg{xcolor}, which names its colours \texttt{\char`\\color@<name>}.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {Color}
+ {
+ \cs_if_exist:cTF { \token_to_str:N \color@ #1 }
+ {
+ \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl
+ }
+ {
+ \int_compare:nTF { \tl_count:n {#1} == 6 }
+ { \tl_set:Nn \l_@@_hexcol_tl {#1} }
+ {
+ \int_compare:nTF { \tl_count:n {#1} == 8 }
+ { \fontspec_parse_colour:viii #1 }
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ { \@@_warning:nx {bad-colour} {#1} }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set:Npn \fontspec_parse_colour:viii #1#2#3#4#5#6#7#8
+ {
+ \tl_set:Nn \l_@@_hexcol_tl {#1#2#3#4#5#6}
+ \tl_if_eq:NNF \l_@@_opacity_tl \c_@@_opacity_tl
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ { \@@_warning:nx {opa-twice-col} {#7#8} }
+ }
+ \tl_set:Nn \l_@@_opacity_tl {#7#8}
+ }
+\aliasfontfeature{Color}{Colour}
+% \end{macrocode}
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {Opacity}
+ {
+ \int_set:Nn \l_@@_tmp_int {255}
+ \@@_int_mult_truncate:Nn \l_@@_tmp_int { #1 }
+ \tl_if_eq:NNF \l_@@_opacity_tl \c_@@_opacity_tl
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ { \@@_warning:nx {opa-twice} {#1} }
+ }
+ \tl_set:Nx \l_@@_opacity_tl
+ {
+ \int_compare:nT { \l_@@_tmp_int <= "F } {0} % zero pad
+ \int_to_hex:n { \l_@@_tmp_int }
+ }
+ }
+% \end{macrocode}
+%
+%
+% \paragraph{Mapping}
+% \begin{macrocode}
+%<*XE>
+\@@_keys_define_code:nnn {fontspec-aat} {Mapping}
+ {
+ \tl_set:Nn \l_@@_mapping_tl { #1 }
+ }
+\@@_keys_define_code:nnn {fontspec-opentype} {Mapping}
+ {
+ \tl_set:Nn \l_@@_mapping_tl { #1 }
+ }
+%</XE>
+%<*LU>
+\@@_keys_define_code:nnn {fontspec-opentype} {Mapping}
+ {
+ \str_if_eq:nnTF {#1} {tex-text}
+ {
+ \@@_warning:n {no-mapping-ligtex}
+ \msg_redirect_name:nnn {fontspec} {no-mapping-ligtex} {none}
+ \keys_set:nn {fontspec-opentype} { Ligatures=TeX }
+ }
+ { \@@_warning:n {no-mapping} }
+ }
+%</LU>
+% \end{macrocode}
+%
+%
+% \subsubsection{Continuous font axes}
+%
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec} {Weight}
+ {
+ \@@_update_featstr:n{weight=#1}
+ }
+\@@_keys_define_code:nnn {fontspec} {Width}
+ {
+ \@@_update_featstr:n{width=#1}
+ }
+\@@_keys_define_code:nnn {fontspec} {OpticalSize}
+%<*XE>
+ {
+ \bool_if:NTF \l_@@_ot_bool
+ {
+ \tl_set:Nn \l_@@_optical_size_tl {/ S = #1}
+ }
+ {
+ \bool_if:NT \l_@@_mm_bool
+ {
+ \@@_update_featstr:n { optical size = #1 }
+ }
+ }
+ \bool_if:nT { !\l_@@_ot_bool && !\l_@@_mm_bool }
+ {
+ \bool_if:NT \l_@@_firsttime_bool
+ { \@@_warning:nx {no-opticals} {\l_fontspec_fontname_tl} }
+ }
+ }
+%</XE>
+%<*LU>
+ {
+ \tl_set:Nn \l_@@_optical_size_tl {/ S = #1}
+ }
+%</LU>
+% \end{macrocode}
+%
+% \subsubsection{Font transformations}
+% These are to be specified to apply directly to a font shape:
+% \begin{macrocode}
+\keys_define:nn {fontspec}
+ {
+ FakeSlant .code:n =
+ {
+ \@@_update_featstr:n {slant=#1}
+ },
+ FakeSlant .default:n = {0.2}
+ }
+\keys_define:nn {fontspec}
+ {
+ FakeStretch .code:n =
+ {
+ \@@_update_featstr:n {extend=#1}
+ },
+ FakeStretch .default:n = {1.2}
+ }
+%<*XE>
+\keys_define:nn {fontspec}
+ {
+ FakeBold .code:n =
+ {
+ \@@_update_featstr:n {embolden=#1}
+ },
+ FakeBold .default:n = {1.5}
+ }
+%</XE>
+%<*LU>
+\keys_define:nn {fontspec}
+ {
+ FakeBold .code:n = { \@@_warning:n {fakebold-only-xetex} }
+ }
+%</LU>
+% \end{macrocode}
+% These are to be given to a shape that has no real bold/italic
+% to signal that \pkg{fontspec} should automatically create `fake' shapes.
+%
+% The behaviour is currently that only if both \opt{AutoFakeSlant} \emph{and}
+% \opt{AutoFakeBold} are specified, the bold italic is also faked.
+%
+% These features presently \emph{override} real shapes found in the font;
+% in the future I'd like these features to be ignored in this case, instead.
+% (This is just a bit harder to program in the current design of
+% \pkg{fontspec}.)
+% \begin{macrocode}
+\keys_define:nn {fontspec}
+ {
+ AutoFakeSlant .code:n =
+ {
+ \bool_if:NT \l_@@_firsttime_bool
+ {
+ \tl_set:Nn \l_@@_fake_slant_tl {#1}
+ \clist_put_right:Nn \l_@@_fontfeat_it_clist {FakeSlant=#1}
+ \tl_set_eq:NN \l_@@_fontname_it_tl \l_fontspec_fontname_tl
+ \bool_set_false:N \l_@@_noit_bool
+
+ \tl_if_empty:NF \l_@@_fake_embolden_tl
+ {
+ \clist_put_right:Nx \l_@@_fontfeat_bfit_clist
+ {FakeBold=\l_@@_fake_embolden_tl}
+ \clist_put_right:Nx \l_@@_fontfeat_bfit_clist {FakeSlant=#1}
+ \tl_set_eq:NN \l_@@_fontname_bfit_tl \l_fontspec_fontname_tl
+ }
+ }
+ },
+ AutoFakeSlant .default:n = {0.2}
+ }
+% \end{macrocode}
+% Same but reversed:
+% \begin{macrocode}
+\keys_define:nn {fontspec}
+ {
+ AutoFakeBold .code:n =
+ {
+ \bool_if:NT \l_@@_firsttime_bool
+ {
+ \tl_set:Nn \l_@@_fake_embolden_tl {#1}
+ \clist_put_right:Nn \l_@@_fontfeat_bf_clist {FakeBold=#1}
+ \tl_set_eq:NN \l_@@_fontname_bf_tl \l_fontspec_fontname_tl
+ \bool_set_false:N \l_@@_nobf_bool
+
+ \tl_if_empty:NF \l_@@_fake_slant_tl
+ {
+ \clist_put_right:Nx \l_@@_fontfeat_bfit_clist
+ {FakeSlant=\l_@@_fake_slant_tl}
+ \clist_put_right:Nx \l_@@_fontfeat_bfit_clist {FakeBold=#1}
+ \tl_set_eq:NN \l_@@_fontname_bfit_tl \l_fontspec_fontname_tl
+ }
+ }
+ },
+ AutoFakeBold .default:n = {1.5}
+ }
+% \end{macrocode}
+%
+%
+% \subsubsection{Raw feature string}
+% This allows savvy \XeTeX-ers to input font features manually if they have
+% already memorised the OpenType abbreviations and don't mind not having error checking.
+% \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-opentype} {RawFeature}
+ {
+ \@@_update_featstr:n {#1}
+ }
+\@@_keys_define_code:nnn {fontspec-aat} {RawFeature}
+ {
+ \@@_update_featstr:n {#1}
+ }
+% \end{macrocode}
+%
+%
+%
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-lang.dtx b/macros/latex/contrib/fontspec/fontspec-code-lang.dtx
new file mode 100644
index 0000000000..7b7acfc921
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-lang.dtx
@@ -0,0 +1,419 @@
+%%^^A%% fontspec-code-lang.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Font language definitions}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \begin{macrocode}
+\newfontlanguage{Abaza}{ABA}
+\newfontlanguage{Abkhazian}{ABK}
+\newfontlanguage{Adyghe}{ADY}
+\newfontlanguage{Afrikaans}{AFK}
+\newfontlanguage{Afar}{AFR}
+\newfontlanguage{Agaw}{AGW}
+\newfontlanguage{Altai}{ALT}
+\newfontlanguage{Amharic}{AMH}
+\newfontlanguage{Arabic}{ARA}
+\newfontlanguage{Aari}{ARI}
+\newfontlanguage{Arakanese}{ARK}
+\newfontlanguage{Assamese}{ASM}
+\newfontlanguage{Athapaskan}{ATH}
+\newfontlanguage{Avar}{AVR}
+\newfontlanguage{Awadhi}{AWA}
+\newfontlanguage{Aymara}{AYM}
+\newfontlanguage{Azeri}{AZE}
+\newfontlanguage{Badaga}{BAD}
+\newfontlanguage{Baghelkhandi}{BAG}
+\newfontlanguage{Balkar}{BAL}
+\newfontlanguage{Baule}{BAU}
+\newfontlanguage{Berber}{BBR}
+\newfontlanguage{Bench}{BCH}
+\newfontlanguage{Bible~Cree}{BCR}
+\newfontlanguage{Belarussian}{BEL}
+\newfontlanguage{Bemba}{BEM}
+\newfontlanguage{Bengali}{BEN}
+\newfontlanguage{Bulgarian}{BGR}
+\newfontlanguage{Bhili}{BHI}
+\newfontlanguage{Bhojpuri}{BHO}
+\newfontlanguage{Bikol}{BIK}
+\newfontlanguage{Bilen}{BIL}
+\newfontlanguage{Blackfoot}{BKF}
+\newfontlanguage{Balochi}{BLI}
+\newfontlanguage{Balante}{BLN}
+\newfontlanguage{Balti}{BLT}
+\newfontlanguage{Bambara}{BMB}
+\newfontlanguage{Bamileke}{BML}
+\newfontlanguage{Breton}{BRE}
+\newfontlanguage{Brahui}{BRH}
+\newfontlanguage{Braj~Bhasha}{BRI}
+\newfontlanguage{Burmese}{BRM}
+\newfontlanguage{Bashkir}{BSH}
+\newfontlanguage{Beti}{BTI}
+\newfontlanguage{Catalan}{CAT}
+\newfontlanguage{Cebuano}{CEB}
+\newfontlanguage{Chechen}{CHE}
+\newfontlanguage{Chaha~Gurage}{CHG}
+\newfontlanguage{Chattisgarhi}{CHH}
+\newfontlanguage{Chichewa}{CHI}
+\newfontlanguage{Chukchi}{CHK}
+\newfontlanguage{Chipewyan}{CHP}
+\newfontlanguage{Cherokee}{CHR}
+\newfontlanguage{Chuvash}{CHU}
+\newfontlanguage{Comorian}{CMR}
+\newfontlanguage{Coptic}{COP}
+\newfontlanguage{Cree}{CRE}
+\newfontlanguage{Carrier}{CRR}
+\newfontlanguage{Crimean~Tatar}{CRT}
+\newfontlanguage{Church~Slavonic}{CSL}
+\newfontlanguage{Czech}{CSY}
+\newfontlanguage{Danish}{DAN}
+\newfontlanguage{Dargwa}{DAR}
+\newfontlanguage{Woods~Cree}{DCR}
+\newfontlanguage{German}{DEU}
+\newfontlanguage{Dogri}{DGR}
+\newfontlanguage{Divehi}{DIV}
+\newfontlanguage{Djerma}{DJR}
+\newfontlanguage{Dangme}{DNG}
+\newfontlanguage{Dinka}{DNK}
+\newfontlanguage{Dungan}{DUN}
+\newfontlanguage{Dzongkha}{DZN}
+\newfontlanguage{Ebira}{EBI}
+\newfontlanguage{Eastern~Cree}{ECR}
+\newfontlanguage{Edo}{EDO}
+\newfontlanguage{Efik}{EFI}
+\newfontlanguage{Greek}{ELL}
+\newfontlanguage{English}{ENG}
+\newfontlanguage{Erzya}{ERZ}
+\newfontlanguage{Spanish}{ESP}
+\newfontlanguage{Estonian}{ETI}
+\newfontlanguage{Basque}{EUQ}
+\newfontlanguage{Evenki}{EVK}
+\newfontlanguage{Even}{EVN}
+\newfontlanguage{Ewe}{EWE}
+\newfontlanguage{French~Antillean}{FAN}
+\newfontlanguage{Farsi}{FAR}
+\newfontlanguage{Parsi}{FAR}
+\newfontlanguage{Persian}{FAR}
+\newfontlanguage{Finnish}{FIN}
+\newfontlanguage{Fijian}{FJI}
+\newfontlanguage{Flemish}{FLE}
+\newfontlanguage{Forest~Nenets}{FNE}
+\newfontlanguage{Fon}{FON}
+\newfontlanguage{Faroese}{FOS}
+\newfontlanguage{French}{FRA}
+\newfontlanguage{Frisian}{FRI}
+\newfontlanguage{Friulian}{FRL}
+\newfontlanguage{Futa}{FTA}
+\newfontlanguage{Fulani}{FUL}
+\newfontlanguage{Ga}{GAD}
+\newfontlanguage{Gaelic}{GAE}
+\newfontlanguage{Gagauz}{GAG}
+\newfontlanguage{Galician}{GAL}
+\newfontlanguage{Garshuni}{GAR}
+\newfontlanguage{Garhwali}{GAW}
+\newfontlanguage{Ge'ez}{GEZ}
+\newfontlanguage{Gilyak}{GIL}
+\newfontlanguage{Gumuz}{GMZ}
+\newfontlanguage{Gondi}{GON}
+\newfontlanguage{Greenlandic}{GRN}
+\newfontlanguage{Garo}{GRO}
+\newfontlanguage{Guarani}{GUA}
+\newfontlanguage{Gujarati}{GUJ}
+\newfontlanguage{Haitian}{HAI}
+\newfontlanguage{Halam}{HAL}
+\newfontlanguage{Harauti}{HAR}
+\newfontlanguage{Hausa}{HAU}
+\newfontlanguage{Hawaiin}{HAW}
+\newfontlanguage{Hammer-Banna}{HBN}
+\newfontlanguage{Hiligaynon}{HIL}
+\newfontlanguage{Hindi}{HIN}
+\newfontlanguage{High~Mari}{HMA}
+\newfontlanguage{Hindko}{HND}
+\newfontlanguage{Ho}{HO}
+\newfontlanguage{Harari}{HRI}
+\newfontlanguage{Croatian}{HRV}
+\newfontlanguage{Hungarian}{HUN}
+\newfontlanguage{Armenian}{HYE}
+\newfontlanguage{Igbo}{IBO}
+\newfontlanguage{Ijo}{IJO}
+\newfontlanguage{Ilokano}{ILO}
+\newfontlanguage{Indonesian}{IND}
+\newfontlanguage{Ingush}{ING}
+\newfontlanguage{Inuktitut}{INU}
+\newfontlanguage{Irish}{IRI}
+\newfontlanguage{Irish~Traditional}{IRT}
+\newfontlanguage{Icelandic}{ISL}
+\newfontlanguage{Inari~Sami}{ISM}
+\newfontlanguage{Italian}{ITA}
+\newfontlanguage{Hebrew}{IWR}
+\newfontlanguage{Javanese}{JAV}
+\newfontlanguage{Yiddish}{JII}
+\newfontlanguage{Japanese}{JAN}
+\newfontlanguage{Judezmo}{JUD}
+\newfontlanguage{Jula}{JUL}
+\newfontlanguage{Kabardian}{KAB}
+\newfontlanguage{Kachchi}{KAC}
+\newfontlanguage{Kalenjin}{KAL}
+\newfontlanguage{Kannada}{KAN}
+\newfontlanguage{Karachay}{KAR}
+\newfontlanguage{Georgian}{KAT}
+\newfontlanguage{Kazakh}{KAZ}
+\newfontlanguage{Kebena}{KEB}
+\newfontlanguage{Khutsuri~Georgian}{KGE}
+\newfontlanguage{Khakass}{KHA}
+\newfontlanguage{Khanty-Kazim}{KHK}
+\newfontlanguage{Khmer}{KHM}
+\newfontlanguage{Khanty-Shurishkar}{KHS}
+\newfontlanguage{Khanty-Vakhi}{KHV}
+\newfontlanguage{Khowar}{KHW}
+\newfontlanguage{Kikuyu}{KIK}
+\newfontlanguage{Kirghiz}{KIR}
+\newfontlanguage{Kisii}{KIS}
+\newfontlanguage{Kokni}{KKN}
+\newfontlanguage{Kalmyk}{KLM}
+\newfontlanguage{Kamba}{KMB}
+\newfontlanguage{Kumaoni}{KMN}
+\newfontlanguage{Komo}{KMO}
+\newfontlanguage{Komso}{KMS}
+\newfontlanguage{Kanuri}{KNR}
+\newfontlanguage{Kodagu}{KOD}
+\newfontlanguage{Korean~Old~Hangul}{KOH}
+\newfontlanguage{Konkani}{KOK}
+\newfontlanguage{Kikongo}{KON}
+\newfontlanguage{Komi-Permyak}{KOP}
+\newfontlanguage{Korean}{KOR}
+\newfontlanguage{Komi-Zyrian}{KOZ}
+\newfontlanguage{Kpelle}{KPL}
+\newfontlanguage{Krio}{KRI}
+\newfontlanguage{Karakalpak}{KRK}
+\newfontlanguage{Karelian}{KRL}
+\newfontlanguage{Karaim}{KRM}
+\newfontlanguage{Karen}{KRN}
+\newfontlanguage{Koorete}{KRT}
+\newfontlanguage{Kashmiri}{KSH}
+\newfontlanguage{Khasi}{KSI}
+\newfontlanguage{Kildin~Sami}{KSM}
+\newfontlanguage{Kui}{KUI}
+\newfontlanguage{Kulvi}{KUL}
+\newfontlanguage{Kumyk}{KUM}
+\newfontlanguage{Kurdish}{KUR}
+\newfontlanguage{Kurukh}{KUU}
+\newfontlanguage{Kuy}{KUY}
+\newfontlanguage{Koryak}{KYK}
+\newfontlanguage{Ladin}{LAD}
+\newfontlanguage{Lahuli}{LAH}
+\newfontlanguage{Lak}{LAK}
+\newfontlanguage{Lambani}{LAM}
+\newfontlanguage{Lao}{LAO}
+\newfontlanguage{Latin}{LAT}
+\newfontlanguage{Laz}{LAZ}
+\newfontlanguage{L-Cree}{LCR}
+\newfontlanguage{Ladakhi}{LDK}
+\newfontlanguage{Lezgi}{LEZ}
+\newfontlanguage{Lingala}{LIN}
+\newfontlanguage{Low~Mari}{LMA}
+\newfontlanguage{Limbu}{LMB}
+\newfontlanguage{Lomwe}{LMW}
+\newfontlanguage{Lower~Sorbian}{LSB}
+\newfontlanguage{Lule~Sami}{LSM}
+\newfontlanguage{Lithuanian}{LTH}
+\newfontlanguage{Luba}{LUB}
+\newfontlanguage{Luganda}{LUG}
+\newfontlanguage{Luhya}{LUH}
+\newfontlanguage{Luo}{LUO}
+\newfontlanguage{Latvian}{LVI}
+\newfontlanguage{Majang}{MAJ}
+\newfontlanguage{Makua}{MAK}
+\newfontlanguage{Malayalam~Traditional}{MAL}
+\newfontlanguage{Mansi}{MAN}
+\newfontlanguage{Marathi}{MAR}
+\newfontlanguage{Marwari}{MAW}
+\newfontlanguage{Mbundu}{MBN}
+\newfontlanguage{Manchu}{MCH}
+\newfontlanguage{Moose~Cree}{MCR}
+\newfontlanguage{Mende}{MDE}
+\newfontlanguage{Me'en}{MEN}
+\newfontlanguage{Mizo}{MIZ}
+\newfontlanguage{Macedonian}{MKD}
+\newfontlanguage{Male}{MLE}
+\newfontlanguage{Malagasy}{MLG}
+\newfontlanguage{Malinke}{MLN}
+\newfontlanguage{Malayalam~Reformed}{MLR}
+\newfontlanguage{Malay}{MLY}
+\newfontlanguage{Mandinka}{MND}
+\newfontlanguage{Mongolian}{MNG}
+\newfontlanguage{Manipuri}{MNI}
+\newfontlanguage{Maninka}{MNK}
+\newfontlanguage{Manx~Gaelic}{MNX}
+\newfontlanguage{Moksha}{MOK}
+\newfontlanguage{Moldavian}{MOL}
+\newfontlanguage{Mon}{MON}
+\newfontlanguage{Moroccan}{MOR}
+\newfontlanguage{Maori}{MRI}
+\newfontlanguage{Maithili}{MTH}
+\newfontlanguage{Maltese}{MTS}
+\newfontlanguage{Mundari}{MUN}
+\newfontlanguage{Naga-Assamese}{NAG}
+\newfontlanguage{Nanai}{NAN}
+\newfontlanguage{Naskapi}{NAS}
+\newfontlanguage{N-Cree}{NCR}
+\newfontlanguage{Ndebele}{NDB}
+\newfontlanguage{Ndonga}{NDG}
+\newfontlanguage{Nepali}{NEP}
+\newfontlanguage{Newari}{NEW}
+\newfontlanguage{Nagari}{NGR}
+\newfontlanguage{Norway~House~Cree}{NHC}
+\newfontlanguage{Nisi}{NIS}
+\newfontlanguage{Niuean}{NIU}
+\newfontlanguage{Nkole}{NKL}
+\newfontlanguage{N'ko}{NKO}
+\newfontlanguage{Dutch}{NLD}
+\newfontlanguage{Nogai}{NOG}
+\newfontlanguage{Norwegian}{NOR}
+\newfontlanguage{Northern~Sami}{NSM}
+\newfontlanguage{Northern~Tai}{NTA}
+\newfontlanguage{Esperanto}{NTO}
+\newfontlanguage{Nynorsk}{NYN}
+\newfontlanguage{Oji-Cree}{OCR}
+\newfontlanguage{Ojibway}{OJB}
+\newfontlanguage{Oriya}{ORI}
+\newfontlanguage{Oromo}{ORO}
+\newfontlanguage{Ossetian}{OSS}
+\newfontlanguage{Palestinian~Aramaic}{PAA}
+\newfontlanguage{Pali}{PAL}
+\newfontlanguage{Punjabi}{PAN}
+\newfontlanguage{Palpa}{PAP}
+\newfontlanguage{Pashto}{PAS}
+\newfontlanguage{Polytonic~Greek}{PGR}
+\newfontlanguage{Pilipino}{PIL}
+\newfontlanguage{Palaung}{PLG}
+\newfontlanguage{Polish}{PLK}
+\newfontlanguage{Provencal}{PRO}
+\newfontlanguage{Portuguese}{PTG}
+\newfontlanguage{Chin}{QIN}
+\newfontlanguage{Rajasthani}{RAJ}
+\newfontlanguage{R-Cree}{RCR}
+\newfontlanguage{Russian~Buriat}{RBU}
+\newfontlanguage{Riang}{RIA}
+\newfontlanguage{Rhaeto-Romanic}{RMS}
+\newfontlanguage{Romanian}{ROM}
+\newfontlanguage{Romany}{ROY}
+\newfontlanguage{Rusyn}{RSY}
+\newfontlanguage{Ruanda}{RUA}
+\newfontlanguage{Russian}{RUS}
+\newfontlanguage{Sadri}{SAD}
+\newfontlanguage{Sanskrit}{SAN}
+\newfontlanguage{Santali}{SAT}
+\newfontlanguage{Sayisi}{SAY}
+\newfontlanguage{Sekota}{SEK}
+\newfontlanguage{Selkup}{SEL}
+\newfontlanguage{Sango}{SGO}
+\newfontlanguage{Shan}{SHN}
+\newfontlanguage{Sibe}{SIB}
+\newfontlanguage{Sidamo}{SID}
+\newfontlanguage{Silte~Gurage}{SIG}
+\newfontlanguage{Skolt~Sami}{SKS}
+\newfontlanguage{Slovak}{SKY}
+\newfontlanguage{Slavey}{SLA}
+\newfontlanguage{Slovenian}{SLV}
+\newfontlanguage{Somali}{SML}
+\newfontlanguage{Samoan}{SMO}
+\newfontlanguage{Sena}{SNA}
+\newfontlanguage{Sindhi}{SND}
+\newfontlanguage{Sinhalese}{SNH}
+\newfontlanguage{Soninke}{SNK}
+\newfontlanguage{Sodo~Gurage}{SOG}
+\newfontlanguage{Sotho}{SOT}
+\newfontlanguage{Albanian}{SQI}
+\newfontlanguage{Serbian}{SRB}
+\newfontlanguage{Saraiki}{SRK}
+\newfontlanguage{Serer}{SRR}
+\newfontlanguage{South~Slavey}{SSL}
+\newfontlanguage{Southern~Sami}{SSM}
+\newfontlanguage{Suri}{SUR}
+\newfontlanguage{Svan}{SVA}
+\newfontlanguage{Swedish}{SVE}
+\newfontlanguage{Swadaya~Aramaic}{SWA}
+\newfontlanguage{Swahili}{SWK}
+\newfontlanguage{Swazi}{SWZ}
+\newfontlanguage{Sutu}{SXT}
+\newfontlanguage{Syriac}{SYR}
+\newfontlanguage{Tabasaran}{TAB}
+\newfontlanguage{Tajiki}{TAJ}
+\newfontlanguage{Tamil}{TAM}
+\newfontlanguage{Tatar}{TAT}
+\newfontlanguage{TH-Cree}{TCR}
+\newfontlanguage{Telugu}{TEL}
+\newfontlanguage{Tongan}{TGN}
+\newfontlanguage{Tigre}{TGR}
+\newfontlanguage{Tigrinya}{TGY}
+\newfontlanguage{Thai}{THA}
+\newfontlanguage{Tahitian}{THT}
+\newfontlanguage{Tibetan}{TIB}
+\newfontlanguage{Turkish}{TRK,TUR}
+\newfontlanguage{Turkmen}{TKM}
+\newfontlanguage{Temne}{TMN}
+\newfontlanguage{Tswana}{TNA}
+\newfontlanguage{Tundra~Nenets}{TNE}
+\newfontlanguage{Tonga}{TNG}
+\newfontlanguage{Todo}{TOD}
+\newfontlanguage{Tsonga}{TSG}
+\newfontlanguage{Turoyo~Aramaic}{TUA}
+\newfontlanguage{Tulu}{TUL}
+\newfontlanguage{Tuvin}{TUV}
+\newfontlanguage{Twi}{TWI}
+\newfontlanguage{Udmurt}{UDM}
+\newfontlanguage{Ukrainian}{UKR}
+\newfontlanguage{Urdu}{URD}
+\newfontlanguage{Upper~Sorbian}{USB}
+\newfontlanguage{Uyghur}{UYG}
+\newfontlanguage{Uzbek}{UZB}
+\newfontlanguage{Venda}{VEN}
+\newfontlanguage{Vietnamese}{VIT}
+\newfontlanguage{Wa}{WA}
+\newfontlanguage{Wagdi}{WAG}
+\newfontlanguage{West-Cree}{WCR}
+\newfontlanguage{Welsh}{WEL}
+\newfontlanguage{Wolof}{WLF}
+\newfontlanguage{Tai~Lue}{XBD}
+\newfontlanguage{Xhosa}{XHS}
+\newfontlanguage{Yakut}{YAK}
+\newfontlanguage{Yoruba}{YBA}
+\newfontlanguage{Y-Cree}{YCR}
+\newfontlanguage{Yi~Classic}{YIC}
+\newfontlanguage{Yi~Modern}{YIM}
+\newfontlanguage{Chinese~Hong~Kong}{ZHH}
+\newfontlanguage{Chinese~Phonetic}{ZHP}
+\newfontlanguage{Chinese~Simplified}{ZHS}
+\newfontlanguage{Chinese~Traditional}{ZHT}
+\newfontlanguage{Zande}{ZND}
+\newfontlanguage{Zulu}{ZUL}
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-load.dtx b/macros/latex/contrib/fontspec/fontspec-code-load.dtx
new file mode 100644
index 0000000000..93b25e92e3
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-load.dtx
@@ -0,0 +1,72 @@
+%%^^A%% fontspec-code-load.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{The \texttt{fontspec.sty} loading file}
+%
+% Before we begin, for the rest of the package we use the \texttt{@@} \textsf{expl3}
+% module syntax with module name `\texttt{fontspec}'.
+% \begin{macrocode}
+%<@@=fontspec>
+% \end{macrocode}
+% The \texttt{fontspec.sty} file is simply set up to load the appropriate
+% \texttt{fontspec-xetex.sty} or \texttt{fontspec-luatex.sty} file.
+% This is performed by the following code.
+%
+% \begin{macrocode}
+%<*load>
+% \end{macrocode}
+%
+% \paragraph{\LuaLaTeX}
+% \begin{macrocode}
+\sys_if_engine_luatex:T
+ {
+ \RequirePackage{luaotfload}
+ \lua_now:e{require("fontspec")}
+ \RequirePackageWithOptions{fontspec-luatex}
+ \endinput
+ }
+% \end{macrocode}
+%
+% \paragraph{\XeLaTeX}
+% \begin{macrocode}
+\sys_if_engine_xetex:T
+ {
+ \RequirePackageWithOptions{fontspec-xetex}
+ \endinput
+ }
+% \end{macrocode}
+%
+% \paragraph{Other}
+% If not one of the above, error and exit.
+% \begin{macrocode}
+\msg_new:nnn {fontspec} {cannot-use-pdftex}
+ {
+ The~ fontspec~ package~ requires~ either~ XeTeX~ or~ LuaTeX.\\\\
+ You~ must~ change~ your~ typesetting~ engine~ to,~ e.g.,~
+ "xelatex"~ or~ "lualatex" instead~ of~ "latex"~ or~ "pdflatex".
+ }
+\msg_fatal:nn {fontspec} {cannot-use-pdftex}
+% \end{macrocode}
+%
+% \paragraph{Closing}
+% That's the end of the \texttt{fontspec.sty} file.
+% \begin{macrocode}
+\endinput
+%</load>
+% \end{macrocode}
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-math.dtx b/macros/latex/contrib/fontspec/fontspec-code-math.dtx
new file mode 100644
index 0000000000..dd6dfdad05
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-math.dtx
@@ -0,0 +1,260 @@
+%%^^A%% fontspec-code-math.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Selecting maths fonts}
+% Here, the fonts used in math mode are redefined to correspond to the
+% default roman, sans serif and typewriter fonts. Unfortunately, you
+% can only define maths fonts in the preamble, otherwise I'd run this
+% code whenever \cs{setmainfont} and friends was run.
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \begin{macro}{\fontspec_setup_maths:}
+% Everything here is performed \cs{AtBeginDocument} in order to
+% overwrite \pkg{euler}'s attempt. This means \pkg{fontspec} must be
+% loaded \emph{after} \pkg{euler}. We set up a conditional to return
+% an error if this rule is violated.
+%
+% Since every maths setup is slightly different, we also take
+% different paths for defining various math glyphs depending which
+% maths font package has been loaded.
+%
+% \begin{macrocode}
+\@ifpackageloaded{euler}
+ { \bool_gset_true:N \g_@@_pkg_euler_loaded_bool }
+ { \bool_gset_false:N \g_@@_pkg_euler_loaded_bool }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \fontspec_setup_maths:
+ {
+ \@ifpackageloaded{euler}
+ {
+ \bool_if:NTF \g_@@_pkg_euler_loaded_bool
+ { \bool_gset_true:N \g_@@_math_euler_bool }
+ { \@@_error:n {euler-too-late} }
+ }
+ {}
+ \@ifpackageloaded{lucbmath}{ \bool_gset_true:N \g_@@_math_lucida_bool }{}
+ \@ifpackageloaded{lucidabr}{ \bool_gset_true:N \g_@@_math_lucida_bool }{}
+ \@ifpackageloaded{lucimatx}{ \bool_gset_true:N \g_@@_math_lucida_bool }{}
+% \end{macrocode}
+% Knuth's CM fonts fonts are all squashed together, combining letters,
+% accents, text symbols and maths symbols all in the one font,
+% \texttt{cmr}, plus other things in other fonts. Because we are
+% changing the roman font in the document, we need to redefine all of
+% the maths glyphs in \LaTeX's \texttt{operators} maths font to still
+% go back to the legacy \texttt{cmr} font for all these random glyphs,
+% unless a separate maths font package has been loaded instead.
+%
+% In every case, the maths accents are always taken from the
+% \texttt{operators} font, which is generally the main text
+% font. (Actually, there is a \cmd\hat\ accent in
+% \texttt{EulerFractur}, but it's \emph{ugly}. So I ignore it. Sorry
+% if this causes inconvenience.)
+% \begin{macrocode}
+ \DeclareSymbolFont{legacymaths}{OT1}{cmr}{m}{n}
+ \SetSymbolFont{legacymaths}{bold}{OT1}{cmr}{bx}{n}
+ \DeclareMathAccent{\acute} {\mathalpha}{legacymaths}{19}
+ \DeclareMathAccent{\grave} {\mathalpha}{legacymaths}{18}
+ \DeclareMathAccent{\ddot} {\mathalpha}{legacymaths}{127}
+ \DeclareMathAccent{\tilde} {\mathalpha}{legacymaths}{126}
+ \DeclareMathAccent{\bar} {\mathalpha}{legacymaths}{22}
+ \DeclareMathAccent{\breve} {\mathalpha}{legacymaths}{21}
+ \DeclareMathAccent{\check} {\mathalpha}{legacymaths}{20}
+ \DeclareMathAccent{\hat} {\mathalpha}{legacymaths}{94} % too bad, euler
+ \DeclareMathAccent{\dot} {\mathalpha}{legacymaths}{95}
+ \DeclareMathAccent{\mathring}{\mathalpha}{legacymaths}{23}
+% \end{macrocode}
+% \paragraph{\cmd\colon: what's going on?} Okay, so \verb":" and \cmd\colon\ in maths mode are defined in a few places, so I need to work out what does what. Respectively, we have:
+% \begin{Verbatim}
+% % fontmath.ltx:
+% \DeclareMathSymbol{\colon}{\mathpunct}{operators}{"3A}
+% \DeclareMathSymbol{:}{\mathrel}{operators}{"3A}
+%
+% % amsmath.sty:
+% \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
+% \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
+%
+% % euler.sty:
+% \DeclareMathSymbol{:}\mathrel {EulerFraktur}{"3A}
+%
+% % lucbmath.sty:
+% \DeclareMathSymbol{\@tempb}{\mathpunct}{operators}{58}
+% \ifx\colon\@tempb
+% \DeclareMathSymbol{\colon}{\mathpunct}{operators}{58}
+% \fi
+% \DeclareMathSymbol{:}{\mathrel}{operators}{58}
+% \end{Verbatim}
+% ($\mathrm{3A_{16}}=\mathrm{58_{10}}$) So I think, based on this summary, that it is fair to tell \pkg{fontspec} to `replace' the operators font with legacymaths for this symbol, except when \pkg{amsmath} is loaded since we want to keep its definition.
+%
+%
+% \begin{macrocode}
+ \group_begin:
+ \mathchardef\@tempa="603A \relax
+ \ifx\colon\@tempa
+ \DeclareMathSymbol{\colon}{\mathpunct}{legacymaths}{58}
+ \fi
+ \group_end:
+% \end{macrocode}
+% The following symbols are only defined specifically in \pkg{euler}, so skip them
+% if that package is loaded.
+% \begin{macrocode}
+ \bool_if:NF \g_@@_math_euler_bool
+ {
+ \DeclareMathSymbol{!}{\mathclose}{legacymaths}{33}
+ \DeclareMathSymbol{:}{\mathrel} {legacymaths}{58}
+ \DeclareMathSymbol{;}{\mathpunct}{legacymaths}{59}
+ \DeclareMathSymbol{?}{\mathclose}{legacymaths}{63}
+% \end{macrocode}
+% And these ones are defined both in \pkg{euler} and \pkg{lucbmath},
+% so we only need to run this code if no extra maths package has been
+% loaded.
+% \begin{macrocode}
+ \bool_if:NF \g_@@_math_lucida_bool
+ {
+ \DeclareMathSymbol{0}{\mathalpha}{legacymaths}{`0}
+ \DeclareMathSymbol{1}{\mathalpha}{legacymaths}{`1}
+ \DeclareMathSymbol{2}{\mathalpha}{legacymaths}{`2}
+ \DeclareMathSymbol{3}{\mathalpha}{legacymaths}{`3}
+ \DeclareMathSymbol{4}{\mathalpha}{legacymaths}{`4}
+ \DeclareMathSymbol{5}{\mathalpha}{legacymaths}{`5}
+ \DeclareMathSymbol{6}{\mathalpha}{legacymaths}{`6}
+ \DeclareMathSymbol{7}{\mathalpha}{legacymaths}{`7}
+ \DeclareMathSymbol{8}{\mathalpha}{legacymaths}{`8}
+ \DeclareMathSymbol{9}{\mathalpha}{legacymaths}{`9}
+ \DeclareMathSymbol{\Gamma}{\mathalpha}{legacymaths}{0}
+ \DeclareMathSymbol{\Delta}{\mathalpha}{legacymaths}{1}
+ \DeclareMathSymbol{\Theta}{\mathalpha}{legacymaths}{2}
+ \DeclareMathSymbol{\Lambda}{\mathalpha}{legacymaths}{3}
+ \DeclareMathSymbol{\Xi}{\mathalpha}{legacymaths}{4}
+ \DeclareMathSymbol{\Pi}{\mathalpha}{legacymaths}{5}
+ \DeclareMathSymbol{\Sigma}{\mathalpha}{legacymaths}{6}
+ \DeclareMathSymbol{\Upsilon}{\mathalpha}{legacymaths}{7}
+ \DeclareMathSymbol{\Phi}{\mathalpha}{legacymaths}{8}
+ \DeclareMathSymbol{\Psi}{\mathalpha}{legacymaths}{9}
+ \DeclareMathSymbol{\Omega}{\mathalpha}{legacymaths}{10}
+ \DeclareMathSymbol{+}{\mathbin}{legacymaths}{43}
+ \DeclareMathSymbol{=}{\mathrel}{legacymaths}{61}
+ \DeclareMathDelimiter{(}{\mathopen} {legacymaths}{40}{largesymbols}{0}
+ \DeclareMathDelimiter{)}{\mathclose}{legacymaths}{41}{largesymbols}{1}
+ \DeclareMathDelimiter{[}{\mathopen} {legacymaths}{91}{largesymbols}{2}
+ \DeclareMathDelimiter{]}{\mathclose}{legacymaths}{93}{largesymbols}{3}
+ \DeclareMathDelimiter{/}{\mathord}{legacymaths}{47}{largesymbols}{14}
+ \DeclareMathSymbol{\mathdollar}{\mathord}{legacymaths}{36}
+ \renewcommand{\hbar}{{\mathchar"AF\mkern-9mu h}}% TODO: test with other fonts
+ }
+ }
+% \end{macrocode}
+% Finally, we change the font definitions for \cmd\mathrm\ and so
+% on. These are defined using the \cmd\g_@@_mathrm_tl\ (\dots) macros,
+% which default to \cmd\rmdefault\ but may be specified with the
+% \cmd\setmathrm\ (\dots) commands in the preamble.
+%
+% Since \LaTeX\ only generally defines one level of boldness, we omit
+% \cmd\mathbf\ in the \textsf{bold} maths series. It can be specified
+% as per usual with \cmd\setboldmathrm, which stores the appropriate
+% family name in \cmd\g_@@_bfmathrm_tl.
+% \begin{macrocode}
+ \DeclareSymbolFont{operators}\g_fontspec_encoding_tl\g_@@_mathrm_tl\mddefault\updefault
+ \SetSymbolFont{operators}{normal}\g_fontspec_encoding_tl\g_@@_mathrm_tl\mddefault\updefault
+ \DeclareSymbolFontAlphabet\mathrm{operators}
+ \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g_@@_mathrm_tl\mddefault\itdefault
+ \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g_@@_mathrm_tl\bfdefault\updefault
+ \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g_@@_mathsf_tl\mddefault\updefault
+ \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g_@@_mathtt_tl\mddefault\updefault
+ \SetSymbolFont{operators}{bold}\g_fontspec_encoding_tl\g_@@_mathrm_tl\bfdefault\updefault
+ \tl_if_empty:NTF \g_@@_bfmathrm_tl
+ {
+ \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g_@@_mathrm_tl\bfdefault\itdefault
+ }
+ {
+ \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g_@@_bfmathrm_tl\mddefault\updefault
+ \SetMathAlphabet\mathbf{bold}\g_fontspec_encoding_tl\g_@@_bfmathrm_tl\bfdefault\updefault
+ \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g_@@_bfmathrm_tl\mddefault\itdefault
+ }
+ \SetMathAlphabet\mathsf{bold}\g_fontspec_encoding_tl\g_@@_mathsf_tl\bfdefault\updefault
+ \SetMathAlphabet\mathtt{bold}\g_fontspec_encoding_tl\g_@@_mathtt_tl\bfdefault\updefault
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_maybe_setup_maths:}
+% We're a little less sophisticated about not executing the maths setup if various other maths font packages are loaded. This list is based on the wonderful `\LaTeX Font Catalogue': \url{http://www.tug.dk/FontCatalogue/mathfonts.html}. I'm sure there are more I've missed. Do the \TeX\ Gyre fonts have maths support yet?
+%
+% Untested: would |\unless\ifnum\Gamma=28672\relax\bool_set_false:N \g_@@_math_bool\fi| be a better test?
+% This needs more cooperation with euler and lucida, I think.
+% \begin{macrocode}
+\cs_new:Nn \fontspec_maybe_setup_maths:
+ {
+ \@ifpackageloaded{anttor}
+ {
+ \ifx\define@antt@mathversions a\bool_gset_false:N \g_@@_math_bool\fi
+ }{}
+ \@ifpackageloaded{arevmath} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{eulervm} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{mathdesign} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{concmath} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{cmbright} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{mathesf} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{gfsartemisia} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{gfsneohellenic} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{iwona}
+ {
+ \ifx\define@iwona@mathversions a\bool_set_false:N \g_@@_math_bool\fi
+ }{}
+ \@ifpackageloaded{kpfonts}{\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{kmath} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{kurier}
+ {
+ \ifx\define@kurier@mathversions a\bool_set_false:N \g_@@_math_bool\fi
+ }{}
+ \@ifpackageloaded{fouriernc} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{fourier} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{lmodern} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{mathpazo} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{mathptmx} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{MinionPro} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{unicode-math} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{breqn} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{pxfonts} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{txfonts} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{newpxmath} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{newtxmath} {\bool_gset_false:N \g_@@_math_bool}{}
+ \@ifpackageloaded{mtpro2} {\bool_gset_false:N \g_@@_math_bool}{}
+ \bool_if:NT \g_@@_math_bool
+ {
+ \@@_info:n {setup-math}
+ \fontspec_setup_maths:
+ }
+ }
+\AtBeginDocument{\fontspec_maybe_setup_maths:}
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-msg.dtx b/macros/latex/contrib/fontspec/fontspec-code-msg.dtx
new file mode 100644
index 0000000000..0a37b69284
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-msg.dtx
@@ -0,0 +1,285 @@
+%%^^A%% fontspec-code-msg.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Error/warning/info messages}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% Shorthands for messages:
+% \begin{macrocode}
+\cs_new:Npn \@@_error:n { \msg_error:nn {fontspec} }
+\cs_new:Npn \@@_error:nn { \msg_error:nnn {fontspec} }
+\cs_new:Npn \@@_error:nx { \msg_error:nnx {fontspec} }
+\cs_new:Npn \@@_warning:n { \msg_warning:nn {fontspec} }
+\cs_new:Npn \@@_warning:nx { \msg_warning:nnx {fontspec} }
+\cs_new:Npn \@@_warning:nxx { \msg_warning:nnxx {fontspec} }
+\cs_new:Npn \@@_info:n { \msg_info:nn {fontspec} }
+\cs_new:Npn \@@_info:nx { \msg_info:nnx {fontspec} }
+\cs_new:Npn \@@_info:nxx { \msg_info:nnxx {fontspec} }
+\cs_new:Npn \@@_trace:n { \msg_trace:nn {fontspec} }
+% \end{macrocode}
+%
+% Allow messages to be written with spaces acting as normal:
+% \begin{macrocode}
+\cs_generate_variant:Nn \msg_new:nnn {nnx}
+\cs_generate_variant:Nn \msg_new:nnnn {nnxx}
+\cs_new:Nn \@@_msg_new:nnn
+ { \msg_new:nnx {#1} {#2} { \tl_trim_spaces:n {#3} } }
+\cs_new:Nn \@@_msg_new:nnnn
+ { \msg_new:nnxx {#1} {#2} { \tl_trim_spaces:n {#3} } { \tl_trim_spaces:n {#4} } }
+\char_set_catcode_space:n {32}
+% \end{macrocode}
+%
+% \subsection{Errors}
+%
+% \begin{macrocode}
+\@@_msg_new:nnn {fontspec} {only-inside-encdef}
+ {
+ \exp_not:N#1can only be used in the second argument
+ to \string\DeclareUnicodeEncoding.
+ }
+\@@_msg_new:nnn {fontspec} {no-size-info}
+ {
+ Size information must be supplied.\\
+ For example, SizeFeatures={Size={8-12},...}.
+ }
+\@@_msg_new:nnnn {fontspec} {font-not-found}
+ {
+ The font "#1" cannot be found.
+ }
+ {
+ A font might not be found for many reasons.\\
+ Check the spelling, where the font is installed etc. etc.\\\\
+ When in doubt, ask someone for help!
+ }
+\@@_msg_new:nnnn {fontspec} {rename-feature-not-exist}
+ {
+ The feature #1 doesn't appear to be defined.
+ }
+ {
+ It looks like you're trying to rename a feature that doesn't exist.
+ }
+\@@_msg_new:nnn {fontspec} {no-glyph}
+ {
+ '#1' does not contain glyph #2.
+ }
+\@@_msg_new:nnnn {fontspec} {euler-too-late}
+ {
+ The euler package must be loaded BEFORE fontspec.
+ }
+ {
+ fontspec only overwrites euler's attempt to
+ define the maths text fonts if fontspec is
+ loaded after euler. Type <return> to proceed
+ with incorrect \string\mathit, \string\mathbf, etc.
+ }
+\@@_msg_new:nnnn {fontspec} {no-xcolor}
+ {
+ Cannot load named colours without the xcolor package.
+ }
+ {
+ Sorry, I can't do anything to help. Instead of loading
+ the color package, use xcolor instead.
+ }
+\@@_msg_new:nnnn {fontspec} {unknown-color-model}
+ {
+ Error loading colour `#1'; unknown colour model.
+ }
+ {
+ Sorry, I can't do anything to help. Please report this error
+ to my developer with a minimal example that causes the problem.
+ }
+\@@_msg_new:nnnn {fontspec} {not-in-addfontfeatures}
+ {
+ The "#1" font feature cannot be used in \string\addfontfeatures.
+ }
+ {
+ This is due to how TeX loads fonts; such settings
+ are global so adding them mid-document within a group causes
+ confusion. You'll need to define multiple font families to achieve
+ what you want.
+ }
+% \end{macrocode}
+%
+% \subsection{Warnings}
+%
+% \begin{macrocode}
+\@@_msg_new:nnn {fontspec} {tu-clash}
+ {
+ I have found the tuenc.def encoding definition file but the TU encoding is not
+ defined by the LaTeX2e kernel; attempting to correct but you really should update
+ to the latest version of LaTeX2e.
+ }
+\@@_msg_new:nnn {fontspec} {tu-missing}
+ {
+ The TU encoding seems to be missing; please update to the latest version of LaTeX2e.
+ }
+\@@_msg_new:nnn {fontspec} {addfontfeatures-ignored}
+ {
+ \string\addfontfeature (s) ignored \msg_line_context:;
+ it cannot be used with a font that wasn't selected by a fontspec command.\\
+ \\
+ The current font is "\use:c{font@name}".\\
+ \int_compare:nTF { \clist_count:n {#1} = 1 }
+ { The requested feature is "#1". }
+ { The requested features are "#1". }
+ }
+\@@_msg_new:nnn {fontspec} {feature-option-overwrite}
+ {
+ Option '#2' of font feature '#1' overwritten.
+ }
+\@@_msg_new:nnn {fontspec} {ot-tag-too-long}
+ {
+ OpenType tag '#1' is too long; script, language, and feature tags must be four characters or fewer.
+ }
+\@@_msg_new:nnn {fontspec} {aat-feature-not-exist}
+ {
+ '\l_keys_key_tl=\l_keys_value_tl' feature not supported
+ for AAT font '\l_fontspec_fontname_tl'.
+ }
+\@@_msg_new:nnn {fontspec} {aat-feature-not-exist-in-font}
+ {
+ AAT feature '\l_keys_key_tl=\l_keys_value_tl' (#1) not available
+ in font '\l_fontspec_fontname_tl'.
+ }
+\@@_msg_new:nnn {fontspec} {icu-feature-not-exist}
+ {
+ '\l_keys_key_tl=\l_keys_value_tl' feature not supported
+ for OpenType font '\l_fontspec_fontname_tl'
+ }
+\@@_msg_new:nnn {fontspec} {icu-feature-not-exist-in-font}
+ {
+ OpenType feature '\l_keys_key_tl=\l_keys_value_tl' (#1) not available
+ for font '\l_fontspec_fontname_tl'
+ with script '\l_@@_script_name_tl' and language '\l_@@_lang_name_tl'.
+ }
+\@@_msg_new:nnn {fontspec} {no-opticals}
+ {
+ '#1' doesn't appear to have an Optical Size axis.
+ }
+\@@_msg_new:nnn {fontspec} {language-not-exist}
+ {
+ Language '#1' not available
+ for font '\l_fontspec_fontname_tl'
+ with script '\l_@@_script_name_tl'.
+ }
+\@@_msg_new:nnn {fontspec} {only-xetex-feature}
+ {
+ Ignored XeTeX-only feature: '#1'.
+ }
+\@@_msg_new:nnn {fontspec} {only-luatex-feature}
+ {
+ Ignored LuaTeX-only feature: '#1'.
+ }
+\@@_msg_new:nnn {fontspec} {unknown-renderer}
+ {
+ Renderer '#1' unknown. Assuming Harfbuzz with 'shaper=#1'.
+ Please raise a fontspec issue to add this shaper to the interface.
+ }
+\@@_msg_new:nnn {fontspec} {no-mapping}
+ {
+ Input mapping not supported in LuaTeX.
+ }
+\@@_msg_new:nnn {fontspec} {no-mapping-ligtex}
+ {
+ Input mapping not supported in LuaTeX.\\
+ Use "Ligatures=TeX" instead of "Mapping=tex-text".
+ }
+\@@_msg_new:nnn {fontspec} {cm-default-obsolete}
+ {
+ The "cm-default" package option is obsolete.
+ }
+\@@_msg_new:nnn {fontspec} {fakebold-only-xetex}
+ {
+ The "FakeBold" and "AutoFakeBold" options are only available with XeLaTeX.\\
+ Option ignored.
+ }
+\@@_msg_new:nnn {fontspec} {font-index-needs-ttc}
+ {
+ The "FontIndex" feature is only supported by TTC (TrueType Collection) fonts.\\
+ Feature ignored.
+ }
+\@@_msg_new:nnn {fontspec} {feat-cannot-remove}
+ {
+ The "#1" feature cannot be deactivated. Request ignored.
+ }
+% \end{macrocode}
+%
+% \subsection{Info messages}
+%
+% \begin{macrocode}
+\@@_msg_new:nnn {fontspec} {defining-font}
+ {
+ Font family '\g_@@_nfss_family_tl' created for font '#2'
+ with options [\l_@@_all_features_clist].\\
+ \\
+ This font family consists of the following NFSS series/shapes:\\
+ \g_@@_defined_shapes_tl
+ }
+\@@_msg_new:nnn {fontspec} {no-font-shape}
+ {
+ Could not resolve font "#1" (it probably doesn't exist).
+ }
+\@@_msg_new:nnn {fontspec} {set-scale}
+ {
+ \l_fontspec_fontname_tl\space scale = \l_@@_scale_tl.
+ }
+\@@_msg_new:nnn {fontspec} {setup-math}
+ {
+ Adjusting the maths setup (use [no-math] to avoid this).
+ }
+\@@_msg_new:nnn {fontspec} {no-script}
+ {
+ Font "#1" does not contain requested Script "#2".
+ }
+\@@_msg_new:nnn {fontspec} {opa-twice}
+ {
+ Opacity set twice, in both Colour and Opacity.\\
+ Using specification "Opacity=#1".
+ }
+\@@_msg_new:nnn {fontspec} {opa-twice-col}
+ {
+ Opacity set twice, in both Opacity and Colour.\\
+ Using an opacity specification in hex of "#1/FF".
+ }
+\@@_msg_new:nnn {fontspec} {bad-colour}
+ {
+ Bad colour declaration "#1".
+ Colour must be one of:\\
+ * a named xcolor colour\\
+ * a six-digit hex colour RRGGBB\\
+ * an eight-digit hex colour RRGGBBTT with opacity
+ }
+% \end{macrocode}
+%
+% Reset `space' behaviour:
+% \begin{macrocode}
+\char_set_catcode_ignore:n {32}
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-opening.dtx b/macros/latex/contrib/fontspec/fontspec-code-opening.dtx
new file mode 100644
index 0000000000..ed2a1cba30
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-opening.dtx
@@ -0,0 +1,213 @@
+%%^^A%% fontspec-code-opening.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Opening code}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \subsection{Package options}
+%
+% \begin{macrocode}
+\DeclareOption{cm-default}
+ {
+ \@@_warning:n {cm-default-obsolete}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareOption {math} { \bool_gset_true:N \g_@@_math_bool }
+\DeclareOption {no-math} { \bool_gset_false:N \g_@@_math_bool }
+\DeclareOption {config} { \bool_gset_true:N \g_@@_cfg_bool }
+\DeclareOption {no-config}{ \bool_gset_false:N \g_@@_cfg_bool }
+\DeclareOption {euenc} { \bool_gset_true:N \g_@@_euenc_bool }
+\DeclareOption {tuenc} { \bool_gset_false:N \g_@@_euenc_bool }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareOption {quiet}
+ {
+ \msg_redirect_module:nnn { fontspec } { warning } { info }
+ \msg_redirect_module:nnn { fontspec } { info } { none }
+ }
+\DeclareOption{silent}
+ {
+ \msg_redirect_module:nnn { fontspec } { warning } { none }
+ \msg_redirect_module:nnn { fontspec } { info } { none }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ExecuteOptions{config,math,tuenc}
+\ProcessOptions*
+% \end{macrocode}
+%
+%
+%
+%
+% \subsection{Encodings}
+%
+% Soon to be the default, with a just-in-case check:
+% \begin{macrocode}
+\bool_if:NF \g_@@_euenc_bool
+ {
+ \file_if_exist:nTF {tuenc.def}
+ {
+ \cs_if_exist:cF {T@TU}
+ {
+ \@@_warning:n {tu-clash}
+ \DeclareFontEncoding{TU}{}{}
+ \DeclareFontSubstitution{TU}{lmr}{m}{n}
+ }
+ }
+ {
+ \@@_warning:n {tu-missing}
+ \bool_gset_true:N \g_@@_euenc_bool
+ }
+ }
+\bool_if:NTF \g_@@_euenc_bool
+ {
+%<XE> \tl_gset:Nn \g_fontspec_encoding_tl {EU1}
+%<LU> \tl_gset:Nn \g_fontspec_encoding_tl {EU2}
+ }
+ { \tl_gset:Nn \g_fontspec_encoding_tl { TU } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_set:Nn \rmdefault {lmr}
+\tl_set:Nn \sfdefault {lmss}
+\tl_set:Nn \ttdefault {lmtt}
+\RequirePackage[\g_fontspec_encoding_tl]{fontenc}
+\tl_set_eq:NN \UTFencname \g_fontspec_encoding_tl % for xunicode if needed
+% \end{macrocode}
+% To overcome the encoding changing the current font size, but only if a class has been loaded first:
+% \begin{macrocode}
+\tl_if_in:NnT \@filelist {.cls} { \normalsize }
+% \end{macrocode}
+% Dealing with a couple of the problems introduced by \pkg{babel}:
+% \begin{macrocode}
+\tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl
+\tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl
+\AtBeginDocument
+ {
+ \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl
+ \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl
+ }
+% \end{macrocode}
+% That latin encoding definition is repeated to suppress font warnings.
+% Something to do with \cmd\select@language\ ending up in the \texttt{.aux}
+% file which is read at the beginning of the document.
+%
+% \begin{macrocode}
+\bool_if:NT \g_@@_euenc_bool
+ {
+%<LU> \cs_set_eq:NN \fontspec_tmp: \XeTeXpicfile
+%<LU> \cs_set:Npn \XeTeXpicfile {}
+ \RequirePackage{xunicode}
+%<LU> \cs_set_eq:NN \XeTeXpicfile \fontspec_tmp:
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Generic functions}
+%
+% \begin{macro}{\FontspecSetCheckBoolTrue}
+% \begin{macro}{\FontspecSetCheckBoolFalse}
+% These strange set functions are to simplify returning code from LuaTeX:
+% \begin{macrocode}
+\cs_new:Npn \FontspecSetCheckBoolTrue { \bool_set_true:N \l_@@_check_bool }
+\cs_new:Npn \FontspecSetCheckBoolFalse { \bool_set_false:N \l_@@_check_bool }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@_keys_set_known:nnN}
+% \begin{macrocode}
+\cs_new:Nn \@@_keys_set_known:nnN
+ {
+%<debug> \typeout{:::: Keys~set:~{#1}~{#2} }
+ \keys_set_known:nnN {#1} {#2} #3
+%<debug> \typeout{:::: Leftover:~{#3} }
+ }
+\cs_generate_variant:Nn \@@_keys_set_known:nnN {nx}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_int_mult_truncate:Nn}
+% Missing in expl3, IMO.
+% \begin{macrocode}
+\cs_new:Nn \@@_int_mult_truncate:Nn
+ {
+ \int_set:Nn #1 { \__dim_eval:w #2 #1 \__dim_eval_end: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_lua_function:ne}
+% \begin{macro}{\@@_lua_function:nee}
+% \begin{macro}{\@@_lua_function:neee}
+% \begin{macro}{\@@_lua_function:neeee}
+% \begin{macrocode}
+%<*LU>
+\cs_set:Npn \@@_lua_function:ne #1#2 { \lua_now:e { fontspec.#1 ("#2") } }
+\cs_set:Npn \@@_lua_function:nee #1#2#3 { \lua_now:e { fontspec.#1 ("#2","#3") } }
+\cs_set:Npn \@@_lua_function:neee #1#2#3#4 { \lua_now:e { fontspec.#1 ("#2","#3","#4") } }
+\cs_set:Npn \@@_lua_function:neeee #1#2#3#4#5 { \lua_now:e { fontspec.#1 ("#2","#3","#4","#5") } }
+%</LU>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \subsection{\pkg{expl3} variants}
+%
+% \begin{macrocode}
+\cs_generate_variant:Nn \int_set:Nn {Nv}
+\cs_generate_variant:Nn \keys_set:nn {nx}
+\cs_generate_variant:Nn \keys_set_known:nnN {nx}
+\cs_generate_variant:Nn \prop_put:Nnn {Nxx}
+\cs_generate_variant:Nn \prop_put:Nnn {NxV}
+\cs_generate_variant:Nn \prop_gput_if_new:Nnn {NxV}
+\cs_generate_variant:Nn \prop_gput:Nnn {Nxn}
+\cs_generate_variant:Nn \prop_get:NnNT {NxN}
+\cs_generate_variant:Nn \prop_get:NnNTF {NxN}
+\cs_generate_variant:Nn \str_if_eq:nnTF {nv}
+\cs_generate_variant:Nn \tl_if_empty_p:n {e}
+\cs_generate_variant:Nn \tl_if_empty:nTF {x}
+\cs_generate_variant:Nn \tl_if_empty:nF {x}
+\cs_generate_variant:Nn \tl_if_empty:nF {f}
+\cs_generate_variant:Nn \tl_if_eq:nnT {ox}
+\cs_generate_variant:Nn \tl_replace_all:Nnn {Nnx}
+% \end{macrocode}
+%
+%
+%
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-opentype.dtx b/macros/latex/contrib/fontspec/fontspec-code-opentype.dtx
new file mode 100644
index 0000000000..2a2f2703e3
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-opentype.dtx
@@ -0,0 +1,478 @@
+%%^^A%% fontspec-code-opentype.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{OpenType definitions code}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+%
+%
+% \begin{macro}{\@@_define_opentype_feature_group:n}
+% \begin{macrocode}
+\cs_new:Nn \@@_define_opentype_feature_group:n
+ {
+ \keys_define:nn {fontspec-opentype} { #1 .multichoice: , .groups:n = {opentype} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_define_opentype_feature:nnnnn}
+% \darg{Feature key}
+% \darg{Feature option val}
+% \darg{Check feature --- leave empty for no check}
+% \darg{Exact tag string to activate --- leave empty for disable only}
+% \darg{Tags to remove (clist)}
+% \begin{macrocode}
+\cs_new:Nn \@@_feat_prop_add:nn
+ {
+ \tl_if_empty:nF {#1}
+ {
+ \prop_if_in:NnF \g_@@_OT_features_prop {#1}
+ {
+ \prop_gput:Nnn \g_@@_OT_features_prop {#1} {#2}
+ }
+ }
+ }
+\cs_new:Nn \@@_define_opentype_feature:nnnnn
+ {
+ \@@_feat_prop_add:nn {#3} {#1\,=\,#2}
+ \tl_if_empty:nTF {#4}
+ {
+ \keys_define:nn {fontspec-opentype}
+ {
+ #1/#2 .code:n =
+ { \@@_remove_clashing_featstr:n {#5} } ,
+ #1/#2 .groups:n = {opentype}
+ }
+ }
+ {
+ \keys_define:nn {fontspec-opentype}
+ {
+ #1/#2 .code:n =
+ {
+%<debug> \typeout{::::::::fontspec-opentype~#1/#2~=~#3/#4/#5}
+ \@@_make_OT_feature:nnn {#3} {#4} {#5}
+ } ,
+ #1/#2 .groups:n = {opentype}
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_define_opentype_onoffreset:nnnnn}
+% \darg{Feature key}
+% \darg{Feature option val}
+% \darg{Check feature}
+% \darg{Tag prefix to activate: \texttt{+\#4} = on, \texttt{-\#4} = off.}
+% \darg{Tags to remove in the on case (clist)}
+% \begin{macrocode}
+\cs_new:Nn \@@_feat_off:n {#1Off}
+\cs_new:Nn \@@_feat_reset:n {#1Reset}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_define_opentype_onoffreset:nnnnn
+ {
+ \exp_args:Nnx \@@_define_opentype_feature:nnnnn {#1} {#2} {#3} {+#4} {#5}
+ \exp_args:Nnx \@@_define_opentype_feature:nnnnn {#1} { \@@_feat_off:n {#2} } {#3} {-#4} {}
+ \exp_args:Nnx \@@_define_opentype_feature:nnnnn {#1} { \@@_feat_reset:n {#2} } {} {} {+#4,-#4}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_define_opentype_onreset:nnnnn}
+% \darg{Feature key}
+% \darg{Feature option val}
+% \darg{Check feature}
+% \darg{Exact tag string to activate}
+% \darg{Tags to remove (clist)}
+% \begin{macrocode}
+\cs_new:Nn \@@_define_opentype_onreset:nnnnn
+ {
+ \exp_args:Nnx \@@_define_opentype_feature:nnnnn {#1} {#2} {#3} {#4} {#5}
+ \exp_args:Nnx \@@_define_opentype_feature:nnnnn {#1} { \@@_feat_reset:n {#2} } {} {} {#4}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Adding features when loading fonts}
+%
+% When remove clashing features,
+% \begin{enumerate}
+% \item remove the feature being added (to avoid duplicates);
+% \item remove the inverse of the feature (to avoid cancellation);
+% \item finally remove all clashing features.
+% \end{enumerate}
+% \begin{macrocode}
+\cs_new:Nn \@@_make_OT_feature:nnn
+ {
+%<debug> \typeout{:: @@_make_OT_feature:nnn \exp_not:n { {#1}{#2}{#3} } }
+
+ \bool_set_true:N \l_@@_proceed_bool
+
+ \tl_if_empty:nF {#1}
+ {
+ \exp_args:No \@@_check_ot_feat:NnF \l_@@_fontface_cs_tl {#1}
+ {
+ \@@_warning:nx {icu-feature-not-exist-in-font} {#1}
+ \bool_set_false:N \l_@@_proceed_bool
+ }
+ }
+
+ \@@_remove_clashing_featstr:x { #2 , \@@_swap_plus_minus:n {#2} , #3 }
+
+ \bool_if:NT \l_@@_proceed_bool { \@@_update_featstr:n {#2} }
+ }
+\cs_generate_variant:Nn \@@_make_OT_feature:nnn {xxx}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_swap_plus_minus:n { \@@_swap_plus_minus_aux:Nq #1 \q_nil }
+\cs_new:Npn \@@_swap_plus_minus_aux:Nq #1#2 \q_nil
+ { \str_case:nn {#1} { {+} {-#2} {-} {+#2} } }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@_check_script:NnTF}
+% This macro takes an OpenType script tag and checks if it exists in the current
+% font. \cmd\l_@@_script_int\ is used to store
+% the number corresponding to the script tag string.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_check_script:Nn {TF,T}
+ {
+%<debug>\typeout{:: _check_script:Nn~#1~/~#2}
+ \bool_if:NTF \l_@@_never_check_bool
+ { \prg_return_true: }
+ {
+ \bool_if:nTF { \tl_if_empty_p:e {#2} }
+ { \prg_return_false: }
+ {
+%<*XE>
+%<debug>\typeout{::::~ checking~ script~ #2}
+ \@@_iv_str_to_num:Nx \l_@@_strnum_int {#2}
+ \int_set:Nn \l_tmpb_int { \XeTeXOTcountscripts #1 }
+ \int_zero:N \l_tmpa_int
+ \bool_set_false:N \l__fontspec_check_bool
+ \bool_until_do:nn { \int_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
+ {
+ \ifnum \XeTeXOTscripttag #1 \l_tmpa_int = \l_@@_strnum_int
+ \bool_set_true:N \l__fontspec_check_bool
+ \int_set:Nn \l_tmpa_int {\l_tmpb_int}
+ \else
+ \int_incr:N \l_tmpa_int
+ \fi
+ }
+ \bool_if:NTF \l__fontspec_check_bool \prg_return_true: \prg_return_false:
+%</XE>
+%<*LU>
+ \@@_ot_validate_tag:x {#2}
+ \cs_if_eq:NNTF #1 \font
+ { \tl_set:Nx \l_@@_tmp_tl {\curr@fontshape/\f@size} }
+ { \tl_set:Nx \l_@@_tmp_tl {\cs_to_str:N #1} }
+%<debug>\typeout{::::~ checking:~"\l_@@_tmp_tl",~ "#2"}
+ \lua_now:e { fontspec.check_ot_script("\l_@@_tmp_tl", "#2") }
+ \bool_if:NTF \l__fontspec_check_bool
+ {
+%<debug>\typeout{::::::~ TRUE}
+ \prg_return_true:
+ }
+ {
+%<debug>\typeout{::::::~ FALSE}
+ \prg_return_false:
+ }
+%</LU>
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_check_lang:NnnTF}
+% \begin{macro}{\@@_check_lang:NnTF}
+% This macro takes an OpenType language tag and checks if it exists in the current
+% font/script. \cmd\l_@@_language_int\ is used to store
+% the number corresponding to the language tag string.
+% The script used is whatever's held in \cmd\l_@@_script_int. By default, that's the
+% number corresponding to `|latn|'.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_check_lang:Nn {TF}
+ {
+ \@@_check_lang:NnnTF #1 {#2} {\l_@@_script_tl} {\prg_return_true:} {\prg_return_false:}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_check_lang:Nnn {TF}
+ {
+%<debug>\typeout{:: _check_lang:Nn~#1~/~#2~/~#3~/}
+ \bool_if:NTF \l_@@_never_check_bool
+ { \prg_return_true: }
+ {
+ \bool_if:nTF { \tl_if_empty_p:e {#3} }
+ { \prg_return_false: }
+ {
+%<*XE>
+ \@@_iv_str_to_num:Nx \l_@@_strnum_int {#2}
+ \@@_iv_str_to_num:Nx \l_@@_script_int {#3}
+ \int_set:Nn \l_@@_tmpb_int
+ { \XeTeXOTcountlanguages #1 \l_@@_script_int }
+ \int_zero:N \l_@@_tmpa_int
+ \bool_set_false:N \l__fontspec_check_bool
+ \bool_until_do:nn { \int_compare_p:nNn \l_@@_tmpa_int = \l_@@_tmpb_int }
+ {
+ \int_set:Nn \l_@@_tmpc_int
+ { \XeTeXOTlanguagetag #1 \l_@@_script_int \l_@@_tmpa_int }
+
+ \int_compare:nNnTF \l_@@_tmpc_int = \l_@@_strnum_int
+ {
+ \bool_set_true:N \l__fontspec_check_bool
+ \int_set:Nn \l_@@_tmpa_int {\l_@@_tmpb_int}
+ }
+ {
+ \int_incr:N \l_@@_tmpa_int
+ }
+ }
+ \bool_if:NTF \l__fontspec_check_bool \prg_return_true: \prg_return_false:
+%</XE>
+%<*LU>
+ \@@_ot_validate_tag:x {#2}
+ \@@_ot_validate_tag:x {#3}
+ \cs_if_eq:NNTF #1 \font
+ { \tl_set:Nx \l_@@_tmp_tl {\curr@fontshape/\f@size} }
+ { \tl_set:Nx \l_@@_tmp_tl {\cs_to_str:N #1} }
+ \@@_lua_function:neee {check_ot_lang} {\l_@@_tmp_tl} {#2} {#3}
+ \bool_if:NTF \l__fontspec_check_bool \prg_return_true: \prg_return_false:
+%</LU>
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@_check_ot_feat:NnTF}
+% \begin{macro}{\@@_check_ot_feat:NnnnTF}
+% This macro takes an OpenType feature tag and checks if it exists in the current
+% font/script/language.
+% \cmd\l_@@_strnum_int\ is used to store the number corresponding to the feature tag string.
+% The script used is whatever's held in \cmd\l_@@_script_int. By default, that's the
+% number corresponding to `|latn|'. The language used is \cmd\l_@@_language_int,
+% by default |0|, the `default language'.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_check_ot_feat:Nn {TF,F}
+ {
+ \@@_check_ot_feat:NnnnTF #1 {#2} {\l_@@_lang_tl} {\l_@@_script_tl}
+ {\prg_return_true:} {\prg_return_false:}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_check_ot_feat:Nnnn {TF,F}
+ {
+ \bool_if:NTF \l_@@_never_check_bool
+ { \prg_return_true: }
+ {
+ \bool_if:nTF { \tl_if_empty_p:e {#3} || \tl_if_empty_p:e {#4} }
+ { \prg_return_false: }
+ {
+%<*XE>
+%<debug>\typeout{::~ fontspec_check_ot_feat:nnn~ {#2}{#3}{#4}}
+ \@@_iv_str_to_num:Nx \l_@@_strnum_int {#2}
+ \@@_iv_str_to_num:Nx \l_@@_language_int {#3}
+ \@@_lang_dflt_correct:N \l_@@_language_int
+ \@@_iv_str_to_num:Nx \l_@@_script_int {#4}
+ \int_set:Nn \l_tmpb_int
+ {
+ \XeTeXOTcountfeatures #1
+ \l_@@_script_int
+ \l_@@_language_int
+ }
+ \int_zero:N \l_tmpa_int
+ \bool_set_false:N \l_@@_check_bool
+ \bool_until_do:nn { \int_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
+ {
+ \ifnum\XeTeXOTfeaturetag #1 \l_@@_script_int \l_@@_language_int
+ \l_tmpa_int =\l_@@_strnum_int
+ \bool_set_true:N \l_@@_check_bool
+ \int_set:Nn \l_tmpa_int {\l_tmpb_int}
+ \else
+ \int_incr:N \l_tmpa_int
+ \fi
+ }
+ \bool_if:NTF \l_@@_check_bool \prg_return_true: \prg_return_false:
+%</XE>
+%<*LU>
+%<debug>\typeout{::~ fontspec_check_ot_feat:n~ {#1}}
+ \@@_ot_validate_tag:x {#2}
+ \@@_ot_validate_tag:x {#3}
+ \@@_ot_validate_tag:x {#4}
+ \cs_if_eq:NNTF #1 \font
+ { \tl_set:Nx \l_@@_tmp_tl {\curr@fontshape/\f@size} }
+ { \tl_set:Nx \l_@@_tmp_tl {\cs_to_str:N #1} }
+ \@@_lua_function:neeee {check_ot_feat} {\l_@@_tmp_tl} {#2} {#3} {#4}
+ \bool_if:NTF \l_@@_check_bool \prg_return_true: \prg_return_false:
+%</LU>
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{OpenType feature information}
+%
+% \begin{macrocode}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {aalt}{Access~All~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {abvf}{Above-base~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {abvm}{Above-base~Mark~Positioning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {abvs}{Above-base~Substitutions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {afrc}{Alternative~Fractions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {akhn}{Akhands}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {blwf}{Below-base~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {blwm}{Below-base~Mark~Positioning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {blws}{Below-base~Substitutions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {calt}{Contextual~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {case}{Case-Sensitive~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ccmp}{Glyph~Composition~/~Decomposition}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cfar}{Conjunct~Form~After~Ro}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cjct}{Conjunct~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {clig}{Contextual~Ligatures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cpct}{Centered~CJK~Punctuation}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cpsp}{Capital~Spacing}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cswh}{Contextual~Swash}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {curs}{Cursive~Positioning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {cvNN}{Character~Variant~$N$}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {c2pc}{Petite~Capitals~From~Capitals}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {c2sc}{Small~Capitals~From~Capitals}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {dist}{Distances}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {dlig}{Discretionary~Ligatures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {dnom}{Denominators}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {dtls}{Dotless~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {expt}{Expert~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {falt}{Final~Glyph~on~Line~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {fin2}{Terminal~Forms~\#2}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {fin3}{Terminal~Forms~\#3}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {fina}{Terminal~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {flac}{Flattened~accent~forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {frac}{Fractions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {fwid}{Full~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {half}{Half~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {haln}{Halant~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {halt}{Alternate~Half~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hist}{Historical~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hkna}{Horizontal~Kana~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hlig}{Historical~Ligatures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hngl}{Hangul}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hojo}{Hojo~Kanji~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {hwid}{Half~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {init}{Initial~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {isol}{Isolated~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ital}{Italics}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {jalt}{Justification~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {jp78}{JIS78~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {jp83}{JIS83~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {jp90}{JIS90~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {jp04}{JIS2004~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {kern}{Kerning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {lfbd}{Left~Bounds}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {liga}{Standard~Ligatures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ljmo}{Leading~Jamo~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {lnum}{Lining~Figures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {locl}{Localized~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ltra}{Left-to-right~alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ltrm}{Left-to-right~mirrored~forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {mark}{Mark~Positioning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {med2}{Medial~Forms~\#2}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {medi}{Medial~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {mgrk}{Mathematical~Greek}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {mkmk}{Mark~to~Mark~Positioning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {mset}{Mark~Positioning~via~Substitution}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {nalt}{Alternate~Annotation~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {nlck}{NLC~Kanji~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {nukt}{Nukta~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {numr}{Numerators}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {onum}{Oldstyle~Figures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {opbd}{Optical~Bounds}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ordn}{Ordinals}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ornm}{Ornaments}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {palt}{Proportional~Alternate~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pcap}{Petite~Capitals}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pkna}{Proportional~Kana}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pnum}{Proportional~Figures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pref}{Pre-Base~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pres}{Pre-base~Substitutions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pstf}{Post-base~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {psts}{Post-base~Substitutions}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {pwid}{Proportional~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {qwid}{Quarter~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rand}{Randomize}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rclt}{Required~Contextual~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rkrf}{Rakar~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rlig}{Required~Ligatures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rphf}{Reph~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rtbd}{Right~Bounds}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rtla}{Right-to-left~alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rtlm}{Right-to-left~mirrored~forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ruby}{Ruby~Notation~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {rvrn}{Required~Variation~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {salt}{Stylistic~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {sinf}{Scientific~Inferiors}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {size}{Optical~size}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {smcp}{Small~Capitals}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {smpl}{Simplified~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ssNN}{Stylistic~Set~$N$}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {ssty}{Math~script~style~alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {stch}{Stretching~Glyph~Decomposition}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {subs}{Subscript}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {sups}{Superscript}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {swsh}{Swash}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {titl}{Titling}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {tjmo}{Trailing~Jamo~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {tnam}{Traditional~Name~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {tnum}{Tabular~Figures}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {trad}{Traditional~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {twid}{Third~Widths}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {unic}{Unicase}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {valt}{Alternate~Vertical~Metrics}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vatu}{Vattu~Variants}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vert}{Vertical~Writing}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vhal}{Alternate~Vertical~Half~Metrics}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vjmo}{Vowel~Jamo~Forms}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vkna}{Vertical~Kana~Alternates}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vkrn}{Vertical~Kerning}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vpal}{Proportional~Alternate~Vertical~Metrics}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vrt2}{Vertical~Alternates~and~Rotation}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {vrtr}{Vertical~Alternates~for~Rotation}
+\prop_gput:Nnn \g_@@_all_opentype_feature_names_prop {zero}{Slashed~Zero}
+% \end{macrocode}
+% TODO: move the above elsewhere!!
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-patches.dtx b/macros/latex/contrib/fontspec/fontspec-code-patches.dtx
new file mode 100644
index 0000000000..14037be075
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-patches.dtx
@@ -0,0 +1,182 @@
+%%^^A%% fontspec-code-patches.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Patching code}
+%
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+%
+%
+% \subsection{Verbatims}
+%
+% Many thanks to Apostolos Syropoulos for discovering this problem and writing the redefinion of \LaTeX's |verbatim| environment and \cs{verb*} command.
+%
+% \begin{macro}{\fontspec_visible_space:}
+% Print \unichar{2423}{Open box}, which is used to visibly display a space character.
+% \begin{macrocode}
+\cs_new_protected:Nn \fontspec_visible_space:
+ {
+ \@@_primitive_font_glyph_if_exist:NnTF \font {"2423}
+ { \char"2423\scan_stop: }
+ { \fontspec_visible_space_fallback: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_visible_space_fallback:}
+% If the current font doesn't have \unichar{2423}{Open box}, use Latin Modern Mono instead.
+% \begin{macrocode}
+\cs_new_protected:Nn \fontspec_visible_space_fallback:
+ {
+ {
+ \usefont{\g_fontspec_encoding_tl}{lmtt}{\f@series}{\f@shape}
+ \textvisiblespace
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fontspec_print_visible_spaces:}
+% Helper macro to turn spaces (\verb|^^20|) active and print visible space instead.
+% \begin{macrocode}
+\group_begin:
+\char_set_catcode_active:n{"20}%
+\cs_gset:Npn\fontspec_print_visible_spaces:{%
+\char_set_catcode_active:n{"20}%
+\cs_set_eq:NN^^20\fontspec_visible_space:%
+}%
+\group_end:
+% \end{macrocode}
+% \end{macro}
+%
+% In 2019 there will be a new kernel-supported command for generalising `verbatim visible spaces'.
+% For now we check if the new command is defined and disable all patching if so.
+% In 2020, I suppose, I'll remove all the patching code here.
+%
+% \begin{macrocode}
+\AtBeginDocument
+ {
+ \cs_if_exist:NF \verbvisiblespace
+ {
+ \@@_patch_verb:
+ \@@_patch_verbatim:
+ \@@_patch_moreverb:
+ \@@_patch_fancyvrb:
+ \@@_patch_listings:
+ }
+ }
+% \end{macrocode}
+%
+%
+% \begin{macro}{\verb}
+% \begin{macro}{\verb*}
+% Redefine \cmd\verb\ to use \cmd\fontspec_print_visible_spaces:.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_verb:
+ {
+ \def\verb
+ {
+ \relax\ifmmode\hbox\else\leavevmode\null\fi
+ \bgroup
+ \verb@eol@error \let\do\@makeother \dospecials
+ \verbatim@font\@noligs
+ \@ifstar\@@sverb\@verb
+ }
+ \def\@@sverb{\fontspec_print_visible_spaces:\@sverb}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{environment}{verbatim*}
+% With the \pkg{verbatim} package.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_verbatim:
+ {
+ \@ifpackageloaded{verbatim}
+ {
+ \cs_set:cpn {verbatim*}
+ {
+ \group_begin: \@verbatim \fontspec_print_visible_spaces: \verbatim@start
+ }
+ }
+% \end{macrocode}
+% This is for vanilla \LaTeX.
+% \begin{macrocode}
+ {
+ \cs_set:cpn {verbatim*}
+ {
+ \@verbatim \fontspec_print_visible_spaces: \@sxverbatim
+ }
+ }
+ }
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{listingcont*}
+% This is for \pkg{moreverb}.
+% The main |listing*| environment inherits this definition.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_moreverb:
+ {
+ \@ifpackageloaded{moreverb}
+ {
+ \cs_set:cpn {listingcont*}
+ {
+ \cs_set:Npn \verbatim@processline
+ {
+ \thelisting@line \global\advance\listing@line1\relax
+ \the\verbatim@line\par
+ }
+ \@verbatim \fontspec_print_visible_spaces: \verbatim@start
+ }
+ }{}
+ }
+% \end{macrocode}
+% \end{environment}
+%
+% \pkg{listings} and \pkg{fancvrb} make things nice and easy:
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_fancyvrb:
+ {
+ \@ifpackageloaded{fancyvrb}
+ {
+ \cs_set_eq:NN \FancyVerbSpace \fontspec_visible_space:
+ }{}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_listings:
+ {
+ \@ifpackageloaded{listings}
+ {
+ \cs_set_eq:NN \lst@visiblespace \fontspec_visible_space:
+ }{}
+ }
+% \end{macrocode}
+%
+%
+%
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-scripts.dtx b/macros/latex/contrib/fontspec/fontspec-code-scripts.dtx
new file mode 100644
index 0000000000..3d5644dd2a
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-scripts.dtx
@@ -0,0 +1,184 @@
+%%^^A%% fontspec-code-scripts.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Font script definitions}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% \begin{macrocode}
+\newfontscript{Adlam}{adlm}
+\newfontscript{Ahom}{ahom}
+\newfontscript{Anatolian~Hieroglyphs}{hluw}
+\newfontscript{Arabic}{arab}
+\newfontscript{Armenian}{armn}
+\newfontscript{Avestan}{avst}
+\newfontscript{Balinese}{bali}
+\newfontscript{Bamum}{bamu}
+\newfontscript{Bassa~Vah}{bass}
+\newfontscript{Batak}{batk}
+\newfontscript{Bengali}{bng2,beng}
+\newfontscript{Bhaiksuki}{bhks}
+\newfontscript{Bopomofo}{bopo}
+\newfontscript{Brahmi}{brah}
+\newfontscript{Braille}{brai}
+\newfontscript{Buginese}{bugi}
+\newfontscript{Buhid}{buhd}
+\newfontscript{Byzantine~Music}{byzm}
+\newfontscript{Canadian~Syllabics}{cans}
+\newfontscript{Carian}{cari}
+\newfontscript{Caucasian~Albanian}{aghb}
+\newfontscript{Chakma}{cakm}
+\newfontscript{Cham}{cham}
+\newfontscript{Cherokee}{cher}
+\newfontscript{CJK~Ideographic}{hani}
+\newfontscript{Coptic}{copt}
+\newfontscript{Cypriot~Syllabary}{cprt}
+\newfontscript{Cyrillic}{cyrl}
+\newfontscript{Default}{DFLT}
+\newfontscript{CustomDefault}{latn,DFLT}
+\newfontscript{Deseret}{dsrt}
+\newfontscript{Devanagari}{dev2,deva}
+\newfontscript{Duployan}{dupl}
+\newfontscript{Egyptian~Hieroglyphs}{egyp}
+\newfontscript{Elbasan}{elba}
+\newfontscript{Ethiopic}{ethi}
+\newfontscript{Georgian}{geor}
+\newfontscript{Glagolitic}{glag}
+\newfontscript{Gothic}{goth}
+\newfontscript{Grantha}{gran}
+\newfontscript{Greek}{grek}
+\newfontscript{Gujarati}{gjr2,gujr}
+\newfontscript{Gurmukhi}{gur2,guru}
+\newfontscript{Hangul~Jamo}{jamo}
+\newfontscript{Hangul}{hang}
+\newfontscript{Hanunoo}{hano}
+\newfontscript{Hatran}{hatr}
+\newfontscript{Hebrew}{hebr}
+\newfontscript{Hiragana~and~Katakana}{kana}
+\newfontscript{Imperial~Aramaic}{armi}
+\newfontscript{Inscriptional~Pahlavi}{phli}
+\newfontscript{Inscriptional~Parthian}{prti}
+\newfontscript{Javanese}{java}
+\newfontscript{Kaithi}{kthi}
+\newfontscript{Kannada}{knd2,knda}
+\newfontscript{Kayah~Li}{kali}
+\newfontscript{Kharosthi}{khar}
+\newfontscript{Khmer}{khmr}
+\newfontscript{Khojki}{khoj}
+\newfontscript{Khudawadi}{sind}
+\newfontscript{Lao}{lao~}
+\newfontscript{Latin}{latn}
+\newfontscript{Lepcha}{lepc}
+\newfontscript{Limbu}{limb}
+\newfontscript{Linear~A}{lina}
+\newfontscript{Linear~B}{linb}
+\newfontscript{Lisu}{lisu}
+\newfontscript{Lycian}{lyci}
+\newfontscript{Lydian}{lydi}
+\newfontscript{Mahajani}{mahj}
+\newfontscript{Malayalam}{mlm2,mlym}
+\newfontscript{Mandaic}{mand}
+\newfontscript{Manichaean}{mani}
+\newfontscript{Marchen}{marc}
+\newfontscript{Math}{math}
+\newfontscript{Meitei~Mayek}{mtei}
+\newfontscript{Mende~Kikakui}{mend}
+\newfontscript{Meroitic~Cursive}{merc}
+\newfontscript{Meroitic~Hieroglyphs}{mero}
+\newfontscript{Miao}{plrd}
+\newfontscript{Modi}{modi}
+\newfontscript{Mongolian}{mong}
+\newfontscript{Mro}{mroo}
+\newfontscript{Multani}{mult}
+\newfontscript{Musical~Symbols}{musc}
+\newfontscript{Myanmar}{mym2,mymr}
+\newfontscript{N'Ko}{nko~}
+\newfontscript{Nabataean}{nbat}
+\newfontscript{Newa}{newa}
+\newfontscript{Odia}{ory2,orya}
+\newfontscript{Ogham}{ogam}
+\newfontscript{Ol~Chiki}{olck}
+\newfontscript{Old~Italic}{ital}
+\newfontscript{Old~Hungarian}{hung}
+\newfontscript{Old~North~Arabian}{narb}
+\newfontscript{Old~Permic}{perm}
+\newfontscript{Old~Persian~Cuneiform}{xpeo}
+\newfontscript{Old~South~Arabian}{sarb}
+\newfontscript{Old~Turkic}{orkh}
+\newfontscript{Osage}{osge}
+\newfontscript{Osmanya}{osma}
+\newfontscript{Pahawh~Hmong}{hmng}
+\newfontscript{Palmyrene}{palm}
+\newfontscript{Pau~Cin~Hau}{pauc}
+\newfontscript{Phags-pa}{phag}
+\newfontscript{Phoenician}{phnx}
+\newfontscript{Psalter~Pahlavi}{phlp}
+\newfontscript{Rejang}{rjng}
+\newfontscript{Runic}{runr}
+\newfontscript{Samaritan}{samr}
+\newfontscript{Saurashtra}{saur}
+\newfontscript{Sharada}{shrd}
+\newfontscript{Shavian}{shaw}
+\newfontscript{Siddham}{sidd}
+\newfontscript{Sign~Writing}{sgnw}
+\newfontscript{Sinhala}{sinh}
+\newfontscript{Sora~Sompeng}{sora}
+\newfontscript{Sumero-Akkadian~Cuneiform}{xsux}
+\newfontscript{Sundanese}{sund}
+\newfontscript{Syloti~Nagri}{sylo}
+\newfontscript{Syriac}{syrc}
+\newfontscript{Tagalog}{tglg}
+\newfontscript{Tagbanwa}{tagb}
+\newfontscript{Tai~Le}{tale}
+\newfontscript{Tai~Lu}{talu}
+\newfontscript{Tai~Tham}{lana}
+\newfontscript{Tai~Viet}{tavt}
+\newfontscript{Takri}{takr}
+\newfontscript{Tamil}{tml2,taml}
+\newfontscript{Tangut}{tang}
+\newfontscript{Telugu}{tel2,telu}
+\newfontscript{Thaana}{thaa}
+\newfontscript{Thai}{thai}
+\newfontscript{Tibetan}{tibt}
+\newfontscript{Tifinagh}{tfng}
+\newfontscript{Tirhuta}{tirh}
+\newfontscript{Ugaritic~Cuneiform}{ugar}
+\newfontscript{Vai}{vai~}
+\newfontscript{Warang~Citi}{wara}
+\newfontscript{Yi}{yi~~}
+% \end{macrocode}
+% For convenience or backwards compatibility:
+% \begin{macrocode}
+\newfontscript{CJK}{hani}
+\newfontscript{Kana}{kana}
+\newfontscript{Maths}{math}
+\newfontscript{N'ko}{nko~}
+\newfontscript{Oriya}{ory2,orya}
+% \end{macrocode}
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-user.dtx b/macros/latex/contrib/fontspec/fontspec-code-user.dtx
new file mode 100644
index 0000000000..1a0173c981
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-user.dtx
@@ -0,0 +1,540 @@
+%%^^A%% fontspec-code-user.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{User command internals}
+% \label{sec:codeinternal}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+%
+% \subsection{Font selection}
+%
+% \begin{macro}{\@@_main_fontspec:nn}
+% This is the main command of the package that
+% selects fonts with various features. It takes two arguments: the
+% font name and the optional requested features of that
+% font.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_fontspec:nn
+ {
+ \fontspec_set_family:Nnn \f@family {#1} {#2}
+ \fontencoding { \g_@@_nfss_enc_tl }
+ \selectfont
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setmainfont}
+% The following three macros perform equivalent operations setting
+% the default font for a particular family: `roman', sans serif, or typewriter
+% (monospaced).
+%
+% They end with |\normalfont| so that if they're
+% used in the document, the change registers immediately.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setmainfont:nn
+ {
+ \fontspec_set_family:Nnn \l_@@_rmfamily_family_tl {#1} {#2}
+ \tl_set_eq:NN \rmdefault \l_@@_rmfamily_family_tl
+ \use:x
+ {
+ \exp_not:n { \DeclareRobustCommand \rmfamily }
+ {
+ \exp_not:N \fontencoding { \g_@@_nfss_enc_tl }
+ \exp_not:N \fontfamily { \l_@@_rmfamily_family_tl }
+ \exp_not:N \selectfont
+ }
+ }
+ \str_if_eq:eeT {\familydefault} {\rmdefault}
+ { \tl_set_eq:NN \encodingdefault \g_@@_nfss_enc_tl }
+ \@@_setmainfont_hook:nn {#1} {#2}
+ \normalfont
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setsansfont}
+% Same as above.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setsansfont:nn
+ {
+ \fontspec_set_family:Nnn \l_@@_sffamily_family_tl {#1} {#2}
+ \tl_set_eq:NN \sfdefault \l_@@_sffamily_family_tl
+ \use:x
+ {
+ \exp_not:n { \DeclareRobustCommand \sffamily }
+ {
+ \exp_not:N \fontencoding { \g_@@_nfss_enc_tl }
+ \exp_not:N \fontfamily { \l_@@_sffamily_family_tl }
+ \exp_not:N \selectfont
+ }
+ }
+ \str_if_eq:eeT {\familydefault} {\sfdefault}
+ { \tl_set_eq:NN \encodingdefault \g_@@_nfss_enc_tl }
+ \@@_setsansfont_hook:nn {#1} {#2}
+ \normalfont
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setmonofont}
+% Same as above.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setmonofont:nn
+ {
+ \fontspec_set_family:Nnn \l_@@_ttfamily_family_tl {#1} {#2}
+ \tl_set_eq:NN \ttdefault \l_@@_ttfamily_family_tl
+ \use:x
+ {
+ \exp_not:n { \DeclareRobustCommand \ttfamily }
+ {
+ \exp_not:N \fontencoding { \g_@@_nfss_enc_tl }
+ \exp_not:N \fontfamily { \l_@@_ttfamily_family_tl }
+ \exp_not:N \selectfont
+ }
+ }
+ \str_if_eq:eeT {\familydefault} {\ttdefault}
+ { \tl_set_eq:NN \encodingdefault \g_@@_nfss_enc_tl }
+ \@@_setmonofont_hook:nn {#1} {#2}
+ \normalfont
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
+% \begin{macro}{\setmathrm}
+% These commands are analogous to \cmd\setmainfont\ and others,
+% but for selecting the font used for \cmd\mathrm, \etc. They
+% can only be used in the preamble of the
+% document. \cmd\setboldmathrm\ is used for specifying which
+% fonts should be used in \cmd\boldmath.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setmathrm:nn
+ {
+%<XE> \fontspec_gset_family:Nnn \g_@@_mathrm_tl {#1} {#2}
+%<LU> \fontspec_gset_family:Nnn \g_@@_mathrm_tl {Renderer=Basic,#1} {#2}
+ \@@_setmathrm_hook:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setboldmathrm}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setboldmathrm:nn
+ {
+%<XE> \fontspec_gset_family:Nnn \g_@@_bfmathrm_tl {#1} {#2}
+%<LU> \fontspec_gset_family:Nnn \g_@@_bfmathrm_tl {Renderer=Basic,#1} {#2}
+ \@@_setboldmathrm_hook:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setmathsf}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setmathsf:nn
+ {
+%<XE> \fontspec_gset_family:Nnn \g_@@_mathsf_tl {#1} {#2}
+%<LU> \fontspec_gset_family:Nnn \g_@@_mathsf_tl {Renderer=Basic,#1} {#2}
+ \@@_setmathsf_hook:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setmathtt}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_setmathtt:nn
+ {
+%<XE> \fontspec_gset_family:Nnn \g_@@_mathtt_tl {#1} {#2}
+%<LU> \fontspec_gset_family:Nnn \g_@@_mathtt_tl {Renderer=Basic,#1} {#2}
+ \@@_setmathtt_hook:nn {#1} {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Hooks:
+% \begin{macrocode}
+\cs_set_eq:NN \@@_setmainfont_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setsansfont_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setmonofont_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setmathrm_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setmathsf_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setmathtt_hook:nn \use_none:nn
+\cs_set_eq:NN \@@_setboldmathrm_hook:nn \use_none:nn
+% \end{macrocode}
+%
+% Hmm, this isn't necessary with \pkg{unicode-math}; oh well:
+% \begin{macrocode}
+\@onlypreamble\setmathrm
+\@onlypreamble\setboldmathrm
+\@onlypreamble\setmathsf
+\@onlypreamble\setmathtt
+% \end{macrocode}
+%
+% If the commands above are not executed, then \cmd\rmdefault\ (\etc)
+% will be used.
+% \begin{macrocode}
+\tl_gset:Nn \g_@@_mathrm_tl {\rmdefault}
+\tl_gset:Nn \g_@@_mathsf_tl {\sfdefault}
+\tl_gset:Nn \g_@@_mathtt_tl {\ttdefault}
+% \end{macrocode}
+%
+% \begin{macro}{\@@_main_newfontfamily:NnnN}
+% The inner fontspec workings define a font family, which is then used in a typical
+% NFSS \cmd\fontfamily\ declaration, saved in the macro name specified.
+% The fourth argument determines which xparse function to set the macro with (new/renew/etc).
+% \begin{macrocode}
+\cs_new:Nn \@@_main_newfontfamily:NnnN
+ {
+ \fontspec_set_family:cnn { l_@@_ \cs_to_str:N #1 _family_tl } {#2} {#3}
+ \use:x
+ {
+ \exp_not:N #4 \exp_not:N #1 {}
+ {
+ \exp_not:N \fontfamily { \use:c { l_@@_ \cs_to_str:N #1 _family_tl } }
+ \exp_not:N \fontencoding { \g_@@_nfss_enc_tl }
+ \exp_not:N \selectfont
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_main_newfontface:NnnN}
+% \cmd\newfontface\ uses the fact that if the argument to \feat{BoldFont}, etc., is empty (\ie, |BoldFont={}|), then no bold font is searched for.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_newfontface:NnnN
+ {
+ \@@_main_newfontfamily:NnnN #1 { BoldFont={},ItalicFont={},SmallCapsFont={},#2 } {#3} #4
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Font feature selection}
+%
+% \begin{macro}{\@@_set_default_features:nn}
+% \begin{macrocode}
+\cs_new:Nn \@@_set_default_features:nn
+ {
+ \IfBooleanTF {#1} \clist_gput_right:Nn \clist_gset:Nn
+ \g_@@_default_fontopts_clist {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_set_font_default_features:nnn}
+% The optional argument |#2| specifies font identifier(s).
+% Branch for either (a)~single token input such as \verb|\rmdefault|, or (b)~otherwise assume its a fontname.
+% In that case, strip spaces and file extensions and lower-case to ensure consistency.
+% \begin{macrocode}
+\cs_new:Nn \@@_set_font_default_features:nnn
+ {
+%<debug> \typeout{\unexpanded{_set_font_default_features:nnn:{#1}{#2}{#3}}}
+ \clist_map_inline:nn {#2}
+ {
+ \tl_if_single:nTF {##1}
+ { \tl_set:No \l_@@_tmp_tl { \cs:w l_@@_ \cs_to_str:N ##1 _family_tl\cs_end: } }
+ { \@@_sanitise_fontname:Nn \l_@@_tmp_tl {##1} }
+
+ \IfBooleanTF {#1}
+ {
+ \prop_get:NVNF \g_@@_fontopts_prop \l_@@_tmp_tl \l_@@_tmpb_tl
+ { \tl_clear:N \l_@@_tmpb_tl }
+ \tl_put_right:Nn \l_@@_tmpb_tl {#3,}
+ \prop_gput:NVV \g_@@_fontopts_prop \l_@@_tmp_tl \l_@@_tmpb_tl
+ }
+ {
+ \tl_if_empty:nTF {#3}
+ { \prop_gremove:NV \g_@@_fontopts_prop \l_@@_tmp_tl }
+ { \prop_gput:NVn \g_@@_fontopts_prop \l_@@_tmp_tl {#3,} }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\addfontfeatures}
+% In order to be able to extend the feature selection of
+% a given font, two things need to be known: the currently selected
+% features, and the currently selected font. Every time a font
+% family is created, this information is saved inside a control
+% sequence with the name of the font family itself.
+%
+% This macro extracts this information, then appends the requested
+% font features to add to the already existing ones, and calls the
+% font again with the top level \cs{fontspec} command.
+%
+% The default options are \emph{not} applied (which is why
+% \cs{g_fontspec_default_fontopts_tl} is emptied inside the group; this is allowed
+% as \cmd\l_fontspec_family_tl\ is globally defined in \cmd\@@_select_font_family:nn), so this
+% means that the only added features to the font are strictly those
+% specified by this command.
+%
+% \cs{addfontfeature} is defined as an alias, as I found that I
+% often typed this instead when adding only a single font feature.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_addfontfeatures:n
+ {
+%<debug> \typeout{^^J::::::::::::::::::::::::::::::::::^^J: addfontfeatures}
+ \fontspec_if_fontspec_font:TF
+ {
+ \group_begin:
+ \keys_set_known:nnN {fontspec-addfeatures} {#1} \l_@@_tmp_tl
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {options} \l_@@_options_tl
+ \prop_get:cnN {g_@@_fontinfo_ \f@family _prop} {fontname} \l_@@_fontname_tl
+ \bool_set_true:N \l_@@_disable_defaults_bool
+%<debug> \typeout{ \@@_select_font_family:nn { \l_@@_options_tl , #1 } {\l_@@_fontname_tl} }
+ \use:x
+ {
+ \@@_select_font_family:nn
+ { \l_@@_options_tl , #1 } {\l_@@_fontname_tl}
+ }
+ \group_end:
+ \fontfamily \g_@@_nfss_family_tl \selectfont
+ }
+ {
+ \@@_warning:nx {addfontfeatures-ignored} {#1}
+ }
+ \ignorespaces
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Defining new font features}
+%
+% \begin{macro}{\newfontfeature}
+% \cs{newfontfeature} takes two arguments: the name of the feature
+% tag by which to reference it, and the string that is used to
+% select the font feature.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_newfontfeature:nn
+ {
+ \keys_define:nn { fontspec }
+ {
+ #1 .code:n = { \@@_update_featstr:n {#2} }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\newAATfeature}
+% This command assigns a new AAT feature by its code (|#2|,|#3|) to a new name (|#1|).
+% Better than \cmd\newfontfeature\ because it checks if the feature exists in the
+% font it's being used for.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_newAATfeature:nnnn
+ {
+ \keys_if_exist:nnF { fontspec } {#1}
+ { \@@_define_aat_feature_group:n {#1} }
+
+ \keys_if_choice_exist:nnnT {fontspec} {#1} {#2}
+ { \@@_warning:nxx {feature-option-overwrite} {#1} {#2} }
+
+ \@@_define_aat_feature:nnnn {#1}{#2}{#3}{#4}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newopentypefeature}
+% This command assigns a new OpenType feature by its abbreviation (|#2|) to a new name (|#1|).
+% Better than \cmd\newfontfeature\ because it checks if the feature exists in the
+% font it's being used for.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_newopentypefeature:nnn
+ {
+ \keys_if_exist:nnF { fontspec / options } {#1}
+ { \@@_define_opentype_feature_group:n {#1} }
+
+ \keys_if_choice_exist:nnnT {fontspec} {#1} {#2}
+ { \@@_warning:nxx {feature-option-overwrite} {#1} {#2} }
+
+ \exp_args:Nnnx \@@_define_opentype_feature:nnnnn
+ {#1} {#2} { \@@_strip_plus_minus:n {#3} } {#3} {}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_strip_plus_minus:n { \@@_strip_plus_minus_aux:Nq #1 \q_nil }
+\cs_new:Npn \@@_strip_plus_minus_aux:Nq #1#2 \q_nil
+ {
+ \str_case:nnF {#1} { {+} {#2} {-} {#2} } {#1#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\aliasfontfeature}
+% User commands for renaming font features and font feature options.
+% \begin{macrocode}
+\cs_new:Nn \@@_main_aliasfontfeature:nn
+ {
+%<debug> \typeout{::::::::::::::::::::^^J:: aliasfontfeature{#1}{#2}}
+ \bool_set_false:N \l_@@_alias_bool
+
+ \clist_map_inline:Nn \g_@@_all_keyval_modules_clist
+ {
+ \keys_if_exist:nnT {##1} {#1}
+ {
+%<debug> \typeout{:::: Key~exists~##1~/~#1}
+ \bool_set_true:N \l_@@_alias_bool
+ \keys_define:nn {##1}
+ { #2 .code:n = { \keys_set:nn {##1} { #1 = {####1} } } }
+ }
+ }
+
+ \bool_if:NF \l_@@_alias_bool
+ { \@@_warning:nx {rename-feature-not-exist} {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\aliasfontfeatureoption}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_aliasfontfeatureoption:nnn
+ {
+ \bool_set_false:N \l_@@_alias_bool
+
+ \clist_map_inline:Nn \g_@@_all_keyval_modules_clist
+ {
+ \keys_if_exist:nnT { ##1 / #1 } {#2}
+ {
+%<debug> \typeout{:::: Keyval~exists~##1~/~#1~=~#2}
+ \bool_set_true:N \l_@@_alias_bool
+ \keys_define:nn { ##1 / #1 }
+ { #3 .code:n = { \keys_set:nn {##1} { #1 = {#2} } } }
+ }
+
+ \keys_if_exist:nnT { ##1 / #1 } {#2Reset}
+ {
+%<debug> \typeout{:::: Keyval~exists~##1~/~#1~=~#2Reset}
+ \keys_define:nn { ##1 / #1 }
+ { #3Reset .code:n = { \keys_set:nn {##1} { #1 = {#2Reset} } } }
+ }
+
+ \keys_if_exist:nnT { ##1 / #1 } {#2Off}
+ {
+%<debug> \typeout{:::: Keyval~exists~##1~/~#1~=~#2Off}
+ \keys_define:nn { ##1 / #1 }
+ { #3Off .code:n = { \keys_set:nn {##1} { #1 = {#2Off} } } }
+ }
+ }
+
+ \bool_if:NF \l_@@_alias_bool
+ { \@@_warning:nx {rename-feature-not-exist} {#1/#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@_main_DeclareFontExtensions:n}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_DeclareFontExtensions:n
+ {
+ \clist_set:Nn \l_@@_extensions_clist { #1 }
+ }
+% \end{macrocode}
+% Defaults:
+% \begin{macrocode}
+\@@_main_DeclareFontExtensions:n {.otf,.ttf,.OTF,.TTF,.ttc,.TTC,.dfont}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{High level conditionals}
+%
+%
+% \begin{macro}{\IfFontFeatureActiveTF}
+% \begin{macrocode}
+\cs_new:Nn \@@_main_IfFontFeatureActiveTF:nnn
+ {
+%<debug> \typeout{^^J:::::::::::::::::::::::::::::::::::::::::::::::}
+%<debug> \typeout{:IfFontFeatureActiveTF \exp_not:n{{#1}{#2}{#3}}}
+ \@@_if_font_feature:nTF {#1} {#2} {#3}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_if_font_feature:n {TF}
+ {
+ \tl_gclear:N \g_@@_single_feat_tl
+ \group_begin:
+ \@@_font_suppress_not_found_error:
+ \@@_init:
+ \bool_set_true:N \l_@@_ot_bool
+ \bool_set_true:N \l_@@_never_check_bool
+ \bool_set_false:N \l_@@_firsttime_bool
+ \clist_clear:N \l_@@_fontfeat_clist
+ \@@_get_features:n {#1}
+ \group_end:
+
+%<debug> \typeout{:::> \exp_not:N\g_@@_rawfeatures_sclist->~{\g_@@_rawfeatures_sclist}}
+%<debug> \typeout{:::> \exp_not:N\g_@@_single_feat_tl->~{\g_@@_single_feat_tl}}
+
+ \tl_if_empty:NTF \g_@@_single_feat_tl { \prg_return_false: }
+ {
+ \exp_args:NV \fontspec_if_current_feature:nTF \g_@@_single_feat_tl
+ { \prg_return_true: } { \prg_return_false: }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{\cs{oldstylenums} and \cs{liningnums}}
+%
+% \begin{macro}{\oldstylenums}
+% \begin{macro}{\liningnums}
+% This command needs a redefinition.
+% And we may as well provide the reverse command.
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_main_oldstylenums:n
+ {
+ \group_begin:
+ \addfontfeature{Numbers=OldStyle}
+ #1
+ \group_end:
+ }
+\cs_new_protected:Nn \@@_main_liningnums:n
+ {
+ \group_begin:
+ \addfontfeature{Numbers=Lining}
+ #1
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-vars.dtx b/macros/latex/contrib/fontspec/fontspec-code-vars.dtx
new file mode 100644
index 0000000000..ae5132b95c
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-vars.dtx
@@ -0,0 +1,332 @@
+%%^^A%% fontspec-code-vars.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Declaration of variables}
+%
+% \iffalse
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+% \fi
+%
+% This file consists solely of declaration of variables used by \pkg{fontspec}.
+% In some cases these variables are also initialised with default values.
+% In time I would like to move these initialisations
+%
+% \paragraph{Booleans}
+%
+% \begin{macro}{\l_@@_firsttime_bool}
+% As \cs{keys_set:nn} is run multiple times, some of its
+% information storing only occurs once while we decide if the font family
+% has been defined or not. When the later processing is occuring per-shape
+% this no longer needs to happen; this is indicated by the `firsttime'
+% conditional.
+% \begin{macrocode}
+\bool_new:N \l_@@_firsttime_bool
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\bool_new:N \l_@@_nobf_bool
+\bool_new:N \l_@@_noit_bool
+\bool_new:N \l_@@_nosc_bool
+\bool_new:N \l_@@_check_bool
+% \end{macrocode}
+%
+% \begin{macrocode}
+\bool_new:N \l_@@_tfm_bool
+\bool_new:N \l_@@_atsui_bool
+\bool_new:N \l_@@_ot_bool
+\bool_new:N \l_@@_mm_bool
+\bool_new:N \l_@@_harfbuzz_bool
+\bool_new:N \l_@@_graphite_bool
+\bool_new:N \l_@@_fontcfg_bool
+\bool_set_true:N \l_@@_fontcfg_bool
+% \end{macrocode}
+% For dealing with legacy maths:
+% \begin{macrocode}
+\bool_new:N \g_@@_math_euler_bool
+\bool_new:N \g_@@_math_lucida_bool
+\bool_new:N \g_@@_pkg_euler_loaded_bool
+% \end{macrocode}
+% For package options:
+% \begin{macrocode}
+\bool_new:N \g_@@_cfg_bool
+\bool_new:N \g_@@_math_bool
+\bool_new:N \g_@@_euenc_bool
+% \end{macrocode}
+%
+% \begin{macrocode}
+\bool_new:N \l_@@_tmpa_bool
+\bool_new:N \l_@@_disable_defaults_bool
+\bool_new:N \l_@@_alias_bool
+\bool_new:N \l_@@_external_bool
+\bool_new:N \l_@@_defining_encoding_bool
+\bool_new:N \l_@@_scriptlang_exist_bool
+\bool_new:N \g_@@_em_normalise_slant_bool
+\bool_new:N \l_@@_proceed_bool
+% \end{macrocode}
+%
+% \begin{macro}{\l_@@_never_check_bool}
+% It is used to disable checking opentype script, language, and tags
+% when running checking code that has a user-defined return path we want to allow the higher-level
+% code to dictate the logic.
+% TODO: tidy this up!
+% \begin{macrocode}
+\bool_new:N \l_@@_never_check_bool
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Counters}
+% \begin{macrocode}
+\int_new:N \l_@@_script_int
+\int_new:N \l_@@_language_int
+\int_new:N \l_@@_strnum_int
+\int_new:N \l_@@_tmp_int
+\int_new:N \l_@@_tmpa_int
+\int_new:N \l_@@_tmpb_int
+\int_new:N \l_@@_tmpc_int
+\int_new:N \l_@@_em_int
+\int_new:N \l_@@_emdef_int
+\int_new:N \l_@@_strong_int
+\int_new:N \l_@@_strongdef_int
+% \end{macrocode}
+%
+% \paragraph{Floats}
+% \begin{macrocode}
+\fp_new:N \l_@@_tmpa_fp
+\fp_new:N \l_@@_tmpb_fp
+% \end{macrocode}
+%
+% \paragraph{Dimensions}
+% \begin{macrocode}
+\dim_new:N \l_@@_tmpa_dim
+\dim_new:N \l_@@_tmpb_dim
+\dim_new:N \l_@@_tmpc_dim
+% \end{macrocode}
+%
+% \paragraph{Sequences}
+% \begin{macrocode}
+\seq_new:N \l_@@_bf_series_seq
+% \end{macrocode}
+%
+% \paragraph{Comma-lists}
+% \begin{macrocode}
+\clist_new:N \g_@@_default_fontopts_clist
+\clist_new:N \g_@@_all_keyval_modules_clist
+\clist_new:N \l_@@_sizefeat_clist
+\clist_set:Nn \l_@@_sizefeat_clist {Size={-}}
+\clist_new:N \l_@@_extensions_clist
+\clist_new:N \l_@@_fontopts_clist
+\clist_new:N \l_@@_family_fontopts_clist
+\clist_new:N \l_@@_all_features_clist
+\clist_new:N \l_@@_leftover_clist
+\clist_new:N \l_@@_keys_leftover_clist
+\clist_new:N \l_@@_sizing_leftover_clist
+\clist_new:N \l_@@_fontfeat_clist
+\clist_new:N \l_@@_fontfeat_curr_clist
+\clist_new:N \l_@@_arg_clist
+\clist_new:N \l_@@_this_feat_clist
+% \end{macrocode}
+%
+% \begin{macrocode}
+\clist_new:N \l_@@_fontfeat_up_clist
+\clist_new:N \l_@@_fontfeat_bf_clist
+\clist_new:N \l_@@_fontfeat_it_clist
+\clist_new:N \l_@@_fontfeat_bfit_clist
+\clist_new:N \l_@@_fontfeat_sl_clist
+\clist_new:N \l_@@_fontfeat_bfsl_clist
+\clist_new:N \l_@@_fontfeat_sc_clist
+% \end{macrocode}
+%
+% \paragraph{Property lists}
+% \begin{macrocode}
+\prop_new:N \g_@@_fontopts_prop
+\prop_new:N \l_@@_nfss_prop
+\prop_new:N \l_@@_nfssfont_prop
+\prop_new:N \g_@@_OT_features_prop
+\prop_new:N \g_@@_all_opentype_feature_names_prop
+\prop_new:N \g_@@_em_prop
+\prop_new:N \g_@@_strong_prop
+\prop_new:N \g_@@_fontid_family_prop
+\prop_new:N \g_@@_family_int_prop
+% \end{macrocode}
+%
+% \paragraph{Token lists}
+%
+% \paragraph{Visible (perhaps?)}
+%
+% \begin{macrocode}
+\tl_new:N \l_fontspec_family_tl
+\tl_new:N \g_fontspec_encoding_tl
+\tl_new:N \l_fontspec_fontname_tl
+% \end{macrocode}
+%
+% \paragraph{2e interactions}
+%
+% \begin{macrocode}
+\tl_clear_new:N \UTFencname
+\tl_clear_new:N \cyrillicencoding
+\tl_clear_new:N \latinencoding
+% \end{macrocode}
+%
+% \paragraph{Renderer/shaper}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_renderer_tl
+\tl_new:N \l_@@_mode_tl
+\tl_new:N \l_@@_shaper_tl
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_new:N \g_@@_defined_shapes_tl
+\tl_new:N \g_@@_single_feat_tl
+\tl_new:N \l_@@_basename_tl
+\tl_new:N \g_@@_curr_series_tl
+\tl_new:N \l_@@_curr_fontname_tl
+\tl_new:N \l_@@_curr_bfname_tl
+\tl_new:N \l_@@_ext_filename_tl
+\tl_new:N \l_@@_extension_tl
+\tl_new:N \l_@@_font_path_tl
+\tl_new:N \l_@@_fontid_tl
+\tl_new:N \l_@@_fontname_tl
+\tl_new:N \l_@@_options_tl
+\tl_new:N \l_@@_saved_fontname_tl
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_new:N \g_@@_nfss_enc_tl
+\tl_new:N \g_@@_nfss_family_tl
+\tl_new:N \l_@@_nfss_sc_tl
+\tl_new:N \l_@@_nfss_tl
+\tl_new:N \l_@@_nfss_fam_tl
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_size_tl
+\tl_new:N \l_@@_sizedfont_tl
+\tl_new:N \l_@@_this_font_tl
+\tl_new:N \l_@@_ttc_index_tl
+\tl_new:N \l_@@_smcp_shape_tl
+% \end{macrocode}
+%
+% \paragraph{EM and STRONG}
+% \begin{macrocode}
+\tl_new:N \l_@@_emshape_query_tl
+\tl_new:N \l_@@_em_switch_tl
+\tl_new:N \l_@@_strong_switch_tl
+% \end{macrocode}
+%
+% \paragraph{Scratch variables}
+% \begin{macrocode}
+\tl_new:N \l_@@_tmp_tl
+\tl_new:N \l_@@_tmpa_tl
+\tl_new:N \l_@@_tmpb_tl
+\tl_new:N \l_@@_em_tmp_tl
+\tl_new:N \l_@@_strong_tmp_tl
+% \end{macrocode}
+%
+% \paragraph{Maths fonts}
+% \begin{macrocode}
+\tl_new:N \g_@@_mathrm_tl
+\tl_new:N \g_@@_bfmathrm_tl
+\tl_new:N \g_@@_mathsf_tl
+\tl_new:N \g_@@_mathtt_tl
+% \end{macrocode}
+%
+% Defaults: (these are set elsewhere; TODO: check if redundant)
+% \begin{macrocode}
+\tl_gset:Nn \g_@@_mathrm_tl {\rmdefault}
+\tl_gset:Nn \g_@@_mathsf_tl {\sfdefault}
+\tl_gset:Nn \g_@@_mathtt_tl {\ttdefault}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_family_label_tl
+\tl_new:N \l_@@_fake_slant_tl
+\tl_new:N \l_@@_fake_embolden_tl
+% \end{macrocode}
+%
+% \paragraph{Internal font names}
+% \begin{macrocode}
+\tl_new:N \l_@@_fontname_up_tl
+\tl_new:N \l_@@_fontname_bf_tl
+\tl_new:N \l_@@_fontname_it_tl
+\tl_new:N \l_@@_fontname_bfit_tl
+\tl_new:N \l_@@_fontname_sl_tl
+\tl_new:N \l_@@_fontname_bfsl_tl
+\tl_new:N \l_@@_fontname_sc_tl
+% \end{macrocode}
+%
+% \paragraph{Script and Language}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_script_tl
+\tl_new:N \l_@@_script_name_tl
+\tl_set:Nn \l_@@_script_name_tl {CustomDefault}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_lang_tl
+\tl_new:N \l_@@_lang_name_tl
+\tl_set:Nn \l_@@_lang_name_tl {Default}
+% \end{macrocode}
+%
+% \paragraph{Generic font features}
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_scale_tl
+\tl_new:N \l_@@_hyphenchar_tl
+\tl_new:N \l_@@_hexcol_tl
+\tl_new:N \l_@@_opacity_tl
+\tl_new:N \l_@@_optical_size_tl
+\tl_new:N \l_@@_mapping_tl
+\tl_new:N \l_@@_punctspace_adjust_tl
+\tl_new:N \l_@@_wordspace_adjust_tl
+\tl_new:N \l_@@_postadjust_tl
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tl_const:Nn \c_@@_hexcol_tl {000000}
+\tl_const:Nn \c_@@_opacity_tl {FF~}
+\tl_const:Nn \c_@@_postadjust_tl { \l_@@_wordspace_adjust_tl \l_@@_punctspace_adjust_tl }
+% \end{macrocode}
+%
+% \paragraph{Semi-colon-lists}
+% Not a real data structure but sensible to name accordingly.
+% \begin{macrocode}
+\tl_new:N \g_@@_rawfeatures_sclist
+\tl_new:N \l_@@_pre_feat_sclist
+% \end{macrocode}
+%
+% \paragraph{Font families}
+% \begin{macrocode}
+\tl_new:N \l_@@_rmfamily_family_tl
+\tl_new:N \l_@@_sffamily_family_tl
+\tl_new:N \l_@@_ttfamily_family_tl
+% \end{macrocode}
+%
+%
+%
+% \iffalse
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+% \fi
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code-xfss.dtx b/macros/latex/contrib/fontspec/fontspec-code-xfss.dtx
new file mode 100644
index 0000000000..4f1bdd2d56
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code-xfss.dtx
@@ -0,0 +1,290 @@
+%%^^A%% fontspec-code-xfss.dtx -- part of FONTSPEC <wspr.io/fontspec>
+
+% \section{Changes to the NFSS}
+%
+% \begin{macrocode}
+%<*fontspec>
+% \end{macrocode}
+%
+%
+% \subsection{Italic small caps and so on} \label{sec:sishape}
+%
+% \begin{macro}{\sishape}
+% \begin{macro}{\textsi}
+% These commands for actually selecting italic small caps have been defined for many years; I'm inclined to drop them.
+% They're probably used very infrequently; I personally prefer just writing
+% |\textit{\textsc{...}}| instead.
+%
+% \begin{macrocode}
+\providecommand*\itscdefault{\itdefault\scdefault}
+\providecommand*\slscdefault{\sldefault\scdefault}
+\DeclareRobustCommand{\sishape}
+ {
+ \not@math@alphabet\sishape\relax
+ \fontshape{\itscdefault}\selectfont
+ }
+\DeclareTextFontCommand{\textsi}{\sishape}
+% \end{macrocode}
+% \end{macro} \end{macro}
+%
+% \LaTeX's `shape' font axis needs to be overloaded to support italic small caps and slanted small caps.
+% These are the combinations to support:
+% \begin{macrocode}
+\cs_new:Nn \@@_shape_merge:nn { c_@@_shape_#1_#2_tl }
+\cs_new:Nn \@@_merge_default_shapes:
+ {
+ \tl_const:cn { \@@_shape_merge:nn \itdefault \scdefault } {\itscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \sldefault \scdefault } {\slscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \scdefault \itdefault } {\itscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \scdefault \sldefault } {\slscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \slscdefault \itdefault } {\itscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \itscdefault \sldefault } {\slscdefault}
+ \tl_const:cn { \@@_shape_merge:nn \itscdefault \updefault } {\scdefault}
+ \tl_const:cn { \@@_shape_merge:nn \slscdefault \updefault } {\scdefault}
+ }
+\@@_merge_default_shapes:
+% \end{macrocode}
+%
+% \begin{macro}{\@@_merge_shape:n}
+% These macros enable the overload on the |\..shape| commands.
+% First, a shape `new+current' (prefix) or `current+new' (suffix) is tried.
+% If not found, fall back on the `new' shape.
+% \begin{macrocode}
+\cs_new:Nn \@@_merge_shape:n
+ {
+ \@@_if_merge_shape:nTF {#1}
+ { \fontshape { \tl_use:c { \@@_shape_merge:nn {\f@shape} {#1} } } \selectfont }
+ { \fontshape {#1} \selectfont }
+ }
+% \end{macrocode}
+% The following is rather specific; it only returns true if the merged shape exists,
+% but more importantly also if the merged shape is defined for the current font.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \@@_if_merge_shape:n {TF}
+ {
+ \bool_lazy_and:nnTF
+ { \tl_if_exist_p:c { \@@_shape_merge:nn {\f@shape} {#1} } }
+ {
+ \cs_if_exist_p:c
+ {
+ \f@encoding/\f@family/\f@series/
+ \tl_use:c { \@@_shape_merge:nn {\f@shape} {#1} }
+ }
+ }
+ \prg_return_true: \prg_return_false:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\itshape} \begin{macro}{\scshape} \begin{macro}{\upshape} \begin{macro}{\slshape}
+% The original |\..shape| commands are redefined to use the merge shape macro.
+% \begin{macrocode}
+\DeclareRobustCommand \itshape
+ {
+ \not@math@alphabet\itshape\mathit
+ \@@_merge_shape:n\itdefault
+ }
+\DeclareRobustCommand \slshape
+ {
+ \not@math@alphabet\slshape\relax
+ \@@_merge_shape:n\sldefault
+ }
+\DeclareRobustCommand \scshape
+ {
+ \not@math@alphabet\scshape\relax
+ \@@_merge_shape:n\scdefault
+ }
+\DeclareRobustCommand \upshape
+ {
+ \not@math@alphabet\upshape\relax
+ \@@_merge_shape:n\updefault
+ }
+% \end{macrocode}
+% \end{macro} \end{macro} \end{macro} \end{macro}
+%
+%
+%
+% \subsection{Emphasis}
+%
+% \begin{macro}{\emfontdeclare}
+% \begin{macrocode}
+\cs_new_protected:Npn \emfontdeclare #1
+ {
+ \prop_gclear:N \g_@@_em_prop
+ \int_zero:N \l_@@_emdef_int
+ \bool_gset_true:N \g_@@_em_normalise_slant_bool
+
+ \tl_if_in:nnT {#1} {\slshape}
+ {
+ \tl_if_in:nnT {#1} {\itshape}
+ {
+ \bool_gset_false:N \g_@@_em_normalise_slant_bool
+ }
+ }
+
+ \group_begin:
+ \normalfont
+ \clist_map_inline:nn {\emreset,#1}
+ {
+ ##1
+ \prop_gput_if_new:NxV \g_@@_em_prop { \f@shape } { \l_@@_emdef_int }
+ \prop_gput:Nxn \g_@@_em_prop { switch-\int_use:N \l_@@_emdef_int } { ##1 }
+ \int_incr:N \l_@@_emdef_int
+ }
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\em}
+% \begin{macrocode}
+\DeclareRobustCommand \em
+ {
+ \@nomath\em
+ \tl_set:Nx \l_@@_emshape_query_tl { \f@shape }
+
+ \bool_if:NT \g_@@_em_normalise_slant_bool
+ {
+ \tl_replace_all:Nnn \l_@@_emshape_query_tl {/sl} {/it}
+ }
+
+%<debug> \typeout{Emph~ level:~\int_use:N \l_@@_em_int}
+ \prop_get:NxNT \g_@@_em_prop { \l_@@_emshape_query_tl } \l_@@_em_tmp_tl
+ {
+ \int_set:Nn \l_@@_em_int { \l_@@_em_tmp_tl }
+%<debug> \typeout{Shape~ (\l_@@_emshape_query_tl)~ detected;~ new~ level:~\int_use:N \l_@@_em_int}
+ }
+
+ \int_incr:N \l_@@_em_int
+
+ \prop_get:NxNTF \g_@@_em_prop { switch-\int_use:N \l_@@_em_int } \l_@@_em_switch_tl
+ { \l_@@_em_switch_tl }
+ {
+ \int_zero:N \l_@@_em_int
+ \emreset
+ }
+
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\emph}
+% \begin{macro}{\emshape}
+% \begin{macro}{\eminnershape}
+% \begin{macro}{\emreset}
+% \begin{macrocode}
+\DeclareTextFontCommand{\emph}{\em}
+\cs_set:Npn \emreset { \upshape }
+\cs_set:Npn \emshape { \itshape }
+\cs_set:Npn \eminnershape { \upshape }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \subsection{Strong emphasis}
+%
+% \begin{macro}{\strongfontdeclare}
+% \begin{macrocode}
+\cs_new_protected:Npn \strongfontdeclare #1
+ {
+ \prop_gclear:N \g_@@_strong_prop
+ \int_zero:N \l_@@_strongdef_int
+
+ \group_begin:
+ \normalfont
+ \clist_map_inline:nn {\strongreset,#1}
+ {
+ ##1
+ \prop_gput_if_new:NxV \g_@@_strong_prop { \f@series } { \l_@@_strongdef_int }
+ \prop_gput:Nxn \g_@@_strong_prop { switch-\int_use:N \l_@@_strongdef_int } { ##1 }
+ \int_incr:N \l_@@_strongdef_int
+ }
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\strongenv}
+% \begin{macrocode}
+\DeclareRobustCommand \strongenv
+ {
+ \@nomath\strongenv
+
+%<debug> \typeout{Strong~ level:~\int_use:N \l_@@_strong_int}
+ \prop_get:NxNT \g_@@_strong_prop { \f@series } \l_@@_strong_tmp_tl
+ {
+ \int_set:Nn \l_@@_strong_int { \l_@@_strong_tmp_tl }
+%<debug> \typeout{Series~ (\f@series)~ detected;~ new~ level:~\int_use:N \l_@@_strong_int}
+ }
+
+ \int_incr:N \l_@@_strong_int
+
+ \prop_get:NxNTF \g_@@_strong_prop { switch-\int_use:N \l_@@_strong_int } \l_@@_strong_switch_tl
+ { \l_@@_strong_switch_tl }
+ {
+ \int_zero:N \l_@@_strong_int
+ \strongreset
+ }
+
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\strong}
+% \begin{macro}{\strongreset}
+% \begin{macrocode}
+\DeclareTextFontCommand{\strong}{\strongenv}
+\cs_set:Npn \strongreset {}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\reset@font}
+% Ensure nesting resets when necessary:
+% \begin{macrocode}
+\cs_set:Npn \reset@font
+ {
+ \normalfont
+ \int_zero:N \l_@@_em_int
+ \int_zero:N \l_@@_strong_int
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Programmer's interface for setting nesting levels:
+% \begin{macrocode}
+\cs_new:Nn \fontspec_set_em_level:n { \int_set:Nn \l_@@_em_int {#1} }
+\cs_new:Nn \fontspec_set_strong_level:n { \int_set:Nn \l_@@_strong_int {#1} }
+% \end{macrocode}
+%
+% Defaults:
+% \begin{macrocode}
+\strongfontdeclare{ \bfseries }
+\emfontdeclare{ \emshape, \eminnershape }
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</fontspec>
+% \end{macrocode}
+
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code.ltx b/macros/latex/contrib/fontspec/fontspec-code.ltx
new file mode 100644
index 0000000000..c164175b5f
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code.ltx
@@ -0,0 +1,42 @@
+%%^^A%% fontspec-code.ltx -- part of FONTSPEC <wspr.io/fontspec>
+
+\ifdefined \XeTeXOTcountscripts \else \makeatletter
+ \@latex@error{^^J*** The fontspec documentation can only be typeset with `xelatex` ***\@gobble}\@ehc
+\fi
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\renewcommand\partname{File}
+\begin{document}
+\maketitle
+\tableofcontents
+\newpage
+
+\def\DTX#1{\clearpage\part{#1}\DocInput{#1}}
+\FONTSPECDTX
+
+\clearpage
+\PrintChanges
+
+\clearpage
+\setcounter{IndexColumns}{2}
+\PrintIndex
+
+\end{document}
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-code.pdf b/macros/latex/contrib/fontspec/fontspec-code.pdf
new file mode 100644
index 0000000000..2d68690c48
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-code.pdf
Binary files differ
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-api.tex b/macros/latex/contrib/fontspec/fontspec-doc-api.tex
new file mode 100644
index 0000000000..ed85ad9fa5
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-api.tex
@@ -0,0 +1,344 @@
+%%^^A%% fontspec-doc-api.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{Customisation and programming interface}
+
+This is the beginning of some work to provide some hooks that use
+\pkg{fontspec} for various macro programming purposes.
+
+
+\section{Defining new features} \label{sec:newfeatures}
+This package cannot hope to contain every possible font
+feature. Three commands are provided for selecting font features
+that are not provided for out of the box. If you are using
+them a lot, chances are I've left something out, so please let me
+know.
+
+\DescribeMacro{\newAATfeature}
+New \AAT\ features may be created with this command:\par
+{\centering\cmd\newAATfeature\marg{feature}\marg{option}\marg{feature code}\marg{selector code}\par}\noindent
+Use the \XeTeX\ file \path{AAT-info.tex} to obtain the code numbers.
+See \exref{newAATfeat}.
+
+\begin{Xexample}{newAATfeat}{Assigning new \AAT\ features.}
+ \newAATfeature{Alternate}{HoeflerSwash}{17}{1}
+ \fontspec{Hoefler Text Italic}[Alternate=HoeflerSwash]
+ This is XeTeX by Jonathan Kew.
+\end{Xexample}
+
+
+\DescribeMacro{\newopentypefeature}
+New OpenType features may be created with this command:\par
+{\centering\cmd\newopentypefeature\marg{feature}\marg{option}\marg{feature tag}\par}
+The synonym \cs{newICUfeature} is deprecated.
+
+Here's what it would look like in practise:
+\begin{Verbatim}
+\newopentypefeature{Style}{NoLocalForms}{-locl}
+\end{Verbatim}
+
+\DescribeMacro{\newfontfeature}
+In case the above commands do not accommodate the desired font feature
+(perhaps a new \XeTeX\ feature that \pkg{fontspec} hasn't been updated
+to support), a command is provided to pass arbitrary input into the
+font selection string:\par
+{\centering\cmd{\newfontfeature}\marg{name}\marg{input string}\par}
+
+For example, Zapfino used to
+contain an AAT feature `Avoid d-collisions'. To access it
+with this package, you could do some like the following:
+
+\begin{Verbatim}
+ \newfontfeature{AvoidD} {Special= Avoid d-collisions}
+ \newfontfeature{NoAvoidD}{Special=!Avoid d-collisions}
+ \fontspec{Zapfino}[AvoidD,Variant=1]
+ sockdolager rubdown \\
+ \fontspec{Zapfino}[NoAvoidD,Variant=1]
+ sockdolager rubdown
+\end{Verbatim}
+
+The advantage to using the \cmd\newAATfeature\ and \cmd\newopentypefeature\
+commands instead of \cs{newfontfeature} is that they check if the selected font actually contains the desired font
+feature at load time. By contrast, \cmd\newfontfeature\ will not give a warning
+for improper input.
+
+
+\section{Defining new scripts and languages}
+\label{sec:newscriptlang}
+
+\DescribeMacro{\newfontscript}
+\DescribeMacro{\newfontlanguage}
+While the scripts and languages listed in \ref{tab:ot-scpt} and \ref{tab:ot-lang}
+are intended to be comprehensive, there may be some missing; alternatively,
+you might wish to use different names to access scripts/languages that are
+already listed.
+Adding scripts and languages can be performed with the \cmd\newfontscript\
+and \cmd\newfontlanguage\ commands. For example,
+\begin{Verbatim}
+ \newfontscript{Arabic}{arab}
+ \newfontlanguage{Zulu}{ZUL}
+\end{Verbatim}
+The first argument is the \pkg{fontspec} name, the second the OpenType
+tag. The advantage to using these commands rather than \cmd\newfontfeature\
+(see \vref{sec:newfeatures}) is the error-checking that is performed when
+the script or language is requested.
+
+Both commands accept a comma-separated list of OpenType tags in order of preference.
+This permits, for example, supporting both new and old versions of a language tag with
+a common user interface:
+\begin{Verbatim}
+ \newfontlanguage{Turkish}{TRK,TUR}
+\end{Verbatim}
+Here, a font that is requested with \verb|Script=Turkish| will first be checked for the
+OpenType language tag \verb|TRK|, which will be selected if available. If not available,
+the \verb|TUR| tag will be queried and used if possible as a fallback.
+
+
+\section{Going behind \pkg{fontspec}'s back}
+Expert users may wish not to use \pkg{fontspec}'s feature handling at all,
+while still taking advantage of its \LaTeX\ font selection conveniences. The
+\feat{RawFeature} font feature allows font feature selection using a literal feature selection string if you happen to have the OpenType feature tag memorised.
+
+\begin{Xexample}{raw}{Using raw font features directly.}
+ \fontspec{texgyrepagella-regular.otf}[RawFeature=+smcp]
+ Pagella small caps
+\end{Xexample}
+
+Multiple features can either be included in a single declaration:\par
+{\centering|[RawFeature=+smcp;+onum]|\par}
+\noindent or with multiple declarations:\par
+{\centering|[RawFeature=+smcp, RawFeature=+onum]|\par}
+
+
+\section{Renaming existing features \& options}
+\label{sec:aliasfontfeature}
+
+\DescribeMacro{\aliasfontfeature}
+If you don't like the name of a particular font feature,
+it may be aliased to another with the
+\cs{aliasfontfeature}\marg{existing name}\marg{new name} command,
+such as shown in \exref{alias}.
+
+\begin{Xexample}{alias}{Renaming font features.}
+ \aliasfontfeature{ItalicFeatures}{IF}
+ \fontspec{Hoefler Text}[IF = {Alternate=1}]
+ Roman Letters \itshape And Swash
+\end{Xexample}
+
+Spaces in feature (and option names, see below) \emph{are} allowed. (You may have
+noticed this already in the lists of OpenType scripts and languages).
+
+\DescribeMacro{\aliasfontfeatureoption}
+If you wish to change the name of a font feature option,
+it can be aliased to another with the command
+\cs{aliasfontfeatureoption}\marg{font feature}\marg{existing name}\marg{new name}, such as shown in \exref{aliasopt}.
+
+\begin{Lexample}{aliasopt}{Renaming font feature options.}
+ \aliasfontfeature{VerticalPosition}{Vert Pos}
+ \aliasfontfeatureoption{VerticalPosition}{ScientificInferior}{Sci Inf}
+ \fontspec{LinLibertine_R.otf}[Vert Pos=Sci Inf]
+ Scientific Inferior: 12345
+\end{Lexample}
+
+This example demonstrates an important point: when aliasing the feature
+options, the \emph{original} feature name must be used when declaring
+to which feature the option belongs.
+
+Only feature options that exist as sets of fixed strings may be altered in
+this way. That is, \opt{Proportional} can be aliased to \opt{Prop} in the
+\feat{Letters} feature, but \opt{550099BB} cannot be substituted for \opt{Purple}
+in a \feat{Color} specification. For this type of thing, the \cmd\newfontfeature\
+command should be used to declare a new, \eg, \feat{PurpleColor} feature:
+\begin{Verbatim}
+ \newfontfeature{PurpleColor}{color=550099BB}
+\end{Verbatim}
+Except that this example was written before support for named colours was
+implemented. But you get the idea.
+
+
+
+
+\section{Programming interface}
+\label{sec:api}
+
+
+\subsection{Variables}
+
+\DescribeMacro{\l_fontspec_family_tl}
+\DescribeMacro{\l_fontspec_font}
+In some cases, it is useful to know what the \LaTeX\ font family
+of a specific \pkg{fontspec} font is. After a \cmd\fontspec-like
+command, this is stored inside the \cmd\l_fontspec_family_tl\ macro.
+Otherwise, \LaTeX's own \cmd\f@family\ macro can be useful here,
+too.
+The raw \TeX\ font that is defined from the `base' font in the family is stored in \cmd{\l_fontspec_font}.
+
+\DescribeMacro{\g_fontspec_encoding_tl}
+Package authors who need to load fonts with legacy \LaTeX\ \NFSS\ commands may also need to know what the default font encoding is.
+Since this has changed from \texttt{EU1}/\texttt{EU2} to \texttt{TU}, it is best to use the variables \cs{g_fontspec_encoding_tl} or \cs{UTFencname} instead.
+
+\subsection{Functions for loading new fonts and families}
+
+\begin{macro}{\fontspec_gset_family:Nnn}
+\begin{macro}{\fontspec_set_family:Nnn}
+\darg{\LaTeX\ family}
+\darg{fontspec features}
+\darg{font name}
+Defines a new \NFSS\ family from given \meta{features} and \meta{font},
+and stores the family name in the variable \meta{family}.
+This font family can then be selected with standard \LaTeX\ commands
+\cs{fontfamily}\marg{family}\cs{selectfont}.
+See the standard \pkg{fontspec} user commands for applications of this
+function.
+\end{macro}
+\end{macro}
+
+\begin{macro}{\fontspec_gset_fontface:NNnn}
+\begin{macro}{\fontspec_set_fontface:NNnn}
+\darg{primitive font}
+\darg{\LaTeX\ family}
+\darg{fontspec features}
+\darg{font name}
+Variant of the above in which the primitive \TeX\ font command is stored in
+the variable \meta{primitive font}.
+If a family is loaded (with bold and italic shapes) the primitive font
+command will only select the regular face.
+This feature is designed for \LaTeX\ programmers who need to
+perform subsequent font-related tests on the \meta{primitive font}.
+\end{macro}
+\end{macro}
+
+
+\subsection{Conditionals}
+
+The following functions in \pkg{expl3} syntax may be used
+for writing code that interfaces with \pkg{fontspec}-loaded fonts.
+The following conditionals are all provided in |TF|, |T|, and |F| forms.
+
+\subsubsection{Querying font families}
+
+\begin{macro}{\fontspec_font_if_exist:nTF}
+Test whether the `font name' (|#1|) exists or is loadable.
+The syntax of |#1| is a restricted/simplified version of \pkg{fontspec}'s usual font loading syntax; fonts to be loaded by filename are detected by the presence of an appropriate extension (|.otf|, etc.), and paths should be included inline.
+E.g.:
+\begin{Verbatim}
+ \fontspec_font_if_exist:nTF {cmr10}{T}{F}
+ \fontspec_font_if_exist:nTF {Times~ New~ Roman}{T}{F}
+ \fontspec_font_if_exist:nTF {texgyrepagella-regular.otf}{T}{F}
+ \fontspec_font_if_exist:nTF {/Users/will/Library/Fonts/CODE2000.TTF}{T}{F}
+\end{Verbatim}
+\end{macro}
+The synonym \cs{IfFontExistsTF} is provided for `document authors'.
+
+
+\begin{macro}{\fontspec_if_fontspec_font:TF}
+Test whether the currently selected font has been loaded by fontspec.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_opentype:TF}
+Test whether the currently selected font is an OpenType font.
+Always true for \LuaTeX{} fonts.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_small_caps:TF}
+Test whether the currently selected font has a `small caps' face to be selected
+with |\scshape| or similar.
+Note that testing whether the font has the |Letters=SmallCaps| font feature is
+sufficient but not necessary for this command to return true, since small caps
+can also be loaded from separate font files.
+The logic of this command is complicated by the fact that \pkg{fontspec} will
+merge shapes together (for italic small caps, etc.).
+\end{macro}
+
+
+\subsubsection{Availability of features}
+
+\begin{macro}{\fontspec_if_aat_feature:nnTF}
+Test whether the currently selected font contains the \AAT\
+feature (|#1|,|#2|).
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_feature:nTF}
+Test whether the currently selected font contains the raw OpenType
+feature |#1|. E.g.: |\fontspec_if_feature:nTF {pnum} {True} {False}|.
+Returns false if the font is not loaded by fontspec or is not an OpenType
+font.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_feature:nnnTF}
+Test whether the currently selected font with raw OpenType script tag |#1| and raw OpenType language tag |#2| contains the raw OpenType feature tag |#3|. E.g.: |\fontspec_if_feature:nnnTF {latn} {ROM} {pnum} {True} {False}|.
+Returns false if the font is not loaded by fontspec or is not an OpenType
+font.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_script:nTF}
+Test whether the currently selected font contains the raw OpenType
+script |#1|. E.g.: |\fontspec_if_script:nTF {latn} {True} {False}|.
+Returns false if the font is not loaded by fontspec or is not an OpenType
+font.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_language:nTF}
+Test whether the currently selected font contains the raw OpenType language
+tag |#1|. E.g.: |\fontspec_if_language:nTF {ROM} {True} {False}|.
+Returns false if the font is not loaded by fontspec or is not an OpenType
+font.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_language:nnTF}
+Test whether the currently selected font contains the raw OpenType language
+tag |#2| in script |#1|. E.g.: |\fontspec_if_language:nnTF {cyrl} {SRB} {True} {False}|.
+Returns false if the font is not loaded by fontspec or is not an OpenType
+font.
+\end{macro}
+
+
+\subsubsection{Currently selected features}
+
+\begin{macro}{\fontspec_if_current_feature:nTF}
+Test whether the currently loaded font is using the specified raw
+OpenType feature tag |#1|.
+The tag string |#1| should be prefixed with |+| to query an active feature, and with a |-| (hyphen) to query a disabled feature.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_current_script:nTF}
+Test whether the currently loaded font is using the specified raw
+OpenType script tag |#1|.
+\end{macro}
+
+
+\begin{macro}{\fontspec_if_current_language:nTF}
+Test whether the currently loaded font is using the specified raw
+OpenType language tag |#1|.
+\end{macro}
+
+\end{document}
+
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
+
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-enc.tex b/macros/latex/contrib/fontspec/fontspec-doc-enc.tex
new file mode 100644
index 0000000000..42a30d41f5
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-enc.tex
@@ -0,0 +1,216 @@
+%%^^A%% fontspec-doc-enc.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{Commands for accents and symbols (`encodings')}
+\label{part:enc}
+
+\textbf{The functionality described in this section is experimental.}
+
+In the pre-Unicode era, significant work was required by \LaTeX\ to ensure that
+input characters in the source could be interpreted correctly depending on file encoding,
+and that glyphs in the output were selected correctly depending on the font encoding.
+With Unicode, we have the luxury of a single file and font encoding that is used for both input
+and output.
+
+While this may provide some illusion that we could get away simply with typing
+Unicode text and receive correct output, this is not always the case.
+For a start, hyphenation in particular is language-specific, so tags should be used
+when switch between languages in a document.
+The \pkg{babel} and \pkg{polyglossia} packages both provide features for this.
+
+Multilingual documents will often use different fonts for different languages,
+not just for style, but for the more pragmatic reason that fonts do not all contain
+the same glyphs. (In fact, only test fonts such as Code2000 provide
+anywhere near the full Unicode coverage.)
+Indeed, certain fonts may be perfect for a certain application but miss a handful
+of necessary diacritics or accented letters.
+In these cases, \pkg{fontspec} can leverage the font encoding technology built
+into \LaTeX2\ to provide on a per-font basis either provide fallback options or
+error messages when a desired accent or symbol is not available.
+However, at present
+these features can only be provided for input using \LaTeX\ commands rather
+than Unicode input; for example, typing |\`e| instead of |è| or |\textcopyright|
+instead of |©| in the source file.
+
+The most widely-used encoding in \LaTeXe\ was |T1| with companion `|TS1|' symbols
+provided by the \pkg{textcomp} package.
+These encodings provided glyphs to typeset text in a variety of western European languages.
+As with most legacy \LaTeXe\ input methods, accents and symbols were input using
+encoding-dependent commands such as |\`e| as described above.
+As of 2017, in \LaTeXe\ on \XeTeX\ and \LuaTeX, the default encoding is |TU|,
+which uses Unicode for input and output.
+The |TU| encoding provides appropriate encoding-dependent definitions for input commands
+to match the coverage of the |T1+TS1| encodings.
+Wider coverage is not provided by default since (a)~each font will provide different glyph coverage, and
+(b)~it is expected that most users will be writing with direct Unicode input.
+
+For those users who do need finer-grained control, \pkg{fontspec} provides an
+interface for a more extensible system.
+
+
+\section{A new Unicode-based encoding from scratch}
+
+Let's say you need to provide support for a document originally written with fonts
+in the |OT2| encoding, which contains encoding-dependent commands for Cyrillic letters.
+An example from the |OT2| encoding definition file (|ot2enc.def|) reads:
+\begin{Verbatim}[numbers=left,firstnumber=57]
+\DeclareTextSymbol{\CYRIE}{OT2}{5}
+\DeclareTextSymbol{\CYRDJE}{OT2}{6}
+\DeclareTextSymbol{\CYRTSHE}{OT2}{7}
+\DeclareTextSymbol{\cyrnje}{OT2}{8}
+\DeclareTextSymbol{\cyrlje}{OT2}{9}
+\DeclareTextSymbol{\cyrdzhe}{OT2}{10}
+\end{Verbatim}
+
+To recreate this encoding in a form suitable for \pkg{fontspec}, create a new file
+named, say, |fontrange-cyr.def| and populate it with
+\begin{Verbatim}
+...
+\DeclareTextSymbol{\CYRIE} {\LastDeclaredEncoding}{"0404}
+\DeclareTextSymbol{\CYRDJE} {\LastDeclaredEncoding}{"0402}
+\DeclareTextSymbol{\CYRTSHE}{\LastDeclaredEncoding}{"040B}
+\DeclareTextSymbol{\cyrnje} {\LastDeclaredEncoding}{"045A}
+\DeclareTextSymbol{\cyrlje} {\LastDeclaredEncoding}{"0459}
+\DeclareTextSymbol{\cyrdzhe}{\LastDeclaredEncoding}{"045F}
+...
+\end{Verbatim}
+The numbers |"0404|, |"0402|, \dots, are the Unicode slots (in hexadecimal)
+of each glyph respectively.
+The \pkg{fontspec} package provides a number of shorthands to simplify this style of input; in this case,
+you could also write
+\begin{Verbatim}
+\EncodingSymbol{\CYRIE}{"0404}
+...
+\end{Verbatim}
+
+To use this encoding in a \pkg{fontspec} font, you would first add this to your preamble:
+\begin{Verbatim}
+\DeclareUnicodeEncoding{unicyr}{
+ \input{fontrange-cyr.def}
+}
+\end{Verbatim}
+Then follow it up with a font loading call such as
+\begin{Verbatim}
+\setmainfont{...}[NFSSEncoding=unicyr]
+\end{Verbatim}
+The first argument |unicyr| is the name of the `encoding' to use in the
+font family. (There's nothing special about the name chosen but it must be unique.)
+The second argument to |\DeclareUnicodeEncoding| also allows adjustments to be made
+for per-font changes.
+We'll cover this use case in the next section.
+
+
+\section{Adjusting a pre-existing encoding}
+
+There are three reasons to adjust a pre-existing encoding:
+to add, to remove, and to redefine some symbols, letters, and/or accents.
+
+When adding symbols, etc., simply write
+\begin{Verbatim}
+\DeclareUnicodeEncoding{unicyr}{
+ \input{tuenc.def}
+ \input{fontrange-cyr.def}
+ \EncodingSymbol{\textruble}{"20BD}
+}
+\end{Verbatim}
+Of course if you consistently add a number of symbols to an encoding it would be
+a good idea to create a new |fontrange-XX.def| file to suit your needs.
+
+When removing symbols, use the |\UndeclareSymbol|\marg{cmd} command.
+For example, if you a loading a font that you know is missing, say, the interrobang
+(not that unusual a situation), you might write:
+\begin{Verbatim}
+\DeclareUnicodeEncoding{nobang}{
+ \input{tuenc.def}
+ \UndeclareSymbol\textinterrobang
+}
+\end{Verbatim}
+Provided that you use the command |\textinterrobang| to typeset this symbol,
+it will appear in fonts with the default encoding, while in any font loaded with
+the |nobang| encoding an attempt to access the symbol will either use the default
+fallback definition or return an error, depending on the symbol being undeclared.
+
+
+The third use case is to redefine a symbol or accent. The most common use case
+in this scenario is to adjust a specific accent command to either fine-tune its placement
+or to `fake' it entirely.
+For example, the underdot diacritic is used in typeset Sanskrit,
+but it is not necessarily included as an accent symbol is all fonts.
+By default the underdot is defined in |TU| as:
+\begin{Verbatim}
+\EncodingAccent{\d}{"0323}
+\end{Verbatim}
+For fonts with a missing (or poorly-spaced) |"0323| accent glyph, the `traditional' \TeX\ fake accent
+construction could be used instead:
+\begin{Verbatim}
+\DeclareUnicodeEncoding{fakeacc}{
+ \input{tuenc.def}
+ \EncodingCommand{\d}[1]{%
+ \hmode@bgroup
+ \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}%
+ \egroup
+ }
+}
+\end{Verbatim}
+This would be set up in a document as such:
+\begin{Verbatim}
+\newfontfamily\sanskitfont{CharisSIL}
+\newfontfamily\titlefont{Posterama}[NFSSEncoding=fakeacc]
+\end{Verbatim}
+Then later in the document, no additional work is needed:
+\begin{Verbatim}
+...{\titlefont kalita\d m}... % <- uses fake accent
+...{\sanskitfont kalita\d m}... % <- uses real accent
+\end{Verbatim}
+To reiterate from above, typing this input with Unicode text (`|kalitaṃ|')
+will \emph{bypass} this encoding mechanism and you will receive only what is contained
+literally within the font.
+
+
+\section{Summary of commands}
+
+The \LaTeXe\ kernel provides the following font encoding commands suitable for Unicode encodings:
+\begin{quote}\obeylines
+ \cs{DeclareTextCommand}\marg{command}\marg{encoding}\oarg{num}\oarg{default}\marg{code}
+ \cs{DeclareUnicodeAccent}\marg{command}\marg{encoding}\marg{slot}
+ \cs{DeclareTextSymbol}\marg{command}\marg{encoding}\marg{slot}
+ \cs{DeclareTextComposite}\marg{command}\marg{encoding}\marg{letter}\marg{slot}
+ \cs{DeclareTextCompositeCommand}\marg{command}\marg{encoding}\marg{letter}\marg{code}
+ \cs{UndeclareTextCommand}\marg{command}\marg{encoding}
+\end{quote}
+See |fntguide.pdf| for full documentation of these.
+As shown above, the following shorthands are provided by \pkg{fontspec} to simplify
+the process of defining Unicode font range encodings:
+\begin{quote}\obeylines
+ \cs{EncodingCommand}\marg{command}\oarg{num}\oarg{default}\marg{code}
+ \cs{EncodingAccent}\marg{command}\marg{code}
+ \cs{EncodingSymbol}\marg{command}\marg{code}
+ \cs{EncodingComposite}\marg{command}\marg{letter}\marg{slot}
+ \cs{EncodingCompositeCommand}\marg{command}\marg{letter}\marg{code}
+ \cs{UndeclareSymbol}\marg{command}
+ \cs{UndeclareAccent}\marg{command}
+ \cs{UndeclareCommand}\marg{command}
+ \cs{UndeclareComposite}\marg{command}\marg{letter}
+\end{quote}
+
+\end{document}
+
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-featset.tex b/macros/latex/contrib/fontspec/fontspec-doc-featset.tex
new file mode 100644
index 0000000000..60e85ca925
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-featset.tex
@@ -0,0 +1,622 @@
+%%^^A%% fontspec-doc-featset.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{Selecting font features}
+\label{sec:selectingfeature}
+
+The commands discussed so far such as \cs{fontspec} each take an optional argument for
+accessing the font features of the requested font.
+Commands are provided to set default features to be applied for all fonts, and even to change the features that a font is presently loaded with.
+Different font shapes can be loaded with separate features, and different features can even be selected for different sizes that the font appears in.
+This part discusses these options.
+
+\section{Default settings}
+\label{sec:defaults}
+
+\cmdbox{\cmd\defaultfontfeatures\marg{font features}}
+
+It is sometimes useful to define
+font features that are applied to every subsequent font selection command.
+This may be defined with the
+\cmd{\defaultfontfeatures} command, shown in \exref{dff}.
+New calls of \cs{defaultfontfeatures} overwrite previous ones, and defaults can be reset by calling the command with an empty argument.
+
+\begin{Xexample}{dff}{A demonstration of the \cs{defaultfontfeatures} command.}
+ \fontspec{texgyreadventor-regular.otf}
+ Some default text 0123456789 \\
+ \defaultfontfeatures{
+ Numbers=OldStyle, Color=888888
+ }
+ \fontspec{texgyreadventor-regular.otf}
+ Now grey, with old-style figures:
+ 0123456789
+\end{Xexample}
+
+\cmdbox{\cmd\defaultfontfeatures\oarg{font name}\marg{font features}}
+
+Default font features can be specified on a per-font and per-face basis
+by using the optional argument to \cs{defaultfontfeatures} as shown.
+\begin{Verbatim}
+ \defaultfontfeatures[texgyreadventor-regular.otf]{Color=blue}
+ \setmainfont{texgyreadventor-regular.otf}% will be blue
+\end{Verbatim}
+Multiple fonts may be affected by using a comma separated list of font names.
+
+\cmdbox{\cmd\defaultfontfeatures\oarg{\cs{font-switch}}\marg{font features}}
+
+\textbf{New in v2.4}.
+Defaults can also be applied to symbolic families such as those created with the |\newfontfamily| command and for |\rmfamily|, |\sffamily|, and |\ttfamily|:
+\begin{Verbatim}
+ \defaultfontfeatures[\rmfamily,\sffamily]{Ligatures=TeX}
+ \setmainfont{texgyreadventor-regular.otf}% will use standard TeX ligatures
+\end{Verbatim}
+The line above to set \TeX-like ligatures is now activated by \emph{default} in \texttt{fontspec.cfg}.
+To reset default font features, simply call the command with an empty argument:
+\begin{Verbatim}
+ \defaultfontfeatures[\rmfamily,\sffamily]{}
+ \setmainfont{texgyreadventor-regular.otf}% will no longer use standard TeX ligatures
+\end{Verbatim}
+
+\cmdbox{\cmd\defaultfontfeatures\texttt{+}\marg{font features}\\
+ \cmd\defaultfontfeatures\texttt{+}\oarg{font name}\marg{font features}}
+
+\textbf{New in v2.4}.
+Using the |+| form of the command appends the \meta{font features} to any already-selected defaults.
+
+
+\section{Working with the currently selected features}
+\label{sec:addfontfeatures}
+
+
+\cmdbox{\cmd\IfFontFeatureActiveTF\marg{font feature}\marg{true code}\marg{false code}}
+
+This command queries the currently selected font face and executes the appropriate branch based on whether the \meta{font feature} as specified by \pkg{fontspec} is currently active.
+
+For example, the following will print `True':
+\begin{Verbatim}
+\setmainfont{texgyrepagella-regular.otf}[Numbers=OldStyle]
+\IfFontFeatureActiveTF{Numbers=OldStyle}{True}{False}
+\end{Verbatim}
+
+Note that there is no way for \pkg{fontspec} to know what the default features of a font will be. For example, by default the |texgyrepagella| fonts use lining numbers. But in the following example, querying for lining numbers returns false since they have not been explicitly requested:
+\begin{Verbatim}
+\setmainfont{texgyrepagella-regular.otf}
+\IfFontFeatureActiveTF{Numbers=Lining}{True}{False}
+\end{Verbatim}
+
+Please note: At time of writing this function only supports OpenType fonts; AAT/Graphite fonts under the \XeTeX\ engine are not supported.
+
+
+\cmdbox{\cmd\addfontfeatures\marg{font features}}
+
+This command allows font features to
+be changed without knowing what features are currently selected or even what
+font is being used. A good example of this could be to add a hook to all
+tabular material to use monospaced numbers, as shown in \exref{aff}.
+If you attempt to \emph{change} an already-selected feature, \pkg{fontspec} will try to de-activate any features that clash with the new ones.
+\Eg, the following two invocations are mutually exclusive:
+\begin{Verbatim}
+\addfontfeature{Numbers=OldStyle}...
+\addfontfeature{Numbers=Lining}...
+123
+\end{Verbatim}
+Since |Numbers=Lining| comes last, it takes precedence and deactivates the call |Numbers=OldStyle|.
+
+\begin{Lexample}{aff}{A demonstration of the \cs{addfontfeatures} command.}
+ \fontspec{texgyreadventor-regular.otf}%
+ [Numbers={Proportional,OldStyle}]
+ `In 1842, 999 people sailed 97 miles in
+ 13 boats. In 1923, 111 people sailed 54
+ miles in 56 boats.' \bigskip
+
+ {\addfontfeatures{Numbers={Monospaced,Lining}}
+ \begin{tabular}{@{} cccc @{}}
+ Year & People & Miles & Boats \\
+ \hline 1842 & 999 & 75 & 13 \\
+ 1923 & 111 & 54 & 56
+ \end{tabular}}
+\end{Lexample}
+
+\DescribeMacro{\addfontfeature}
+This command may also be executed under the alias \cmd{\addfontfeature}.
+
+
+\subsection{Priority of feature selection}
+Features defined with \cs{addfontfeatures} override features
+specified by \cs{fontspec}, which in turn override features
+specified by \cs{defaultfontfeatures}. If in doubt, whenever a
+new font is chosen for the first time, an entry is made in the
+transcript (\texttt{.log}) file displaying the font name and the
+features requested.
+
+
+\section{Different features for different font shapes}
+\label{sec:bfit-feat}
+
+\cmdbox{
+ \feat{BoldFeatures}\texttt=\marg{features} \\
+ \feat{ItalicFeatures}\texttt=\marg{features} \\
+ \feat{BoldItalicFeatures}\texttt=\marg{features} \\
+ \feat{SlantedFeatures}\texttt=\marg{features} \\
+ \feat{BoldSlantedFeatures}\texttt=\marg{features} \\
+ \feat{SmallCapsFeatures}\texttt=\marg{features} \\
+ \feat{UprightFeatures}\texttt=\marg{features}
+}
+
+It is entirely possible that separate fonts in a family will require
+separate options; \eg, Hoefler Text Italic contains various swash
+feature options that are completely unavailable in the upright shapes.
+
+The font features defined at the top level of the optional \cmd\fontspec\
+argument are applied to \emph{all} shapes of the family.
+Using \feat{Upright-}, \feat{SmallCaps-}, \feat{Bold-},
+\feat{Italic-}, and \feat{BoldItalicFeatures},
+separate font features may be defined to their respective shapes
+\emph{in addition} to, and with precedence over, the `global' font features.
+See \exref{itfeat}.
+
+\begin{Xexample}{itfeat}{Features for, say, just italics.}
+\fontspec{EBGaramond-Regular.otf}%
+ [ItalicFont=EBGaramond-Italic.otf]
+\itshape Don’t Ask Victoria! \\
+\addfontfeature{ItalicFeatures={Style=Swash}}
+Don’t Ask Victoria! \\
+\end{Xexample}
+
+Note that because most fonts include their small caps glyphs
+within the main font, features specified with \feat{SmallCapsFeatures} are applied \emph{in addition} to
+any other shape-specific features as defined above, and hence \feat{SmallCapsFeatures}
+can be nested within \feat{ItalicFeatures} and friends. Every combination
+of upright, italic, bold and small caps can thus be assigned individual
+features, as shown in the somewhat ludicrous \exref{scfeat}.
+
+\begin{Xexample}{scfeat}{An example of setting the \feat{SmallCapsFeatures}
+separately for each font shape.}
+ \fontspec{texgyretermes}[
+ Extension = {.otf},
+ UprightFont = {*-regular}, ItalicFont = {*-italic},
+ BoldFont = {*-bold}, BoldItalicFont = {*-bolditalic},
+ UprightFeatures={Color = 220022,
+ SmallCapsFeatures = {Color=115511}},
+ ItalicFeatures={Color = 2244FF,
+ SmallCapsFeatures = {Color=112299}},
+ BoldFeatures={Color = FF4422,
+ SmallCapsFeatures = {Color=992211}},
+ BoldItalicFeatures={Color = 888844,
+ SmallCapsFeatures = {Color=444422}},
+ ]
+ Upright {\scshape Small Caps}\\
+ \itshape Italic {\scshape Italic Small Caps}\\
+ \upshape\bfseries Bold {\scshape Bold Small Caps}\\
+ \itshape Bold Italic {\scshape Bold Italic Small Caps}
+\end{Xexample}
+
+
+\section{Selecting fonts from TrueType Collections (TTC files)}
+TrueType Collections are multiple fonts contained within a single file.
+Each font within a collection must be explicitly chosen using the \feat{FontIndex} command.
+Since TrueType Collections are often used to contain the italic/bold shapes in a family, \pkg{fontspec} automatically selects the italic, bold, and bold italic fontfaces from the same file.
+For example, to load the macOS system font Optima:
+\begin{Verbatim}
+\setmainfont{Optima.ttc}[
+ Path = /System/Library/Fonts/ ,
+ UprightFeatures = {FontIndex=0} ,
+ BoldFeatures = {FontIndex=1} ,
+ ItalicFeatures = {FontIndex=2} ,
+ BoldItalicFeatures = {FontIndex=3} ,
+]
+\end{Verbatim}
+Support for TrueType Collections has only been tested in \XeTeX, but should also work with an up-to-date version of \LuaTeX\ and the \pkg{luaotfload} package.
+
+
+\section{Different features for different font sizes}
+\label{sec:sizefeature}
+
+\cmdbox{
+\ttfamily SizeFeatures = \char`\{\\
+\null\quad...\\
+\null\quad\char`\{~Size =
+\rmfamily\meta{size range}\ttfamily
+,
+\rmfamily \meta{font features}\ttfamily
+~\char`\} , \\
+\null\quad\char`\{~Size =
+\rmfamily\meta{size range}\ttfamily
+, Font =
+\rmfamily\meta{font name}\texttt, \meta{font features}\ttfamily
+~\char`\} , \\
+\null\quad... \\
+\char`\}}
+
+The \feat{SizeFeature} feature is a little more complicated
+than the previous features discussed. It allows different fonts
+and different font features to be selected for a given font
+family as the point size varies.
+
+It takes a comma separated list of braced, comma separated lists of features for each size range.
+Each sub-list must contain the \opt{Size} option
+to declare the size range, and optionally \opt{Font} to change the
+font based on size. Other (regular) fontspec features that are added
+are used on top of the font features that would be used anyway.
+A demonstration to clarify these details is shown in \exref{sizefeat}.
+A less trivial example is shown in the context of optical font sizes
+in \vref{sec:opticalsize}.
+
+\begin{Xexample}{sizefeat}{An example of specifying different font features for different sizes of font with \feat{SizeFeatures}.}
+ \fontspec{texgyrechorus-mediumitalic.otf}[
+ SizeFeatures={
+ {Size={-8}, Font=texgyrebonum-italic.otf, Color=AA0000},
+ {Size={8-14}, Color=00AA00},
+ {Size={14-}, Color=0000AA}} ]
+
+ {\scriptsize Small\par} Normal size\par {\Large Large\par}
+\end{Xexample}
+
+To be precise, the \opt{Size} sub-feature accepts arguments in the form shown in \vref{tab:sizing}.
+Braces around the size range are optional. For an exact font size (|Size=X|)
+font sizes chosen near that size will `snap'. For example, for size definitions
+at exactly 11pt and 14pt, if a 12pt font is requested \emph{actually} the
+11pt font will be selected. This is a remnant of the past when fonts were designed
+in metal (at obviously rigid sizes) and later when bitmap fonts were similarly
+designed for fixed sizes.
+
+If additional features are only required for a single size, the other sizes
+must still be specified. As in:
+\begin{Verbatim}
+ SizeFeatures={
+ {Size=-10,Numbers=Uppercase},
+ {Size=10-}}
+\end{Verbatim}
+Otherwise, the font sizes greater than 10 won't be defined at all!
+
+\begin{table}
+\caption{Syntax for specifying the size to apply custom font features.}\label{tab:sizing}
+\centering
+\begin{tabular}{@{}ll@{}}
+\toprule
+Input & Font size, $s$ \\
+\midrule
+ |Size = X-| & $s \geq \texttt{X}$ \\
+ |Size = -Y| & $s < \texttt{Y}$ \\
+ |Size = X-Y| & $\texttt{X} \leq s < \texttt{Y}$ \\
+ |Size = X| & $s = \texttt{X}$ \\
+\bottomrule
+\end{tabular}
+\end{table}
+
+\paragraph{Interaction with other features}
+For \feat{SizeFeatures} to work with \feat{ItalicFeatures}, \feat{BoldFeatures}, etc., and \feat{SmallCapsFeatures}, a strict heirarchy is required:
+\begin{Verbatim}
+ UprightFeatures =
+ {
+ SizeFeatures =
+ {
+ {
+ Size = -10,
+ Font = ..., % if necessary
+ SmallCapsFeatures = {...},
+ ... % other features for this size range
+ },
+ ... % other size ranges
+ }
+ }
+\end{Verbatim}
+Suggestions on simplifying this interface welcome.
+
+
+\section{Font independent options}
+\label{sec:font-ind-features}
+
+Features introduced in this section may be used with any font.
+
+\subsection{Colour}
+
+\feat{Color} (or \feat{Colour}) uses font specifications to set the colour of
+the text.
+You should think of this as the literal glyphs of the font being coloured in a certain way.
+Notably, this mechanism is different to that of the \pkg{color}/\pkg{xcolor}/\pkg{hyperref}/etc.\ packages, and in fact using \pkg{fontspec} commands to set colour will prevent your text from changing colour using those packages at all!
+For example, if you set the colour in a \verb|\setmainfont| command, \verb|\color{...}| and related commands, including hyperlink colouring, will no longer have any effect on text in this font.)
+Therefore, \pkg{fontspec}'s colour commands are best used to set explicit colours in specific situations, and the \pkg{xcolor} package is recommended for more general colour functionality.
+
+The colour is defined as a triplet of two-digit Hex RGB
+values, with optionally another value for the transparency (where
+|00| is completely transparent and |FF| is opaque.)
+\begin{Lexample}{color}{Selecting colour with transparency.}
+ \fontsize{48}{48}
+ \fontspec{texgyrebonum-bold.otf}
+ {\addfontfeature{Color=FF000099}W}\kern-0.4ex
+ {\addfontfeature{Color=0000FF99}S}\kern-0.4ex
+ {\addfontfeature{Color=DDBB2299}P}\kern-0.5ex
+ {\addfontfeature{Color=00BB3399}R}
+\end{Lexample}
+Transparency is supported by \LuaLaTeX; \XeLaTeX\ with the \texttt{xdvipdfmx} driver
+does not support this feature.
+
+If you load the \pkg{xcolor} package, you may use any named colour instead
+of writing the colours in hexadecimal.
+\begin{Verbatim}
+ \usepackage{xcolor}
+ ...
+ \fontspec[Color=red]{Verdana} ...
+ \definecolor{Foo}{rgb}{0.3,0.4,0.5}
+ \fontspec[Color=Foo]{Verdana} ...
+\end{Verbatim}
+The \pkg{color} package is \emph{not} supported; use \pkg{xcolor} instead.
+
+You may specify the transparency with a named colour using the \feat{Opacity}
+feature which takes an decimal from zero to one corresponding to
+transparent to opaque respectively:
+\begin{Verbatim}
+ \fontspec[Color=red,Opacity=0.7]{Verdana} ...
+\end{Verbatim}
+It is still possible to specify a colour in six-char hexadecimal form
+while defining opacity in this way, if you like.
+
+\subsection{Scale}
+
+\cmdbox{
+ \feat{Scale} = \meta{number} \\
+ \feat{Scale} = \opt{MatchLowercase} \\
+ \feat{Scale} = \opt{MatchUppercase}
+}
+
+In its explicit form, \feat{Scale} takes a single
+numeric argument for linearly scaling the font, as demonstrated
+in \exref{fontload}.
+
+As well as a numerical argument, the \feat{Scale} feature
+also accepts options \opt{MatchLowercase}
+and \opt{MatchUppercase}, which will scale the font being selected to match
+the current default roman font to either the height of the lowercase or
+uppercase letters, respectively; these features are shown in \exref{scale}.
+The amount of scaling used in each instance is reported in the \texttt{.log} file.
+
+\begin{Xexample}{scale}{Automatically calculated scale values.}
+ \setmainfont{Georgia}
+ \newfontfamily\lc[Scale=MatchLowercase]{Verdana}
+ The perfect match {\lc is hard to find.}\\
+ \newfontfamily\uc[Scale=MatchUppercase]{Arial}
+ L O G O \uc F O N T
+\end{Xexample}
+
+Additional calls to the \feat{Scale} feature overwrite the settings of the former.
+If you want to accumulate scale factors (useful perhaps to fine-tune the settings of
+\opt{MatchLowercase}), the \feat{ScaleAgain} feature can be used as many times as
+necessary. For example:
+\begin{Verbatim}
+ [ Scale = 1.1 , Scale = 1.2 ] % -> scale of 1.2
+ [ Scale = 1.1 , ScaleAgain = 1.2 ] % -> scale of 1.32
+\end{Verbatim}
+
+Note that when |Scale=MatchLowercase| is used with |\setmainfont|, the new `main'
+font of the document will be scaled to match the old default.
+If you wish to automatically scale all fonts except have the main font use `natural'
+scaling, you may write
+\begin{Verbatim}
+ \defaultfontfeatures{ Scale = MatchLowercase }
+ \defaultfontfeatures[\rmfamily]{ Scale = 1}
+\end{Verbatim}
+One or both of these lines may be placed into a local |fontspec.cfg| file
+(see \vref{sec:config}) for this behaviour to be effected in your own documents
+automatically.
+(Also see \vref{sec:defaults} for more information on setting font defaults.)
+
+
+
+
+\subsection{Interword space}
+
+While the space between words can be varied on an individual
+basis with the \TeX\ primitive \cmd\spaceskip\ command, it is
+more convenient to specify this information when the font is
+first defined.
+
+The space in between words in a paragraph will be chosen automatically,
+and generally will not need to be adjusted. For those
+times when the precise details are important, the \feat{WordSpace}
+feature is
+provided, which takes either a single scaling factor to scale the
+default value, or a triplet of comma-separated
+values to scale the nominal value, the stretch, and the shrink of the
+interword space by, respectively. (|WordSpace={|$x$|}| is the same as
+|WordSpace={|$x$|,|$x$|,|$x$|}|.)
+
+\begingroup
+\let\centering\relax
+\begin{Xexample}{wordspace}{Scaling the default interword space. An exaggerated value has been chosen to emphasise the effects here.}
+ \fontspec{texgyretermes-regular.otf}
+ Some text for our example to take
+ up some space, and to demonstrate
+ the default interword space.
+ \bigskip
+
+ \fontspec{texgyretermes-regular.otf}%
+ [WordSpace = 0.3]
+ Some text for our example to take
+ up some space, and to demonstrate
+ the default interword space.
+\end{Xexample}
+\endgroup
+
+Note that \TeX's optimisations in how it loads fonts means that you cannot
+use this feature in \cs{addfontfeatures}.
+
+\subsection{Post-punctuation space}
+
+If \cmd\frenchspacing\ is \emph{not} in effect, \TeX\ will allow extra
+space after some punctuation in its goal of justifying the lines of text.
+Generally, this is considered old-fashioned, but occasionally in small amounts the
+effect can be justified, pardon the pun.
+
+The \feat{PunctuationSpace} feature takes a scaling factor by which to
+adjust the nominal value chosen for the font; this is demonstrated in
+\exref{punctspace}.
+Note that |PunctuationSpace=0|
+is \emph{not} equivalent to \cmd\frenchspacing, although the difference
+will only be apparent when a line of text is under-full.
+
+\begin{Lexample}{punctspace}{Scaling the default post-punctuation space.}
+ \nonfrenchspacing
+ \fontspec{texgyreschola-regular.otf}
+ Letters, Words. Sentences. \par
+ \fontspec{texgyreschola-regular.otf}[PunctuationSpace=2]
+ Letters, Words. Sentences. \par
+ \fontspec{texgyreschola-regular.otf}[PunctuationSpace=0]
+ Letters, Words. Sentences.
+\end{Lexample}
+
+Note that \TeX's optimisations in how it loads fonts means that you cannot
+use this feature in \cs{addfontfeatures}.
+
+
+
+\subsection{The hyphenation character}
+
+The letter used for hyphenation may be chosen with the \feat{HyphenChar}
+feature.
+With one exception (\feat{HyphenChar} \texttt{=} \opt{None}),
+this is a \XeTeX-only feature since \LuaTeX\ cannot set the hyphenation character on a per-font basis;
+see its \cs{prehyphenchar} primitive for further details.
+
+\feat{HyphenChar} takes three types of input, which are chosen according to some
+simple rules. If the input is the string \opt{None}, then hyphenation is
+suppressed for this font.
+If the input is a single character, then this character is used.
+Finally, if the input is longer than a single character
+it must be the UTF-8 slot number of the hyphen character you desire.
+
+This package redefines \LaTeX's \cmd\-\ macro such that it adjusts along with the above changes.
+
+\begin{Xexample}{hyphchar}{Explicitly choosing the hyphenation character.}
+ \def\text{\fbox{\parbox{1.55cm}{%
+ EXAMPLE HYPHENATION%
+ }}\qquad\qquad\null\par\bigskip}
+
+ \fontspec{LinLibertine_R.otf}[HyphenChar=None]
+ \text
+ \fontspec{LinLibertine_R.otf}[HyphenChar={+}]
+ \text
+\end{Xexample}
+
+Note that \TeX's optimisations in how it loads fonts means that you cannot
+use this feature in \cs{addfontfeatures}.
+
+\subsection{Optical font sizes} \label{sec:opticalsize}
+
+Optically scaled fonts thicken out as the font size decreases
+in order to make the glyph shapes more robust (less prone to losing
+detail), which improves legibility. Conversely, at large optical
+sizes the serifs and other small details may be more delicately
+rendered.
+
+OpenType fonts with optical scaling can exist in
+several discrete sizes (in separate font files).
+When loading fonts by name, \XeTeX\ and Lua\TeX\ engines will attempt to
+\emph{automatically} load the appropriate font as determined by the current font size.
+An example of this behaviour is shown in \exref{optsize}, in which some larger text is
+mechanically scaled down to compare the difference for equivalent font sizes.
+
+The \feat{OpticalSize} feature may be used to specify a different optical size.
+With \feat{OpticalSize} set (\exref{optsize0})
+to zero, no optical size font substitution is performed.
+
+\begin{Lexample}{optsize}{A demonstration of automatic optical size selection.}
+ \fontspec{Latin Modern Roman}
+ Automatic optical size \\
+ \scalebox{0.4}{\Huge
+ Automatic optical size}
+\end{Lexample}
+
+\begin{Lexample}{optsize0}{Explicit optical size substitution for the Latin Modern Roman family.}
+ \fontspec{Latin Modern Roman}[OpticalSize=5]
+ Latin Modern optical sizes \\
+ \fontspec{Latin Modern Roman}[OpticalSize=8]
+ Latin Modern optical sizes \\
+ \fontspec{Latin Modern Roman}[OpticalSize=12]
+ Latin Modern optical sizes \\
+ \fontspec{Latin Modern Roman}[OpticalSize=17]
+ Latin Modern optical sizes
+\end{Lexample}
+
+The \feat{SizeFeatures} feature (\vref*{sec:sizefeature}) can be
+used to specify exactly which optical sizes will be used for ranges
+of font size. For example, something like:
+\begin{Verbatim}
+ \fontspec{Latin Modern Roman}[
+ UprightFeatures = { SizeFeatures = {
+ {Size=-10, OpticalSize=8 },
+ {Size= 10-14, OpticalSize=10},
+ {Size= 14-18, OpticalSize=14},
+ {Size= 18-, OpticalSize=18}}}
+ ]
+\end{Verbatim}
+
+\subsection{Font transformations}
+
+In rare situations users may want to mechanically distort the shapes of the glyphs in the current font such as shown in \exref{fake}. Please don't overuse these features; they are \emph{not} a good alternative to having the real shapes.
+
+\begin{Xexample}{fake}{Articifial font transformations.}
+ \fontspec{Quattrocento.otf} \emph{ABCxyz} \quad
+ \fontspec{Quattrocento.otf}[FakeSlant=0.2] ABCxyz
+
+ \fontspec{Quattrocento.otf} ABCxyz \quad
+ \fontspec{Quattrocento.otf}[FakeStretch=1.2] ABCxyz
+
+ \fontspec{Quattrocento.otf} \textbf{ABCxyz} \quad
+ \fontspec{Quattrocento.otf}[FakeBold=1.5] ABCxyz
+\end{Xexample}
+
+If values are omitted, their defaults are as shown above.
+
+If you want the bold shape to be faked automatically, or the italic shape
+to be slanted automatically, use the \feat{AutoFakeBold} and
+\feat{AutoFakeSlant} features. For example, the following two invocations
+are equivalent:
+\begin{Verbatim}
+ \fontspec[AutoFakeBold=1.5]{Charis SIL}
+ \fontspec[BoldFeatures={FakeBold=1.5}]{Charis SIL}
+\end{Verbatim}
+If both of the \feat{AutoFake...} features are used, then the bold italic
+font will also be faked.
+
+The \feat{FakeBold} and \feat{AutoFakeBold} features are only available with the \XeTeX\ engine and will be ignored in \LuaTeX.
+
+
+\subsection{Letter spacing}
+Letter spacing, or tracking, is the term given to adding (or subtracting) a small amount of horizontal space in between adjacent characters. It is specified with the \feat{LetterSpace}, which takes a numeric argument,
+shown in \exref{tracking}.
+
+The letter spacing parameter is a normalised additive factor (not a scaling factor); it is defined as a percentage of the font size. That is, for a 10\,pt font, a letter spacing parameter of `|1.0|' will add 0.1\,pt between each letter.
+
+\begin{Xexample}{tracking}{The \feat{LetterSpace} feature.}
+ \fontspec{Didot}
+ \addfontfeature{LetterSpace=0.0}
+ USE TRACKING FOR DISPLAY CAPS TEXT \\
+ \addfontfeature{LetterSpace=2.0}
+ USE TRACKING FOR DISPLAY CAPS TEXT
+\end{Xexample}
+
+This functionality is not generally used for lowercase text in modern typesetting but does have historic precedent in a variety of situations.
+In particular, small amounts of letter spacing can be very useful, when setting small caps or all caps titles.
+Also see the OpenType \opt{Uppercase} option of the \feat{Letters} feature (\vref*{sec:letters}).
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-fontsel.tex b/macros/latex/contrib/fontspec/fontspec-doc-fontsel.tex
new file mode 100644
index 0000000000..c1900322c0
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-fontsel.tex
@@ -0,0 +1,639 @@
+%%^^A%% fontspec-doc-fontsel.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{General font selection}
+
+\section{Main commands}
+\label{sec:main-cmd}
+
+This section concerns the variety of commands that can be used to select
+fonts.
+
+\bigskip
+\cmdbox{%
+ \CMD{\string\setmainfont}\marg{font}\oarg{font features}\\
+ \CMD{\string\setsansfont}{\color[gray]{0.5}\marg{font}\oarg{font features}}\\
+ \CMD{\string\setmonofont}{\color[gray]{0.5}\marg{font}\oarg{font features}}
+}
+
+These are the main font-selecting commands of this package which select the standard fonts used in a document, as shown in \exref{fontload}.
+Here, the scales of the fonts have been chosen to equalise their
+lowercase letter heights. The \feat{Scale} font feature will be discussed
+further in \vref{sec:font-ind-features}, including methods for automatic
+scaling.
+Note that further options may need to be added to select appropriate bold/italic fonts,
+but this shows the main idea.
+
+Note that while these commands all look and behave largely identically, the default setup for font loading automatically adds the |Ligatures=TeX| feature for the \cs{setmainfont} and \cs{setsansfont} commands.
+These defaults (and further customisations possible) are discussed in \vref{sec:defaults}.
+
+\bigskip
+\cmdbox{%
+ \CMD{\string\newfontfamily}\meta{cmd}\marg{font}\oarg{font features}\\
+ \CMD{\string\setfontfamily}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}\\
+ \CMD{\string\renewfontfamily}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}
+ \CMD{\string\providefontfamily}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}
+}
+
+These commands define new font family commands (like \cs{rmfamily}).
+The |new| command checks if \meta{cmd} has been defined, and issues an error if so.
+The |renew| command checks if \meta{cmd} has been defined, and issues an error if not.
+The |provide| command checks if \meta{cmd} has been defined, and silently aborts if so.
+The |set| command never checks; use at your own risk.
+
+
+
+\bigskip
+\cmdbox{%
+ \CMD{\string\fontspec}\marg{font}\oarg{font features}
+}
+
+The plain \cs{fontspec} command is not generally recommended for document use. It is an
+ad hoc commands best suited for testing and loading fonts on a one-off basis.
+
+All of the commands listed above accept comma-separated
+\meta{font feature}=\meta{option} lists; these are described later:
+\begin{itemize}
+\item For general font features, see \vref{sec:font-ind-features}
+\item For OpenType fonts, see Part~\vref{sec:opentype-features}
+\item For \XeTeX-only general font features, see Part~\vref{sec:xetex-features}
+\item For \LuaTeX-only general font features, see Part~\vref{sec:luatex-features}
+\item For features for \AAT\ fonts in \XeTeX, see \vref{sec:aat-features}
+\end{itemize}
+
+\begin{Lexample}{fontload}{Loading the default, sans serif, and monospaced fonts.}
+ \setmainfont{texgyrebonum-regular.otf}
+ \setsansfont{lmsans10-regular.otf}[Scale=MatchLowercase]
+ \setmonofont{Inconsolatazi4-Regular.otf}[Scale=MatchLowercase]
+
+ \rmfamily Pack my box with five dozen liquor jugs\par
+ \sffamily Pack my box with five dozen liquor jugs\par
+ \ttfamily Pack my box with five dozen liquor jugs
+\end{Lexample}
+
+\section{Font selection}
+
+In both \LuaTeX\ and \XeTeX, fonts can be selected (using the \meta{font} argument in \ref{sec:main-cmd}) either by `font name' or by `file name', but there are some differences in how each engine finds and selects fonts --- don't be too surprised if a font invocation in one engine needs correction to work in the other.
+
+
+\subsection{By font name}
+
+Fonts known to \LuaTeX\ or \XeTeX\ may be loaded by their standard names as
+you'd speak them out loud, such as \emph{Times New Roman} or
+\emph{Adobe Garamond}.
+`Known to' in this case generally means `exists in a standard fonts location'
+such as |~/Library/Fonts| on \MacOSX, or |C:\Windows\Fonts| on Windows.
+In \LuaTeX, fonts found in the \textsc{texmf} tree can also be loaded by name.
+In \XeTeX, fonts found in the \textsc{texmf} tree can be loaded in Windows and Linux,
+but not on \MacOSX.
+
+The simplest example might be something like
+\begin{Verbatim}
+ \setmainfont{Cambria}[ ... ]
+\end{Verbatim}
+in which the bold and italic fonts will be found automatically
+(if they exist) and are immediately accessible with the usual
+\cs{textit} and \cs{textbf} commands.
+
+The `font name' can be found in various ways, such as by looking in the name listed in a application like \emph{Font Book} on Mac~OS~X.
+Alternatively, \TeX{}Live contains the \texttt{otfinfo} command line program, which can query this information; for example:
+\begin{Verbatim}
+ otfinfo -i `kpsewhich lmroman10-regular.otf`
+\end{Verbatim}
+results in a line that reads:
+\begin{Verbatim}
+ Preferred family: Latin Modern Roman
+\end{Verbatim}
+(The `preferred family' name is usually better than the `family' name.)
+
+\paragraph{\LuaTeX\ users only}
+In order to load fonts by their name rather than by their filename (\eg,
+`Latin Modern Roman' instead of `ec-lmr10'), you may need to run the script
+\texttt{luaotfload-tool}, which is distributed with the \pkg{luaotfload}
+package. Note that if you do not execute this script beforehand, the first
+time you attempt to typeset the process will pause for (up to) several
+minutes. (But only the first time.)
+Please see the \pkg{luaotfload} documentation for more information.
+
+
+\subsection{By file name}
+\label{sec:by-file-name}
+
+\XeTeX\ and \LuaTeX\ also allow fonts to be loaded by file name instead of font name.
+When you have a very large collection of fonts, you will sometimes not
+wish to have them all installed in your system's font directories.
+In this case, it is more convenient to load them from a different location on your disk.
+This technique is also necessary in \XeTeX\ when loading OpenType fonts that are present within your \TeX\ distribution, such as \path{/usr/local/texlive/2013/texmf-dist/fonts/opentype/public}.
+Fonts in such locations are visible to \XeTeX\ but cannot be loaded by font name, only file name; \LuaTeX\ does not have this restriction.
+
+When selecting fonts by file name, any font that can be found in the default
+search paths may be used directly (including in the current directory)
+without having to explicitly define the location of the font file on disk.
+
+Fonts selected by filename must include bold and italic variants explicitly,
+unless a \texttt{.fontspec} file is supplied for the font family (see section~\ref{sec:fontspecfile}).
+We'll give some first examples specifying everything explicitly:
+\begin{Verbatim}
+ \setmainfont{texgyrepagella-regular.otf}[
+ BoldFont = texgyrepagella-bold.otf ,
+ ItalicFont = texgyrepagella-italic.otf ,
+ BoldItalicFont = texgyrepagella-bolditalic.otf ]
+\end{Verbatim}
+\pkg{fontspec} knows that the font is to be selected by file name by the
+presence of the `|.otf|' extension.
+An alternative is to specify the extension separately, as shown following:
+\begin{Verbatim}
+ \setmainfont{texgyrepagella-regular}[
+ Extension = .otf ,
+ BoldFont = texgyrepagella-bold ,
+ ... ]
+\end{Verbatim}
+If desired, an abbreviation can be applied to the font names based on the
+mandatory `font name' argument:
+\begin{Verbatim}
+ \setmainfont{texgyrepagella}[
+ Extension = .otf ,
+ UprightFont = *-regular ,
+ BoldFont = *-bold ,
+ ... ]
+\end{Verbatim}
+In this case `texgyrepagella' is no longer the name of an actual font,
+but is used to construct the font names for each shape;
+the |*| is replaced by `texgyrepagella'.
+Note in this case that |UprightFont| is required for constructing the font
+name of the normal font to use.
+
+To load a font that is not in one of the default search paths, its location
+in the filesystem must be specified with the |Path| feature:
+\begin{Verbatim}
+ \setmainfont{texgyrepagella}[
+ Path = /Users/will/Fonts/ ,
+ UprightFont = *-regular ,
+ BoldFont = *-bold ,
+ ... ]
+\end{Verbatim}
+Note that \XeTeX\ and \LuaTeX\ are able to load the font without giving an
+extension, but \pkg{fontspec} must know to search for the file; this can can
+be indicated by using the |Path| feature without an argument:
+\begin{Verbatim}
+ \setmainfont{texgyrepagella-regular}[
+ Path, BoldFont = texgyrepagella-bold,
+ ... ]
+\end{Verbatim}
+My preference is to always be explicit and include the extension; this also allows \pkg{fontspec} to automatically identify that the font should be loaded by filename.
+
+In previous versions of the package, the |Path| feature was also provided under the alias |ExternalLocation|, but this latter name is now deprecated and should not be used for new documents.
+
+
+\subsection{By custom file name using a \texttt{.fontspec} file}
+\label{sec:fontspecfile}
+
+When \pkg{fontspec} is first asked to load a font, a font settings file is searched
+for with the name `\meta{fontname}\texttt{.fontspec}'.\footnote{Located in the current folder or within a standard \texttt{texmf} location.}
+If you want to \emph{disable} this feature on a per-font basis, use the \feat{IgnoreFontspecFile} font option.
+
+The contents of this file can be used to specify font shapes and font features without having to have this information present within each document.
+Therefore, it can be more flexible than the alternatives listed above.
+
+When searching for this \texttt{.fontspec} file, \meta{fontname} is stripped of spaces and file extensions are omitted.
+For example, given |\setmainfont{TeX Gyre Adventor}|, the \texttt{.fontspec} file would be
+called \texttt{TeXGyreAdventor.fontspec}.
+If you wanted to transparently load options for |\setmainfont{texgyreadventor-regular.otf}|, the configuration
+file would be \texttt{texgyreadventor-regular.fontspec}.
+
+N.B. that while spaces are stripped, the lettercase of the names should match.
+
+This mechanism can be used to define custom names or aliases for your font collections.
+The syntax within this file follows from the \cs{defaultfontfeatures}, defined in more detail later but mirroring the standard \pkg{fontspec} font loading syntax.
+As an example, suppose we're defining a font family to be loaded with \verb|\setmainfont{My Charis}|.
+The corresponding \texttt{MyCharis.fontspec} file would contain, say,
+\begin{Verbatim}
+ \defaultfontfeatures[My Charis]
+ {
+ Extension = .ttf ,
+ UprightFont = CharisSILR,
+ BoldFont = CharisSILB,
+ ItalicFont = CharisSILI,
+ BoldItalicFont = CharisSILBI,
+ % <any other desired options>
+ }
+\end{Verbatim}
+The optional argument to \cs{defaultfontfeatures} must exactly match that requested by the font loading command (\verb|\setmainfont|, etc.) --- in particular note that spaces are significant here, so |\setmainfont{MyCharis}| will not `see' the default font feature setting within the \texttt{.fontspec} file.
+
+Finally, note that options for individual font faces can also be defined in this way.
+To continue the example above, here we colour the different faces:
+\begin{Verbatim}
+ \defaultfontfeatures[CharisSILR]{Color=blue}
+ \defaultfontfeatures[CharisSILB]{Color=red}
+\end{Verbatim}
+Such configuration lines could be stored either inline inside \texttt{My Charis.fontspec}
+or within their own \texttt{.fontspec} files; in this way, \pkg{fontspec} is designed to
+handle `nested' configuration options.
+
+Where \cs{defaultfontfeatures} is being used to specify font faces by a custom name,
+the \feat{Font} feature is used to set the filename of the font face. For example:
+\begin{Verbatim}
+ \defaultfontfeatures[charis]
+ {
+ UprightFont = charis-regular,
+ % <other desired options for all font faces in the family>
+ }
+
+ \defaultfontfeatures[charis-regular]
+ {
+ Font = CharisSILR
+ % <other desired options just for the `upright' font>
+ }
+\end{Verbatim}
+The \pkg{fontspec} interface here is designed to be flexible to accomodate a variety
+of use cases; there is more than one way to achieve the same outcome when font faces are
+collected together into a larger font family.
+
+
+\subsection{Querying whether a font `exists'}
+
+\cmdbox{
+ \CMD{\string\IfFontExistsTF}\marg{font name}\marg{true branch}\marg{false branch}
+}
+
+The conditional \cs{IfFontExistsTF} is provided to test whether the \meta{font name} exists or is loadable.
+If it is, the \meta{true branch} code is executed; otherwise, the \meta{false branch} code is.
+
+This command can be slow since the engine may resort to scanning the filesystem for a missing font.
+Nonetheless, it has been a popular request for users who wish to define `fallback fonts' for their documents for greater portability.
+
+In this command, the syntax for the \meta{font name} is a restricted/simplified version of the font loading syntax used for \cs{fontspec} and so on.
+Fonts to be loaded by filename are detected by the presence of an appropriate extension (|.otf|, etc.), and paths should be included inline.
+E.g.:
+\begin{Verbatim}
+ \IfFontExistsTF{cmr10}{T}{F}
+ \IfFontExistsTF{Times New Roman}{T}{F}
+ \IfFontExistsTF{texgyrepagella-regular.otf}{T}{F}
+ \IfFontExistsTF{/Users/will/Library/Fonts/CODE2000.TTF}{T}{F}
+\end{Verbatim}
+
+The \cs{IfFontExistsTF} command is a synonym for the programming interface function \cs{fontspec_font_if_exist:nTF} (\vref*{sec:api}).
+
+
+
+\section{Commands to select font families}
+
+For cases when a specific font with a specific
+feature set is going to be re-used many times in a document, it is inefficient
+to keep calling \cs{fontspec} for every use. While the \cs{fontspec} command does not define
+a new font instance after the first call, the feature options must still be
+parsed and processed.
+
+For this reason, new commands can be created for loading a particular font
+family with the \cmd\newfontfamily\ command and variants,
+outlined in \vref{sec:main-cmd} and demonstrated in \exref{nff}.
+This macro should be used to create commands that would be used in
+the same way as \cmd\rmfamily, for example.
+If you would like to create a command that only changes the font
+inside its argument (i.e., the same behaviour as \cs{emph}) define it using regular \LaTeX\
+commands:
+\begin{Verbatim}
+ \newcommand\textnote[1]{{\notefont #1}}
+ \textnote{This is a note.}
+\end{Verbatim}
+Note that the double braces are intentional; the inner pair are used to
+to delimit the scope of the font change.
+
+\begin{Lexample}{nff}{Defining new font families.}
+ \newfontfamily\notefont{Kurier}
+ \notefont This is a \emph{note}.
+\end{Lexample}
+
+\emph{Comment for advanced users:}
+The commands defined by \cs{newfontfamily} (and \cs{newfontface}; see next section) include
+their encoding information, so even if the document is set to use a
+legacy \TeX\ encoding, such commands will still work correctly. For example,
+\begin{Verbatim}
+\documentclass{article}
+\usepackage{fontspec}
+\newfontfamily\unicodefont{Lucida Grande}
+\usepackage{mathpazo}
+\usepackage[T1]{fontenc}
+\begin{document}
+A legacy \TeX\ font. {\unicodefont A unicode font.}
+\end{document}
+\end{Verbatim}
+
+
+\section{Commands to select single font faces}
+
+\cmdbox{%
+ \CMD{\string\newfontface}\meta{cmd}\marg{font}\oarg{font features}\\
+ \CMD{\string\setfontface}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}\\
+ \CMD{\string\renewfontface}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}\\
+ \CMD{\string\providefontface}{\color[gray]{0.5}\meta{cmd}\marg{font}\oarg{font features}}
+}
+
+Sometimes only a specific font face is desired, without accompanying italic or bold variants
+being automatically selected.
+This is common when selecting a fancy italic font, say, that has swash features unavailable
+in the upright forms. \cmd\newfontface\ is used for this purpose, shown
+in \exref{nfface}, which is repeated in \vref{sec:contextuals}.
+
+\begin{Xexample}{nfface}{Defining a single font face.}
+ \newfontface\fancy{Hoefler Text Italic}%
+ [Contextuals={WordInitial,WordFinal}]
+ \fancy where is all the vegemite
+ % \emph, \textbf, etc., all don't work
+\end{Xexample}
+
+
+\subsection{More control over font shape selection}
+\label{sec:bfitfonts}
+
+\cmdbox{
+ \feat{BoldFont} = \meta{font name} \\
+ \feat{ItalicFont} = \meta{font name} \\
+ \feat{~BoldItalicFont} = \meta{font name} \\
+ \feat{SlantedFont} = \meta{font name} \\
+ \feat{BoldSlantedFont} = \meta{font name} \\
+ \feat{SmallCapsFont} = \meta{font name} \\
+ \feat{UprightFont} = \meta{font name}
+}
+
+The automatic bold, italic, and bold italic font selections will not be
+adequate for the needs of every font: while some fonts mayn't even
+have bold or italic shapes, in which case a skilled (or lucky)
+designer may be able to chose well-matching accompanying shapes from
+a different font altogether, others can have a range of bold and
+italic fonts to chose among. The \feat{BoldFont} and
+\feat{ItalicFont} features are provided for these situations. If only
+one of these is used, the bold italic font is requested as the
+default from the \emph{new} font. See \exref{bff}.
+
+\begin{Xexample}{bff}{Explicit selection of the bold font.}
+ \fontspec{Helvetica Neue UltraLight}%
+ [BoldFont={Helvetica Neue}]
+ Helvetica Neue UltraLight \\
+ {\itshape Helvetica Neue UltraLight Italic} \\
+ {\bfseries Helvetica Neue } \\
+ {\bfseries\itshape Helvetica Neue Italic} \\
+\end{Xexample}
+
+If a bold italic shape is not defined, or you want to specify
+\emph{both} custom bold and italic shapes, the \feat{BoldItalicFont}
+feature is provided.
+
+
+
+\subsubsection{Small caps and slanted font shapes}
+
+When a font family has both slanted \emph{and} italic shapes, these may be specified separately using the analogous features \feat{SlantedFont} and \feat{BoldSlantedFont}.
+Without these, however, the \LaTeX\ font switches for slanted (\cs{textsl}, \cs{slshape}) will default to the italic shape.
+
+Pre-OpenType, it was common for font families to be distributed with small caps glyphs in separate fonts, due to the limitations on the number of glyphs allowed in the PostScript Type~1 format.
+Such fonts may be used by declaring the \feat{SmallCapsFont} of the family you are specifying:
+\begin{Verbatim}
+ \setmainfont{Minion MM Roman}[
+ SmallCapsFont={Minion MM Small Caps & Oldstyle Figures}
+ ]
+ Roman 123 \\ \textsc{Small caps 456}
+\end{Verbatim}
+In fact, you should specify the small caps font for each individual bold and
+italic shape as in
+\begin{Verbatim}
+ \setmainfont{ <upright> }[
+ UprightFeatures = { SmallCapsFont={ <sc> } } ,
+ BoldFeatures = { SmallCapsFont={ <bf sc> } } ,
+ ItalicFeatures = { SmallCapsFont={ <it sc> } } ,
+ BoldItalicFeatures = { SmallCapsFont={ <bf it sc> } } ,
+ ]
+ Roman 123 \\ \textsc{Small caps 456}
+\end{Verbatim}
+For most modern fonts that have small caps as a font feature, this level of
+control isn't generally necessary.
+
+All of the bold, italic, and small caps fonts can be loaded with different
+font features from the main font. See \ref{sec:bfit-feat} for details.
+When an OpenType font is selected for |SmallCapsFont|, the small caps
+font feature is \emph{not} automatically enabled. In this case, users
+should write instead, if necessary,
+\begin{Verbatim}
+ \setmainfont{...}[
+ SmallCapsFont={...},
+ SmallCapsFeatures={Letters=SmallCaps},
+ ]
+\end{Verbatim}
+
+\subsection{Specifically choosing the \NFSS\ family}
+
+In \LaTeX's \NFSS, font families are defined with names such as `\texttt{ppl}' (Palatino), `\texttt{lmr}' (Latin Modern Roman), and so on, which are selected with the \cs{fontfamily} command:
+\begin{Verbatim}
+ \fontfamily{ppl}\selectfont
+\end{Verbatim}
+In \pkg{fontspec}, the family names are auto-generated based on the fontname of the font; for example, writing |\fontspec{Times New Roman}| for the first time would generate an internal font family name of `\texttt{TimesNewRoman(1)}'.
+Please note that should not rely on the name that is generated.
+
+In certain cases it is desirable to be able to choose this internal font family name so it can be re-used elsewhere for interacting with other packages that use the \LaTeX's font selection interface; an example might be
+\begin{Verbatim}
+ \usepackage{fancyvrb}
+ \fvset{fontfamily=myverbatimfont}
+\end{Verbatim}
+To select a font for use in this way in \pkg{fontspec} use the \feat{NFSSFamily} feature:\footnote{Thanks to Luca Fascione for the example and motivation for finally implementing this feature.}
+\begin{Verbatim}
+ \newfontfamily\verbatimfont[NFSSFamily=myverbatimfont]{Inconsolata}
+\end{Verbatim}
+It is then possible to write commands such as:
+\begin{Verbatim}
+ \fontfamily{myverbatimfont}\selectfont
+\end{Verbatim}
+which is essentially the same as writing |\verbatimfont|, or to go back to the orginal example:
+\begin{Verbatim}
+ \fvset{fontfamily=myverbatimfont}
+\end{Verbatim}
+Only use this feature when necessary; the in-built font switching commands that \pkg{fontspec} generates (such as |\verbatimfont| in the example above) are recommended in all other cases.
+
+If you don't wish to explicitly set the \NFSS\ family but you would like to know what it is, an alternative mechanism for package writers is introduced as part of the \pkg{fontspec} programming interface; see the function \cs{fontspec_set_family:Nnn} for details (\vref*{sec:api}).
+
+\subsection{Choosing additional \NFSS\ font faces}
+
+\LaTeX's font selection scheme (\NFSS) is more flexible than the \pkg{fontspec} interface discussed up until this point.
+It assigns to each font face a \emph{family} (discussed above), a \emph{series} such as bold or light or condensed, and a \emph{shape} such as italic or slanted or small caps.
+The \pkg{fontspec} features such as \feat{BoldFont} and so on all assign faces for the default series and shapes of the \NFSS, but it's not uncommon to have font families that have multiple weights and shapes and so on.
+
+If you set up a regular font family with the `standard four' (upright, bold, italic, and bold italic) shapes and then want to use, say, a light font for a certain document element, many users will be perfectly happy to use \cs{newfontface}\cs{\meta{switch}} and use the resulting font \cs{\meta{switch}}.
+In other cases, however, it is more convenient or even necessary to load additional fonts using additional \NFSS\ specifiers.
+
+\cmdbox{
+ \texttt{FontFace = }\marg{series}\marg{shape}
+ \texttt{\char`\{} \texttt{Font = }\meta{font name} \texttt, \meta{features} \texttt{\char`\}} \\
+ \texttt{FontFace = }\marg{series}\marg{shape}\marg{font name}
+}
+
+The font thus specified will inherit the font features of the main font, with optional additional \meta{features} as requested.
+(Note that the optional \marg{features} argument is still surrounded with curly braces.)
+Multiple \feat{FontFace} commands may be used in a single declaration to specify multiple fonts.
+As an example:
+\begin{Verbatim}
+ \setmainfont{font1.otf}[
+ FontFace = {c}{\updefault}{ font2.otf } ,
+ FontFace = {c}{m}{ Font = font3.otf , Color = red }
+ ]
+\end{Verbatim}
+Writing |\fontseries{c}\selectfont| will result in |font2| being selected, which then followed by |\fontshape{m}\selectfont| will result in |font3| being selected (in red).
+A font face that is defined in terms of a different series but an upright shape (|\updefault|, as shown above) will attempt to find a matching small caps feature and define that face as well.
+Conversely, a font face defined in terms of a non-standard font shape will not.
+
+There are some standards for choosing shape and series codes; the \LaTeXe\ font selection guide\footnote{\texttt{texdoc fntguide}} lists series |m| for medium, |b| for bold, |bx| for bold extended, |sb| for semi-bold, and |c| for condensed.
+A far more comprehensive listing is included in Appendix~A of Philipp Lehman's `The Font Installation Guide'\footnote{\texttt{texdoc fontinstallationguide}} covering 14 separate weights and 12 separate widths.
+
+The \feat{FontFace} command also interacts properly with the \feat{SizeFeatures} command as follows: (nonsense set of font selection choices)
+\begin{Verbatim}
+ FontFace = {c}{n}{
+ Font = Times ,
+ SizeFeatures = {
+ { Size = -10 , Font = Georgia } ,
+ { Size = 10-15} , % default "Font = Times"
+ { Size = 15- , Font = Cochin } ,
+ },
+ },
+\end{Verbatim}
+Note that if the first \feat{Font} feature is omitted then each size needs its own inner \feat{Font} declaration.
+
+\subsubsection{An example for \cs{strong}}
+\label{sec:strong-example}
+
+If you wanted to set up a font family to allow nesting of the \cs{strong}
+to easily access increasing font weights, you might use a declaration along the following lines:
+\begin{Verbatim}
+\setmonofont{SourceCodePro}[
+ Extension = .otf ,
+ UprightFont = *-Light ,
+ BoldFont = *-Regular ,
+ FontFace = {k}{n}{*-Black} ,
+]
+\strongfontdeclare{\bfseries,\fontseries{k}\selectfont}
+\end{Verbatim}
+
+Further `syntactic sugar' is planned to make this process somewhat easier.
+
+
+\subsection{Math(s) fonts}
+
+When \cmd\setmainfont, \cmd\setsansfont\ and \cmd\setmonofont\ are used in the
+preamble, they also define the fonts to be used in maths mode inside the
+\cmd\mathrm-type commands. This only occurs in the preamble because \LaTeX\
+freezes the maths fonts after this stage of the processing. The \pkg{fontspec}
+package must also be loaded after any maths font packages (\eg, \pkg{euler})
+to be successful. (Actually, it is \emph{only} \pkg{euler} that is the
+problem.\note{Speaking of \pkg{euler}, if you want to use its
+\texttt{[mathbf]} option, it won't work, and you'll need to put this after
+\pkg{fontspec} is loaded instead:
+\ttfamily\cmd\AtBeginDocument\char`\{\cmd\DeclareMathAlphabet\cmd\mathbf\char`\{U\char`\}\char`\{eur\char`\}\char`\{b\char`\}\char`\{n\char`\}})
+
+Note that \pkg{fontspec} will not change the font for general mathematics;
+only the upright and bold shapes will be affected.
+To change the font used for the mathematical symbols, see either the
+\pkg{mathspec} package or the \pkg{unicode-math} package.
+
+Note that you may find that loading some maths packages won't be as smooth as
+you expect since \pkg{fontspec} (and \XeTeX\ in general) breaks many of the
+assumptions of \TeX\ as to where maths characters and accents can be found.
+Contact me if you have troubles, but I can't guarantee to be able to fix any
+incompatibilities. The Lucida and Euler maths fonts should be fine; for all
+others keep an eye out for problems.
+
+\cmdbox{
+ \cmd{\setmathrm}\marg{font name}\oarg{font features} \\
+ \cmd{\setmathsf}\marg{font name}\oarg{font features} \\
+ \cmd{\setmathtt}\marg{font name}\oarg{font features} \\
+ \cmd{\setboldmathrm}\marg{font name}\oarg{font features}
+}
+
+However, the default text fonts may not necessarily be the ones you
+wish to use when typesetting maths (especially with the use of fancy
+ligatures and so on). For this reason, you may optionally use the
+commands above (in the same way as our other
+\cmd\fontspec-like commands) to explicitly state which fonts to use
+inside such commands as \cmd\mathrm. Additionally, the
+\cmd\setboldmathrm\ command allows you define the font used for
+\cmd\mathrm\ when in bold maths mode (which is activated with, among
+others, \cmd\boldmath).
+
+For example, if you were using Optima with the Euler maths font, you
+might have this in your preamble:
+\begin{Verbatim}
+ \usepackage{mathpazo}
+ \usepackage{fontspec}
+ \setmainfont{Optima}
+ \setmathrm{Optima}
+ \setboldmathrm[BoldFont={Optima ExtraBlack}]{Optima Bold}
+\end{Verbatim}
+These commands are compatible with the \pkg{unicode-math} package.
+Having said that, \pkg{unicode-math} also defines a more general way of defining fonts to use in maths mode, so you can ignore this subsection if you're already using that package.
+
+
+\section{Miscellaneous font selecting details}
+
+\paragraph{The optional argument --- from v2.4}
+For the first decade of \pkg{fontspec}'s life, optional font features were selected with a bracketed argument before the font name, as in:
+\begin{Verbatim}
+ \setmainfont[
+ lots and lots ,
+ and more and more ,
+ an excessive number really ,
+ of font features could go here
+ ]{myfont.otf}
+\end{Verbatim}
+This always looked like ugly syntax to me, because the most important detail --- the name of the font --- was tucked away at the end.
+The order of these arguments has now been reversed:
+\begin{Verbatim}
+ \setmainfont{myfont.otf}[
+ lots and lots ,
+ and more and more ,
+ an excessive number really ,
+ of font features could go here
+ ]
+\end{Verbatim}
+I hope this doesn't cause any problems.
+\begin{enumerate}
+ \item Backwards compatibility has been preserved, so either input method works.
+ \item In fact, you can write
+ \begin{Verbatim}
+ \fontspec[Ligatures=Rare]{myfont.otf}[Color=red]
+ \end{Verbatim}
+ if you really felt like it and both sets of features would be applied.
+
+ \item
+ Following standard \pkg{xparse} behaviour, there must be no space before the opening bracket; writing
+ \begin{Verbatim*}
+\fontspec{myfont.otf} [Color=red]
+ \end{Verbatim*}
+ will result in |[Color=red]| not being recognised an argument and therefore it will be typeset as text. When breaking over lines, write either of:
+ \begin{Verbatim}
+ \fontspec{myfont.otf}% \fontspec{myfont.otf}[
+ [Color=red] Color=Red]
+ \end{Verbatim}
+
+\end{enumerate}
+
+\paragraph{Spaces}
+\cmd\fontspec\ and \cmd\addfontfeatures\ ignore trailing spaces as
+if it were a `naked' control sequence; \eg, `|M. \fontspec{...} N|' and
+`|M. \fontspec{...}N|' are the same.
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-intro.tex b/macros/latex/contrib/fontspec/fontspec-doc-intro.tex
new file mode 100644
index 0000000000..28b8a00338
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-intro.tex
@@ -0,0 +1,247 @@
+%%^^A%% fontspec-doc-intro.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{Getting started}
+
+\section{History}
+
+This package began life as a \LaTeX\ interface to select system-installed
+\MacOSX\ fonts in \name{Jonathan Kew}'s \XeTeX, the first widely-used
+Unicode extension to \TeX. Over time, \XeTeX\ was extended to support OpenType
+fonts and then was ported into a cross-platform program to run also on Windows
+and Linux.
+
+More recently, \LuaTeX\ is fast becoming the \TeX\ engine of the day; it
+supports Unicode encodings and OpenType fonts and opens up the internals of
+\TeX\ via the Lua programming language. Hans Hagen's Con\TeX t Mk.\,IV is a
+re-write of his powerful typesetting system, taking full advantage of
+\LuaTeX's features including font support; a kernel of his work in this area
+has been extracted to be useful for other \TeX\ macro systems as well, and
+this has enabled \pkg{fontspec} to be adapted for \LaTeX\ when run with the
+\LuaTeX\ engine.
+
+
+
+\section{Introduction}
+
+The \pkg{fontspec} package allows users of either \XeTeX\ or \LuaTeX\ to
+load OpenType fonts in a \LaTeX\ document. No font installation is necessary,
+and font features can be selected and used as desired throughout the document.
+
+Without \pkg{fontspec}, it is necessary to write cumbersome font definition
+files for \LaTeX, since \LaTeX's font selection scheme (known as the
+`\textsc{nfss}') has a lot going on behind the scenes to allow easy
+commands like \cmd\emph\ or \cmd\bfseries. With an uncountable number of
+fonts now available for use, however, it becomes less desirable to have to
+write these font definition (|.fd|) files for every font one wishes to use.
+
+Because \pkg{fontspec} is designed to work in a variety of modes, this
+user documentation is split into separate sections that are designed to be
+relatively independent. Nonetheless, the basic functionality all behaves in
+the same way, so previous users of \pkg{fontspec} under \XeTeX\ should have
+little or no difficulty switching over to \LuaTeX.
+
+This manual can get rather in-depth, as there are a lot of details
+to cover. See the documents \path{fontspec-example.tex} for a complete minimal example
+to get started quickly.
+
+
+\subsection{Acknowledgements}
+
+This package could not have been possible without the early and continued support
+the author of \XeTeX, Jonathan Kew. When I started this package, he steered
+me many times in the right direction.
+
+I've had great
+feedback over the years on feature requests, documentation queries, bug reports, font suggestions, and so on from lots of people all around the world.
+Many thanks to you all.
+
+Thanks to David Perry and Markus B\"ohning for numerous documentation
+improvements and David Perry again for contributing the text for one of the
+sections of this manual.
+
+Special thanks to Khaled Hosny, who was the driving force behind the support for \LuaLaTeX, ultimately leading to version 2.0 of the package.
+
+
+
+\section{Package loading and options}
+
+For basic use, no package options are required:
+\begin{Verbatim}
+ \usepackage{fontspec}
+\end{Verbatim}
+Package options will be introduced below; some preliminary details are discussed first.
+
+
+\subsection{Font encodings}
+The 2016 release of \pkg{fontspec} initiated some changes for font encodings and the loading of \pkg{xunicode}.
+The 2017 release rolls out those changes as default.
+
+The now-default \texttt{tuenc} package option switches the \textsc{nfss} font encoding to \texttt{TU}.
+\texttt{TU} is a new Unicode font encoding, intended for both \XeTeX\ and \LuaTeX\ engines, and automatically contains support for symbols covered by \LaTeX's traditional \texttt{T1} and \texttt{TS1} font encodings (for example, |\%|, |\textbullet|, |\"u|, and so on).
+As a result, with this package option, Ross Moore's \pkg{xunicode} package is \textbf{not} loaded.
+Some new, experimental, features are now provided to customise some encoding details; see Part~\vref{part:enc} for further details.
+
+Pre-2017 behaviour can be achieved with the \texttt{euenc} package option.
+This selects the \texttt{EU1} or \texttt{EU2} encoding (\XeTeX/\LuaTeX, resp.) and loads the \pkg{xunicode} package.
+Package authors and users who have referred explicitly to the encoding names \texttt{EU1} or \texttt{EU2} should update their code or documents.
+(See internal variable names described in \vref{sec:api} for how to do this properly.)
+
+
+\subsection{Maths fonts adjustments}
+By default, \pkg{fontspec} adjusts \LaTeX's default maths setup in order to maintain the correct Computer Modern symbols when the roman font changes.
+However, it will attempt to avoid doing this if another maths font package is loaded (such as \pkg{mathpazo} or the \pkg{unicode-math} package).
+
+If you find that \pkg{fontspec} is incorrectly changing the maths font when it shouldn't be, apply the |no-math| package option to manually suppress its behaviour here.
+
+
+\subsection{Configuration}
+\label{sec:config}
+
+If you wish to customise any part of the
+\pkg{fontspec} interface, this should be done by creating your own
+\texttt{fontspec.cfg} file,
+which will be automatically loaded if it is found by \XeTeX\ or \LuaTeX.
+A |fontspec.cfg| file is distributed with \pkg{fontspec} with a small number of defaults set up within it.
+
+To customise \pkg{fontspec} to your liking, use the standard |.cfg| file as a starting point or write your own from scratch, then either place it in the same folder as the main document for isolated cases, or in a location
+that \XeTeX\ or \LuaTeX\ searches by default; \eg\ in Mac\TeX: \path{~/Library/texmf/tex/latex/}.
+
+The package option |no-config| will suppress the loading of the |fontspec.cfg| file under all circumstances.
+
+
+\subsection{Warnings}
+\label{sec:quiet-warnings}
+
+This package can give some warnings that can be harmless if you know what
+you're doing. Use the |quiet| package option to write these warnings to the
+transcript (\texttt{.log}) file instead.
+
+Use the |silent| package option to completely suppress these warnings if you
+don't even want the |.log| file cluttered up.
+
+
+
+\section{Interaction with \LaTeXe\ and other packages}
+
+This section documents some areas of adjustment that \pkg{fontspec} makes
+to improve default behaviour with \LaTeXe\ and third-party packages.
+
+
+\subsection{Verbatim}
+\label{sec:verb}
+
+Many verbatim mechanisms assume the existence of a `visible space' character that exists in the \textsc{ascii} space slot of the typewriter font. This character is known in Unicode as \unichar{2423}{box open}, which looks like this: `\verb*| |'.
+
+When a Unicode typewriter font is used, \LaTeX\ no longer prints visible spaces for the |verbatim*| environment and |\verb*| command.
+This problem is fixed by using the correct Unicode glyph, and the following packages are patched to do the same:
+\pkg{listings}, \pkg{fancyvrb}, \pkg{moreverb}, and \pkg{verbatim}.
+
+In the case that the typewriter font does not contain `\verb*| |', the Latin Modern Mono font is used as a fallback.
+
+In 2019, \LaTeX\ will use a new command \cs{verbvisiblespace} for internal commands and for
+third party packages. If this new command is defined, \pkg{fontspec}'s patching code here
+will be entirely disabled and the packages listed above should no longer rely on \pkg{fontspec}
+to redefine their internals.
+
+
+\subsection{Commands for old-style and lining numbers}
+
+\DescribeMacro{\oldstylenums}
+\DescribeMacro{\liningnums}
+\LaTeX's definition of \cs{oldstylenums} relies on strange font encodings.
+We provide a \pkg{fontspec}-compatible alternative and while we're at it
+also throw in the reverse option as well. Use \cs{oldstylenums}\marg{text}
+to explicitly use old-style (or lowercase) numbers in \meta{text}, and
+the reverse for \cs{liningnums}\marg{text}.
+
+
+\subsection{Italic small caps}
+
+\DescribeMacro{\itshape}
+\DescribeMacro{\slshape}
+\DescribeMacro{\scshape}
+Note that this package redefines the \cs{itshape}, \cs{slshape}, and \cs{scshape} commands in order to allow them to select italic small caps in conjunction.
+With these changes, writing |\itshape\scshape| will lead to italic small caps, and |\upshape| subsequently then moves back to small caps only. |\upshape| again returns from small caps to upright regular.
+(And similarly for for |\slshape|. In addition, once italic small caps are selected then |\slshape| will switch to slanted small caps, and vice versa.)
+
+
+\subsection{Emphasis and nested emphasis}
+
+\DescribeMacro{\eminnershape}
+\LaTeXe\ allows you to specify the behaviour of \cs{emph} nested within \cs{emph} by setting the \cs{eminnershape} command.
+For example,
+\begin{Verbatim}
+ \renewcommand\eminnershape{\upshape\scshape}
+\end{Verbatim}
+will produce small caps within |\emph{\emph{...}}|.
+
+\DescribeMacro{\emfontdeclare}
+The \pkg{fontspec} package takes this idea one step further to allow arbitrary font shape changes and arbitrary levels of nesting within emphasis.
+This is performed using the |\emfontdeclare| command, which takes a comma-separated list of font switches corresponding to increasing levels of emphasis.
+An example:
+\begin{enumerate}
+\item |\emfontdeclare{\itshape,\upshape\scshape,\itshape}| will lead to `italics', `small caps', then `italic small caps' as the level of emphasis increases, as long as italic small caps are defined for the font.
+ Note that |\upshape| is required because the font changes are cascading.
+\end{enumerate}
+The implementation of this feature tries to be `smart' and guess what level of emphasis to use in the case of manual font changing.
+This is reliable only if you use shape-changing commands in \cs{emfontdeclare}.
+For example:
+\begin{Verbatim}
+ \emfontdeclare{\itshape,\upshape\scshape,\itshape}
+ ...
+ \scshape small caps \emph{hello}
+\end{Verbatim}
+Here, the emphasised text `hello' will be printed in italic small caps since |\emph| can detect that the current font shape is already in the second `mode' of emphasis.
+
+\DescribeMacro{\emreset}
+Finally, if you have so much nested emphasis that |\emfontdeclare| runs out of options, it will insert |\emreset| (by default just |\upshape|) and start again from the beginning.
+
+
+\subsection{Strong emphasis}
+
+\DescribeMacro{\strong}
+\DescribeMacro{\strongenv}
+The \cs{strong} macro is used analogously to \cs{emph} but produces variations in weight.
+If you need it in environment form, use |\begin{strongenv}...\end{strongenv}|.
+
+As with emphasis, this font-switching command is intended to move through a range
+of font weights. For example, if the fonts are set up correctly it allows usage such as
+|\strong{...\strong{...}}| in which each nested \cs{strong} macro increases the
+weight of the font.
+
+\DescribeMacro{\strongfontdeclare}
+Currently this feature set is somewhat experimental and there is no syntactic sugar
+to easily define a range of font weights using \pkg{fontspec} commands.
+Use, say, the following to define first bold and then black (|k|) font faces for \cs{strong}:
+\begin{Verbatim}
+ \strongfontdeclare{\bfseries,\fontseries{k}\selectfont}
+\end{Verbatim}
+
+\DescribeMacro{\strongreset}
+If too many levels of \cs{strong} are reached, \cs{strongreset} is inserted.
+By default this is a no-op and the font will simply remain the same.
+Use \cs{renewcommand}\cs{strongreset}|{\mdseries}| to start again from the beginning if desired.
+
+An example for setting up a font family for use with \cs{strong} is discussed in \vref{sec:strong-example}.
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-luatex.tex b/macros/latex/contrib/fontspec/fontspec-doc-luatex.tex
new file mode 100644
index 0000000000..e6f752d6e9
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-luatex.tex
@@ -0,0 +1,94 @@
+%%^^A%% fontspec-doc-luatex.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{\LuaTeX-only font features}
+\label{sec:luatex-features}
+
+\section{Different font technologies and shapers}
+\label{sec:renderer-luatex}
+
+\LuaTeX\ does not directly support any font rendering technologies out of the box, it
+requires additional functionality to be added to properly support and control technologies such as OpenType.
+
+Using the \feat{Renderer} feature, there are a number of options that \pkg{fontspec} can pass to the engine to control which font technology is being used.
+Pre-2019, there were two options provided by \pkg{luaotfload} that generally did not require user intervention.
+
+\begin{itemize}
+\item \feat{Renderer} = \opt{Node} : the default `mode' for typesetting OpenType fonts.
+\item \feat{Renderer} = \opt{Base} : a simplified mode useful only in a limited number of situations such as mathematics typesetting.
+\end{itemize}
+
+From 2019 the possibility of using the Harfbuzz text shaping engine within \LuaTeX\ has
+been developed by Khaled Hosny. When running a suitable \LuaTeX\ engine with Harfbuzz support, \pkg{fontspec} provides the following options:
+
+\begin{itemize}
+\item \feat{Renderer} = \opt{Harfbuzz} : use the Harfbuzz engine without an explicit `shaper'.
+\item \feat{Renderer} = \opt{OpenType} : use the Harfbuzz engine with the OpenType shaper.
+\item \feat{Renderer} = \opt{AAT} : use the Harfbuzz engine with the AAT shaper.
+\item \feat{Renderer} = \opt{Graphite} : use the Harfbuzz engine with the Graphite shaper.
+\item \feat{Renderer} = \meta{foo} : use the Harfbuzz engine with the \meta{foo} shaper.
+\end{itemize}
+
+Support for the Harfbuzz renderer is preliminary and may be improved over time.
+Please treat the interface for Harfbuzz fonts as subject to change.
+
+
+\section{Custom font features}
+
+\LuaTeX, via the \pkg{luaotfload} package, allows the definition and re-definition of custom OpenType features for a selected font. This facility is particularly useful to implement custom substitutions or to disable unwanted but not all ligatures.
+
+Figure~\ref{fig:featurefile} shows an minimal example of this type of functionality.
+This example creates a new OpenType feature, \texttt{oneb}, which substitutes the glyph
+when typesetting `\texttt{1}' for the named glyph \texttt{one.ss01}. The glyph names
+are font specific and can be interrogated with third-party software such as \emph{FontForge}.
+
+A third-party collection of additional examples are maintained in the repository `\texttt{fonts-in-luatex}'\footnote{\url{https://github.com/mewtant/fonts-in-luatex}}.
+These examples are intended to correct or adjust font features in a range of commercial fonts and provide a good introduction to some of the possibilities that \LuaTeX\ affords.
+
+Please refer to the \LuaTeX/\pkg{luaotfload} documentation for more details.
+
+\begin{figure}
+\caption{An example of custom font features.}
+\label{fig:featurefile}
+\hrule
+\begin{Verbatim}
+\documentclass{article}
+\usepackage{fontspec}
+\directlua{
+ fonts.handlers.otf.addfeature {
+ name = "oneb",
+ type = "substitution",
+ data = {
+ ["1"] = "one.ss01",
+ }
+ }
+}
+\setmainfont{Vollkorn-Regular.otf}[RawFeature=+oneb]
+\begin{document}
+1234567890
+\end{document}
+\end{Verbatim}
+\hrule
+\end{figure}
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
+
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-opentype.tex b/macros/latex/contrib/fontspec/fontspec-doc-opentype.tex
new file mode 100644
index 0000000000..9e16c370ee
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-opentype.tex
@@ -0,0 +1,1476 @@
+%%^^A%% fontspec-doc-opentype.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{OpenType}
+\label{sec:opentype-features}
+
+\section{Introduction}
+\label{sec:opentype-features-intro}
+
+OpenType fonts (and other `smart' font technologies such as AAT and Graphite) can change the appearance of text in many different ways.
+These changes are referred to as font features.
+When the user applies a feature~--- for example, small capitals~--- to a run of text, the code inside the font makes appropriate substitutions and small capitals appear in place of lowercase letters.
+However, the use of such features does not affect the underlying text.
+In our small caps example, the lowercase letters are still stored in the document; only the appearance has been changed by the OpenType feature.
+This makes it possible to search and copy text without difficulty.
+If the user selected a different font that does not support small caps, the `plain' lowercase letters would appear instead.
+
+Some OpenType features are required to support particular scripts, and these features are often applied automatically.
+The Indic scripts, for example, often require that characters be reshaped and reordered after they are typed by the user, in order to display them in the traditional ways that readers expect.
+Other features can be applied to support a particular language.
+The Junicode font for medievalists uses by default the Old English shape of the letter thorn, while in modern Icelandic thorn has a more rounded shape.
+If a user tags some text as being in Icelandic, Junicode will automatically change to the Icelandic shape through an OpenType feature that localises the shapes of letters.
+
+There are a large group of OpenType features, designed to support high quality typography a multitude of languages and writing scripts.
+Examples of some font features have already been shown in previous sections; the complete set of OpenType font features supported by \pkg{fontspec} is described below in \ref{sec:ot-feat}.
+
+The OpenType specification provides four-letter codes (e.g., \texttt{smcp} for small capitals) for each feature. The four-letter codes are given below along with the \pkg{fontspec} names for various features, for the benefit of people who are already familiar with OpenType. You can ignore the codes if they don't mean anything to you.
+
+
+\subsection{How to select font features}
+
+Font features are selected by a series of \meta{feature}=\meta{option}
+selections. Features are (usually) grouped logically; for example, all
+font features relating to ligatures are accessed by writing \verb|Ligatures={...}| with the appropriate argument(s), which could be \texttt{TeX}, \texttt{Rare}, etc., as shown below in \ref{sec:ot-feat-liga}.
+
+Multiple options may be given to
+any feature that accepts non-numerical input, although doing so will
+not always work. Some options will override others in generally
+obvious ways; \Verb|Numbers={OldStyle,Lining}| doesn't make much
+sense because the two options are mutually exclusive, and \XeTeX\
+will simply use the last option that is specified (in this case
+using \opt{Lining} over \opt{OldStyle}).
+
+If a feature or an option is requested that the font does not have,
+a warning is given in the console output. As mentioned in \vref{sec:quiet-warnings}
+these warnings can be suppressed by selecting the \texttt{[quiet]} package option.
+
+\subsection{How do I know what font features are supported by my fonts?}
+
+Although I've long desired to have a feature within \pkg{fontspec} to display the OpenType features within a font, it's never been high on my priority list.
+One reason for that is the existence of the document |opentype-info.tex|, which is available on \textsc{ctan} or typing |kpsewhich opentype-info.tex| in a Terminal window.
+Make a copy of this file and place it somewhere convenient.
+Then open it in your regular \TeX\ editor and change the font name to the font you'd like to query; after running through plain \XeTeX, the output \textsc{pdf} will look something like this:
+
+\begin{framed}
+
+%%% From OpenType-info.tex %%%
+\DeleteShortVerb\"
+\def\myfontname{[Asana-Math.otf]}
+\font\testfont="\myfontname/OT" at 10pt\relax
+
+\rightskip=0pt plus 1fil
+
+\font\titlefont=ec-lmssbx10 at 12pt
+\font\tenrm=ec-lmss10 at 9pt \tenrm
+\font\tentt=ec-lmtt10 at 9pt
+
+\def\fourcharcode#1{\begingroup
+ \count0=#1\count1=\count0
+ \ifnum\count0=0
+ $\langle$default$\rangle$%
+ \else
+ \tentt
+ '%
+ \divide\count0 by "1000000
+ \char\count0
+ \multiply\count0 by "1000000
+ \advance\count1 by -\count0
+ \count0=\count1
+ \divide\count0 by "10000
+ \char\count0
+ \multiply\count0 by "10000
+ \advance\count1 by -\count0
+ \count0=\count1
+ \divide\count0 by "100
+ \char\count0
+ \multiply\count0 by "100
+ \advance\count1 by -\count0
+ \ifnum\count1=32 \ \else \char\count1 \fi
+ '%
+ \fi
+ \endgroup
+}
+
+\newcount\scriptcount
+\newcount\scriptindex
+\newcount\scripttag
+\newcount\langcount
+\newcount\langindex
+\newcount\langtag
+\newcount\featurecount
+\newcount\featureindex
+\newcount\featuretag
+
+\leftline{\titlefont OpenType Layout features found in `\myfontname'}
+\nobreak
+
+\scriptcount=\XeTeXOTcountscripts\testfont
+\ifnum\scriptcount=0 \noindent None\par\fi
+
+\loop
+ \ifnum\scriptindex<\scriptcount
+ \smallskip
+ \scripttag=\XeTeXOTscripttag\testfont\scriptindex
+ \noindent script = \fourcharcode{\scripttag}\endgraf\nobreak
+ \langcount=\XeTeXOTcountlanguages\testfont\scripttag
+ \advance\langcount by 1 % one extra to get the default language system
+ {\loop
+ \langtag=\XeTeXOTlanguagetag\testfont\scripttag\langindex
+ \indent language = \fourcharcode{\langtag}\endgraf\nobreak
+ \featurecount=\XeTeXOTcountfeatures\testfont\scripttag\langtag
+ {\indent\indent \hangindent=3\parindent \hangafter=1 features = \loop
+ \featuretag=\XeTeXOTfeaturetag\testfont\scripttag\langtag\featureindex
+ \fourcharcode{\featuretag}
+ \advance\featureindex by 1
+ \ifnum\featureindex<\featurecount \repeat\endgraf}
+ \advance\langindex by 1
+ \ifnum\langindex<\langcount \medskip \repeat}
+ \advance\scriptindex by 1
+\repeat
+\end{framed}
+
+\noindent I intentionally picked a font above that by design contains few font features; `regular' text fonts such as Latin Modern Roman contain many more, and I didn't want to clutter up the document too much.
+After finding the scripts, languages, and features contained within the font, you'll then need to cross-check the OpenType tags with the `logical' names used by \pkg{fontspec}.
+
+\paragraph{otfinfo}
+Alternatively, and more simply, you can use the command line tool |otfinfo|, which is distributed with \TeX{}Live.
+Simply type in a Terminal window, say:
+\begin{Verbatim}
+ otfinfo -f `kpsewhich lmromandunh10-oblique.otf`
+\end{Verbatim}
+which results in:
+\begin{Verbatim}[frame=single]
+aalt Access All Alternates
+cpsp Capital Spacing
+dlig Discretionary Ligatures
+frac Fractions
+kern Kerning
+liga Standard Ligatures
+lnum Lining Figures
+onum Oldstyle Figures
+pnum Proportional Figures
+size Optical Size
+tnum Tabular Figures
+zero Slashed Zero
+\end{Verbatim}
+
+
+\section{OpenType scripts and languages}\label{sec:ot}
+
+Fonts that include glyphs for various scripts and languages may contain different font features for the different character sets and languages they support, and different font features may behave differently depending on the script or language chosen.
+When multilingual fonts are used, it is important to select which language
+they are being used for, and more importantly what script is being used.
+
+The `script' refers to the alphabet in use; for example, both English
+and French use the Latin script. Similarly, the Arabic script can be used
+to write in both the Arabic and Persian languages.
+
+The
+\feat{Script} and \feat{Language} features are used to designate this information. The possible options are
+tabulated in \vref{tab:ot-scpt} and \vref{tab:ot-lang},
+respectively. When a script or language is requested that is not
+supported by the current font, a warning is printed in the console output.
+See \vref{sec:newscriptlang} for methods to create new \feat{Script} or \feat{Language}
+options if required.
+
+Because these font features can
+change which features are able to be selected for the font, the \feat{Script} and \feat{Language}
+settings are automatically selected
+by \pkg{fontspec} before all others, and, if \XeTeX\ is being used, will
+specifically select the \opt{OpenType}
+renderer for this font, as described in \vref{sec:renderer-xetex}.
+
+OpenType fonts can make available different font features depending on the Script and
+Language chosen.
+In addition, these settings can also set up their own font behaviour
+and glyph selection (one example is differences in style between some of the letters in the
+alphabet used for Bulgarian, Serbian, and Russian).
+The \pkg{fontspec} feature \feat{LocalForms} \texttt{=} \opt{Off} will disable some of
+these substitutions if desired for some reason.
+It is important to note that \feat{LocalForms} \texttt{=} \opt{On} is a default not of \pkg{fontspec}
+but of the underlying font shaping engines in both \XeTeX\ and \LuaTeX/\pkg{otfload}.
+
+
+\subsection{\feat{Script} and \feat{Language} examples}
+
+In the examples shown in \exref{script-lang},
+the Code2000 font\note{\url{http://www.code2000.net/}}
+is used to typeset various input texts with and without the OpenType Script
+applied for various alphabets.
+The text is only rendered correctly in the second case;
+many examples of incorrect diacritic spacing as
+well as a lack of contextual ligatures and rearrangement can be
+seen.
+Thanks to \name{Jonathan Kew}, \name{Yves Codet} and
+\name{Gildas Hamel} for their contributions towards these examples.
+
+\begin{Xexample}[firstline=14,lastline=23]{script-lang}{An example of various Scripts and Languages.}
+\def\testfeature#1#2{%^^A
+ \fontspec{\examplefont}#2 & \fontspec[#1]{\examplefont}#2\\[1ex]}
+\def \examplefont{CODE2000.TTF}
+\def \arabictext{العربي}
+\def \devanagaritext{हिन्दी}
+\def \bengalitext{লেখ}
+\def \gujaratitext{મર્યાદા-સૂચક નિવેદન}
+\def \malayalamtext{നമ്മുടെ പാരബര്യ}
+\def \gurmukhitext{ਆਦਿ ਸਚੁ ਜੁਗਾਦਿ ਸਚੁ}
+\def \tamiltext{தமிழ் தேடி}
+\def \hebrewtext{רִדְתָּֽהּ}
+\def \vietnamesetext{cấp số mỗi}
+\begin{tabular}{r@{\quad}l}
+ \testfeature{Script=Arabic}{\arabictext}
+ \testfeature{Script=Devanagari}{\devanagaritext}
+ \testfeature{Script=Bengali}{\bengalitext}
+ \testfeature{Script=Gujarati}{\gujaratitext}
+ \testfeature{Script=Malayalam}{\malayalamtext}
+ \testfeature{Script=Gurmukhi}{\gurmukhitext}
+ \testfeature{Script=Tamil}{\tamiltext}
+ \testfeature{Script=Hebrew}{\hebrewtext}
+ \def\examplefont{DoulosSILR.ttf}
+ \testfeature{Language=Vietnamese}{\vietnamesetext}
+\end{tabular}
+\end{Xexample}
+
+
+
+\begin{table}[!hbp]
+ \caption{Defined \opt{Script}s for OpenType fonts. Aliased names are shown in adjacent positions marked with red pilcrows ({\sffamily\textcolor{red}{\P}}).}
+ \label{tab:ot-scpt}
+\def\dup{\makebox[0pt][r]{\textcolor{red}{\P}}}
+\setlength\columnseprule{0pt}
+ \hrule
+ \begin{multicols}{4}\setlength\parindent{0pt}
+ \sffamily\scriptsize
+ Adlam \par
+ Ahom \par
+ Anatolian Hieroglyphs \par
+ Arabic \par
+ Armenian \par
+ Avestan \par
+ Balinese \par
+ Bamum \par
+ Bassa Vah \par
+ Batak \par
+ Bengali \par
+ Bhaiksuki \par
+ Bopomofo \par
+ Brahmi \par
+ Braille \par
+ Buginese \par
+ Buhid \par
+ Byzantine Music \par
+ Canadian Syllabics \par
+ Carian \par
+ Caucasian Albanian \par
+ Chakma \par
+ Cham \par
+ Cherokee \par
+ \dup CJK \par
+ \dup CJK Ideographic \par
+ Coptic \par
+ Cypriot Syllabary \par
+ Cyrillic \par
+ Default \par
+ Deseret \par
+ Devanagari \par
+ Duployan \par
+ Egyptian Hieroglyphs \par
+ Elbasan \par
+ Ethiopic \par
+ Georgian \par
+ Glagolitic \par
+ Gothic \par
+ Grantha \par
+ Greek \par
+ Gujarati \par
+ Gurmukhi \par
+ Hangul Jamo \par
+ Hangul \par
+ Hanunoo \par
+ Hatran \par
+ Hebrew \par
+ \dup Hiragana and Katakana \par
+ \dup Kana \par
+ Imperial Aramaic \par
+ Inscriptional Pahlavi \par
+ Inscriptional Parthian \par
+ Javanese \par
+ Kaithi \par
+ Kannada \par
+ Kayah Li \par
+ Kharosthi \par
+ Khmer \par
+ Khojki \par
+ Khudawadi \par
+ Lao \par
+ Latin \par
+ Lepcha \par
+ Limbu \par
+ Linear A \par
+ Linear B \par
+ Lisu \par
+ Lycian \par
+ Lydian \par
+ Mahajani \par
+ Malayalam \par
+ Mandaic \par
+ Manichaean \par
+ Marchen \par
+ \dup Math \par
+ \dup Maths \par
+ Meitei Mayek \par
+ Mende Kikakui \par
+ Meroitic Cursive \par
+ Meroitic Hieroglyphs \par
+ Miao \par
+ Modi \par
+ Mongolian \par
+ Mro \par
+ Multani \par
+ Musical Symbols \par
+ Myanmar \par
+ \dup N'Ko \par
+ \dup N'ko \par
+ Nabataean \par
+ Newa \par
+ Ogham \par
+ Ol Chiki \par
+ Old Italic \par
+ Old Hungarian \par
+ Old North Arabian \par
+ Old Permic \par
+ Old Persian Cuneiform \par
+ Old South Arabian \par
+ Old Turkic \par
+ \dup Oriya \par
+ \dup Odia \par
+ Osage \par
+ Osmanya \par
+ Pahawh Hmong \par
+ Palmyrene \par
+ Pau Cin Hau \par
+ Phags-pa \par
+ Phoenician \par
+ Psalter Pahlavi \par
+ Rejang \par
+ Runic \par
+ Samaritan \par
+ Saurashtra \par
+ Sharada \par
+ Shavian \par
+ Siddham \par
+ Sign Writing \par
+ Sinhala \par
+ Sora Sompeng \par
+ Sumero-Akkadian Cuneiform \par
+ Sundanese \par
+ Syloti Nagri \par
+ Syriac \par
+ Tagalog \par
+ Tagbanwa \par
+ Tai Le \par
+ Tai Lu \par
+ Tai Tham \par
+ Tai Viet \par
+ Takri \par
+ Tamil \par
+ Tangut \par
+ Telugu \par
+ Thaana \par
+ Thai \par
+ Tibetan \par
+ Tifinagh \par
+ Tirhuta \par
+ Ugaritic Cuneiform \par
+ Vai \par
+ Warang Citi \par
+ Yi
+ \end{multicols}
+ \hrule
+\end{table}
+
+\begin{table}[p]
+ \vspace*{-3cm}
+ \hspace{-3cm}
+ \def\dup{\makebox[0pt][r]{\textcolor{red}{\P}}}
+ \begin{minipage}{\linewidth+4cm}
+ \caption{Defined \opt{Language}s for OpenType fonts. Aliased names are shown in adjacent positions marked with red pilcrows ({\sffamily\textcolor{red}{\P}}).}
+ \label{tab:ot-lang}
+ \setlength\columnseprule{0pt}
+ \hrule
+ \begin{multicols}{6}
+ \everypar{\setlength\parindent{0pt}\setlength\hangindent{2em}}
+ \sffamily\footnotesize\raggedright
+ Abaza \par
+ Abkhazian \par
+ Adyghe \par
+ Afrikaans \par
+ Afar \par
+ Agaw \par
+ Altai \par
+ Amharic \par
+ Arabic \par
+ Aari \par
+ Arakanese \par
+ Assamese \par
+ Athapaskan \par
+ Avar \par
+ Awadhi \par
+ Aymara \par
+ Azeri \par
+ Badaga \par
+ Baghelkhandi \par
+ Balkar \par
+ Baule \par
+ Berber \par
+ Bench \par
+ Bible Cree \par
+ Belarussian \par
+ Bemba \par
+ Bengali \par
+ Bulgarian \par
+ Bhili \par
+ Bhojpuri \par
+ Bikol \par
+ Bilen \par
+ Blackfoot \par
+ Balochi \par
+ Balante \par
+ Balti \par
+ Bambara \par
+ Bamileke \par
+ Breton \par
+ Brahui \par
+ Braj Bhasha \par
+ Burmese \par
+ Bashkir \par
+ Beti \par
+ Catalan \par
+ Cebuano \par
+ Chechen \par
+ Chaha Gurage \par
+ Chattisgarhi \par
+ Chichewa \par
+ Chukchi \par
+ Chipewyan \par
+ Cherokee \par
+ Chuvash \par
+ Comorian \par
+ Coptic \par
+ Cree \par
+ Carrier \par
+ Crimean Tatar \par
+ Church Slavonic \par
+ Czech \par
+ Danish \par
+ Dargwa \par
+ Woods Cree \par
+ German \par
+ Default \par
+ Dogri \par
+ Divehi \par
+ Djerma \par
+ Dangme \par
+ Dinka \par
+ Dungan \par
+ Dzongkha \par
+ Ebira \par
+ Eastern Cree \par
+ Edo \par
+ Efik \par
+ Greek \par
+ English \par
+ Erzya \par
+ Spanish \par
+ Estonian \par
+ Basque \par
+ Evenki \par
+ Even \par
+ Ewe \par
+ French Antillean \par
+ \dup Farsi \par
+ \dup Parsi \par
+ \dup Persian \par
+ Finnish \par
+ Fijian \par
+ Flemish \par
+ Forest Nenets \par
+ Fon \par
+ Faroese \par
+ French \par
+ Frisian \par
+ Friulian \par
+ Futa \par
+ Fulani \par
+ Ga \par
+ Gaelic \par
+ Gagauz \par
+ Galician \par
+ Garshuni \par
+ Garhwali \par
+ Ge'ez \par
+ Gilyak \par
+ Gumuz \par
+ Gondi \par
+ Greenlandic \par
+ Garo \par
+ Guarani \par
+ Gujarati \par
+ Haitian \par
+ Halam \par
+ Harauti \par
+ Hausa \par
+ Hawaiin \par
+ Hammer-Banna \par
+ Hiligaynon \par
+ Hindi \par
+ High Mari \par
+ Hindko \par
+ Ho \par
+ Harari \par
+ Croatian \par
+ Hungarian \par
+ Armenian \par
+ Igbo \par
+ Ijo \par
+ Ilokano \par
+ Indonesian \par
+ Ingush \par
+ Inuktitut \par
+ Irish \par
+ Irish Traditional \par
+ Icelandic \par
+ Inari Sami \par
+ Italian \par
+ Hebrew \par
+ Javanese \par
+ Yiddish \par
+ Japanese \par
+ Judezmo \par
+ Jula \par
+ Kabardian \par
+ Kachchi \par
+ Kalenjin \par
+ Kannada \par
+ Karachay \par
+ Georgian \par
+ Kazakh \par
+ Kebena \par
+ Khutsuri Georgian \par
+ Khakass \par
+ Khanty-Kazim \par
+ Khmer \par
+ Khanty-Shurishkar \par
+ Khanty-Vakhi \par
+ Khowar \par
+ Kikuyu \par
+ Kirghiz \par
+ Kisii \par
+ Kokni \par
+ Kalmyk \par
+ Kamba \par
+ Kumaoni \par
+ Komo \par
+ Komso \par
+ Kanuri \par
+ Kodagu \par
+ Korean Old Hangul \par
+ Konkani \par
+ Kikongo \par
+ Komi-Permyak \par
+ Korean \par
+ Komi-Zyrian \par
+ Kpelle \par
+ Krio \par
+ Karakalpak \par
+ Karelian \par
+ Karaim \par
+ Karen \par
+ Koorete \par
+ Kashmiri \par
+ Khasi \par
+ Kildin Sami \par
+ Kui \par
+ Kulvi \par
+ Kumyk \par
+ Kurdish \par
+ Kurukh \par
+ Kuy \par
+ Koryak \par
+ Ladin \par
+ Lahuli \par
+ Lak \par
+ Lambani \par
+ Lao \par
+ Latin \par
+ Laz \par
+ L-Cree \par
+ Ladakhi \par
+ Lezgi \par
+ Lingala \par
+ Low Mari \par
+ Limbu \par
+ Lomwe \par
+ Lower Sorbian \par
+ Lule Sami \par
+ Lithuanian \par
+ Luba \par
+ Luganda \par
+ Luhya \par
+ Luo \par
+ Latvian \par
+ Majang \par
+ Makua \par
+ Malayalam Traditional \par
+ Mansi \par
+ Marathi \par
+ Marwari \par
+ Mbundu \par
+ Manchu \par
+ Moose Cree \par
+ Mende \par
+ Me'en \par
+ Mizo \par
+ Macedonian \par
+ Male \par
+ Malagasy \par
+ Malinke \par
+ Malayalam Reformed \par
+ Malay \par
+ Mandinka \par
+ Mongolian \par
+ Manipuri \par
+ Maninka \par
+ Manx Gaelic \par
+ Moksha \par
+ Moldavian \par
+ Mon \par
+ Moroccan \par
+ Maori \par
+ Maithili \par
+ Maltese \par
+ Mundari \par
+ Naga-Assamese \par
+ Nanai \par
+ Naskapi \par
+ N-Cree \par
+ Ndebele \par
+ Ndonga \par
+ Nepali \par
+ Newari \par
+ Nagari \par
+ Norway House Cree \par
+ Nisi \par
+ Niuean \par
+ Nkole \par
+ N'ko \par
+ Dutch \par
+ Nogai \par
+ Norwegian \par
+ Northern Sami \par
+ Northern Tai \par
+ Esperanto \par
+ Nynorsk \par
+ Oji-Cree \par
+ Ojibway \par
+ Oriya \par
+ Oromo \par
+ Ossetian \par
+ Palestinian Aramaic \par
+ Pali \par
+ Punjabi \par
+ Palpa \par
+ Pashto \par
+ Polytonic Greek \par
+ Pilipino \par
+ Palaung \par
+ Polish \par
+ Provencal \par
+ Portuguese \par
+ Chin \par
+ Rajasthani \par
+ R-Cree \par
+ Russian Buriat \par
+ Riang \par
+ Rhaeto-Romanic \par
+ Romanian \par
+ Romany \par
+ Rusyn \par
+ Ruanda \par
+ Russian \par
+ Sadri \par
+ Sanskrit \par
+ Santali \par
+ Sayisi \par
+ Sekota \par
+ Selkup \par
+ Sango \par
+ Shan \par
+ Sibe \par
+ Sidamo \par
+ Silte Gurage \par
+ Skolt Sami \par
+ Slovak \par
+ Slavey \par
+ Slovenian \par
+ Somali \par
+ Samoan \par
+ Sena \par
+ Sindhi \par
+ Sinhalese \par
+ Soninke \par
+ Sodo Gurage \par
+ Sotho \par
+ Albanian \par
+ Serbian \par
+ Saraiki \par
+ Serer \par
+ South Slavey \par
+ Southern Sami \par
+ Suri \par
+ Svan \par
+ Swedish \par
+ Swadaya Aramaic \par
+ Swahili \par
+ Swazi \par
+ Sutu \par
+ Syriac \par
+ Tabasaran \par
+ Tajiki \par
+ Tamil \par
+ Tatar \par
+ TH-Cree \par
+ Telugu \par
+ Tongan \par
+ Tigre \par
+ Tigrinya \par
+ Thai \par
+ Tahitian \par
+ Tibetan \par
+ Turkmen \par
+ Temne \par
+ Tswana \par
+ Tundra Nenets \par
+ Tonga \par
+ Todo \par
+ Turkish \par
+ Tsonga \par
+ Turoyo Aramaic \par
+ Tulu \par
+ Tuvin \par
+ Twi \par
+ Udmurt \par
+ Ukrainian \par
+ Urdu \par
+ Upper Sorbian \par
+ Uyghur \par
+ Uzbek \par
+ Venda \par
+ Vietnamese \par
+ Wa \par
+ Wagdi \par
+ West-Cree \par
+ Welsh \par
+ Wolof \par
+ Tai Lue \par
+ Xhosa \par
+ Yakut \par
+ Yoruba \par
+ Y-Cree \par
+ Yi Classic \par
+ Yi Modern \par
+ Chinese Hong Kong \par
+ Chinese Phonetic \par
+ Chinese Simplified \par
+ Chinese Traditional \par
+ Zande \par
+ Zulu
+ \end{multicols}
+ \hspace{4pt}
+ \hrule
+ \end{minipage}
+\end{table}
+
+
+\section{OpenType font features}
+\label{sec:ot-feat}
+
+There are a finite set of OpenType font features, and \pkg{fontspec} provides an
+interface to around half of them.
+Full documentation will be presented in the following sections, including how to
+enable and disable individual features, and how they interact.
+
+A brief reference is provided (\vref*{tab:all-ot}) but note that this is an incomplete
+listing --- only the `enable' keys are shown, and where alternative interfaces are
+provided for convenience only the first is shown.
+(E.g., |Numbers=OldStyle| is the same as |Numbers=Lowercase|.)
+
+For completeness, the complete list of OpenType features \emph{not} provided with
+a \pkg{fontspec} interface is shown in \vref{tab:none-ot}.
+Features omitted are partially by design and partially by oversight;
+for example, the |aalt| feature is largely useless in \TeX\ since it is designed
+for providing a textsc{gui} interface for selecting `all alternates' of a glyph.
+Others, such as optical bounds for example, simply haven't yet been considered
+due to a lack of fonts available for testing.
+Suggestions welcome for how/where to add these missing features to the package.
+
+\ExplSyntaxOn
+\def\allOTfeat{
+ \prop_map_inline:Nn \g__fontspec_all_opentype_feature_names_prop
+ { \opentypefeature{##1}{##2} }
+}
+\newcommand\opentypefeature[2]{
+ \prop_get:NnNT \g__fontspec_OT_features_prop {#1} \tmpa
+ {
+ \raggedright
+ \hangindent=5.2cm
+ \makebox[1cm][l]{\textsc{#1}}
+ \makebox[4.2cm][l]{
+ \int_compare:nT { \tl_count:N \tmpa > 25 } {\ttcondensed} {\ttfamily}
+ \tmpa
+ }
+ \textit{#2}
+ \par
+ \vspace{2pt}
+ }
+}
+\ExplSyntaxOff
+
+\begin{table}
+\caption{Summary of OpenType features in \textsf{fontspec}, alphabetic by feature tag.}
+\label{tab:all-ot}
+\centerline{%
+\begin{minipage}{18cm}
+\small
+\hrule\smallskip
+\begin{multicols}{2}
+\parindent =0pt
+\allOTfeat
+\end{multicols}
+\vspace*{-\smallskipamount}
+\hrule
+\end{minipage}}
+\end{table}
+
+\ExplSyntaxOn
+\renewcommand\opentypefeature[2]{
+ \prop_get:NnNF \g__fontspec_OT_features_prop {#1} \tmpa
+ {
+ \raggedright
+ \hangindent=0.9cm
+ \makebox[0.9cm][l]{\textsc{#1}}%
+ \textit{#2}
+ \par
+ }
+}
+\ExplSyntaxOff
+
+\begin{table}
+\caption{List of \emph{unsupported} OpenType features.}
+\label{tab:none-ot}
+\bigskip
+\centerline{%
+\begin{minipage}{15cm}
+\hrule\smallskip
+\begin{multicols}{3}
+\parindent =0pt
+\allOTfeat
+\end{multicols}
+\vspace*{-\smallskipamount}
+\hrule
+\end{minipage}}
+\end{table}
+
+\subsection{Tag-based features}
+
+
+\subsubsection{Alternates --- \texttt{salt}}
+
+The \feat{Alternate} feature, alias \feat{StylisticAlternates}, is used to access alternate font glyphs when variations exist in the font, such as in \exref{salt}.
+It uses a numerical selection, starting from zero, that will be different for each font.
+Note that the \texttt{Style=Alternate} option is equivalent
+to \texttt{Alternate=0} to access the default case.
+
+\begin{Xexample}[firstline=2]{salt}{The \feat{Alternate} feature.}
+ \huge
+ \fontspec{LinLibertine_R.otf}
+ \textsc{a} \& h \\
+ \addfontfeature{Alternate=0}
+ \textsc{a} \& h
+\end{Xexample}
+
+Note that the indexing starts from zero.
+With the \LuaTeX\ engine, |Alternate=Random| selects a random alternate.
+
+See \vref{sec:newfeatures} for a way to assign names to alternates if desired.
+
+
+\subsubsection{Character Variants --- \texttt{cvNN}}
+
+`Character Variations' are selected
+numerically to adjust the output of (usually) a single character for the
+particular font. These correspond to the OpenType features |cv01| to |cv99|.
+
+For each character that can be varied, it is possible to select among
+possible options for that particular glyph.
+For example, in the example below, variants are chosen for glyphs `4' and `5',
+and the trailing |:|\meta{n} corresponds to which variety to choose.
+\begin{Verbatim}
+ \fontspec{EB Garamond 12 Italic}[CharacterVariant={4,5:2}] \& violet
+\end{Verbatim}
+The numbering is entirely font-soecific. Glyph `5' might be the character `v', for example.
+Character variants are specifically designed not to conflict with each
+other, so you can enable them individually per character.
+(Unlike stylistic alternates, say.)
+Note that the indexing starts from zero.
+
+
+\subsubsection{Contextuals}
+This feature refers to substitutions of glyphs that vary `contextually' by their relative position in a word or string of characters;
+features such as contextual swashes are accessed via the options shown in \ref{feat:Contextuals}.
+
+\begin{features}{Contextuals}
+\otf*{Swash}{cswh}
+\otf*{Alternate}{calt}
+\otf*{WordInitial}{init}
+\otf*{WordFinal}{fina}
+\otf*{LineFinal}{falt}
+\otf*{Inner}{medi}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+Historic forms are accessed in OpenType
+fonts via the feature \feat{Style=Historic}; this is generally \emph{not}
+contextual in OpenType, which is why it is not included in this feature.
+
+
+\subsubsection{Diacritics}
+
+Specifies how combining diacritics should be placed.
+These will usually be controlled automatically
+according to the Script setting.
+
+\begin{features}{Diacritics}
+\otf*{MarkToBase}{mark}
+\otf*{MarkToMark}{mkmk}
+\otf*{AboveBase}{abvm}
+\otf*{BelowBase}{blwm}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+
+\subsubsection{Fractions --- \texttt{frac}}
+
+\begin{features}{Fractions}
+\otf{On}{+frac}
+\otf{Off}{-frac}
+\otf{Reset}{}
+\cmidrule{2-4}
+\otf*{Alternate}{afrc}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+For OpenType fonts use a regular text slash to create fractions, but
+the \feat{Fraction} feature must be explicitly activated.
+Some (Asian fonts predominantly) also provide for the
+\opt{Alternate} feature. These are both shown in \exref{ot-frac}.
+
+\begin{Xexample}{ot-frac}{The \feat{Fractions} feature.}
+ \fontspec{Hiragino Maru Gothic Pro W4}
+ 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
+ \addfontfeature{Fractions=On}
+ 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
+ \addfontfeature{Fractions=Alternate}
+ 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
+\end{Xexample}
+
+
+
+\subsubsection{Kerning --- \texttt{kern}}
+\label{sec:kerning}
+
+Specifies how inter-glyph spacing should behave.
+Well-made fonts include information for how differing
+amounts of space should be inserted between separate character pairs.
+This kerning space is inserted automatically but in rare
+circumstances you may wish to turn it off.
+
+\begin{features}{Kerning}
+\otf{On}{+kern}
+\otf{Off}{-kern}
+\otf{Reset}{}
+\cmidrule{2-4}
+\otf*{Uppercase}{cpsp}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+As briefly mentioned previously at the end of \vref{sec:letters},
+the \opt{Uppercase} option will add a small amount of tracking between
+uppercase letters, seen in \exref{kernup}, which uses the Romande
+fonts\note{\url{http://arkandis.tuxfamily.org/adffonts.html}}
+(thanks to Clea F. Rees for the suggestion).
+The \opt{Uppercase} option acts separately to the regular kerning
+controlled by the \opt{On}/\opt{Off} options.
+
+\begin{Xexample}[firstline=2]{kernup}{Adding extra kerning for uppercase letters. (The difference is usually very small.)}
+ \large
+ \fontspec{RomandeADFStd-DemiBold.otf}
+ UPPERCASE EXAMPLE \\
+ \addfontfeature{Kerning=Uppercase}
+ UPPERCASE EXAMPLE
+\end{Xexample}
+
+
+\subsubsection{Letters} \label{sec:letters}
+The \opt{Letters} feature specifies how the letters in the current font
+will look. OpenType fonts may contain the following options:
+\opt{Uppercase}, \opt{SmallCaps}, \opt{PetiteCaps},
+\opt{UppercaseSmallCaps}, \opt{UppercasePetiteCaps}, and
+\opt{Unicase}.
+
+\begin{features}{Letters}
+\otf*{Uppercase}{case}
+\otf*{SmallCaps}{smcp}
+\otf*{PetiteCaps}{pcap}
+\otf*{UppercaseSmallCaps}{c2sc}
+\otf*{UppercasePetiteCaps}{c2pc}
+\otf*{Unicase}{unic}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+Petite caps are smaller than small caps.
+\opt{SmallCaps} and \opt{PetiteCaps}
+turn lowercase letters into the smaller caps letters,
+whereas the \opt{Uppercase...} options turn the \emph{capital} letters into
+the smaller
+caps (good, \eg, for applying to already uppercase acronyms like
+`NASA').
+This difference is shown in \exref{caps}.
+`Unicase' is a weird hybrid of upper and lower case letters.
+
+\begin{Lexample}{caps}{Small caps from lowercase or uppercase letters.}
+ \fontspec{texgyreadventor-regular.otf}[Letters=SmallCaps]
+ THIS SENTENCE no verb \\
+ \fontspec{texgyreadventor-regular.otf}[Letters=UppercaseSmallCaps]
+ THIS SENTENCE no verb
+\end{Lexample}
+
+Note that the \opt{Uppercase} option will (probably)
+not actually map letters to uppercase.
+ \note{If you want automatic uppercase letters, look to \LaTeX's
+ \cmd\MakeUppercase\ command.}
+It is designed to select various
+uppercase forms for glyphs such as accents and dashes, such as shown
+in \exref{letters-uppercase}; note the raised position of the hyphen
+to better match the surrounding letters.
+
+\begin{Lexample}{letters-uppercase}{An example of the \opt{Uppercase} option of the \feat{Letters} feature.}
+ \fontspec{LinLibertine_R.otf}
+ UPPER-CASE example \\
+ \addfontfeature{Letters=Uppercase}
+ UPPER-CASE example
+\end{Lexample}
+
+The \feat{Kerning} feature also contains an \opt{Uppercase} option,
+which adds a small amount of spacing in between letters (see \vref{sec:kerning}).
+
+
+\subsubsection{Ligatures}
+\label{sec:ot-feat-liga}
+
+\feat{Ligatures} refer to the replacement of two separate characters
+with a specially drawn glyph for functional or \ae sthetic reasons.
+The list of options, of which multiple may be selected at one time,
+is shown in \ref{feat:Ligatures}.
+A demonstration with the Linux Libertine fonts\note{\url{http://www.linuxlibertine.org/}} is shown in \exref{lig}.
+
+Note the additional features accessed with \verb|Ligatures=TeX|. These are
+not actually real OpenType features, but additions provided by \pkg{luaotfload} (i.e., \LuaTeX\ only) to emulate \TeX's behaviour for \textsc{ascii} input of curly quotes and punctuation. In \XeTeX\ this is achieved with the \feat{Mapping} feature (see \vref{sec:mapping}) but for consistency \verb|Ligatures=TeX| will perform the same function as \verb|Mapping=tex-text|.
+
+\begin{features}{Ligatures}
+\otf*{Required}{rlig}
+\otf*{Common}{liga}
+\otf*{Contextual}{clig}
+\otf*{Rare/Discretionary}{dlig}
+\otf*{Historic}{hlig}
+\otf*{TeX}{tlig}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+\begin{Lexample}[firstline=2]{lig}{An example of the \feat{Ligatures} feature.}
+ \Huge\centering
+ \def\test#1#2{%
+ #2 $\to$ {\addfontfeature{#1} #2}\\}
+ \fontspec{LinLibertine_R.otf}
+ \test{Ligatures=Historic}{strict}
+ \test{Ligatures=Rare}{wurtzite}
+ \test{Ligatures=NoCommon}{firefly}
+\end{Lexample}
+
+
+\subsubsection{Localised Forms --- \texttt{locl}}
+
+\begin{features}{LocalForms}
+\otf{On}{+locl}
+\otf{Off}{-locl}
+\otf{Reset}{}
+\end{features}
+
+This feature enables and disables glyph substitutions, etc., that are specific to the
+\feat{Language} selected in the font.
+This feature is automatically activated by default when present,
+so it should not be generally necessary to use \feat{LocalForms} \texttt{=} \opt{On}.
+In certain scenarios it may be important to turn it \opt{Off} (although nothing specifically springs to mind).
+
+
+\subsubsection{Numbers}
+
+The \feat{Numbers} feature defines how numbers will look in the
+selected font, accepting options shown in \ref{feat:Numbers}.
+
+\begin{features}{Numbers}
+\otf*{Uppercase}{lnum}
+\otf*{Lowercase}{onum}
+\otf*{Lining}{lnum}
+\otf*{OldStyle}{onum}
+\otf*{Proportional}{pnum}
+\otf*{Monospaced}{tnum}
+\otf*{SlashedZero}{zero}
+\otf*{Arabic}{anum}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+The synonyms
+\opt{Uppercase} and \opt{Lowercase} are equivalent to \opt{Lining} and
+\opt{OldStyle}, respectively.
+The differences have been shown previously
+in \vref{sec:addfontfeatures}.
+The \opt{Monospaced} option is useful for tabular material when digits need
+to be vertically aligned.
+
+The \opt{SlashedZero} option
+replaces the default zero with a slashed version to prevent
+confusion with an uppercase `O', shown in \exref{slashzero}.
+
+\begin{Lexample}{slashzero}{The effect of the \opt{SlashedZero} option.}
+ \fontspec[Numbers=Lining]{texgyrebonum-regular.otf}
+ 0123456789
+ \fontspec[Numbers=SlashedZero]{texgyrebonum-regular.otf}
+ 0123456789
+\end{Lexample}
+
+The \opt{Arabic} option (with tag \verb|anum|) maps regular numerals to their Arabic script or Persian equivalents
+based on the current \opt{Language} setting (see \vref{sec:ot}).
+This option is based on a \LuaTeX\ feature of the \pkg{luaotfload} package,
+not an OpenType feature. (Thus, this feature is unavailable in \XeTeX.)
+
+
+\subsubsection{Ornament --- \texttt{ornm}}
+
+Ornaments are selected with the \feat{Ornament} feature (OpenType feature |ornm|),
+selected numerically such as for the \feat{Annotation} feature.
+
+
+\subsubsection{Style}
+\label{sec:ot-feat-style}
+
+\begin{features}{Style}
+\otf*{Alternate}{salt}
+\otf*{Italic}{ital}
+\otf*{Ruby}{ruby}
+\otf*{Swash}{swsh}
+\otf*{Cursive}{curs}
+\otf*{Historic}{hist}
+\otf*{TitlingCaps}{titl}
+\otf*{HorizontalKana}{hkna}
+\otf*{VerticalKana}{vkna}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+`Ruby' refers to a small optical size, used in
+Japanese typography for annotations.
+For fonts with multiple |salt| OpenType features,
+use the fontspec \feat{Alternate} feature instead.
+
+\Exref{style-alt} shows an example of a font feature that involves glyph substitution
+for particular letters within an alphabet.
+Other options in these categories operate in similar ways, with the choice of how
+particular substitutions are organised with which feature largely up to the font designer.
+
+ \begin{Xexample}[firstline=2]{style-alt}{Example of the \opt{Alternate} option of the \feat{Style} feature.}
+ \Large
+ \fontspec{Quattrocento.otf}
+ M Q W \\
+ \addfontfeature{Style=Alternate}
+ M Q W
+\end{Xexample}
+
+In other features, larger breadths of changes can be seen, covering
+the style of an entire alphabet.
+See \exref{style-itrub}; here, the \opt{Italic} option affects the Latin text
+and the \opt{Ruby} option the Japanese.
+
+\begin{Xexample}[firstline=2]{style-itrub}{Example of the \opt{Italic} and \opt{Ruby} options of the \feat{Style} feature.}
+ \Large \def\kana{ようこそ ワカヨタレソ}
+ \fontspec{Hiragino Mincho Pro}
+ Latin \kana \\
+ \addfontfeature{Style={Italic, Ruby}}
+ Latin \kana
+\end{Xexample}
+
+Note the difference here between the default and the horizontal style kana
+in \exref{style-hvkana}: the horizontal style is slightly wider.
+
+\begin{Xexample}[firstline=2]{style-hvkana}{Example of the \opt{HorizontalKana} and \opt{VerticalKana} options of the \feat{Style} feature.}
+ \Large \def\kana{ようこそ ワカヨタレソ}
+ \fontspec{Hiragino Mincho Pro}
+ \kana \\
+ {\addfontfeature{Style=HorizontalKana}
+ \kana } \\
+ {\addfontfeature{Style=VerticalKana}
+ \kana }
+\end{Xexample}
+
+
+\subsubsection{Stylistic Set variations --- \texttt{ssNN}}
+\label{sec:ot-ss}
+
+This feature selects a `Stylistic Set' variation,
+which usually corresponds to an alternate glyph style for a range of
+characters (usually an alphabet or subset thereof).
+This feature is specified numerically. These correspond to OpenType
+features |ss01|, |ss02|, etc.
+
+Two demonstrations from the Junicode
+font\note{\url{http://junicode.sf.net}}
+are shown in \exref{ss} and \exref{ss2}; thanks to Adam
+Buchbinder for the suggestion.
+
+\begin{Lexample}{ss}{Insular letterforms, as used in medieval Northern Europe, for the Junicode font accessed with the \feat{StylisticSet} feature.}
+ \fontspec{Junicode}
+ Insular forms. \\
+ \addfontfeature{StylisticSet=2}
+ Insular forms. \\
+\end{Lexample}
+
+\begin{Lexample}{ss2}{Enlarged minuscules (capital letters remain unchanged) for the Junicode font, accessed with the \feat{StylisticSet} feature.}
+ \fontspec{Junicode}
+ ENLARGED Minuscules. \\
+ \addfontfeature{StylisticSet=6}
+ ENLARGED Minuscules. \\
+\end{Lexample}
+
+Multiple stylistic sets may be selected simultaneously by writing, e.g.,
+|StylisticSet={1,2,3}|.
+
+The |StylisticSet| feature is a synonym of the \feat{Variant} feature for \AAT\ fonts.
+See \vref{sec:newfeatures} for a way to assign names to stylistic sets, which should be done on a per-font basis.
+
+
+\subsubsection{Vertical Position}
+
+\begin{features}{VerticalPosition}
+\otf*{Superior}{sups}
+\otf*{Inferior}{subs}
+\otf*{Numerator}{numr}
+\otf*{Denominator}{dnom}
+\otf*{ScientificInferior}{sinf}
+\otf*{Ordinal}{ordn}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+The \feat{VerticalPosition} feature is used to access things like
+subscript (\opt{Inferior}) and superscript (\opt{Superior}) numbers and
+letters (and a small amount of punctuation, sometimes).
+The \opt{Ordinal} option will only raise characters that are used
+in some languages directly after a number.
+The \opt{ScientificInferior} feature will move glyphs
+further below the baseline than the \opt{Inferior} feature.
+These are shown in \exref{vertpos}
+
+\opt{Numerator} and \opt{Denominator} should only be used for creating
+arbitrary fractions (see next section).
+
+\begin{Lexample}{vertpos}{The \feat{VerticalPosition} feature.}
+ \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Superior]
+ Superior: 1234567890 \\
+ \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Numerator]
+ Numerator: 12345 \\
+ \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Denominator]
+ Denominator: 12345 \\
+ \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=ScientificInferior]
+ Scientific Inferior: 12345
+\end{Lexample}
+
+The \pkg{realscripts} package
+(which is also loaded by \pkg{xltxtra} for \XeTeX)
+redefines the \cmd\textsubscript\ and
+\cmd\textsuperscript\ commands to use the above font features automatically,
+including for use in footnote labels.
+If this is the only feature of \pkg{xltxtra} you wish to use, consider
+loading \pkg{realscripts} on its own instead.
+
+
+
+\subsection{CJK features}
+
+This section summarises the features which are largely intending for Chinese, Korean,
+and Japanese typesetting.
+
+
+\subsubsection{Annotation --- \texttt{nalt} }
+
+Some fonts are equipped with an extensive range of
+numbers and numerals in different forms. These are accessed with the
+\feat{Annotation} feature (OpenType feature |nalt|), selected numerically as shown in
+\exref{ot-annot}. Note that the indexing starts from zero.
+
+\begin{Xexample}{ot-annot}{Annotation forms for OpenType fonts.}
+ \fontspec{Hiragino Maru Gothic Pro}
+ 1 2 3 4 5 6 7 8 9
+ \def\x#1{\\{\addfontfeature{Annotation=#1}
+ 1 2 3 4 5 6 7 8 9 }}
+ \x0\x1\x2\x3\x4\x5\x6\x7\x7\x8\x9
+\end{Xexample}
+
+
+\subsubsection{Character width}\label{sec:CharacterWidth}
+
+Many Asian fonts are equipped with variously spaced characters for
+shoe-horning into their generally monospaced text.
+These are
+accessed through the \feat{CharacterWidth} feature.
+
+\begin{features}{CharacterWidth}
+\otf*{Proportional}{pwid}
+\otf*{Full} {fwid}
+\otf*{Half} {hwid}
+\otf*{Third} {twid}
+\otf*{Quarter} {qwid}
+\otf*{AlternateProportional}{palt}
+\otf*{AlternateHalf}{halt}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+Japanese alphabetic glyphs (in Hiragana or Katakana) may be typeset
+proportionally, to better fit horizontal measures, or monospaced, to
+fit into the rigid grid imposed by ideographic typesetting. In this
+latter case, there are also half-width forms for squeezing more kana
+glyphs (which are less complex than the kanji they are amongst) into
+a given block of space. The same features are given to roman letters
+in Japanese fonts, for typesetting foreign words in the same style
+as the surrounding text.
+
+\begin{Xexample}[firstline=2]{charwdprop}{Proportional or fixed width forms.}
+ \def\texta{ようこそ}\def\textb{ワカヨタレソ}
+ \def\test{\makebox[2cm][l]{\texta}%
+ \makebox[2.5cm][l]{\textb}%
+ \makebox[2.5cm][l]{abcdef}}
+ \fontspec{Hiragino Mincho Pro}
+ {\addfontfeature{CharacterWidth=Proportional}\test}\\
+ {\addfontfeature{CharacterWidth=Full}\test}\\
+ {\addfontfeature{CharacterWidth=Half}\test}
+\end{Xexample}
+
+The same situation occurs with numbers, which are provided in
+increasingly illegible compressed forms seen in \exref{charwd}.
+
+\begin{Xexample}[firstline=2]{charwd}{Numbers can be compressed significantly.}
+ \centering
+ \fontspec[Renderer=AAT]{Hiragino Mincho Pro}
+ {\addfontfeature{CharacterWidth=Full}
+ ---12321---}\\
+ {\addfontfeature{CharacterWidth=Half}
+ ---1234554321---}\\
+ {\addfontfeature{CharacterWidth=Third}
+ ---123456787654321---}\\
+ {\addfontfeature{CharacterWidth=Quarter}
+ ---12345678900987654321---}
+\end{Xexample}
+
+
+\subsubsection{CJK shape}
+
+\begin{features}{CJKShape}
+\otf{Traditional}{trad}
+\otf{Simplified} {smpl}
+\otf{JIS1978} {jp78}
+\otf{JIS1983} {jp83}
+\otf{JIS1990} {jp90}
+\otf{Expert} {expt}
+\otf{NLC} {nlck}
+\end{features}
+
+There have been many standards for how CJK ideographic
+glyphs are `supposed' to look. Some fonts will contain many alternate
+glyphs available in order to be able to display these gylphs
+correctly in whichever form is appropriate. Both \AAT\ and OpenType
+fonts support the following \feat{CJKShape} options:
+\opt{Traditional}, \opt{Simplified}, \opt{JIS1978}, \opt{JIS1983},
+\opt{JIS1990}, and \opt{Expert}. OpenType also supports the \opt{NLC} option.
+
+\begin{Xexample}[firstline=2]{ot-cjk-shape}{Different standards for CJK ideograph presentation.}
+ \LARGE\def\text{ 唖噛躯 妍并訝}
+ \fontspec{Hiragino Mincho Pro}
+ {\addfontfeature{CJKShape=Traditional}
+ \text } \\
+ {\addfontfeature{CJKShape=NLC}
+ \text } \\
+ {\addfontfeature{CJKShape=Expert}
+ \text }
+\end{Xexample}
+
+
+\subsubsection{Vertical typesetting}
+
+\begin{features}{Vertical}
+\otf*{RotatedGlyphs} {vrt2}
+\otf*{AlternatesForRotation} {vrtr}
+\otf*{Alternates} {vert}
+\otf*{KanaAlternates} {vkna}
+\otf*{Kerning} {vkrn}
+\otf*{AlternateMetrics} {valt}
+\otf*{HalfMetrics} {vhal}
+\otf*{ProportionalMetrics} {vpal}
+\cmidrule{2-4}
+\otf{ResetAll}{}
+\end{features}
+
+OpenType provides a plethora of features for accommodating the varieties of possibilities
+needed for vertical typesetting (CJK and others).
+No capabilities for achieving such vertical typesetting are provided by \pkg{fontspec},
+however; please get in touch if there are improvements that could be made.
+
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-style.sty b/macros/latex/contrib/fontspec/fontspec-doc-style.sty
new file mode 100644
index 0000000000..43fbc38442
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-style.sty
@@ -0,0 +1,290 @@
+
+
+\ProvidesPackage{fontspec-doc-style}
+
+\input{fontspec.dtx}
+\ExplSyntaxOff
+
+\usepackage{fontspec,booktabs,caption,xcolor,flafter,fancyvrb,hologo,graphicx,
+ url,varioref,varwidth,microtype,tocloft,framed,xparse,docmute}
+
+%% Various labelling commands:
+\newcommand*\name[1]{{#1}}
+\newcommand*\opt[1]{\texttt{#1}}
+\newcommand*\feat[1]{\texttt{#1}}
+
+\let\latin\textit
+\def\eg{\latin{e.g.}}
+\def\ie{\latin{i.e.}}
+\def\Eg{\latin{E.g.}}
+\def\Ie{\latin{I.e.}}
+\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}}
+
+\newcommand\note[1]{\unskip\footnote{#1}}
+
+\def\MacOSX{macOS}
+\def\AAT{\textsc{aat}}
+\def\ATSUI{\textsc{atsui}}
+
+\newcommand\NFSS{\textsc{nfss}}
+\newcommand\XeLaTeX{\hologo{XeLaTeX}}
+\newcommand\LuaLaTeX{\hologo{LuaLaTeX}}
+
+% ToC formatting:
+\setlength\cftsubsecnumwidth{1.4\cftsubsecnumwidth}
+%\def\@cfttocstart{\small\begin{multicols}{2}}
+%\def\@cfttocfinish{\end{multicols}}
+
+\fvset{gobble=0}
+
+\captionsetup[table]{position=above}
+\captionsetup[figure]{position=above}
+
+
+%% Fonts
+
+\defaultfontfeatures{Numbers=OldStyle}
+\IfFontExistsTF{AldusNovaPro-Book.otf}
+ {
+ \setmainfont{aldus-nova}
+ \setsansfont{palatino-sans-light}
+ }
+ {
+\setmainfont{texgyrepagella}[
+ Extension = .otf,
+ UprightFont = *-regular ,
+ ItalicFont = *-italic ,
+ BoldFont = *-bold ,
+ BoldItalicFont = *-bolditalic ,
+]
+\setsansfont{texgyreheros}[
+ Extension = .otf,
+ UprightFont = *-regular ,
+ ItalicFont = *-italic ,
+ BoldFont = *-bold ,
+ BoldItalicFont = *-bolditalic ,
+]
+ }
+\setmonofont{lmmono10-regular.otf}[
+ Numbers={Lining,SlashedZero},
+ ItalicFont=lmmonoslant10-regular.otf,
+ BoldFont=lmmonolt10-bold.otf,
+ BoldItalicFont=lmmonolt10-boldoblique.otf,
+]
+\newfontfamily\ttcondensed{lmmonoltcond10-regular.otf}
+
+%% (La)TeX font-related declarations:
+\linespread{1.05} % Pagella needs more space between lines
+\frenchspacing % Remove ugly extra space after punctuation
+
+%% ToC
+\def\@dotsep{1000}
+\setcounter{tocdepth}{2}
+\setlength\columnseprule{0.4pt}
+\renewcommand\tableofcontents{\relax
+ \begin{multicols}{2}[\section*{\contentsname}]\relax
+ \@starttoc{toc}\relax
+ \end{multicols}}
+
+
+%% Index
+\setcounter{IndexColumns}{2}
+\renewenvironment{theglossary}
+ {\small\list{}{}
+ \item\relax
+ \glossary@prologue\GlossaryParms
+ \let\item\@idxitem \ignorespaces
+ \def\pfill{\hspace*{\fill}}}
+ {\endlist}
+
+
+
+%% varioref definitions:
+\labelformat{table}{Table~#1}
+\labelformat{section}{Section~#1}
+\labelformat{subsection}{Section~#1}
+
+\definecolor{niceblue}{rgb}{0.1,0.2,0.8}
+
+
+
+
+%% EXAMPLES
+
+\newif\ifshowexamples
+\showexamplestrue
+
+\newsavebox\X
+\newsavebox\Y
+
+\newcounter{example}
+
+\newcommand\exref[1]{Example~\ref{ex:#1}}
+\newcommand\Exref[1]{Example~\ref{ex:#1}}
+
+\newenvironment{Xexample}[3][]
+ {\VerbatimEnvironment\begin{Fexample}[#1]{#2}{#3}{X}}
+ {\end{Fexample}}
+
+\newenvironment{Lexample}[3][]
+ {\VerbatimEnvironment\begin{Fexample}[#1]{#2}{#3}{L}}
+ {\end{Fexample}}
+
+\newenvironment{Fexample}[4][]
+ {%
+ \def\options{#1}%
+ \def\filename{#2}%
+ \def\captiontext{#3}%
+ \def\prefix{#4}
+ \refstepcounter{example}%
+ \label{ex:\filename}%
+ \ifshowexamples
+ \IfFileExists{zzz-\theexample-\prefix-\filename.tex}{}{%
+ \immediate\write18{rm -f zzz-\theexample-* ;}%
+ }%
+ \fi
+ \VerbatimEnvironment
+ \begin{VerbatimOut}{zzz-\theexample-\prefix-\filename.tex}}
+% text in the environment
+ {\end{VerbatimOut}
+ \begin{figure}
+ \setlength\parindent{0pt}%
+ \edef\@tempa{[gobble=0,fontsize=\noexpand\small,\options]}%
+ \savebox\X{%
+ \expandafter\BVerbatimInput
+ \@tempa{zzz-\theexample-\prefix-\filename.tex}%
+ }%
+ \IfFileExists{zzz-\theexample-\prefix-\filename.pdf}{}
+ {%
+ \edef\XXcmd{%
+ \unexpanded{%
+ \RequirePackage{luatex85}
+ \documentclass[margin=0.2mm]{standalone}
+ \usepackage{booktabs,ifthen,graphicx,xcolor,varwidth}
+ \usepackage{fontspec}
+ \defaultfontfeatures{Ligatures=TeX}
+ \begin{document}
+ \begin{varwidth}{0.7\linewidth}
+ \input} zzz-\theexample-\prefix-\filename.tex
+ \unexpanded{
+ \end{varwidth}
+ \end{document}
+ }%
+ }%
+ \edef\1{%
+ \csname prog@\prefix\endcsname "\unexpanded\expandafter{\XXcmd}";
+ printf '\@percentchar s' '\unexpanded\expandafter{\XXcmd}' > zzz-\theexample-\prefix-\filename-test.tex;
+ }%
+ \ifshowexamples
+ \immediate\write18{\unexpanded\expandafter{\1}}%
+ \fi
+ }%
+ \savebox\Y{%
+ \IfFileExists{zzz-\theexample-\prefix-\filename.pdf}
+ {\includegraphics{zzz-\theexample-\prefix-\filename.pdf}}
+ {\color{red}\itshape ---Example graphic not generated---}%
+ }
+ % TYPESETTING
+ \rule[0.5\baselineskip]{\columnwidth}{1pt}%
+ \vspace{-1.2ex}%
+ \def\@tempa{\small\textsf{Example~\theexample:~}}%
+ \settowidth\@tempdima{\@tempa\captiontext}%
+ \par
+ \ifdim\@tempdima>\linewidth
+ \settowidth\@tempdima{\@tempa}%
+ \@tempa\parbox[t]{\linewidth-\@tempdima}{\small\captiontext}%
+ \vspace{0.4\baselineskip}%
+ \else
+ \parbox{\linewidth}{\centering\@tempa~\captiontext}%
+ \fi
+ \par\rule[0.4\baselineskip]{\columnwidth}{0.4pt}\par
+ \ifdim\dimexpr\wd\X+\wd\Y>\linewidth\relax
+ \null\hfill\makebox[0pt][r]{\usebox\Y}\usebox\X
+ \else
+ \hfill\usebox\Y\hfill\usebox\X
+ \fi
+ \par\rule[0.5\baselineskip]{\columnwidth}{1pt}
+ \end{figure}
+}
+
+\def\prog@X{xelatex
+ -jobname=zzz-\theexample-X-\filename\space}
+
+\def\prog@L{lualatex
+ -jobname=zzz-\theexample-L-\filename\space}
+
+%%%%%%%%%%%%%%%%%%%%%%
+
+\newcommand*\setexsize[1]{\let\examplesize#1}
+\newcommand*\setverbwidth[1]{\def\auxwidth{#1}}
+
+
+
+\newcounter{argument}
+\g@addto@macro\endmacro{\setcounter{argument}{0}}
+\newcommand*\darg[1]{%
+ \stepcounter{argument}%
+ \noindent{\ttfamily\char`\#\theargument~:~}#1\par}
+\newcommand*\doarg[1]{%
+ \stepcounter{argument}%
+ \noindent{\ttfamily\makebox[0pt][r]{[}\char`\#\theargument]:~}#1\par}
+
+\newcommand\unichar[2]{\textsc{\MakeLowercase{u+#1: #2}}}
+
+\newcommand\cmdbox[1]{%
+ \smallskip\par\noindent
+ \fbox{\begin{varwidth}{\linewidth}
+ #1%
+ \end{varwidth}}%
+ \smallskip
+}
+\def\CMD#1{\texttt{\null#1\unskip}}
+
+
+\NewDocumentCommand \otf {somm} {%
+ \featname & #3 & \texttt{#4}
+ \IfBooleanT #1 { & \textdagger }
+ \\
+}
+\newenvironment{features}[1]{%
+ \def\NOTE{}
+ \def\thisfeatname{#1}%
+ \def\featname{\thisfeatname~~\texttt=~~\null\gdef\featname{}}%
+ \begin{table}
+ \caption{Options for the OpenType font feature `\thisfeatname'.}
+ \edef\@tempa{\noexpand\label{feat:\thisfeatname}}\@tempa
+ \centering
+ \begin{tabular}{@{}l@{}l@{\hspace{0.5\tabcolsep}}l@{\hspace{0.5\tabcolsep}}l@{}}
+ \toprule
+ Feature & Option & Tag & \\
+ \midrule
+}{
+ \bottomrule
+ \end{tabular}
+ \par\smallskip
+ \footnotesize
+ \textdagger\ These feature options can be disabled with \texttt{..Off} variants, and reset \\ to default state (neither explicitly on nor off) with \texttt{..Reset}.
+ \NOTE
+ \end{table}
+}
+
+
+%%%%%%%%%%%
+
+\def \MakePrivateLetters {%
+ \catcode `\@ = 11
+ \catcode `\_ = 11
+ \catcode `\: = 11
+}
+
+%% for LaTeX3 csnames
+\catcode `\_= 11
+
+\renewcommand\partname{Part}
+
+
+% /©
+%
+% (COPYRIGHT GOES HERE)
+%
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-doc-xetex.tex b/macros/latex/contrib/fontspec/fontspec-doc-xetex.tex
new file mode 100644
index 0000000000..0dc5e48cac
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-doc-xetex.tex
@@ -0,0 +1,380 @@
+%%^^A%% fontspec-doc-xetex.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\showexamplesfalse
+\begin{document}
+
+\part{Fonts and features with \XeTeX}
+\label{sec:xetex-features}
+
+\section{\XeTeX-only font features}
+
+The features described here are available for any font
+selected by \pkg{fontspec}.
+
+\subsection{Mapping}
+\label{sec:mapping}
+
+The \feat{Mapping} feature enables a \XeTeX\ text-mapping scheme, with an example shown in \exref{mapping}.
+
+\begin{Xexample}{mapping}{\XeTeX's \feat{Mapping} feature.}
+ \fontspec{texgyrepagella-regular.otf}[Mapping=tex-text]
+ ``!`A small amount of---text!''
+\end{Xexample}
+
+Only one mapping can be active at a time and a second call to \feat{Mapping}
+will override the first.
+Using the |tex-text| mapping is also equivalent to writing |Ligatures=TeX|.
+The use of the latter syntax is recommended for better compatibility with
+\LuaTeX\ documents.
+
+
+\subsection{Different font technologies: \AAT, OpenType, and Graphite}\label{sec:renderer-xetex}
+
+\XeTeX\ supports three rendering technologies for typesetting, selected with
+the \feat{Renderer} font feature. The first, \opt{AAT}, is
+that provided only by \MacOSX.
+The second, \opt{OpenType}, is an open source OpenType interpreter.
+It provides greater support for OpenType features, notably contextual arrangement, over \opt{AAT}.
+The third is \opt{Graphite}, which is an alternative to OpenType with particular features for less-common languages and the capability for more powerful font options.
+Features for \opt{OpenType} have already been discussed in \vref{sec:opentype-features};
+\opt{Graphite} and \opt{AAT} features are discussed later in \vref{sec:graphite-features} and \vref{sec:aat-features}.
+
+Unless you have a particular need, the \feat{Renderer} feature is rarely explicitly required: for OpenType
+fonts, the \opt{OpenType} renderer is used automatically, and for \AAT\ fonts,
+\opt{AAT} is chosen by default. Some fonts, however, will contain font tables
+for multiple rendering technologies, such as the Hiragino Japanese fonts
+distributed with \MacOSX, and in these cases one over the other may be preferred.
+
+Among some other font features only available through a specific renderer,
+\opt{OpenType} provides for the \feat{Script} and \feat{Language} features, which allow
+different font behaviour for different alphabets and languages; see \vref{sec:ot}
+for the description of these features. {\em Because these font features can
+change which features are able to be selected for the font instance, they are selected
+by \pkg{fontspec} before all others and will automatically and without warning
+select the \opt{OpenType} renderer.}
+
+
+\subsection{Optical font sizes} \label{sec:aat-opticalsize}
+
+Multiple Master fonts are parameterised over
+orthogonal font axes, allowing continuous selection along such
+features as weight, width, and optical size.
+Whereas an OpenType font will have only a few separate
+optical sizes, a Multiple Master font's optical size can be
+specified over a continuous range. Unfortunately, this flexibility makes
+it harder to create an automatic interface through \LaTeX, and the
+optical size for a Multiple Master font must always be specified
+explicitly.
+\begin{Verbatim}
+ \fontspec{Minion MM Roman}[OpticalSize=11]
+ MM optical size test \\
+ \fontspec{Minion MM Roman}[OpticalSize=47]
+ MM optical size test \\
+ \fontspec{Minion MM Roman}[OpticalSize=71]
+ MM optical size test \\
+\end{Verbatim}
+
+
+\section{The Graphite renderer}
+\label{sec:graphite-features}
+
+Since the Graphite renderer is designed for less common scripts and languages, usually with
+specific or unique requirements, Graphite features are not standard across fonts.
+
+Currently \pkg{fontspec} does not support a convenient interface to select Graphite font
+features and all selection must be done via `raw' font feature selection.
+
+Here's an example:
+\begin{Verbatim}
+ \fontspec{Charis SIL}[
+ Renderer=Graphite,
+ RawFeature={Uppercase Eng alternates=Large eng on baseline}]
+ Ŋ
+\end{Verbatim}
+
+Here's another:
+\begin{Verbatim}
+\fontspec{AwamiNastaliq-Regular.ttf}[Renderer=Graphite] ^^^^06b5
+\addfontfeature{RawFeature={Lam with V=V over bowl}} ^^^^06b5
+\end{Verbatim}
+
+
+
+\section{\MacOSX's \AAT\ fonts}
+\label{sec:aat-features}
+
+\begin{quote}\itshape
+\textbf{Warning!}
+\XeTeX's implementation on \MacOSX\ is currently in a state of flux and the information contained below may well be wrong from 2013 onwards.
+There is a good chance that the features described in this section will not be available any more as \XeTeX's completes its transition to a cross-platform--only application.
+\end{quote}
+
+\MacOSX's font technology began life before the ubiquitous-OpenType era
+and revolved around the Apple-invented `\AAT' font format. This format
+had some advantages (and other disadvantages) but it never became widely
+popular in the font world.
+
+Nonetheless, this is the font format that was first supported by \XeTeX\
+(due to its pedigree on \MacOSX\ in the first place) and was the first
+font format supported by \pkg{fontspec}. A number of fonts distributed with
+\MacOSX\ are still in the \AAT\ format, such as `Skia'.
+
+\subsection{Ligatures}
+
+\feat{Ligatures} refer to the replacement of two separate characters
+with a specially drawn glyph for functional or \ae sthetic reasons.
+For \AAT\ fonts, you may choose from any combination of \opt{Required},
+\opt{Common}, \opt{Rare} (or \opt{Discretionary}), \opt{Logos}, \opt{Rebus},
+\opt{Diphthong}, \opt{Squared}, \opt{AbbrevSquared}, and \opt{Icelandic}.
+
+Some other Apple \AAT\ fonts have those `Rare' ligatures contained in
+the \opt{Icelandic} feature. Notice also that the old \TeX\ trick of
+splitting up a ligature with an empty brace pair does not work in
+\XeTeX; you must use a 0\,pt kern or \cs{hbox} (\eg, \cs{null}) to
+split the characters up if you do not want a ligature to be performed (the usual examples for when this might be desired are words like `shelf\null full').
+
+\subsection{Letters} \label{sec:aat-letters}
+The \opt{Letters} feature specifies how the letters in the current font
+will look. For \AAT\ fonts, you may choose from \opt{Normal},
+\opt{Uppercase}, \opt{Lowercase}, \opt{SmallCaps}, and
+\opt{InitialCaps}.
+
+
+\subsection{Numbers}
+The \feat{Numbers} feature defines how numbers will look in the
+selected font. For \AAT\ fonts, they may be a
+combination of \opt{Lining} or \opt{OldStyle} and \opt{Proportional} or
+\opt{Monospaced} (the latter is good for tabular material). The synonyms
+\opt{Uppercase} and \opt{Lowercase} are equivalent to \opt{Lining} and
+\opt{OldStyle}, respectively. The differences have been shown previously
+in \vref{sec:addfontfeatures}.
+
+\subsection{Contextuals} \label{sec:contextuals}
+This feature refers to glyph substitution that vary by their position;
+things like contextual swashes are implemented here.
+The options for \AAT\ fonts are
+\opt{WordInitial}, \opt{WordFinal} (\exref{wordcx}), \opt{LineInitial},
+\opt{LineFinal}, and \opt{Inner} (\exref{longsaat}, also called `non-final' sometimes). As
+non-exclusive selectors, like the ligatures, you can turn them off
+by prefixing their name with \opt{No}.
+
+\begin{Xexample}{wordcx}{Contextual glyph for the beginnings and ends of words.}
+ \newfontface\fancy{Hoefler Text Italic}[%
+ Contextuals={WordInitial,WordFinal}]
+ \fancy where is all the vegemite
+\end{Xexample}
+
+\begin{Xexample}{longsaat}{A contextual feature for the `long s' can be convenient as the character does not need to be marked up explicitly.}
+ \fontspec{Hoefler Text}[Contextuals=Inner]
+ `Inner' swashes can \emph{sometimes} \\
+ contain the archaic long~s.
+\end{Xexample}
+
+
+
+\subsection{Vertical position}
+The \feat{VerticalPosition} feature is used to access things like
+subscript (\opt{Inferior}) and superscript (\opt{Superior}) numbers and
+letters (and a small amount of punctuation, sometimes).
+The \opt{Ordinal} option is (supposed to be)
+contextually sensitive to only raise characters that appear directly
+after a number.
+These are shown in \exref{aat-supp}.
+
+\begin{Xexample}{aat-supp}{Vertical position for AAT fonts.}
+ \fontspec{Skia}
+ Normal
+ \fontspec{Skia}[VerticalPosition=Superior]
+ Superior
+ \fontspec{Skia}[VerticalPosition=Inferior]
+ Inferior \\
+ \fontspec{Skia}[VerticalPosition=Ordinal]
+ 1st 2nd 3rd 4th 0th 8abcde
+\end{Xexample}
+
+The \pkg{realscripts} package
+(also loaded by \pkg{xltxtra})
+redefines the \cmd\textsubscript\ and
+\cmd\textsuperscript\ commands to use the above font features,
+including for use in footnote labels.
+
+\subsection{Fractions}
+Many fonts come with the capability to typeset various forms of
+fractional material. This is accessed in \pkg{fontspec} with the
+\feat{Fractions} feature, which may be turned \opt{On} or \opt{Off}
+in both \AAT\ and OpenType fonts.
+
+In \AAT\ fonts, the `fraction slash' or solidus character, is
+to be used to create fractions. When \feat{Fractions} are turned
+\opt{On}, then only pre-drawn fractions will be used.
+See \exref{aat-frac}.
+
+Using the \opt{Diagonal} option (\AAT\ only), the font will attempt
+to create the fraction from superscript and subscript
+characters.
+
+\edef\caretcc{\the\catcode`\^}
+\catcode`\^=12\relax
+\begin{Xexample}{aat-frac}{Fractions in AAT fonts. The \texttt{\relax^^^^2044} glyph is the `fraction slash' that may be typed in \MacOSX\ with \textsc{opt+shift+1}; not shown literally here due to font contraints.}
+ \fontspec[Fractions=On]{Skia}
+ 1{^^^^2044}2 \quad 5{^^^^2044}6 \\ % fraction slash
+ 1/2 \quad 5/6 % regular slash
+
+ \fontspec[Fractions=Diagonal]{Skia}
+ 13579{^^^^2044}24680 \\ % fraction slash
+ \quad 13579/24680 % regular slash
+\end{Xexample}
+\catcode`\^=\caretcc\relax
+
+Some (Asian fonts predominantly) also provide for the
+\opt{Alternate} feature shown in \exref{frac-alt}.
+
+\begin{Xexample}{frac-alt}{Alternate design of pre-composed fractions.}
+ \fontspec{Hiragino Maru Gothic Pro}
+ 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
+ \addfontfeature{Fractions=Alternate}
+ 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680
+\end{Xexample}
+
+
+\subsection{Variants}
+The \feat{Variant} feature takes a single numerical input for
+choosing different alphabetic shapes. Don't mind my fancy \exref{aat-var}
+\texttt{:)} I'm just looping through the nine~(\,!\,) variants of
+Zapfino.
+
+\begin{Xexample}[firstline=2,lastline=9]{aat-var}{Nine variants of Zapfino.}
+ \Huge \rule{0pt}{2cm}
+ \newcounter{var}
+ \whiledo{\value{var}<9}{%
+ \edef\1{%
+ \noexpand\fontspec[Variant=\thevar,
+ Color=0099\thevar\thevar]{Zapfino}}\1%
+ \makebox[0.75\width]{d}%
+ \stepcounter{var}}
+ \hspace*{2cm}
+\end{Xexample}
+
+See \vref{sec:newfeatures} for a way to assign names to variants,
+which should be done on a per-font basis.
+
+\subsection{Alternates}
+
+Selection of \feat{Alternate}s \emph{again}
+must be done numerically; see \exref{aat-alt}.
+See \vref{sec:newfeatures} for a way to assign names to alternates,
+which should be done on a per-font basis.
+
+\begin{Xexample}{aat-alt}{Alternate shape selection must be numerical.}
+ \fontspec{Hoefler Text Italic}[Alternate=0]
+ Sphinx Of Black Quartz, {\scshape Judge My Vow} \\
+ \fontspec{Hoefler Text Italic}[Alternate=1]
+ Sphinx Of Black Quartz, {\scshape Judge My Vow}
+\end{Xexample}
+
+
+\subsection{Style}
+
+The options of the \feat{Style} feature
+are defined in \AAT\ as one of the following: \opt{Display},
+\opt{Engraved}, \opt{IlluminatedCaps}, \opt{Italic},
+\opt{Ruby},\footnotemark\ \opt{TallCaps}, or \opt{TitlingCaps}.
+\footnotetext{`Ruby' refers to a small optical size, used in
+Japanese typography for annotations.}
+
+Typical examples for these features are shown in \ref{sec:ot-feat-style}.
+
+
+
+
+
+
+\subsection{CJK shape}
+There have been many standards for how CJK ideographic
+glyphs are `supposed' to look. Some fonts will contain many alternate
+glyphs in order to be able to display these gylphs
+correctly in whichever form is appropriate. Both \AAT\ and OpenType
+fonts support the following \feat{CJKShape} options:
+\opt{Traditional}, \opt{Simplified}, \opt{JIS1978}, \opt{JIS1983},
+\opt{JIS1990}, and \opt{Expert}. OpenType also supports the \opt{NLC} option.
+
+\subsection{Character width}
+See \vref{sec:CharacterWidth} for relevant examples; the features are
+the same between OpenType and \AAT\ fonts.
+\AAT\ also allows \feat{CharacterWidth}|=|\opt{Default} to return to
+the original font settings.
+
+
+
+
+
+
+
+\subsection{Vertical typesetting}
+
+\XeTeX\ provides for vertical typesetting simply with the ability to rotate
+the individual glyphs as a font is used for typesetting, as shown in
+\exref{vert}.
+
+\begin{Xexample}[firstline=2]{vert}{Vertical typesetting.}
+ \def\verttext{共産主義者は}
+ \fontspec{Hiragino Mincho Pro}
+ \verttext
+
+ \fontspec{Hiragino Mincho Pro}[Renderer=AAT,Vertical=RotatedGlyphs]
+ \rotatebox{-90}{\verttext}% requires the graphicx package
+\end{Xexample}
+
+No actual provision is made for typesetting top-to-bottom
+languages; for an example of how to do this, see the vertical Chinese
+example provided in the \XeTeX\ documentation.
+
+
+
+
+\subsection{Diacritics}
+Diacritics are marks, such as the acute accent or the tilde, applied to letters; they usually indicate a change in pronunciation.
+In Arabic scripts, diacritics are used to indicate vowels.
+You may either choose
+to \opt{Show}, \opt{Hide} or \opt{Decompose} them in \AAT\ fonts.
+The \opt{Hide} option is for scripts such as Arabic which may be
+displayed either with or without vowel markings. E.g.,
+\verb|\fontspec[Diacritics=Hide]{...}|
+
+Some older fonts distributed with \MacOSX\ included `|O/|' \etc\ as shorthand for writing `\O' under the label of the \feat{Diacritics} feature. If you come across such fonts, you'll
+want to turn this feature off (imagine typing |hello/goodbye| and
+getting `hell\o goodbye' instead!) by decomposing the two characters
+in the diacritic into the ones you actually
+want. I recommend using
+the proper \LaTeX\ input conventions for obtaining such characters
+instead.
+
+
+
+\subsection{Annotation}
+Various Asian fonts are equipped with a more extensive range of
+numbers and numerals in different forms. These are accessed through
+the \feat{Annotation} feature with the following
+options: \opt{Off},
+\opt{Box}, \opt{RoundedBox}, \opt{Circle}, \opt{BlackCircle},
+\opt{Parenthesis}, \opt{Period}, \opt{RomanNumerals}, \opt{Diamond},
+\opt{BlackSquare}, \opt{BlackRoundSquare}, and \opt{DoubleCircle}.
+
+\end{document}
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec-example.tex b/macros/latex/contrib/fontspec/fontspec-example.tex
new file mode 100644
index 0000000000..bf2831b134
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-example.tex
@@ -0,0 +1,48 @@
+%%^^A%% fontspec-example.tex -- part of FONTSPEC <wspr.io/fontspec>
+
+\documentclass{article}
+
+\usepackage{fontspec}
+
+\setmainfont{TeX Gyre Pagella}
+\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
+\setmonofont{Inconsolata}[Scale=MatchLowercase]
+
+\begin{document}
+\pagestyle{empty}
+
+\section*{The basics of the \textsf{fontspec} package}
+
+The \textsf{fontspec} package enables automatic font selection
+for \LaTeX{} documents typeset with Xe\TeX{} or Lua\TeX.
+The basic command is
+
+{\centering \verb|\fontspec{font display name}[font features]|.\par}
+
+The default, sans serif, and typewriter fonts may be set with the
+commands \verb|\setmainfont|, \verb|\setsansfont| and \verb|\setmonofont|,
+respectively, as shown in the preamble. They take the
+same syntax as the \verb|\fontspec| package. All expected font
+shapes are available:
+
+\begin{center}
+ {\itshape Italics and \scshape small caps\dots}\\
+ {\sffamily\bfseries Bold sans serif and \itshape bold italic sans serif\dots}
+\end{center}
+
+Text fonts in maths mode are also changed (e.g., notice the cosine function in
+`$\cos(n\pi)=\pm 1$') but only if the roman and sans serif fonts are set in
+the preamble; \verb|\setmainfont| will not affect these maths mode fonts when
+called mid-document.
+Maths symbols themselves are not affected.
+
+Notice the font features used to load the default fonts in the preamble.
+\verb|Ligatures=TeX| is automatically enabled for the roman and sans font,
+allowing regular \TeX{} ligatures like \verb|``---''| for ``---''.
+\verb|Scale=MatchLowercase| automatically scales the fonts to
+the same x-height.
+
+Please see the complete \textsf{fontspec} documentation for further
+information.
+
+\end{document}
diff --git a/macros/latex/contrib/fontspec/fontspec-lua.dtx b/macros/latex/contrib/fontspec/fontspec-lua.dtx
new file mode 100644
index 0000000000..4f04001f1f
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec-lua.dtx
@@ -0,0 +1,101 @@
+%%^^A%% fontspec-lua.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Lua module}
+%
+% \begin{macrocode}
+%<*lua>
+% \end{macrocode}
+% \begin{macrocode}
+local err, warn, info, log = luatexbase.provides_module(fontspec.module)
+% \end{macrocode}
+% Some utility functions
+% \begin{macrocode}
+fontspec.log = log or (function (s) luatexbase.module_info("fontspec", s) end)
+fontspec.warning = warn or (function (s) luatexbase.module_warning("fontspec", s) end)
+fontspec.error = err or (function (s) luatexbase.module_error("fontspec", s) end)
+% \end{macrocode}
+%
+% We need a catcode table for tex.sprint(). See issue \#230.
+% TODO: probably time to get rid of the backwards compatibility here:
+% \begin{macrocode}
+local latex
+if luatexbase.registernumber then
+ latex = luatexbase.registernumber("catcodetable@latex")
+else
+ latex = luatexbase.catcodetables.CatcodeTableLaTeX
+end
+% \end{macrocode}
+%
+% The following are the function that get called from \TeX\ end.
+% \begin{macrocode}
+local function tempswatrue() tex.sprint(latex,[[\FontspecSetCheckBoolTrue ]]) end
+local function tempswafalse() tex.sprint(latex,[[\FontspecSetCheckBoolFalse]]) end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_script(fnt, script)
+ if luaotfload.aux.provides_script(font.id(fnt), script) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_lang(fnt, lang, script)
+ if luaotfload.aux.provides_language(font.id(fnt), script, lang) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_feat(fnt, feat, lang, script)
+ for _, f in ipairs { "+trep", "+tlig", "+anum" } do
+ if feat == f then
+ tempswatrue()
+ return
+ end
+ end
+ if luaotfload.aux.provides_feature(font.id(fnt), script, lang, feat) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.mathfontdimen(fnt, str)
+ local mathdimens = luaotfload.aux.get_math_dimension(fnt, str)
+ if mathdimens then
+ tex.sprint(-2,mathdimens)
+ tex.sprint(-2,"sp")
+ else
+ tex.sprint(-2,"0pt")
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</lua>
+% \end{macrocode}
+
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec.cfg b/macros/latex/contrib/fontspec/fontspec.cfg
new file mode 100644
index 0000000000..f7dbe9fc68
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec.cfg
@@ -0,0 +1,22 @@
+
+
+%%% FONTSPEC.CFG %%%
+%
+% This configuration file sets up TeX Ligatures by default for all fonts loaded
+% with `\setmainfont` and `\setsansfont`.
+%
+% In addition, `\setmonofont` has default features to enforce "monospace"
+% settings with regard to space stretchability and shrinkability.
+%
+% Make a copy of this file in your own home TEXMF directory to set up your own
+% defaults.
+
+\defaultfontfeatures
+ [\rmfamily,\sffamily]
+ {Ligatures=TeX}
+
+\defaultfontfeatures
+ [\ttfamily]
+ {WordSpace={1,0,0},
+ HyphenChar=None,
+ PunctuationSpace=WordSpace}
diff --git a/macros/latex/contrib/fontspec/fontspec.dtx b/macros/latex/contrib/fontspec/fontspec.dtx
new file mode 100644
index 0000000000..32d51078ce
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec.dtx
@@ -0,0 +1,117 @@
+%%^^A%% fontspec.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%%^^A%% Metadata for the package, including files and versioning
+
+% \section{Package declaration}
+%
+% List all \texttt{dtx} files for running the \texttt{ins} file
+% and typesetting the code.
+% \begin{macrocode}
+%<*dtx>
+\gdef\FONTSPECDTX{
+ \DTX{fontspec.dtx}
+ \DTX{fontspec-code-load.dtx}
+ \DTX{fontspec-code-vars.dtx}
+ \DTX{fontspec-code-msg.dtx}
+ \DTX{fontspec-code-opening.dtx}
+ \DTX{fontspec-code-fontload.dtx}
+ \DTX{fontspec-code-interfaces.dtx}
+ \DTX{fontspec-code-user.dtx}
+ \DTX{fontspec-code-api.dtx}
+ \DTX{fontspec-code-internal.dtx}
+ \DTX{fontspec-code-opentype.dtx}
+ \DTX{fontspec-code-graphite.dtx}
+ \DTX{fontspec-code-keyval.dtx}
+ \DTX{fontspec-code-feat-opentype.dtx}
+ \DTX{fontspec-code-scripts.dtx}
+ \DTX{fontspec-code-lang.dtx}
+ \DTX{fontspec-code-feat-aat.dtx}
+ \DTX{fontspec-code-enc.dtx}
+ \DTX{fontspec-code-math.dtx}
+ \DTX{fontspec-code-closing.dtx}
+ \DTX{fontspec-code-xfss.dtx}
+ \DTX{fontspec-code-patches.dtx}
+}
+%</dtx>
+% \end{macrocode}
+%
+% Now exit if we're using plain \TeX; this would usually be the case when
+% loading this file with \texttt{fontspec.ins}.
+% \begin{macrocode}
+%<*dtx>
+\def\tmpa{plain}
+\ifx\tmpa\fmtname\expandafter\endinput\fi
+%</dtx>
+% \end{macrocode}
+%
+% Metadata for documentation; the official title and authors of the package.
+% \begin{macrocode}
+%<*dtx>
+\title{
+ The \textsf{fontspec} package\\
+ Font selection for \XeLaTeX\ and \LuaLaTeX
+}
+\author{
+ \textsc{Will Robertson}\\
+ With contributions by Khaled Hosny,\\
+ Philipp Gesang, Joseph Wright, and others.\\
+ \url{http://wspr.io/fontspec/}
+}
+%</dtx>
+% \end{macrocode}
+%
+% Declare the package version and date for each of the \texttt{.sty} files generated.
+% In addition, declare the version and date for this \texttt{.dtx} file.
+% \begin{macrocode}
+%<fontspec>\RequirePackage{xparse}
+%<fontspec&load>\ProvidesExplPackage{fontspec}%
+%<fontspec&XE>\ProvidesExplPackage{fontspec-xetex}%
+%<fontspec&LU>\ProvidesExplPackage{fontspec-luatex}%
+%<*dtx>
+\RequirePackage{xparse}
+\ProvidesExplFile{fontspec.dtx}
+%</dtx>
+%<*fontspec>
+ {2019/03/15}{2.7c}{Font selection for XeLaTeX and LuaLaTeX}
+%</fontspec>
+% \end{macrocode}
+%
+% Here the version and date are setup for typesetting the documentation.
+% \begin{macrocode}
+%<*dtx>
+\GetFileInfo{fontspec.dtx}
+\date{\filedate \qquad \fileversion}
+%</dtx>
+% \end{macrocode}
+%
+% \subsection{\textsf{Lua} header}
+%
+% \begin{macrocode}
+%<lua>fontspec = fontspec or {}
+%<lua>local fontspec = fontspec
+%<lua>fontspec.module = {
+%<lua> name = "fontspec",
+%<lua> version = "2.7c",
+%<lua> date = "2019/03/15",
+%<lua> description = "Font selection for XeLaTeX and LuaLaTeX",
+%<lua> author = "Khaled Hosny, Philipp Gesang, Will Robertson",
+%<lua> copyright = "Khaled Hosny, Philipp Gesang, Will Robertson",
+%<lua> license = "LPPL v1.3c"
+%<lua>}
+% \end{macrocode}
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec.ins b/macros/latex/contrib/fontspec/fontspec.ins
new file mode 100644
index 0000000000..bd49db003b
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec.ins
@@ -0,0 +1,60 @@
+%%^^A%% fontspec.ins -- part of FONTSPEC <wspr.io/fontspec>
+
+\input fontspec.dtx\relax
+\input l3docstrip.tex\relax
+
+\keepsilent
+\usedir{tex/latex/fontspec}
+\let\MetaPrefix\relax
+\preamble
+------------------------------------------------
+The FONTSPEC package <wspr.io/fontspec>
+------------------------------------------------
+Copyright 2004-2017 Will Robertson, LPPL "maintainer"
+Copyright 2009-2013 Khaled Hosny
+------------------------------------------------
+This package is free software and may be redistributed and/or modified under
+the conditions of the LaTeX Project Public License, version 1.3c or higher
+(your choice): <http://www.latex-project.org/lppl/>.
+------------------------------------------------
+\endpreamble
+\nopostamble
+\askforoverwritefalse
+
+\def\MetaPrefix{-- }
+\generate{\file{fontspec.lua}{
+ \from{fontspec.dtx}{lua}
+ \from{fontspec-lua.dtx}{lua}
+}}
+
+\let\MetaPrefix\DoubleperCent
+\ifx\FontspecDebug\undefined\def\FSDEBUG{}\else\def\FSDEBUG{,debug}\fi
+
+\generate{\file{fontspec.sty}{
+ \from{fontspec.dtx}{fontspec,load\FSDEBUG}
+ \from{fontspec-code-load.dtx}{fontspec,load\FSDEBUG}
+}}
+
+\def\DTX#1{\from{#1}{fontspec,XE\FSDEBUG}}
+\generate{\file{fontspec-xetex.sty}{\FONTSPECDTX}}
+
+\def\DTX#1{\from{#1}{fontspec,LU\FSDEBUG}}
+\generate{\file{fontspec-luatex.sty}{\FONTSPECDTX}}
+
+\endbatchfile
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec.ltx b/macros/latex/contrib/fontspec/fontspec.ltx
new file mode 100644
index 0000000000..7ee948df54
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec.ltx
@@ -0,0 +1,40 @@
+%%^^A%% fontspec.ltx -- part of FONTSPEC <wspr.io/fontspec>
+
+\ifdefined \XeTeXOTcountscripts \else \makeatletter
+ \@latex@error{^^J*** The fontspec documentation can only be typeset with `xelatex` ***\@gobble}\@ehc
+\fi
+
+\documentclass[a4paper]{l3doc}
+\usepackage{fontspec-doc-style}
+\begin{document}
+\maketitle
+\tableofcontents
+\newpage
+
+\include{fontspec-doc-intro}
+\include{fontspec-doc-fontsel}
+\include{fontspec-doc-featset}
+\include{fontspec-doc-opentype}
+\include{fontspec-doc-enc}
+\include{fontspec-doc-luatex}
+\include{fontspec-doc-xetex}
+\include{fontspec-doc-api}
+
+\end{document}
+
+\endinput
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2019 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/
diff --git a/macros/latex/contrib/fontspec/fontspec.pdf b/macros/latex/contrib/fontspec/fontspec.pdf
new file mode 100644
index 0000000000..594815b868
--- /dev/null
+++ b/macros/latex/contrib/fontspec/fontspec.pdf
Binary files differ