changeset 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 1f076d7c721d
children 4c44b64e32cd
files docs/_latex/my-doc-fonts.sty docs/conf.py
diffstat 2 files changed, 195 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/_latex/my-doc-fonts.sty	Wed May 13 18:34:29 2026 +0200
@@ -0,0 +1,187 @@
+% -*- coding: utf-8 -*-
+%
+% Some font hacks for my Sphinx PDF documents
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{my-doc-fonts}[%
+  2026/05/13 v0.2 (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}
+}
+
+\newif\if@mdf@@sscode\@mdf@@sscodefalse
+\newif\if@mdf@@inconsolata\@mdf@@inconsolatafalse
+
+\newif\if@mdf@WithDejaVuSansMono
+\newif\if@mdf@WithPlexMono
+\newif\if@mdf@WithAdobeSource
+\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}
+
+%
+% By default use the safe option dejavusansmono because is contains
+% all characters without any hacks.
+%
+\ExecuteOptionsX{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
+\fi
+%
+%
+\if@mdf@WithPlexMono
+  \RequirePackage{newunicodechar}
+  \RequirePackage[DefaultFeatures={Scale=0.92}]{plex-otf}
+  % Dont keep all default font features from plex-otf
+  \defaultfontfeatures{}
+  \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[%
+    UprightFont = *,
+    BoldFont = * Bold,
+    ItalicFont = * Oblique,
+    BoldItalicFont = * Bold Oblique,
+    Scale=MatchLowercase,
+    Ligatures=TeX,
+  ]
+  \newunicodechar{▷}{{\DejaVuSansMono ▷}}% U+25B7
+  \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+2423  Missing!
+  %\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@WithAdobeSource
+  \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,
+  ]
+  \@mdf@@sscodetrue
+\fi
+\if@mdf@WithSpectral
+  \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,
+  ]
+  \@mdf@@sscodetrue
+\fi
+\if@mdf@WithCharter
+  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular}}
+  \setmainfont{XCharter}
+  \setsansfont{Lato}[
+    UprightFont = * Regular,
+    BoldFont = * Bold,
+    ItalicFont = * Italic,
+    BoldItalicFont = * Bold Italic,
+    Scale = MatchLowercase,
+  ]
+  \@mdf@@inconsolatatrue
+\fi
+
+\defaultfontfeatures{}
+
+\if@mdf@@sscode
+  \RequirePackage{newunicodechar}
+  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase}
+  \setmonofont{Source Code Pro}[
+    UprightFont = *,
+    BoldFont = * Bold,
+    ItalicFont = * Italic,
+    BoldItalicFont = * Bold Italic,
+  ]
+  \defaultfontfeatures{}
+  \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[%
+    UprightFont = *,
+    BoldFont = * Bold,
+    ItalicFont = * Oblique,
+    BoldItalicFont = * Bold Oblique,
+  ]
+  \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
+  \PassOptionsToPackage{%
+    verbatimvisiblespace={\textcolor{red}{{\DejaVuSansMono^^^^2423}}},%
+    verbatimcontinued={\textcolor{red}{{\DejaVuSansMono^^^^21aa}}}}%
+    {sphinx}
+\fi
+
+\if@mdf@@inconsolata
+  \RequirePackage{newunicodechar}
+  \defaultfontfeatures{Ligatures=TeX,Numbers={Lining,Tabular},Scale=MatchLowercase}
+  \setmonofont{Inconsolata LGC Nerd Font Mono}[%
+    UprightFont = *,
+    BoldFont = * Bold,
+    ItalicFont = * Italic,
+    BoldItalicFont = * Bold Italic,
+  ]
+  \defaultfontfeatures{}
+  \newfontfamily\DejaVuSansMono{DejaVu Sans Mono}[%
+    UprightFont = *,
+    BoldFont = * Bold,
+    ItalicFont = * Oblique,
+    BoldItalicFont = * Bold Oblique,
+  ]
+  \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
+\fi
+
+\defaultfontfeatures{}
+
+\endinput
--- a/docs/conf.py	Wed May 13 18:17:44 2026 +0200
+++ b/docs/conf.py	Wed May 13 18:34:29 2026 +0200
@@ -132,6 +132,7 @@
 
 # -- Options for LaTeX output ------------------------------------------------
 
+latex_engine = 'lualatex'
 latex_elements = {
     # The paper size ('letterpaper' or 'a4paper').
     #
@@ -141,26 +142,20 @@
     #
     'pointsize': '11pt',
 
-    # Additional stuff for the LaTeX preamble.
-    #
-    # NOTE: "inconsolata" in "fontpkg" errors within pdfTeX: seems to be
-    #       incompatible with some header package.
-    #
-    'preamble': r'''
-        \usepackage{inconsolata}
-    ''',
-
-   'fontpkg': r'''
-        \usepackage{charter}
-        \usepackage[defaultsans]{lato}
-    ''',
+    'babel': r'\usepackage{babel}',
+    'fontpkg': r'\usepackage[charter]{my-doc-fonts}',
 
     # Latex figure (float) alignment
     #
     # 'figure_align': 'htbp',
     # Use "Version" instead of "Release" on the title
     'releasename': 'Version',
+
+    'fncychap': r'\usepackage[Sonny]{fncychap}',
 }
+latex_additional_files = [
+    "_latex/my-doc-fonts.sty",
+]
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title,