Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 218:5114d49a8eab
A new interface for my-doc-fonts.sty and a new implementation of option processing.
Use more stuff from xkeyval to check for given option values.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 15 May 2026 16:35:34 +0200 |
| parents | 3777eb7dbf4a |
| children | a7a6a75cd4b8 |
| files | docs/_latex/my-doc-fonts.sty docs/conf.py |
| diffstat | 2 files changed, 68 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/_latex/my-doc-fonts.sty Fri May 15 14:34:43 2026 +0200 +++ b/docs/_latex/my-doc-fonts.sty Fri May 15 16:35:34 2026 +0200 @@ -14,37 +14,68 @@ \RequirePackage{color} } -\newif\if@mdf@@sscode\@mdf@@sscodefalse -\newif\if@mdf@@inconsolata\@mdf@@inconsolatafalse +\newif\if@mdf@mono@dejavusansmono\@mdf@mono@dejavusansmonofalse +\newif\if@mdf@mono@sscode\@mdf@mono@sscodefalse +\newif\if@mdf@mono@inconsolata\@mdf@mono@inconsolatafalse \newif\if@mdf@WithDejaVuSansMono -\newif\if@mdf@WithPlexMono -\newif\if@mdf@WithAdobeSource +\newif\if@mdf@WithIBMPlex +\newif\if@mdf@WithIBMPlexDejaVuSansMono +\newif\if@mdf@WithAdobeSourcePro \newif\if@mdf@WithSpectral \newif\if@mdf@WithCharter -\def\@mdf@reset@font@options{\@mdf@WithDejaVuSansMonofalse\@mdf@WithPlexMonofalse\@mdf@WithAdobeSourcefalse\@mdf@WithCharterfalse} - -\DeclareOptionX{dejavusansmono}[true]{\@mdf@reset@font@options\csname @mdf@WithDejaVuSansMono#1\endcsname} -\DeclareOptionX{plexmono}[true]{\@mdf@reset@font@options\csname @mdf@WithPlexMono#1\endcsname} -\DeclareOptionX{adobesource}[true]{\@mdf@reset@font@options\csname @mdf@WithAdobeSource#1\endcsname} -\DeclareOptionX{spectral}[true]{\@mdf@reset@font@options\csname @mdf@WithSpectral#1\endcsname} -\DeclareOptionX{charter}[true]{\@mdf@reset@font@options\csname @mdf@WithCharter#1\endcsname} +% A key compatible with options processing as option "fonts" but choices. +\define@choicekey*{my-doc-fonts.sty}{fonts}[\val\nr]{% + dejavusansmono, + plex, ibmplex, + plex-dejavusansmono, + adobesource, adobesourcepro, + spectral, + charter}{% + \@mdf@WithDejaVuSansMonofalse + \@mdf@WithIBMPlexfalse + \@mdf@WithIBMPlexDejaVuSansMonofalse + \@mdf@WithAdobeSourceProfalse + \@mdf@WithSpectralfalse + \@mdf@WithCharterfalse + \ifcase\nr\relax + \@mdf@WithDejaVuSansMonotrue + \or + \@mdf@WithIBMPlextrue + \or + \@mdf@WithIBMPlextrue + \or + \@mdf@WithIBMPlexDejaVuSansMonotrue + \or + \@mdf@WithAdobeSourceProtrue + \or + \@mdf@WithAdobeSourceProtrue + \or + \@mdf@WithSpectraltrue + \or + \@mdf@WithChartertrue + \fi + % Not used for now : store the normalized option value (global and expanded) + \xdef\@mdf@fonts{\val} +} % % By default use the safe option dejavusansmono because is contains % all characters without any hacks. % -\ExecuteOptionsX{dejavusansmono} +\ExecuteOptionsX{fonts=dejavusansmono} \ProcessOptionsX\relax \if@mdf@WithDejaVuSansMono - \RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} - \RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available + % 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 \fi % % -\if@mdf@WithPlexMono +\if@mdf@WithIBMPlex \RequirePackage{newunicodechar} \RequirePackage[DefaultFeatures={Scale=0.92}]{plex-otf} % Dont keep all default font features from plex-otf @@ -79,7 +110,11 @@ verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% {sphinx} \fi -\if@mdf@WithAdobeSource +\if@mdf@WithIBMPlexDejaVuSansMono + \RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} + \@mdf@mono@dejavusansmonotrue +\fi +\if@mdf@WithAdobeSourcePro \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} \setmainfont{Source Serif Pro}[ UprightFont = *, @@ -93,7 +128,7 @@ ItalicFont = * Italic, BoldItalicFont = * Bold Italic, ] - \@mdf@@sscodetrue + \@mdf@mono@sscodetrue \fi \if@mdf@WithSpectral \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} @@ -109,7 +144,7 @@ ItalicFont = * Italic, BoldItalicFont = * Bold Italic, ] - \@mdf@@sscodetrue + \@mdf@mono@sscodetrue \fi \if@mdf@WithCharter \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} @@ -121,12 +156,17 @@ BoldItalicFont = * Bold Italic, Scale = MatchLowercase, ] - \@mdf@@inconsolatatrue + \@mdf@mono@inconsolatatrue \fi \defaultfontfeatures{} -\if@mdf@@sscode +\if@mdf@mono@dejavusansmono + % automatically applied with Scale=MatchLowercase,... + \RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available +\fi + +\if@mdf@mono@sscode \RequirePackage{newunicodechar} \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} \setmonofont{Source Code Pro}[ @@ -157,7 +197,7 @@ {sphinx} \fi -\if@mdf@@inconsolata +\if@mdf@mono@inconsolata \RequirePackage{newunicodechar} \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} \setmonofont{Inconsolata LGC Nerd Font Mono}[% @@ -184,4 +224,10 @@ \defaultfontfeatures{} +\def\testmdf{ + Normalized: \@mdf@fonts\newline + % To be used like + Normalized: \ifx\@mdf@fonts{adobesourcepro} HUHU\else HAHA\fi\newline +} + \endinput
--- a/docs/conf.py Fri May 15 14:34:43 2026 +0200 +++ b/docs/conf.py Fri May 15 16:35:34 2026 +0200 @@ -146,10 +146,7 @@ latex_elements = { "papersize": "a4paper", "babel": r"\usepackage{babel}", - "fontpkg": r"\usepackage[adobesource]{my-doc-fonts}", -# "fontpkg": r"\usepackage[plexmono]{my-doc-fonts}", -# "fontpkg": r"\usepackage[spectral]{my-doc-fonts}", -# "fontpkg": r"\usepackage[charter]{my-doc-fonts}", + "fontpkg": r"\usepackage[fonts=Adobesourcepro]{my-doc-fonts}", "releasename": "Version", "fncychap": r"\usepackage[Sonny]{fncychap}", "preamble": r"\usepackage[stdtitle=false]{my-doc-style}",
