astefanutti / decktape

PDF exporter for HTML presentations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeckTape Container Font Bug

thomas-ferchau opened this issue · comments

I have recently discovered DeckTape and really appreciate that I can now create PDF slides from Asciidoctor / reveal.js files from the command line :-)

My biggest concerns are internal links (#49) - that would really help - and this font-related bug for which I could not find an issue yet.

Bug Description

When generating a PDF with the decktape Docker container from reveal.js slides, fonts do not work properly:

  • The font in the PDF does not look like Arial or Helvetica or sans-serif (defined as font-family).

  • Titles are not bold in the PDF (but they are in the HTML file)

  • Acrobat Reader (on Windows) reports:

    Cannot extract the embedded font 'AAAAAA+WenQuanYiZenHei'. Some characters may not display or print correctly.

  • The problems also occur without custom CSS:

    The default reveal.js theme defines Source Sans Pro, Helvetica, sans-serif as font-family.
    Now Acrobat reader complains about the font BAAAAA+SourceSansPro-Regular.

Example Files

You can download example PDF and HTML files that show the problem and the results with the workaround applied (see below).

Versions and more Details

Decktape image: astefanutti/decktape:3.12.0
Asciidoctor image: asciidoctor/docker-asciidoctor:1.69.0
Acrobat Reader version (Windows): 24.001.20643

The HTML file was created with Asciidoctor reveal.js, but that should not matter.

It also includes FontAwesome to enable the use of icons.

Strange Behaviour

Strangely, some minor changes in the Asciidoc file removed the Acrobat Reader error message (for example, replacing some words by others!).

I cannot reproduce this right now, but the effect was definitely there. It made me try a lot of changes in the document before finding a more stable workaround (see below)...​

If it would help, I might be able to find a combination that changes the behaviour in Acrobat Reader. But I guess the root problem is not really related to that.

Reproduce the Bug

Clone my reproducer repository, follow the setup instructions, and run the following commands:

scripts/build-html.sh && scripts/build-pdf.sh

This produces the following files:

  • fontbug.html

  • pdf/fontbug.pdf (with the problems)

  • pdf/fontbug-workaround.pdf (problems fixed by workaround, see below).

Workaround

I found a workaround in removing wqy-zenhei from Dockerfile:

Replace these lines...​

    ttf-freefont\
    wqy-zenhei &&\
    # /etc/fonts/conf.d/44-wqy-zenhei.conf overrides 'monospace' matching FreeMono.ttf in /etc/fonts/conf.d/69-unifont.conf
    mv /etc/fonts/conf.d/44-wqy-zenhei.conf /etc/fonts/conf.d/74-wqy-zenhei.conf &&\

...​with this...​

    ttf-freefont &&

...​as done in this commit.

That fixes the problems as you can see in fontbug-workaround.pdf. That file is created with the container image ghcr.io/thomas-ferchau/decktape:pr-1 which includes this modification in a fork of decktape.

The workaround does not work without custom CSS - in that case, Acrobat Reader complains about the reveal.js default font: BAAAAA+SourceSansPro-Regular.

If I understand it correctly, /etc/fonts/conf.d/74-wqy-zenhei.conf defines to prefer its fonts which might cause the problem.

I'm also getting this error in Acrobat Reader when opening a PDF that was created by decktape from a revealjs presentation. The revealjs presentation was created with Quarto.

Here's the PDF: fontbug.pdf

And here's the content of the qmd document to create the revealjs HTML file. I'm not including the html file because it has too many external dependencies.

---
title: "Title"
subtitle: "Analysis of customer reviews"
format: revealjs

---


## Content

- Bullet 1
- Bullet 2

Curiously, the font error doesn't occur when I remove the subtitle, or if I shorten it to just the word "Analysis". Acrobat actually lists the font too:

Screenshot 2024-05-21 at 15 19 12

But still shows the message: "Cannot extract the embedded font 'BAAAAA+SourceSansPro-Regular'. Some characters may not display or print correctly." when opening the PDF.

Other PDF readers work: I've tried Preview and Chrome on Mac, and Edge on Windows.

Versions:
decktape 3.12.0
Quarto 1.5.30
macOS 14.4.1
Acrobat Reader 2024.002.20759