From 0301a255fae77afa5fa6eb8a4f22d3b57705b770 Mon Sep 17 00:00:00 2001 From: tmont Date: Thu, 14 Nov 2024 13:57:39 -0800 Subject: [PATCH] fixed font embedding --- README.md | 13 ++++++++++--- index.mjs | 7 +++---- pages/001-title.html | 1 - pages/002-title2.html | 1 - pages/003-toc.html | 1 - pages/{197-timeline.html => 196-timeline.html} | 1 - 6 files changed, 13 insertions(+), 11 deletions(-) rename pages/{197-timeline.html => 196-timeline.html} (99%) diff --git a/README.md b/README.md index eb034dc..9085f56 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,23 @@ To generate PDFs: 2. `mkdir -p rendered` 3. `node index.mjs` +Note that the fonts "Schibsted Grotesk" and "Sometype Mono" must be installed +on the system. + +Also note that this uses Firefox instead of Chrome to generate the PDFs. +Chrome seems to embed the fonts as Type 3 fonts, which are bad for printing. +Firefox seems to embed them as TrueType or Type 1C, which are better. + ``` -tmont@thelio:~/code/sources-of-light (main +) node index.mjs +$ node index.mjs processing 001-title.html... generated PDF at /home/tmont/code/sources-of-light/rendered/001-title.pdf processing 002-title2.html... generated PDF at /home/tmont/code/sources-of-light/rendered/002-title2.pdf processing 003-toc.html... generated PDF at /home/tmont/code/sources-of-light/rendered/003-toc.pdf -processing 197-timeline.html... - generated PDF at /home/tmont/code/sources-of-light/rendered/197-timeline.pdf +processing 196-timeline.html... + generated PDF at /home/tmont/code/sources-of-light/rendered/196-timeline.pdf ``` Rendered pages will be in `rendered/`. diff --git a/index.mjs b/index.mjs index 4343823..4c27527 100644 --- a/index.mjs +++ b/index.mjs @@ -14,7 +14,8 @@ const files = fs.readdirSync(path.join(dirname, 'pages')) .map(file => path.join(dirname, 'pages', file)); const browser = await puppeteer.launch({ - executablePath: '/usr/bin/google-chrome', + browser: 'firefox', + executablePath: '/usr/bin/firefox', }); const page = await browser.newPage(); @@ -23,9 +24,7 @@ for (const file of files) { console.log(`processing ${path.basename(file)}...`); - await page.goto(`file://${file}`, { - waitUntil: 'networkidle0', - }); + await page.goto(`file://${file}`); await page.pdf({ width: '9.25in', diff --git a/pages/001-title.html b/pages/001-title.html index 3eb7193..b4fafa0 100644 --- a/pages/001-title.html +++ b/pages/001-title.html @@ -3,7 +3,6 @@ Title -