All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/11] Fix PDF doc builds on major distros
Date: Tue, 19 Aug 2025 15:32:00 +0200	[thread overview]
Message-ID: <20250819153200.3c2b2ff6@foz.lan> (raw)
In-Reply-To: <142b209d-613a-4659-a0f7-27efa8c6be85@gmail.com>

Em Tue, 19 Aug 2025 11:16:29 +0900
Akira Yokosawa <akiyks@gmail.com> escreveu:

> Hi Mauro,
> 
> Please calm down.
> Apologizes if my wording has annoyed you.
> 
> On Tue, 19 Aug 2025 03:02:39 +0200, Mauro Carvalho Chehab wrote:
> > Em Tue, 19 Aug 2025 08:26:31 +0900
> > Akira Yokosawa <akiyks@gmail.com> escreveu:  
> 
> [...]
> 
> >> Mauro, I can't review on 5/11 unless you provide me exact steps to reproduce
> >> the font discovery issue you said you have observed under debian at 4/11 of
> >> this series.  That is, without assuming your other series of build-wrapper.  
> > 
> > See below.
> >   
> >> The build-wrapper should be upper compatible with the current way of
> >> running sub-make, without any change in conf.py.  
> > 
> > The build-wrapper series doesn't make any changes on conf.py:  
> 
> Of course not, I'm well aware of the fact from the cover letter.
> 
> [...]
> 
> > 4. It prevents the usage of T1 fontenc fonts, which could be
> >    caused by either one of those two reasons:
> > 
> > 	a) \sphinxhyphen{}
> > 	b) index build
> > 
> > I got those when checking what packages were required on some
> > distros (Debian, Ubuntu, Mageia, openMandriva, Gentoo).  
> 
> I couldn't reproduce it at PATCH 4/11 under a Ubnutu-based container
> I've been using, ignoring your sphinx-build-warpper series.

I'm assuming you're referring to patch 5/11, e.g.:

	ceaa95123364 ("docs: conf.py: fix some troubles for LaTeX output")

> I'd really like to see the issue with my eyes on top current way of
> doc building!
> 
> That's all I am asking.
> 
> I have no particular interest in the way you are testing all those
> variety of distros, and have no idea about it.
> 
> Please provide steps to reproduce.
> I'd like to see a Dockerfile based "FROM ubuntu:latest" as the testing
> environment.

Heh, that's why you can't reproduce... you're using a Docker container
and a different Ubuntu version than I.

What I did here was to use a lxc container with 25.04, and used
a script to pick the exact recommendations given by sphinx-pre-install.

The container was created with:

<script>
sudo lxc-create -n ubuntu-test -t download -- --dist ubuntu --release plucky --arch amd64
sudo mkdir -p /var/lib/lxc/ubuntu-test
sudo sh -c cat > /var/lib/lxc/ubuntu-test/config <<EOF
lxc.arch = x86_64
lxc.pty.max = 1024
lxc.tty.max = 4
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:6f:66:8c
lxc.cap.drop = mac_admin mac_override sys_time sys_module sys_rawio
lxc.cgroup.devices.allow = a
lxc.cgroup2.devices.allow = a
lxc.mount.auto = proc sys cgroup
lxc.rootfs.path = /var/lib/lxc/ubuntu-test/rootfs
EOF
</script>

once you get what's needed for make htmldocs work, installing
only the dependencies recommended by sphinx-pre-install, you can
start trying to reproduce the build issues for pdf.

For the steps below, I installed Sphinx latest using venv:

	$ make SPHINXDIRS=peci pdfdocs
	...
	This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2025/dev/Debian) (preloaded format=xelatex)
	entering extended mode
	Latexmk: Getting log file 'peci.log'
	Latexmk: Examining 'peci.fls'
	Latexmk: Examining 'peci.log'
	Latexmk: Missing input file 'tgtermes.sty' (or dependence on it) from following:
	  ! LaTeX Error: File `tgtermes.sty' not found.
	Latexmk: Log file says no output from latex
	Latexmk: For rule 'xelatex', no output was made
	Latexmk: Errors, so I did not complete making targets
	Collected error summary (may duplicate other messages):
	  xelatex: Command for 'xelatex' gave return code 1
	      Refer to 'peci.log' and/or above output for details

	Latexmk: Sometimes, the -f option can be used to get latexmk
	  to try to force complete processing.
	  But normally, you will need to correct the file(s) that caused the
	  error, and then rerun latexmk.
	  In some cases, it is best to clean out generated files before rerunning
	  latexmk after you've corrected the files.
	make[3]: *** [Makefile:29: peci.pdf] Error 12
	make[2]: *** [Documentation/Makefile:148: pdfdocs] Error 1
	make[1]: *** [/root/Makefile:1806: pdfdocs] Error 2
	make: *** [Makefile:248: __sub-make] Error 2

Fix the broken font dependencies require installing other packages:

	# apt install tex-gyre texlive-fonts-recommended texlive-lang-chinese
	texlive-lang-chinese is already the newest version (2024.20250309-1).
	Installing:
	  tex-gyre  texlive-fonts-recommended
	
	Installing dependencies:
	  fonts-texgyre  fonts-texgyre-math

As described at sphinx-pre-install patch:

  commit a888d353ac1eb0d558fda5482c6955d6c4a29f23
  Author: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  Date:   Mon Jul 28 15:54:09 2025 +0200

    scripts: sphinx-pre-install: fix PDF build issues on Ubuntu
    
    PDF output with current Debian-based distros require other
    packages for it to work. The main one is pzdr.tfm. Without
    that, \sphinxhyphen{} won't work, affecting multiple docs.
    
    For CJK, tex-gyre is required.
    
    Add the missing packages to the list.

Now, here's the thing: to get the above dependencies, I played with 
installing/uninstalling multiple packages, until I discovered where
each font dependency was, and where CJK fonts were placed.

Still, the above is not enough:

	$ make cleandocs; LANG=C LC_ALL=C make SPHINXDIRS=peci pdfdocs
	...
	entering extended mode
	Latexmk: Getting log file 'peci.log'
	Latexmk: Examining 'peci.fls'
	Latexmk: Examining 'peci.log'
	Latexmk: Index file 'peci.idx' was written
	Latexmk: References changed.
	Latexmk: Missing input file 'peci.toc' (or dependence on it) from following:
	  No file peci.toc.
	Latexmk: Missing input file 'peci.ind' (or dependence on it) from following:
	  No file peci.ind.
	Latexmk: References changed.
	Latexmk: References changed.
	Latexmk: Log file says output to 'peci.xdv'
	Have index file 'peci.idx', peci.ind peci
	Latexmk: Errors, so I did not complete making targets
	Collected error summary (may duplicate other messages):
	  xelatex: Command for 'xelatex' gave return code 1
      Refer to 'peci.log' and/or above output for details
	
	Latexmk: Sometimes, the -f option can be used to get latexmk
	  to try to force complete processing.
	  But normally, you will need to correct the file(s) that caused the
	  error, and then rerun latexmk.
	  In some cases, it is best to clean out generated files before rerunning
	  latexmk after you've corrected the files.
	make[3]: *** [Makefile:29: peci.pdf] Error 12
	make[2]: *** [Documentation/Makefile:148: pdfdocs] Error 1
	make[1]: *** [/root/Makefile:1806: pdfdocs] Error 2
	make: *** [Makefile:248: __sub-make] Error 2

	$ ls Documentation/output/peci/latex/|grep pdf
	<none>

PS.: such error is intermitent: re-creating containers sometimes
fix the issues; sometimes not. It sounds to be that this is due
to some race condition somewhere.

Also, if you look at the *.tex output, you'll see it is messing with
fonts:

	# grep usepackage Documentation/output/peci/latex/peci.tex 
	\usepackage{cmap}
	\usepackage[T1]{fontenc}
	\usepackage{amsmath,amssymb,amstext}
	\usepackage{babel}
	\usepackage{tgtermes}
	\usepackage{tgheros}
	\usepackage[Bjarne]{fncychap}
	\usepackage[,maxlistdepth=10]{sphinx}
	\usepackage{geometry}
	\usepackage{setspace}
	\usepackage{hyperref}
	\usepackage{hypcap}% it must be loaded after hyperref.
	\usepackage{sphinxmessages}
	        \usepackage{fontspec}

e.g.:

- The tex file is trying to use T1 fontenc and fontspec;

- The fontspec usage came from conf.py preamble, which is not indented
  well:

	# grep -A7 fontspec Documentation/output/peci/latex/peci.tex
	        \usepackage{fontspec}
	        \setsansfont{DejaVu Sans}
	        \setromanfont{DejaVu Serif}
	        \setmonofont{DejaVu Sans Mono}
    
	        % Load kerneldoc specific LaTeX settings
	        \input{kerneldoc-preamble.sty}

On several of my attempts, I got those errors:

	Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
	LaTeX Font Info:    Trying to load font information for T1+lmr on input line 11
	6.
	LaTeX Font Info:    No file T1lmr.fd. on input line 116.

	LaTeX Font Warning: Font shape `T1/lmr/m/n' undefined
	(Font)              using `T1/lmr/m/n' instead on input line 116.

	! Corrupted NFSS tables.
	wrong@fontshape ...message {Corrupted NFSS tables}
                                                  error@fontshape else let f...
	l.116 ...\familydefault\seriesdefault\shapedefault

If you search for it, you would get references like:
	https://tex.stackexchange.com/questions/740050/corrupted-nfss-tables

explaining that using T1 together with fontenc is a very bad idea,
recommending to use instead:

	\usepackage{fontspec}
	\newfontfamily<sometthing>

and not use T1 fontenc.

Unfortunately, I was not able to reproduce this exact error anymore,
at least on Ubuntu. Perhaps I got this one on Gentoo or on some other
distro, but I can't remember anymore how to reproduce this specific
error message.

-

Yet, using my today's container, this specific scenario can be fixed by moving
the font config data from preamble to "fontenc":

<patch>
+from textwrap import dedent
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -441,20 +443,18 @@ latex_elements = {
     # For CJK One-half spacing, need to be in front of hyperref
     "extrapackages": r"\usepackage{setspace}",
     # Additional stuff for the LaTeX preamble.
-    "preamble": """
+    "fontenc": dedent("""
         % Use some font with UTF-8 support with XeLaTeX
         \\usepackage{fontspec}
         \\setsansfont{DejaVu Sans}
         \\setromanfont{DejaVu Serif}
         \\setmonofont{DejaVu Sans Mono}
-    """,
-}
-
-# Load kerneldoc specific LaTeX settings
-latex_elements["preamble"] += """
+    """),
+    "preamble": dedent("""
         % Load kerneldoc specific LaTeX settings
         \\input{kerneldoc-preamble.sty}
-"""
+    """)
+}
</patch> 

which is one of the main changes I made. At the actual change, I opted to
use raw strings, to avoid "\\" e.g.:

	"fontenc": dedent(r"""
             % Use some font with UTF-8 support with XeLaTeX
             \usepackage{fontspec}
             \setsansfont{DejaVu Sans}
             \setromanfont{DejaVu Serif}
             \setmonofont{DejaVu Sans Mono}
	"""),

With that, we have now:

	# grep usepackage Documentation/output/peci/latex/*.tex
	\usepackage{cmap}
	\usepackage{fontspec}
	\usepackage{amsmath,amssymb,amstext}
	\usepackage{babel}
	\usepackage{tgtermes}
	\usepackage{tgheros}
	\usepackage[Bjarne]{fncychap}
	\usepackage[,maxlistdepth=10]{sphinx}
	\usepackage{geometry}
	\usepackage{setspace}
	\usepackage{hyperref}
	\usepackage{hypcap}% it must be loaded after hyperref.
	\usepackage{sphinxmessages}

However, on other tests, including other distros, I found that this
is not enough, because:

1) the *.ind creation may use xindy on some distros and xindy could try
   to use T1 fontenc. So, I had to add this line:

	\PassOptionsToPackage{xindy}{language=english,codepage=utf8,noautomatic}

  to ensure that, if xindy is used, it will get codepage=utf8. 

2) there were some other corner cases that required to add 

	\newfontfamily\headingfont{DejaVu Serif}

Again related to T1 fontenc.

Thanks,
Mauro

  reply	other threads:[~2025-08-19 13:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 11:36 [PATCH 00/11] Fix PDF doc builds on major distros Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 01/11] docs: Makefile: Fix LaTeX paper size settings Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 02/11] docs: conf.py: better handle latex documents Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 03/11] docs: conf.py: fix doc name with SPHINXDIRS Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 04/11] docs: conf.py: rename some vars at latex_documents logic Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 05/11] docs: conf.py: fix some troubles for LaTeX output Mauro Carvalho Chehab
2025-08-20  8:16   ` Akira Yokosawa
2025-10-02 16:30     ` ChaosEsque Team
2025-08-15 11:36 ` [PATCH 06/11] scripts: sphinx-pre-install: fix PDF build issues on Ubuntu Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 07/11] scripts: sphinx-pre-install: add missing gentoo pdf dependencies Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 08/11] scripts: sphinx-pre-install: fix PDF dependencies for openSuse Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 09/11] scripts: sphinx-pre-install: fix dependencies for OpenMandriva Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 10/11] scripts: sphinx-pre-install: fix pdf dependencies for Mageia 9 Mauro Carvalho Chehab
2025-08-15 11:36 ` [PATCH 11/11] scripts: sphinx-pre-install: fix PDF dependencies for gentoo Mauro Carvalho Chehab
2025-08-16  5:06 ` [PATCH 00/11] Fix PDF doc builds on major distros Akira Yokosawa
2025-08-16 11:55   ` Mauro Carvalho Chehab
2025-08-17  9:46     ` Akira Yokosawa
2025-08-17 11:36       ` Mauro Carvalho Chehab
2025-08-17 12:24         ` Akira Yokosawa
2025-08-17 13:45           ` Mauro Carvalho Chehab
2025-08-17 16:07             ` Akira Yokosawa
2025-08-18  0:44               ` Akira Yokosawa
2025-08-18  9:42                 ` Mauro Carvalho Chehab
2025-08-18 10:06                   ` Akira Yokosawa
2025-08-18 11:35                     ` Mauro Carvalho Chehab
2025-08-18 12:00                       ` Akira Yokosawa
2025-08-18 17:07               ` Jonathan Corbet
2025-08-18 23:26                 ` Akira Yokosawa
2025-08-19  1:02                   ` Mauro Carvalho Chehab
2025-08-19  2:16                     ` Akira Yokosawa
2025-08-19 13:32                       ` Mauro Carvalho Chehab [this message]
2025-08-19 23:54                         ` Akira Yokosawa
2025-08-20  7:15                           ` Mauro Carvalho Chehab
2025-08-20 11:41                             ` Akira Yokosawa
2025-08-20 16:48                               ` Mauro Carvalho Chehab
2025-08-20 23:53                                 ` Akira Yokosawa
2025-08-21  0:09                                   ` Akira Yokosawa
2025-08-21  7:52                                     ` Mauro Carvalho Chehab
2025-08-21  7:56                                       ` Mauro Carvalho Chehab
2025-08-21  9:12                                     ` Inkscape - Was: " Mauro Carvalho Chehab
2025-08-18 16:59       ` Jonathan Corbet
2025-08-17 15:32 ` Vegard Nossum
2025-08-18  8:33   ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250819153200.3c2b2ff6@foz.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=akiyks@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.