Compare commits

...

2 Commits

Author SHA1 Message Date
Antonin Stefanutti
0e0a75bcf0
3.14.0 2024-08-16 17:49:42 +02:00
Antonin Stefanutti
659d10dee9 Detect font type before parsing 2024-08-16 17:29:06 +02:00
3 changed files with 14 additions and 4 deletions

View File

@ -497,7 +497,7 @@ async function printSlide(pdf, slide, context) {
// 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 });
font = Font.create(Buffer.from(bytes), { type: fontType(bytes), hinting: true });
} catch (e) {
console.log(chalk.yellow('\nSkipping font compression: %s'), e.message);
return;
@ -534,6 +534,16 @@ async function printSlide(pdf, slide, context) {
}
};
function fontType(bytes) {
const buffer = Buffer.from(bytes);
if (buffer.readInt32BE() === 0x10000) {
return 'ttf';
}
if (buffer.toString('utf8', 0, 4) === 'OTTO') {
return 'otf';
}
}
function mergeGlyph(font, index, glyf) {
if (font.data.glyf.length <= index) {
for (let i = font.data.glyf.length; i < index; i++) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "decktape",
"version": "3.13.0",
"version": "3.14.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "decktape",
"version": "3.13.0",
"version": "3.14.0",
"license": "MIT",
"dependencies": {
"chalk": "5.3.0",

View File

@ -2,7 +2,7 @@
"name": "decktape",
"description": "High-quality PDF exporter for HTML presentation frameworks",
"author": "Antonin Stefanutti",
"version": "3.13.0",
"version": "3.14.0",
"homepage": "https://github.com/astefanutti/decktape",
"license": "MIT",
"main": "decktape.js",