% -*- coding: utf-8 -*-
% SPDX-FileCopyrightText: © 2026 Franz Glasner
% SPDX-License-Identifier: BSD-3-Clause OR MIT
%
% Some font hacks for my Sphinx PDF documents.
% Needs a LaTeX environment with a working `fontspec' package.
%
% Options:
% - nomath:     Disable math support completely
% - noglobalunicodemath: Do not load unicode-math globally but only when
%                        really needed
% - fonts=<FONT>: Use font pairing named <FONT>. See the list below.
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{my-doc-fonts}[%
  2026/06/06 rv:ddd6d2bb4fdb (Franz Glasner) Fonts for Sphinx generated PDFs]
\RequirePackage{xkeyval}
\RequirePackage{fontspec}
\IfFileExists{xcolor.sty}{%
% Should Sphinx load xcolor with its dvipsnames and svgnames options?
    \RequirePackage{xcolor}
}{%
    \RequirePackage{color}
}

\def\if@mdf@optionequalTF#1#2{%
  \begingroup
  \edef\@mdf@tmpa{#1}
  \def\@mdf@tmpb{#2}
  \ifx\@mdf@tmpa\@mdf@tmpb
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup%
}

\newif\if@mdf@mono@dejavusansmono\@mdf@mono@dejavusansmonofalse
\newif\if@mdf@mono@cmmono\@mdf@mono@cmmonofalse
\newif\if@mdf@mono@robotomono\@mdf@mono@robotomonofalse
\newif\if@mdf@mono@sscode\@mdf@mono@sscodefalse
\newif\if@mdf@mono@inconsolata\@mdf@mono@inconsolatafalse
\newif\if@mdf@mono@libertinusmono\@mdf@mono@libertinusmonofalse
\newif\if@mdf@mono@hackmono\@mdf@mono@hackmonofalse
\newif\if@mdf@mono@firamono\@mdf@mono@firamonofalse
\newif\if@mdf@mono@firamonomedium\@mdf@mono@firamonomediumfalse
\newif\if@mdf@mono@gomono\@mdf@mono@gomonofalse
\newif\if@mdf@augment@cmutypewritertext\@mdf@augment@cmutypewritertextfalse
\newif\if@mdf@augment@libertinusmono\@mdf@augment@libertinusmonofalse
\newif\if@mdf@augment@ibmplexmono\@mdf@augment@ibmplexmonofalse
\newif\if@mdf@augment@redhatmono\@mdf@augment@redhatmonofalse
\newif\if@mdf@augment@cascadiacode\@mdf@augment@cascadiacodefalse
\newif\if@mdf@augment@jetbrainsmono\@mdf@augment@jetbrainsmonofalse
\newif\if@mdf@augment@firamono\@mdf@augment@firamonofalse
\newif\if@mdf@augment@gomono\@mdf@augment@gomonofalse

\newif\if@mdf@GlobalUnicodeMath\@mdf@GlobalUnicodeMathtrue
\DeclareOptionX{noglobalunicodemath}{\@mdf@GlobalUnicodeMathfalse}

\newif\if@mdf@UseUnicodeMath\@mdf@UseUnicodeMathtrue
\DeclareOptionX{nomath}{\@mdf@UseUnicodeMathfalse}

\newcommand*{\@mdf@externalname}{}
\DeclareOptionX{externalname}[custom]{\renewcommand*{\@mdf@externalname}{#1}}

\newcommand*{\@mdf@linespread}{}
\DeclareOptionX{linespread}[]{\renewcommand*{\@mdf@linespread}{#1}}

\newif\if@mdf@NeedUprightUnicodeMath\@mdf@NeedUprightUnicodeMathfalse

% Reset all option related font selection flags
\def\@mdf@reset@all@font@options{
  \@mdf@NeedUprightUnicodeMathfalse
}


\gdef\@mdf@option@fonts{}% The original option value
\gdef\@mdf@option@fonts@selection{}% The effective selection "flag"

% A key compatible with options processing as option "fonts" but choices.
\define@choicekey*{my-doc-fonts.sty}{fonts}[\val\nr]{%
  % do not change anything: just deactivate the default "dejavusansmono"
  default,
  external,        % Load font settings from external style files
  % almost no augmentation needed: all characters available
  dejavusansmono,  % use DejaVu Sans Mono as monospaced font
  % the fonts below are augmented for missing characters
  cm,              % assume CM fonts and just fix missing characters
  ibmplex, plex,   % use the IBM Plex family (incl. Math)
  ibmplex-sans, plex-sans,  % Like ibmplex but switch to sans body
  plex-dejavusansmono,  % use IBM Plex Serif/Sans and DejaVu Sans Mono
  adobesourcepro, adobesource,  % Use Adobe Source Serif/Sans/Mono
  adobesourcepro-sans, adobesource-sans,  % Like adobesourcepro but sans body
  spectral,        % use Spectral, Source Sans Pro and Source Code Pro
  charter,         % use XCharter (with XCharter Math), Lato and Inconsolata
  libertinus,      % use Libertinus family (incl. Math)
  garamond,        % EB Garamond (with Math), Libre Franklin and Inconsolata
  tufte,      % Tufte fonts: ETbb (with Math), GilliusADFNo2, DejaVu Sans Mono
  tufte-hack, % Tufte variant: ETbb (with Math), GilliusADFNo2, Hack
  tufte-firamono,  % Tufte variant: ETbb (with Math), GilliusADFNo2, Fira Mono
  palatino,        % Palatino, Inter and Source Code Pro
  palatino-kb,     % Palatino,  Lato and Inconsolata (original KB-Admin style)
  palatino-rosario,% Palatino,  Rosario and CMU Typewriter Text (Asana Math)
  crimson,    % Crimson Pro, (Intel) Clear Sans and Roboto Mono (Erewhon Math)
  crimson-cabin,   % Crimson Pro, Cabin and Source Code Pro (Erewhon Math)
  dejavu,          % All DejaVu fonts (Serif, Sans, Mono)
  merriweather,    % Merriweather, Merriweather Sans, Hack (Concrete Math)
  merriweather-light, % Merriweather Light, Merriweather Sans Light, DejaVu Sans Mono (Concrete Math)
  merriweather-sans, % Merriweather, Merriweather Sans, Cascadia Code (Lete Sans Math)
  merriweather-sans-light, % Merriweather Light, Merriweather Sans Light, Cascadia Code Light (Asana Math)
  literata,            % Literata, Inter, IBM Plex Mono (Concrete Math)
  literata-firamono,   % Literata, Inter, Fira Mono Medium (Concrete Math)
  literata-robotomono, % Literata, Cabin, Roboto Mono (Concrete Math)
  vollkorn,        % Vollkorn, Jost, Cascadia Code (STIX 2 Math)
  erewhon, utopia, % Erewhon, Rosario, Hack, (Erewhon Math)
  gentium,         % Gentium, Alegreya Sans, JetBrains Mono, (Euler Math)
  zillaslab,       % Zilla Slab, Metropolis, IBM Plex Mono Text, (Concrete Math)
  aleo,            % Aleo, Lato, IBM Plex Mono Text, (Euler Math)
  lato,            % Lato, Aleo, IBM Plex Mono Text, (Lete Sans Math)
  lora,            % Lora, Libre Franklin, Go Mono, (Asana Math)
  stix,            % STIX 2 Text, Inter, CMU Typewriter Text, (STIX 2 Math)
  baskerville,     % Libre Baskerville, Metropolis Medium, CMU Typewriter Text, (Euler Math)
  opensans,        % Crimson Pro, Open Sans, IBM Plex Mono, (Erewhon Math)
  firasans,        % Merriweather, Fira Sans, Fira Mono, (Fira Math)
  }{%
  % Not used for now : store the gioven option value (global and expanded)
  \xdef\@mdf@option@fonts{\val}%
  % Not used for now : store the effective option value (global and expanded)
  \xdef\@mdf@option@fonts@selection{\val}%
  % Reset all option related font selection flags
  \@mdf@reset@all@font@options
  % Now set the needed font selection flag
  \ifcase\nr\relax
    \relax% default
  \or
    \relax% external
  \or
    \relax% dejavusansmono
  \or
    \relax% cm
  \or
    \relax % ibmplex
  \or
    \gdef\@mdf@option@fonts@selection{ibmplex}% plex
  \or
    \gdef\@mdf@option@fonts@selection{ibmplex}% ibmplex-sans
  \or
    \gdef\@mdf@option@fonts@selection{ibmplex}% plex-sans
  \or
    \relax% plex-dejavusansmono
  \or
    \relax% adobesourcepro
  \or
    \gdef\@mdf@option@fonts@selection{adobesourcepro}% adobesource
  \or
    \gdef\@mdf@option@fonts@selection{adobesourcepro}% adobesourcepro-sans
  \or
    \gdef\@mdf@option@fonts@selection{adobesourcepro}% adobesource-sans
  \or
    \relax% spectral
  \or
    \relax% charter
  \or
    \relax% libertinus
  \or
    \relax% garamond
  \or
    \relax% tufte
  \or
    \relax% tufte-hack
  \or
    \relax% tufte-firamono
  \or
    \relax% palatino
  \or
    \relax% palatino-kb
  \or
    \relax% palatino-rosario
  \or
    \relax% crimson
  \or
    \relax% crimson-cabin
  \or
    \relax% dejavu
  \or
    \relax% merriweather
  \or
    \relax% merriweather-light
  \or
    \relax% merriweather-sans
  \or
    \relax% merriweather-sans-light
  \or
    \relax% literata
  \or
    \relax% literata-firamono
  \or
    \relax% literata-robotomono
  \or
    \relax% vollkorn
  \or
    \relax% erewhon
  \or
    \gdef\@mdf@option@fonts@selection{erewhon}% utopia
  \or
    \@mdf@NeedUprightUnicodeMathtrue% gentium
  \or
    \relax% zillaslab
  \or
    \@mdf@NeedUprightUnicodeMathtrue% aleo
  \or
    \relax% lato
  \or
    \relax% lora
  \or
    \relax% stix
  \or
    \@mdf@NeedUprightUnicodeMathtrue% baskerville
  \or
    \relax% opensans
  \or
    \relax% firasans
  \else
    \PackageError{my-doc-fonts}{Inconsistent font selection!}{}
  \fi
}

%
% By default use the safe option dejavusansmono because is contains
% all characters without any hacks.
%
\ExecuteOptionsX{fonts=dejavusansmono,externalname}
\ProcessOptionsX\relax

%
% Provide a command (to be redefined if needed) to customize central
% mono font features
%
\newcommand{\@mfd@extra@mono@features}{}

\if@mdf@UseUnicodeMath
  \if@mdf@GlobalUnicodeMath
    \if@mdf@NeedUprightUnicodeMath
      \RequirePackage[math-style=upright]{unicode-math}
    \else
      \RequirePackage{unicode-math}
    \fi
  \fi
\fi

%
% An command to load DejaVuSans fonts for character substitution
%
\def\@mdf@provide@dejavu@mono@families{%
  \ifdefined\DejaVuSansMono%
    \relax%
  \else%
    \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[%
      UprightFont = *,
      BoldFont = * Bold,
      ItalicFont = * Oblique,
      BoldItalicFont = * Bold Oblique,
      \@mfd@extra@mono@features
    ]
  \fi
  \ifdefined\DejaVuSansCondensed%
    \relax%
  \else%
    \newfontfamily\DejaVuSansCondensed{DejaVu Sans Condensed}[%
      UprightFont = *,
      BoldFont = * Bold,
      ItalicFont = * Oblique,
      BoldItalicFont = * Bold Oblique,
      \@mfd@extra@mono@features
    ]
  \fi
}

% Apply a custom lineapread -- if any
\ifx\@mdf@linespread\@empty\relax\else\linespread{\@mdf@linespread}\fi

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{external}{%
  \InputIfFileExists{\@mdf@externalname.fonts}{%
    \PackageInfo{my-doc-fonts}{Loading \@mdf@externalname.fonts font style file}
  }{%
    \PackageError{my-doc-fonts}{Style file \@mdf@externalname.fonts not found}{Provide it or change the file}
  }
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{dejavusansmono}{%
  % default but with DejaVu Sans Mono as monospaced font
  %\RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf}
  %\RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf}  % all symbols are available
  \@mdf@mono@dejavusansmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{cm}{%
  \@mdf@mono@cmmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{ibmplex}{%
  \if@mdf@UseUnicodeMath
    \RequirePackage[%
      DefaultFeatures={Scale=0.92},
      RMSCfont={},% disable default SC font which uses TeX Gyre Termes
      RM={%
        %SmallCapsFont=XCharter-Roman,
        SmallCapsFont=SourceSerifPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        %BoldFeatures={SmallCapsFont=XCharter-Bold},%
        BoldFeatures={SmallCapsFont=SourceSerifPro-Bold},%
        %ItalicFeatures={SmallCapsFont=XCharter-Italic},%
        ItalicFeatures={SmallCapsFont=SourceSerifPro-RegularIt},%
      },
      SSSCfont={},% disable default SC font which uses TeX Gyre Heros
      SS={%
        SmallCapsFont=SourceSansPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSansPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSansPro-RegularIt},%
      },%
      math=true]{plex-otf}
  \else
    \RequirePackage[%
      DefaultFeatures={Scale=0.92},
      RMSCfont={},% disable default SC font which uses TeX Gyre Termes
      RM={%
        SmallCapsFont=SourceSerifPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSerifPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSerifPro-RegularIt},%
      },
      SSSCfont={},% disable default SC font which uses TeX Gyre Heros
      SS={%
        SmallCapsFont=SourceSansPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSansPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSansPro-RegularIt},%
      },%
      math=false]{plex-otf}
  \fi
  \@mdf@augment@ibmplexmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{plex-dejavusansmono}{%
  \if@mdf@UseUnicodeMath
    \RequirePackage[%
      DefaultFeatures={Scale=0.92},
      RMSCfont={},% disable default SC font which uses TeX Gyre Termes
      RM={%
        SmallCapsFont=SourceSerifPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSerifPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSerifPro-RegularIt},%
      },%
      SSSCfont={},% disable default SC font which uses TeX Gyre Heros
      SS={%
        SmallCapsFont=SourceSansPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSansPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSansPro-RegularIt},%
      },%
      mono=false]{plex-otf}
  \else
    \RequirePackage[%
      DefaultFeatures={Scale=0.92},
      RMSCfont={},% disable default SC font which uses TeX Gyre Termes
      RM={%
        SmallCapsFont=SourceSerifPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSerifPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSerifPro-RegularIt},%
      },%
      SSSCfont={},% disable default SC font which uses TeX Gyre Heros
      SS={%
        SmallCapsFont=SourceSansPro-Regular,%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},%
        BoldFeatures={SmallCapsFont=SourceSansPro-Bold},%
        ItalicFeatures={SmallCapsFont=SourceSansPro-RegularIt},%
      },%
      mono=false,%
      math=false]{plex-otf}
  \fi
  \@mdf@mono@dejavusansmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{adobesourcepro}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Source Serif Pro}[
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Source Sans Pro}[
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}
    \setmathfont{XCharter Math}[%
      Scale = MatchLowercase,
    ]
  \fi
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 0.97,}
  \@mdf@mono@sscodetrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{spectral}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Spectral}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Source Sans Pro}[
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \if@mdf@UseUnicodeMath
    \setmathfont{STIX Two Math}[Scale=MatchLowercase]
  \fi
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 0.98,}
  \@mdf@mono@sscodetrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{charter}{%
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \RequirePackage{xcharter-otf}% ALWAYS loads also XCharter Math
  \defaultfontfeatures{}% Reset from package
  \setsansfont{Lato}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    Scale = MatchLowercase,
    Numbers = {Lining, Tabular},
    Ligatures = TeX,
  ]
  \@mdf@mono@inconsolatatrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{libertinus}{%
  \RequirePackage{newunicodechar}
  \if@mdf@UseUnicodeMath
    \RequirePackage[lining,tabular]{libertinus-otf}
    \defaultfontfeatures{}% Reset from package
    \setmathfont{Asana Math}[range={"2713,"2AB7,"22D0},Scale=MatchLowercase]
    \setmathfont{Libertinus Math}[range={},Scale=MatchLowercase]
  \else
    \RequirePackage[lining,tabular,nomath]{libertinus-otf}
  \fi
  \@mdf@augment@libertinusmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{garamond}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \RequirePackage[lining,tabular]{ebgaramond}
  \defaultfontfeatures{}% Reset from package
  \if@mdf@UseUnicodeMath
    \setmathfont{Garamond-Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2713},Scale=MatchLowercase]
    \setmathfont{Garamond-Math}[range={},Scale=MatchLowercase]
  \fi
  \setsansfont{Libre Franklin}[Scale=MatchLowercase,Ligatures=TeX,Numbers={Lining,Tabular}]
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 1.02,}
  \@mdf@mono@inconsolatatrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{tufte-hack}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{ETbb}
  \setsansfont{GilliusADFNo2}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \setmathfont{Libertinus Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2713,"2AB7,"22D0},Scale=MatchLowercase]
    \setmathfont{Libertinus Math}[range={},Scale=MatchLowercase]
  \fi
  \@mdf@mono@hackmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{tufte-firamono}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{ETbb}
  \setsansfont{GilliusADFNo2}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \setmathfont{Libertinus Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2713,"2AB7,"22D0},Scale=MatchLowercase]
    \setmathfont{Libertinus Math}[range={},Scale=MatchLowercase]
  \fi
  \@mdf@mono@firamonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{tufte}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{ETbb}
  \setsansfont{GilliusADFNo2}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \setmathfont{Libertinus Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2713,"2AB7,"22D0},Scale=MatchLowercase]
    \setmathfont{Libertinus Math}[range={},Scale=MatchLowercase]
  \fi
  \@mdf@mono@dejavusansmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{palatino}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{TeXGyrePagellaX}
  \setsansfont{Inter}[Scale=MatchLowercase]
  %\setsansfont{Rosario}[Scale=MatchLowercase,ScaleAgain=1.013]
  %\setmathfont{Asana Math}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \setmathfont{TeX Gyre Pagella Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2AB7},Scale=MatchLowercase]
    \setmathfont{TeX Gyre Pagella Math}[range={},Scale=MatchLowercase]
  \fi
  %\@mdf@mono@sscodetrue
  \@mdf@mono@libertinusmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{palatino-kb}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{TeXGyrePagellaX}
  \setsansfont{Lato}[%
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    Scale=MatchLowercase]
  %\setsansfont{Rosario}[Scale=MatchLowercase,ScaleAgain=1.013]
  %\setmathfont{Asana Math}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \setmathfont{TeX Gyre Pagella Math}[Scale=MatchLowercase]
    \setmathfont{Asana Math}[range={"2AB7},Scale=MatchLowercase]
    \setmathfont{TeX Gyre Pagella Math}[range={},Scale=MatchLowercase]
  \fi
  \@mdf@mono@inconsolatatrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{palatino-rosario}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{Numbers={Lining,Tabular},Ligatures=TeX}
  \setmainfont{TeXGyrePagellaX}
  \setsansfont{Rosario}[%
    Scale=MatchLowercase,
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setmonofont{CMU Typewriter Text}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{Asana Math}
  \fi
  \@mdf@augment@cmutypewritertexttrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{crimson}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX, Numbers={Lining,Tabular}}
  \setmainfont{Crimson Pro}[%
    SmallCapsFont = Erewhon Regular,
    SmallCapsFeatures = {Letters = SmallCaps, Scale = MatchLowercase},
    BoldFeatures = {SmallCapsFont = Erewhon Bold},
    ItalicFeatures = {SmallCapsFont = Erewhon Italic},
  ]
  %\setsansfont{Open Sans}[Scale=MatchLowercase]
  \setsansfont{Clear Sans}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}% Erewhon Math needs this here!
    \setmathfont{Erewhon Math}[Scale=MatchLowercase]
  \fi
  %\@mdf@mono@sscodetrue
  %\@mdf@mono@inconsolatatrue
  \@mdf@mono@robotomonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{crimson-cabin}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX, Numbers={Lining,Tabular}}
  \setmainfont{Crimson Pro}[%
    SmallCapsFont = Erewhon Regular,
    SmallCapsFeatures = {Letters=SmallCaps, Scale=MatchLowercase},
    BoldFeatures = {SmallCapsFont = Erewhon Bold},
    ItalicFeatures = {SmallCapsFont = Erewhon Italic},
  ]
  \setsansfont{Cabin}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}% Erewhon Math needs this here!
    \setmathfont{Erewhon Math}[Scale=MatchLowercase]
  \fi
  %\@mdf@mono@sscodetrue
  \@mdf@mono@inconsolatatrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{opensans}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.05}\fi
  \defaultfontfeatures{Ligatures=TeX, Numbers={Lining,Tabular}}
  \setmainfont{Open Sans}
  \setmainfont{Crimson Pro}[%
    Scale = MatchLowercase,
    SmallCapsFont = Erewhon Regular,
    SmallCapsFeatures = {Letters=SmallCaps, Scale=MatchLowercase},
    BoldFeatures = {SmallCapsFont = Erewhon Bold},
    ItalicFeatures = {SmallCapsFont = Erewhon Italic},
  ]
  \setsansfont{Open Sans}[
    SmallCapsFont = {Montserrat Regular},
    SmallCapsFeatures = {Letters = SmallCaps, Scale = MatchLowercase, ScaleAgain = 0.99},
    ItalicFeatures = {SmallCapsFont = {Montserrat Italic}},
    BoldFeatures = {SmallCapsFont = {Montserrat Bold}},
    BoldItalicFeatures = {SmallCapsFont = {Montserrat Bold Italic}},
  ]
  \setmonofont{IBMPlexMonoText}[%
    Scale = MatchLowercase,
    ScaleAgain = 0.96,
    Extension = .otf,
    UprightFont= IBMPlexMono-Regular,
    BoldFont = IBMPlexMono-Bold,
    ItalicFont = IBMPlexMono-Italic,
    BoldItalicFont = IBMPlexMono-BoldItalic,
    SlantedFont = IBMPlexMono-TextItalic,
  ]
  \@mdf@augment@ibmplexmonotrue
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}% Erewhon Math needs this here!
    \setmathfont{Erewhon Math}[Scale=MatchLowercase]
  \fi
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{dejavu}{%
  \RequirePackage{newunicodechar}
  % automatically applied with Scale=MatchLowercase,...
  \if@mdf@UseUnicodeMath
    \RequirePackage[%
      RM={%
        Scale = 0.92,% as in dejavu-otf
        SmallCapsFont = {XCharter-Roman.otf},%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.12},%
        ItalicFeatures = {SmallCapsFont = {XCharter-Italic.otf}},%
        BoldFeatures = {SmallCapsFont = {XCharter-Bold.otf}},%
        BoldItalicFeatures = {SmallCapsFont = {XCharter-BoldItalic.otf}},%
      },%
      SS={Scale = 0.92},%
      TT={Scale=MatchLowercase,FakeStretch=0.98,ScaleAgain=1.02},%
      mono=true,serif=true,sans=true,math=true]{dejavu-otf}
      \setmathfont{XCharter Math}[range={"2713,"2AB7},Scale=MatchLowercase]
      \setmathfont{DejaVu Math TeX Gyre}[range={},Scale=MatchLowercase]
      %\setmathfont{DejaVu Math TeX Gyre}[range={},version=normal]
      %\setmathfont{DejaVu Math TeX Gyre}[range={},FakeBold=3,version=bold]
  \else
    \RequirePackage[%
      RM={%
        Scale = 0.92,% as in dejavu-otf
        SmallCapsFont = {XCharter-Roman.otf},%
        SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.12},%
        ItalicFeatures = {SmallCapsFont = {XCharter-Italic.otf}},%
        BoldFeatures = {SmallCapsFont = {XCharter-Bold.otf}},%
        BoldItalicFeatures = {SmallCapsFont = {XCharter-BoldItalic.otf}},%
      },%
      SS={Scale = 0.92},%
      TT={Scale=MatchLowercase,FakeStretch=0.98,ScaleAgain=1.02},%
      mono=true,serif=true,sans=true,math=false]{dejavu-otf}
  \fi
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  %
  % Try to fix for missing \mathrm:
  % https://tex.stackexchange.com/questions/669382/latex-error-math-alphabet-identifier-mathrm-is-undefined-in-math-version
  %
  % DOES NOT WORK!
  %\mathversion{normal}\let\mathrm\symup
  % THIS WORKS (see also unicode-math.pdf Section 4.4.3 Operator font):
  \if@mdf@UseUnicodeMath
    \setoperatorfont\symup
  \fi
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{merriweather}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{%
    Scale = 0.92,
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
    Extension = .otf,
  }
  \setmainfont{Merriweather}[%
    UprightFont = *-Regular ,
    ItalicFont = *-Italic ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldItalic
  ]
  \setsansfont{MerriweatherSans}[%
    UprightFont = *-Regular ,
    ItalicFont = *-Italic ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldItalic
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage[no-text]{concmath-otf}% for concmath-otf
  \fi
  \@mdf@mono@hackmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{merriweather-light}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{%
    Scale = 0.92,
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
    Extension = .otf,
  }
  \setmainfont{Merriweather}[%
    UprightFont = *-Light ,
    ItalicFont = *-LightItalic ,
    BoldFont = *-Regular ,
    BoldItalicFont = *-Italic
  ]
  \setsansfont{MerriweatherSans}[%
    UprightFont = *-Light ,
    ItalicFont = *-LightItalic ,
    BoldFont = *-Regular ,
    BoldItalicFont = *-Italic
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage[no-text]{concmath-otf}% for concmath-otf
  \fi
  %\@mdf@mono@hackmonotrue
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 0.98,}
  \@mdf@mono@dejavusansmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{merriweather-sans}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{%
    Scale = 0.92,
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
    Extension = .otf,
  }
  \setmainfont{Merriweather}[%
    UprightFont = *-Regular ,
    ItalicFont = *-Italic ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldItalic
  ]
  \setsansfont{MerriweatherSans}[%
    UprightFont = *-Regular ,
    ItalicFont = *-Italic ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldItalic
  ]
  \defaultfontfeatures{Ligatures = TeX, Numbers = {Lining,Tabular}}
  \setmonofont{CascadiaCode}[Scale=MatchLowercase, ScaleAgain=0.98]
  \@mdf@augment@cascadiacodetrue

  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage{lete-sans-math}
  \fi
%  \@mdf@mono@hackmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{merriweather-sans-light}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \defaultfontfeatures{%
    Scale = 0.92,
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
    Extension = .otf,
  }
  \setmainfont{Merriweather}[%
    UprightFont = *-Light ,
    ItalicFont = *-LightItalic ,
    BoldFont = *-Regular ,
    BoldItalicFont = *-Italic
  ]
  \setsansfont{MerriweatherSans}[%
    UprightFont = *-Light ,
    ItalicFont = *-LightItalic ,
    BoldFont = *-Regular ,
    BoldItalicFont = *-Italic ,
  ]
  \defaultfontfeatures{Ligatures = TeX, Numbers = {Lining,Tabular}}
  \setmonofont{CascadiaCode}[
    Scale = MatchLowercase,
    ScaleAgain = 0.97,
    UprightFont = *-Light,
    ItalicFont = *-LightItalic,
    BoldFont = *-Regular,
    BoldItalicFont = *-Italic]
  \@mdf@augment@cascadiacodetrue
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}
    \setmathfont{Asana Math}[Scale=MatchLowercase]
  \fi
%  \@mdf@mono@hackmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{firasans}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{%
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
  }
  \setmainfont{Fira Sans}
  %\setmainfont{Andada Pro}[Scale=MatchLowercase]
  \setmainfont{Merriweather}[%
    Extension = .otf,
    Scale = MatchLowercase,
    UprightFont = *-Regular ,
    ItalicFont = *-Italic ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldItalic
  ]
  \setsansfont{Fira Sans}[Scale=MatchLowercase]
  %\setmonofont{JetBrains Mono}[Scale=MatchLowercase, ScaleAgain=0.98]
  %\@mdf@augment@jetbrainsmonotrue
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain=0.98}
  \@mdf@mono@firamonotrue
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{Fira Math}
    \setmathfont{Lete Sans Math}[range={"22D0,"2713,"2A04,"2AB7}]
    \setmathfont{Fira Math}[range={}]
  \fi
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{literata}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{%
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
  }
  \setmainfont{Literata}
  \setsansfont{Inter}[Scale=MatchLowercase]
  \setmonofont{IBMPlexMono}[%
    Scale = MatchLowercase,
    ScaleAgain = 0.98,
    Extension = .otf,
    UprightFont= *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic,
    SlantedFont = *-Italic,
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}% for concmath-otf and Plex Mono
    \RequirePackage[no-text]{concmath-otf}
  \fi
  \@mdf@augment@ibmplexmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{literata-firamono}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{%
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
  }
  \setmainfont{Literata}
  \defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
  \setsansfont{Inter}
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage[no-text]{concmath-otf}% for concmath-otf
  \fi
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 0.98,}
  \@mdf@mono@firamonomediumtrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{literata-robotomono}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{%
    Ligatures = TeX,
    Numbers = {Lining,Tabular},
  }
  \setmainfont{Literata}
  \setsansfont{Cabin}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage[no-text]{concmath-otf}% for concmath-otf
  \fi
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain = 0.985,}
  \@mdf@mono@robotomonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{vollkorn}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Vollkorn}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Jost}[%
    Scale = MatchLowercase,
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setmonofont{Cascadia Code}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{STIX Two Math}
  \fi
  \@mdf@augment@cascadiacodetrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{erewhon}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Erewhon}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Rosario}[%
    Scale = MatchLowercase,
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{Erewhon Math}
  \fi
  \@mdf@mono@hackmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{gentium}{%
  \if@mdf@UseUnicodeMath\RequirePackage[math-style=upright]{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Gentium}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Alegreya Sans}[%
    Scale = MatchLowercase,
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setmonofont{JetBrains Mono}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \RequirePackage[Scale=MatchLowercase]{euler-math}
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{XCharter Math}[range={"03F1,"1D71A}]
    \setmathfont{Euler Math}[range={}]
    %\setmathfont{Euler Math}
    %\renewcommand{\varrho}{\rho}
    %\renewcommand{\rho}{\mbfsansrho}
  \fi
  \@mdf@augment@jetbrainsmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{zillaslab}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Zilla Slab}[
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Metropolis}[%
    Scale=MatchLowercase,
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Regular Italic,
    BoldItalicFont = * Bold Italic,
  ]
%  \defaultfontfeatures{Scale=MatchLowercase}
%  \setmonofont{JetBrains Mono}[%
%    Ligatures = TeX
  %  ]
  \setmonofont{IBMPlexMonoText}[%
    Scale=MatchLowercase,
    Extension = .otf,
    UprightFont= IBMPlexMono-Text,
    BoldFont = IBMPlexMono-Bold,
    ItalicFont = IBMPlexMono-TextItalic,
    BoldItalicFont = IBMPlexMono-BoldItalic,
    SlantedFont = IBMPlexMono-TextItalic,
  ]
  \@mdf@augment@ibmplexmonotrue

  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \RequirePackage[no-text]{concmath-otf}% for concmath-otf
  \fi
  %\@mdf@augment@jetbrainsmonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{aleo}{%
  \if@mdf@UseUnicodeMath\RequirePackage[math-style=upright]{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Aleo}[
    Extension = .ttf,
    UprightFont = {Aleo-VariableFont_wght} ,
    UprightFeatures = {Instance = Regular} ,
    ItalicFont = {Aleo-Italic-VariableFont_wght} ,
    ItalicFeatures = {Instance = Italic} ,
    BoldFont = {Aleo-VariableFont_wght} ,
    BoldFeatures = {Instance = Bold} ,
    BoldItalicFont = {Aleo-Italic-VariableFont_wght} ,
    BoldItalicFeatures = {Instance = {Bold Italic}} ,
    SmallCapsFont = {ZillaSlab-Medium.otf} ,
    SmallCapsFeatures = {Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.1} ,
    ItalicFeatures = {SmallCapsFont = {ZillaSlab-MediumItalic.otf}} ,
    BoldFeatures = {SmallCapsFont = {ZillaSlab-Bold.otf}} ,
  ]
  \setsansfont{Lato}[%
    Scale = MatchLowercase,
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setmonofont{IBMPlexMonoText}[%
    Scale = MatchLowercase,
    Extension = .otf,
    UprightFont= IBMPlexMono-Text,
    BoldFont = IBMPlexMono-Bold,
    ItalicFont = IBMPlexMono-TextItalic,
    BoldItalicFont = IBMPlexMono-BoldItalic,
    SlantedFont = IBMPlexMono-TextItalic,
  ]
  \@mdf@augment@ibmplexmonotrue

  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}
    \RequirePackage[Scale=MatchLowercase]{euler-math}
    \setmathfont{XCharter Math}[range={"03F1,"1D71A},Scale=MatchLowercase]
    \setmathfont{Euler Math}[range={},Scale=MatchLowercase]
  \fi
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{lato}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  % Normal procecure because no size adjustments are needed
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{Aleo}[
    Extension = .ttf,
    UprightFont = {Aleo-VariableFont_wght} ,
    UprightFeatures = {Instance = Regular} ,
    ItalicFont = {Aleo-Italic-VariableFont_wght} ,
    ItalicFeatures = {Instance = Italic} ,
    BoldFont = {Aleo-VariableFont_wght} ,
    BoldFeatures = {Instance = Bold} ,
    BoldItalicFont = {Aleo-Italic-VariableFont_wght} ,
    BoldItalicFeatures = {Instance = {Bold Italic}} ,
    SmallCapsFont = {ZillaSlab-Medium.otf} ,
    SmallCapsFeatures = {Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.1} ,
    ItalicFeatures = {SmallCapsFont = {ZillaSlab-MediumItalic.otf}} ,
    BoldFeatures = {SmallCapsFont = {ZillaSlab-Bold.otf}} ,
  ]
  \setsansfont{Lato}[%
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    SmallCapsFont = {Raleway Medium},
    SmallCapsFeatures = {Letters = SmallCaps, Scale = MatchLowercase, ScaleAgain = 1.015},
    ItalicFeatures = {SmallCapsFont = {Raleway Medium Italic}},
    BoldFeatures = {SmallCapsFont = {Raleway Bold}},
  ]
  \setmonofont{IBMPlexMonoText}[%
    Scale = MatchLowercase,
    ScaleAgain = 0.97,
    Extension = .otf,
    UprightFont= IBMPlexMono-Text,
    BoldFont = IBMPlexMono-Bold,
    ItalicFont = IBMPlexMono-TextItalic,
    BoldItalicFont = IBMPlexMono-BoldItalic,
    SlantedFont = IBMPlexMono-TextItalic,
  ]
  \@mdf@augment@ibmplexmonotrue

  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}
    \RequirePackage{lete-sans-math}
  \fi
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{lora}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \ifx\@mdf@linespread\@empty\linespread{1.04}\fi
  \setmainfont{Lora}[%
    Scale = 0.98,
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    SmallCapsFont = {STIX Two Text},
    SmallCapsFeatures={Letters=SmallCaps, Scale=MatchLowercase, ScaleAgain=1.05},
    BoldFeatures={SmallCapsFont={STIX Two Text Bold}},
    ItalicFeatures={SmallCapsFont={STIX Two Text Italic}},
    BoldItalicFeatures={SmallCapsFont={STIX Two Text Bold Italic}},
  ]
  \setsansfont{Libre Franklin}[Scale=MatchLowercase]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{Asana Math}
  \fi
  %\@mdf@mono@libertinusmonotrue
  \renewcommand{\@mfd@extra@mono@features}{ScaleAgain  = 0.95,}
  \@mdf@mono@gomonotrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{baskerville}{%
  \if@mdf@UseUnicodeMath\RequirePackage[math-style=upright]{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \ifx\@mdf@linespread\@empty\linespread{1.06}\fi
  \setmainfont{Libre Baskerville}[%
    Scale=0.92,
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    %BoldItalicFont = * Bold Italic,   % no bold italic font for Baskerville
    SmallCapsFont = {Erewhon Regular},
    SmallCapsFeatures={%
      Letters = SmallCaps,
      Scale = MatchLowercase,
      ScaleAgain=1.16
    },
    BoldFeatures={SmallCapsFont={Erewhon Bold}},
    ItalicFeatures={SmallCapsFont={Erewhon Italic}},
    BoldItalicFeatures={SmallCapsFont={Erewhon Bold Italic}},
  ]
  \setsansfont{Metropolis}[%
    Scale = MatchLowercase,
    UprightFont= * Medium,
    ItalicFont = * Medium Italic,
    BoldFont = * Bold,
    BoldItalicFont = * Bold Italic,
  ]
  \setmonofont{CMU Typewriter Text}[%
    Scale = MatchLowercase,
    ScaleAgain = 0.98,
  ]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{}
    \RequirePackage[Scale=MatchLowercase]{euler-math}
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{XCharter Math}[range={"03F1,"1D71A}]
    \setmathfont{Euler Math}[range={}]
  \fi
  \@mdf@augment@cmutypewritertexttrue
}{}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{stix}{%
  \if@mdf@UseUnicodeMath\RequirePackage{unicode-math}\fi
  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
  \setmainfont{STIX Two Text}[%
    UprightFont = * Regular,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
  ]
  \setsansfont{Inter}[Scale=MatchLowercase]
  \setmonofont{CMU Typewriter Text}[Scale=MatchLowercase, ScaleAgain=0.97]
  \if@mdf@UseUnicodeMath
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmathfont{STIX Two Math}
  \fi
  \@mdf@augment@cmutypewritertexttrue
}{}

%
% MONO
%

% Used for most
\defaultfontfeatures{%
  Scale=MatchLowercase,
  Ligatures=TeX,
  Numbers={Lining,Tabular}
}

\if@mdf@mono@dejavusansmono
  \RequirePackage{newunicodechar}
  % automatically applied with Scale=MatchLowercase,...
%  \defaultfontfeatures{%
%    Ligatures=TeX,
%    Numbers={Lining,Tabular},
%    Scale=MatchLowercase,
%    \@mfd@extra@mono@features
%  }
  \RequirePackage[DefaultFeatures={Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase},mono=true,serif=false,sans=false,math=false,TT={\@mfd@extra@mono@features}]{dejavu-otf}  % almost all symbols are available
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
\fi

\if@mdf@mono@cmmono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≠}{{\DejaVuSansMono ≠}}% U+2260
  \newunicodechar{≤}{{\DejaVuSansMono ≤}}% U+2264
  \newunicodechar{≥}{{\DejaVuSansMono ≥}}% U+2265
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@mono@sscode
  \RequirePackage{newunicodechar}
  \setmonofont{Source Code Pro}[
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    \@mfd@extra@mono@features
  ]
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@mono@inconsolata
  \RequirePackage{newunicodechar}
  \setmonofont{Inconsolata LGC Nerd Font Mono}[%
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    \@mfd@extra@mono@features
  ]
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4

  %\RequirePackage{pifont}
  %\newunicodechar{✓}{\ding{51}}

  %\newunicodechar{✓}{{\DejaVuSansMono ✓}}% U+2713
\fi

\if@mdf@mono@robotomono
  \RequirePackage{newunicodechar}
  \setmonofont{Roboto Mono}[%
    UprightFont = *,
    BoldFont = * Bold,
    ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    \@mfd@extra@mono@features
  ]
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@mono@hackmono
  \RequirePackage{newunicodechar}
  \setmonofont{Hack}[\@mfd@extra@mono@features]
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{✓}{{\DejaVuSansMono ✓}}% U+2713
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@mono@firamono
  \setmonofont{Fira Mono}[%
    UprightFont = * Regular,
    ItalicFont = * Oblique,
    BoldFont = * Bold,
    BoldItalicFont = * Bold Oblique,
    \@mfd@extra@mono@features
  ]
  \@mdf@augment@firamonotrue
\fi

\if@mdf@mono@firamonomedium
  \setmonofont{Fira Mono}[%
    UprightFont = * Medium,
    ItalicFont = * Medium Oblique,
    BoldFont = * Bold,
    BoldItalicFont = * Bold Oblique,
    \@mfd@extra@mono@features
  ]
  \@mdf@augment@firamonotrue
\fi

\if@mdf@mono@libertinusmono
  \defaultfontfeatures{}
  % This is stolen from libertinus-otf.sty!
  \setmonofont{LibertinusMono}[%
    Ligatures = TeX,
    Numbers = {Lining, Tabular},
    Scale = MatchLowercase,
    FakeStretch = 0.94,
    UprightFont = *-Regular,
    ItalicFont = *-Regular,
    ItalicFeatures = {FakeSlant=0.2},
    SlantedFont = *-Regular,
    SlantedFeatures= {FakeSlant=0.2},
    BoldFont = *-Regular,
    BoldFeatures = {RawFeature={embolden=3}},
    BoldItalicFont = *-Regular,
    BoldItalicFeatures={FakeSlant=0.2,RawFeature={embolden=3}},
    Extension      = .otf,
    \@mfd@extra@mono@features
  ]
  \@mdf@augment@libertinusmonotrue
\fi

\if@mdf@mono@gomono
  \setmonofont{Go Mono}[%
    \@mfd@extra@mono@features
  ]
  \@mdf@augment@gomonotrue
\fi

%
% AUGMENT
%

% Used for all below
\defaultfontfeatures{%
  Scale=MatchLowercase,
  Ligatures=TeX,
  Numbers={Lining,Tabular}
}

\if@mdf@optionequalTF{\@mdf@option@fonts@selection}{external}{%
  \InputIfFileExists{\@mdf@externalname.augment}{%
  \PackageInfo{my-doc-fonts}{Loading \@mdf@externalname.augment font style file}}{}
}{}

\if@mdf@augment@ibmplexmono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  %\newunicodechar{^^^^2423}{{\DejaVuSansMono^^^^2423}}% U+2423
  %\newunicodechar{␣}{\textvisiblespace}% U+2423
  %\catcode`^^^^2423\active\protected\def^^^^2423{\textvisiblespace}

  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@augment@libertinusmono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≠}{{\DejaVuSansMono ≠}}% U+2260
  \newunicodechar{≤}{{\DejaVuSansMono ≤}}% U+2264
  \newunicodechar{≥}{{\DejaVuSansMono ≥}}% U+2265
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \newunicodechar{✓}{{\DejaVuSansMono ✓}}% U+2713
  %\newunicodechar{^^^^2423}{{\DejaVuSansMono^^^^2423}}% U+2423
  %\newunicodechar{␣}{\textvisiblespace}% U+2423
  %\catcode`^^^^2423\active\protected\def^^^^2423{\textvisiblespace}

  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@augment@redhatmono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
%  \newunicodechar{≠}{{\DejaVuSansMono ≠}}% U+2260
  \newunicodechar{≤}{{\DejaVuSansMono ≤}}% U+2264
  \newunicodechar{≥}{{\DejaVuSansMono ≥}}% U+2265
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@augment@cascadiacode
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@augment@jetbrainsmono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
%  \PassOptionsToPackage{%
%    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
%    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
%    {sphinx}
\fi

\if@mdf@augment@firamono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
  \newunicodechar{✓}{{\DejaVuSansMono ✓}}% U+2713

  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\if@mdf@augment@cmutypewritertext
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≠}{{\DejaVuSansMono ≠}}% U+2260
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{≤}{{\DejaVuSansMono ≤}}% U+2264
  \newunicodechar{≥}{{\DejaVuSansMono ≥}}% U+2265
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4
\fi

\if@mdf@augment@gomono
  \RequirePackage{newunicodechar}
  \@mdf@provide@dejavu@mono@families
  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
  \newunicodechar{▹}{{\DejaVuSansMono ▹}}% U+25B9
  \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236
  \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6
  \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5
  \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6
  \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7
  \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2
  \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4
  \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208
  \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C
  \newunicodechar{≠}{{\DejaVuSansMono ≠}}% U+2260
  \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F
  \newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423
  \newunicodechar{↪}{{\DejaVuSansMono ↪}}% U+21AA
  \newunicodechar{↩}{{\DejaVuSansMono ↩}}% U+21A9
  \newunicodechar{≤}{{\DejaVuSansMono ≤}}% U+2264
  \newunicodechar{≥}{{\DejaVuSansMono ≥}}% U+2265
  \newunicodechar{≙}{{\DejaVuSansMono ≙}}% U+2259
  \newunicodechar{⇧}{{\DejaVuSansMono ⇧}}% U+21E7
  \newunicodechar{⌃}{{\DejaVuSansMono ⌃}}% U+2303
  \newunicodechar{⎈}{{\DejaVuSansMono ⎈}}% U+2388
  \newunicodechar{⌥}{{\DejaVuSansMono ⌥}}% U+2325
  \newunicodechar{⎇}{{\DejaVuSansCondensed ⎇}}% U+2387
  \newunicodechar{⌘}{{\DejaVuSansMono ⌘}}% U+2318
  \newunicodechar{⏏}{{\DejaVuSansMono ⏏}}% U+23CF
  \newunicodechar{⌫}{{\DejaVuSansMono ⌫}}% U+232B
  \newunicodechar{⌦}{{\DejaVuSansMono ⌦}}% U+2326
  \newunicodechar{⇥}{{\DejaVuSansMono ⇥}}% U+21E5
  \newunicodechar{⇤}{{\DejaVuSansMono ⇤}}% U+21E4

  \PassOptionsToPackage{%
    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
    {sphinx}
\fi

\defaultfontfeatures{}

\def\testmdf{
  Normalized: \@mdf@option@fonts\newline
}

\endinput
