Mercurial > hgrepos > Python > libs > ConfigMix
comparison docs/_latex/my-doc-fonts.sty @ 771:741ebfe77e55
Build the PDF documentation with lualatex now.
Using OTF/TTF fonts mostly.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 13 May 2026 18:34:29 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 770:1f076d7c721d | 771:741ebfe77e55 |
|---|---|
| 1 % -*- coding: utf-8 -*- | |
| 2 % | |
| 3 % Some font hacks for my Sphinx PDF documents | |
| 4 % | |
| 5 \NeedsTeXFormat{LaTeX2e} | |
| 6 \ProvidesPackage{my-doc-fonts}[% | |
| 7 2026/05/13 v0.2 (Franz Glasner) Fonts for Sphinx generated PDFs] | |
| 8 \RequirePackage{xkeyval} | |
| 9 \RequirePackage{fontspec} | |
| 10 \IfFileExists{xcolor.sty}{% | |
| 11 % Should Sphinx load xcolor with its dvipsnames and svgnames options? | |
| 12 \RequirePackage{xcolor} | |
| 13 }{% | |
| 14 \RequirePackage{color} | |
| 15 } | |
| 16 | |
| 17 \newif\if@mdf@@sscode\@mdf@@sscodefalse | |
| 18 \newif\if@mdf@@inconsolata\@mdf@@inconsolatafalse | |
| 19 | |
| 20 \newif\if@mdf@WithDejaVuSansMono | |
| 21 \newif\if@mdf@WithPlexMono | |
| 22 \newif\if@mdf@WithAdobeSource | |
| 23 \newif\if@mdf@WithSpectral | |
| 24 \newif\if@mdf@WithCharter | |
| 25 | |
| 26 \def\@mdf@reset@font@options{\@mdf@WithDejaVuSansMonofalse\@mdf@WithPlexMonofalse\@mdf@WithAdobeSourcefalse\@mdf@WithCharterfalse} | |
| 27 | |
| 28 \DeclareOptionX{dejavusansmono}[true]{\@mdf@reset@font@options\csname @mdf@WithDejaVuSansMono#1\endcsname} | |
| 29 \DeclareOptionX{plexmono}[true]{\@mdf@reset@font@options\csname @mdf@WithPlexMono#1\endcsname} | |
| 30 \DeclareOptionX{adobesource}[true]{\@mdf@reset@font@options\csname @mdf@WithAdobeSource#1\endcsname} | |
| 31 \DeclareOptionX{spectral}[true]{\@mdf@reset@font@options\csname @mdf@WithSpectral#1\endcsname} | |
| 32 \DeclareOptionX{charter}[true]{\@mdf@reset@font@options\csname @mdf@WithCharter#1\endcsname} | |
| 33 | |
| 34 % | |
| 35 % By default use the safe option dejavusansmono because is contains | |
| 36 % all characters without any hacks. | |
| 37 % | |
| 38 \ExecuteOptionsX{dejavusansmono} | |
| 39 \ProcessOptionsX*\relax | |
| 40 | |
| 41 \if@mdf@WithDejaVuSansMono | |
| 42 \RequirePackage[DefaultFeatures={Scale=0.92},mono=false]{plex-otf} | |
| 43 \RequirePackage[mono=true,serif=false,sans=false,math=false]{dejavu-otf} % all symbols are available | |
| 44 \fi | |
| 45 % | |
| 46 % | |
| 47 \if@mdf@WithPlexMono | |
| 48 \RequirePackage{newunicodechar} | |
| 49 \RequirePackage[DefaultFeatures={Scale=0.92}]{plex-otf} | |
| 50 % Dont keep all default font features from plex-otf | |
| 51 \defaultfontfeatures{} | |
| 52 \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[% | |
| 53 UprightFont = *, | |
| 54 BoldFont = * Bold, | |
| 55 ItalicFont = * Oblique, | |
| 56 BoldItalicFont = * Bold Oblique, | |
| 57 Scale=MatchLowercase, | |
| 58 Ligatures=TeX, | |
| 59 ] | |
| 60 \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7 | |
| 61 \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236 | |
| 62 \newunicodechar{◆}{{\DejaVuSansMono ◆}}% U+25C6 | |
| 63 \newunicodechar{▪}{{\DejaVuSansMono ▪}}% U+25AA | |
| 64 \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5 | |
| 65 \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6 | |
| 66 \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7 | |
| 67 \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2 | |
| 68 \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4 | |
| 69 \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F | |
| 70 \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208 | |
| 71 \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C | |
| 72 %\newunicodechar{␣}{{\DejaVuSansMono ␣}}% U+2423 Missing! | |
| 73 %\newunicodechar{^^^^2423}{{\DejaVuSansMono^^^^2423}}% U+2423 | |
| 74 %\newunicodechar{␣}{\textvisiblespace}% U+2423 | |
| 75 %\catcode`^^^^2423\active\protected\def^^^^2423{\textvisiblespace} | |
| 76 | |
| 77 \PassOptionsToPackage{% | |
| 78 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% | |
| 79 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% | |
| 80 {sphinx} | |
| 81 \fi | |
| 82 \if@mdf@WithAdobeSource | |
| 83 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | |
| 84 \setmainfont{Source Serif Pro}[ | |
| 85 UprightFont = *, | |
| 86 BoldFont = * Bold, | |
| 87 ItalicFont = * Italic, | |
| 88 BoldItalicFont = * Bold Italic, | |
| 89 ] | |
| 90 \setsansfont{Source Sans Pro}[ | |
| 91 UprightFont = *, | |
| 92 BoldFont = * Bold, | |
| 93 ItalicFont = * Italic, | |
| 94 BoldItalicFont = * Bold Italic, | |
| 95 ] | |
| 96 \@mdf@@sscodetrue | |
| 97 \fi | |
| 98 \if@mdf@WithSpectral | |
| 99 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | |
| 100 \setmainfont{Spectral}[ | |
| 101 UprightFont = * Regular, | |
| 102 BoldFont = * Bold, | |
| 103 ItalicFont = * Italic, | |
| 104 BoldItalicFont = * Bold Italic, | |
| 105 ] | |
| 106 \setsansfont{Source Sans Pro}[ | |
| 107 UprightFont = *, | |
| 108 BoldFont = * Bold, | |
| 109 ItalicFont = * Italic, | |
| 110 BoldItalicFont = * Bold Italic, | |
| 111 ] | |
| 112 \@mdf@@sscodetrue | |
| 113 \fi | |
| 114 \if@mdf@WithCharter | |
| 115 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}} | |
| 116 \setmainfont{XCharter} | |
| 117 \setsansfont{Lato}[ | |
| 118 UprightFont = * Regular, | |
| 119 BoldFont = * Bold, | |
| 120 ItalicFont = * Italic, | |
| 121 BoldItalicFont = * Bold Italic, | |
| 122 Scale = MatchLowercase, | |
| 123 ] | |
| 124 \@mdf@@inconsolatatrue | |
| 125 \fi | |
| 126 | |
| 127 \defaultfontfeatures{} | |
| 128 | |
| 129 \if@mdf@@sscode | |
| 130 \RequirePackage{newunicodechar} | |
| 131 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} | |
| 132 \setmonofont{Source Code Pro}[ | |
| 133 UprightFont = *, | |
| 134 BoldFont = * Bold, | |
| 135 ItalicFont = * Italic, | |
| 136 BoldItalicFont = * Bold Italic, | |
| 137 ] | |
| 138 \defaultfontfeatures{} | |
| 139 \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[% | |
| 140 UprightFont = *, | |
| 141 BoldFont = * Bold, | |
| 142 ItalicFont = * Oblique, | |
| 143 BoldItalicFont = * Bold Oblique, | |
| 144 ] | |
| 145 \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236 | |
| 146 \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5 | |
| 147 \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6 | |
| 148 \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7 | |
| 149 \newunicodechar{⇒}{{\DejaVuSansMono ⇒}}% U+21D2 | |
| 150 \newunicodechar{⇔}{{\DejaVuSansMono ⇔}}% U+21D4 | |
| 151 \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F | |
| 152 \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208 | |
| 153 \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C | |
| 154 \PassOptionsToPackage{% | |
| 155 verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},% | |
| 156 verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}% | |
| 157 {sphinx} | |
| 158 \fi | |
| 159 | |
| 160 \if@mdf@@inconsolata | |
| 161 \RequirePackage{newunicodechar} | |
| 162 \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase} | |
| 163 \setmonofont{Inconsolata LGC Nerd Font Mono}[% | |
| 164 UprightFont = *, | |
| 165 BoldFont = * Bold, | |
| 166 ItalicFont = * Italic, | |
| 167 BoldItalicFont = * Bold Italic, | |
| 168 ] | |
| 169 \defaultfontfeatures{} | |
| 170 \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[% | |
| 171 UprightFont = *, | |
| 172 BoldFont = * Bold, | |
| 173 ItalicFont = * Oblique, | |
| 174 BoldItalicFont = * Bold Oblique, | |
| 175 ] | |
| 176 \newunicodechar{∶}{{\DejaVuSansMono ∶}}% U+2236 | |
| 177 \newunicodechar{⟵}{{\DejaVuSansMono ⟵}}% U+27F5 | |
| 178 \newunicodechar{⟶}{{\DejaVuSansMono ⟶}}% U+27F6 | |
| 179 \newunicodechar{⟷}{{\DejaVuSansMono ⟷}}% U+27F7 | |
| 180 \newunicodechar{≟}{{\DejaVuSansMono ≟}}% U+225F | |
| 181 \newunicodechar{∈}{{\DejaVuSansMono ∈}}% U+2208 | |
| 182 \newunicodechar{∌}{{\DejaVuSansMono ∌}}% U+220C | |
| 183 \fi | |
| 184 | |
| 185 \defaultfontfeatures{} | |
| 186 | |
| 187 \endinput |
