diff mbox series

[2/5] doc: Makefile: add support for xelatex

Message ID 20241106-pdf-xetex-v1-2-044eab7e77d3@bootlin.com
State New
Headers show
Series Add support for PDF/Epub generation | expand

Commit Message

Antonin Godard Nov. 6, 2024, 7:48 a.m. UTC
This patch makes the "latexpdf" target compile the documentation with
xelatex instead of the default pdflatex engine.

The reason behind this is stated in [YOCTO #14357]: pdflatex does not
support compiling foreign characters, so we need to resort to another
engine, here xelatex.

It also increases the texmf config buf_size to 10000000 to avoid a
compilation error.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/Makefile | 5 ++++-
 documentation/conf.py  | 7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/documentation/Makefile b/documentation/Makefile
index d0333de2cb84ba648a64e51fd3711113788d6714..12ca2f95f6578a31cd309f80b58a2702561a6b9f 100644
--- a/documentation/Makefile
+++ b/documentation/Makefile
@@ -60,9 +60,12 @@  epub: $(PNGs)
 	$(SOURCEDIR)/set_versions.py
 	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
+# Note: we need to pass buf_size here (which is also configurable from
+# texmf.cnf), to avoid following error:
+#   Unable to read an entire line---bufsize=200000. Please increase buf_size in texmf.cnf.
 latexpdf: $(PDFs)
 	$(SOURCEDIR)/set_versions.py
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+	buf_size=10000000 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
 all: html epub latexpdf
 
diff --git a/documentation/conf.py b/documentation/conf.py
index 9e87df0564c1e93140bce8705d9b45f75cbded58..c7dd4e03fc0e99176a0fa2f74fda58efaf0af9b2 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -158,9 +158,14 @@  html_last_updated_fmt = '%b %d, %Y'
 # Remove the trailing 'dot' in section numbers
 html_secnumber_suffix = " "
 
+# We need XeTeX to process special unicode character, sometimes the contributor
+# list from the release note contains those.
+# See https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html.
+latex_engine = 'xelatex'
+latex_use_xindy = False
 latex_elements = {
     'passoptionstopackages': '\\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
-    'preamble': '\\setcounter{tocdepth}{2}',
+    'preamble': '\\usepackage[UTF8]{ctex}\n\\setcounter{tocdepth}{2}',
 }
 
 # Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG