Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Unicode-friendly renderer for PDF docs #576

Open
legoktm opened this issue Jul 11, 2024 · 0 comments
Open

Use Unicode-friendly renderer for PDF docs #576

legoktm opened this issue Jul 11, 2024 · 0 comments

Comments

@legoktm
Copy link
Member

legoktm commented Jul 11, 2024

In freedomofpress/securedrop-workstation-docs#222 we tried to add a unicode symbol, ⚙ (U+2699), to the docs, which failed because our current latex PDF renderer isn't really great with unicode.

Via sphinx-doc/sphinx#10469 I found https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine

Unfortunately switching to xelatex is only half of the solution, then we need to find a font that supports the gear icon (⚙ (U+2699)) in bold. Neither Noto nor DejaVu Serif have it. For some reason trying to set \setmainfont{Noto Color Emoji} doesn't work. Using Symbola does though, but I'm not super impressed with the rest of that font's quality.

For posterity, here's what I had tried in the workstation-docs repo:

diff --git a/deploy/Dockerfile b/deploy/Dockerfile
index e434507..f27947f 100644
--- a/deploy/Dockerfile
+++ b/deploy/Dockerfile
@@ -1,7 +1,8 @@
 FROM debian:bookworm AS sphinx
 
 ARG GIT_BRANCH=main
-RUN apt-get -q update && apt-get -qy upgrade && apt-get -qy install git make latexmk texlive-latex-extra python3-poetry
+RUN apt-get -q update && apt-get -qy upgrade && apt-get -qy install git make latexmk texlive-xetex texlive-latex-extra python3-poetry \
+    fonts-freefont-otf font-symbola texlive-fonts-extra-links
 COPY ./ .
 RUN poetry install
 RUN deploy/build $GIT_BRANCH
diff --git a/docs/conf.py b/docs/conf.py
index 4a59811..a105b6e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -160,7 +160,13 @@ htmlhelp_basename = 'SecureDropWorkstationdoc'
 
 # -- Options for LaTeX output ---------------------------------------------
 
+latex_engine = 'xelatex'
 latex_elements = {
+    'fontpkg': r'''
+\setmainfont{DejaVu Serif}
+\setsansfont{DejaVu Sans}
+\setmonofont{DejaVu Sans Mono}
+''',
     # The paper size ('letterpaper' or 'a4paper').
     #
     # 'papersize': 'letterpaper',
@@ -177,7 +183,6 @@ latex_elements = {
     # seem to make this magically work, so define individual characters.
     'preamble': r'''
     \usepackage{amssymb}
-    \DeclareUnicodeCharacter{25B8}{$\blacktriangleright$}
     '''
 
     # Latex figure (float) alignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant