Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison docs/_latex/my-doc-fonts.sty @ 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 | 0d6eb4209714 |
| children | a7a6a75cd4b8 |
comparison
equal
deleted
inserted
replaced
| 217:3777eb7dbf4a | 218:5114d49a8eab |
|---|---|
| 12 \RequirePackage{xcolor} | 12 \RequirePackage{xcolor} |
| 13 }{% | 13 }{% |
| 14 \RequirePackage{color} | 14 \RequirePackage{color} |
| 15 } | 15 } |
| 16 | 16 |
| 17 \newif\if@mdf@@sscode\@mdf@@sscodefalse | 17 \newif\if@mdf@mono@dejavusansmono\@mdf@mono@dejavusansmonofalse |
| 18 \newif\if@mdf@@inconsolata\@mdf@@inconsolatafalse | 18 \newif\if@mdf@mono@sscode\@mdf@mono@sscodefalse |
| 19 \newif\if@mdf@mono@inconsolata\@mdf@mono@inconsolatafalse | |
| 19 | 20 |
| 20 \newif\if@mdf@WithDejaVuSansMono | 21 \newif\if@mdf@WithDejaVuSansMono |
| 21 \newif\if@mdf@WithPlexMono | 22 \newif\if@mdf@WithIBMPlex |
| 22 \newif\if@mdf@WithAdobeSource | 23 \newif\if@mdf@WithIBMPlexDejaVuSansMono |
| 24 \newif\if@mdf@WithAdobeSourcePro | |
| 23 \newif\if@mdf@WithSpectral | 25 \newif\if@mdf@WithSpectral |
| 24 \newif\if@mdf@WithCharter | 26 \newif\if@mdf@WithCharter |
| 25 | 27 |
| 26 \def\@mdf@reset@font@options{\@mdf@WithDejaVuSansMonofalse\@mdf@WithPlexMonofalse\@mdf@WithAdobeSourcefalse\@mdf@WithCharterfalse} | 28 % A key compatible with options processing as option "fonts" but choices. |
| 27 | 29 \define@choicekey*{my-doc-fonts.sty}{fonts}[\val\nr]{% |
| 28 \DeclareOptionX{dejavusansmono}[true]{\@mdf@reset@font@options\csname @mdf@WithDejaVuSansMono#1\endcsname} | 30 dejavusansmono, |
| 29 \DeclareOptionX{plexmono}[true]{\@mdf@reset@font@options\csname @mdf@WithPlexMono#1\endcsname} | 31 plex, ibmplex, |
| 30 \DeclareOptionX{adobesource}[true]{\@mdf@reset@font@options\csname @mdf@WithAdobeSource#1\endcsname} | 32 plex-dejavusansmono, |
| 31 \DeclareOptionX{spectral}[true]{\@mdf@reset@font@options\csname @mdf@WithSpectral#1\endcsname} | 33 adobesource, adobesourcepro, |
| 32 \DeclareOptionX{charter}[true]{\@mdf@reset@font@options\csname @mdf@WithCharter#1\endcsname} | 34 spectral, |
| 35 charter}{% | |
| 36 \@mdf@WithDejaVuSansMonofalse | |
| 37 \@mdf@WithIBMPlexfalse | |
| 38 \@mdf@WithIBMPlexDejaVuSansMonofalse | |
| 39 \@mdf@WithAdobeSourceProfalse | |
| 40 \@mdf@WithSpectralfalse | |
| 41 \@mdf@WithCharterfalse | |
| 42 \ifcase\nr\relax | |
| 43 \@mdf@WithDejaVuSansMonotrue | |
| 44 \or | |
| 45 \@mdf@WithIBMPlextrue | |
| 46 \or | |
| 47 \@mdf@WithIBMPlextrue | |
| 48 \or | |
| 49 \@mdf@WithIBMPlexDejaVuSansMonotrue | |
| 50 \or | |
| 51 \@mdf@WithAdobeSourceProtrue | |
| 52 \or | |
| 53 \@mdf@WithAdobeSourceProtrue | |
| 54 \or | |
| 55 \@mdf@WithSpectraltrue | |
| 56 \or | |
| 57 \@mdf@WithChartertrue | |
| 58 \fi | |
| 59 % Not used for now : store the normalized option value (global and expanded) | |
| 60 \xdef\@mdf@fonts{\val} | |
| 61 } | |
| 33 | 62 |
| 34 % | 63 % |
| 35 % By default use the safe option dejavusansmono because is contains | 64 % By default use the safe option dejavusansmono because is contains |
| 36 % all characters without any hacks. | 65 % all characters without any hacks. |
| 37 % | 66 % |
| 38 \ExecuteOptionsX{dejavusansmono} | 67 \ExecuteOptionsX{fonts=dejavusansmono} |
| 39 \ProcessOptionsX\relax | 68 \ProcessOptionsX\relax |
| 40 | 69 |
| 41 \if@mdf@WithDejaVuSansMono | 70 \if@mdf@WithDejaVuSansMono |
| 42 \RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} | 71 % default but with DejaVu Sans Mono as monospaced font |
| 43 \RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available | 72 %\RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} |
| 44 \fi | 73 %\RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available |
| 45 % | 74 \@mdf@mono@dejavusansmonotrue |
| 46 % | 75 \fi |
| 47 \if@mdf@WithPlexMono | 76 % |
| 77 % | |
| 78 \if@mdf@WithIBMPlex | |
| 48 \RequirePackage{newunicodechar} | 79 \RequirePackage{newunicodechar} |
| 49 \RequirePackage[DefaultFeatures={Scale=0.92}]{plex-otf} | 80 \RequirePackage[DefaultFeatures={Scale=0.92}]{plex-otf} |
| 50 % Dont keep all default font features from plex-otf | 81 % Dont keep all default font features from plex-otf |
| 51 \defaultfontfeatures{} | 82 \defaultfontfeatures{} |
| 52 \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[% | 83 \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[% |
| 77 \PassOptionsToPackage{% | 108 \PassOptionsToPackage{% |
| 78 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% | 109 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% |
| 79 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% | 110 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% |
| 80 {sphinx} | 111 {sphinx} |
| 81 \fi | 112 \fi |
| 82 \if@mdf@WithAdobeSource | 113 \if@mdf@WithIBMPlexDejaVuSansMono |
| 114 \RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} | |
| 115 \@mdf@mono@dejavusansmonotrue | |
| 116 \fi | |
| 117 \if@mdf@WithAdobeSourcePro | |
| 83 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | 118 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} |
| 84 \setmainfont{Source Serif Pro}[ | 119 \setmainfont{Source Serif Pro}[ |
| 85 UprightFont = *, | 120 UprightFont = *, |
| 86 BoldFont = * Bold, | 121 BoldFont = * Bold, |
| 87 ItalicFont = * Italic, | 122 ItalicFont = * Italic, |
| 91 UprightFont = *, | 126 UprightFont = *, |
| 92 BoldFont = * Bold, | 127 BoldFont = * Bold, |
| 93 ItalicFont = * Italic, | 128 ItalicFont = * Italic, |
| 94 BoldItalicFont = * Bold Italic, | 129 BoldItalicFont = * Bold Italic, |
| 95 ] | 130 ] |
| 96 \@mdf@@sscodetrue | 131 \@mdf@mono@sscodetrue |
| 97 \fi | 132 \fi |
| 98 \if@mdf@WithSpectral | 133 \if@mdf@WithSpectral |
| 99 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | 134 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} |
| 100 \setmainfont{Spectral}[ | 135 \setmainfont{Spectral}[ |
| 101 UprightFont = * Regular, | 136 UprightFont = * Regular, |
| 107 UprightFont = *, | 142 UprightFont = *, |
| 108 BoldFont = * Bold, | 143 BoldFont = * Bold, |
| 109 ItalicFont = * Italic, | 144 ItalicFont = * Italic, |
| 110 BoldItalicFont = * Bold Italic, | 145 BoldItalicFont = * Bold Italic, |
| 111 ] | 146 ] |
| 112 \@mdf@@sscodetrue | 147 \@mdf@mono@sscodetrue |
| 113 \fi | 148 \fi |
| 114 \if@mdf@WithCharter | 149 \if@mdf@WithCharter |
| 115 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | 150 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} |
| 116 \setmainfont{XCharter} | 151 \setmainfont{XCharter} |
| 117 \setsansfont{Lato}[ | 152 \setsansfont{Lato}[ |
| 119 BoldFont = * Bold, | 154 BoldFont = * Bold, |
| 120 ItalicFont = * Italic, | 155 ItalicFont = * Italic, |
| 121 BoldItalicFont = * Bold Italic, | 156 BoldItalicFont = * Bold Italic, |
| 122 Scale = MatchLowercase, | 157 Scale = MatchLowercase, |
| 123 ] | 158 ] |
| 124 \@mdf@@inconsolatatrue | 159 \@mdf@mono@inconsolatatrue |
| 125 \fi | 160 \fi |
| 126 | 161 |
| 127 \defaultfontfeatures{} | 162 \defaultfontfeatures{} |
| 128 | 163 |
| 129 \if@mdf@@sscode | 164 \if@mdf@mono@dejavusansmono |
| 165 % automatically applied with Scale=MatchLowercase,... | |
| 166 \RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available | |
| 167 \fi | |
| 168 | |
| 169 \if@mdf@mono@sscode | |
| 130 \RequirePackage{newunicodechar} | 170 \RequirePackage{newunicodechar} |
| 131 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} | 171 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} |
| 132 \setmonofont{Source Code Pro}[ | 172 \setmonofont{Source Code Pro}[ |
| 133 UprightFont = *, | 173 UprightFont = *, |
| 134 BoldFont = * Bold, | 174 BoldFont = * Bold, |
| 155 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% | 195 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% |
| 156 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% | 196 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% |
| 157 {sphinx} | 197 {sphinx} |
| 158 \fi | 198 \fi |
| 159 | 199 |
| 160 \if@mdf@@inconsolata | 200 \if@mdf@mono@inconsolata |
| 161 \RequirePackage{newunicodechar} | 201 \RequirePackage{newunicodechar} |
| 162 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} | 202 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} |
| 163 \setmonofont{Inconsolata LGC Nerd Font Mono}[% | 203 \setmonofont{Inconsolata LGC Nerd Font Mono}[% |
| 164 UprightFont = *, | 204 UprightFont = *, |
| 165 BoldFont = * Bold, | 205 BoldFont = * Bold, |
| 182 \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C | 222 \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C |
| 183 \fi | 223 \fi |
| 184 | 224 |
| 185 \defaultfontfeatures{} | 225 \defaultfontfeatures{} |
| 186 | 226 |
| 227 \def\testmdf{ | |
| 228 Normalized: \@mdf@fonts\newline | |
| 229 % To be used like | |
| 230 Normalized: \ifx\@mdf@fonts{adobesourcepro} HUHU\else HAHA\fi\newline | |
| 231 } | |
| 232 | |
| 187 \endinput | 233 \endinput |
