Skip to content

Commit

Permalink
Skip compression for ill-formed fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti committed May 5, 2023
1 parent e21e7a0 commit 9c0903b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion decktape.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,16 @@ async function printSlide(pdf, slide, context) {
return;
}
const bytes = decodePDFRawStream(file).decode();
const font = Font.create(Buffer.from(bytes), { type: 'ttf', hinting: true });
let font;
try {
// Some fonts written in the PDF may be ill-formed. Let's skip font compression in that case,
// until it's fixed in Puppeteer > Chromium > Skia.
// This happens for system fonts like Helvetica Neue for which cmap table is missing.
font = Font.create(Buffer.from(bytes), { type: 'ttf', hinting: true });
} catch (e) {
console.log(chalk.yellow('\nSkipping font compression: %s'), e.message);
return;
}
// Some fonts happen to have no metadata, which is required by fonteditor
if (!font.data.name) {
font.data.name = {};
Expand Down

0 comments on commit 9c0903b

Please sign in to comment.