Skip to content

Commit

Permalink
fix(fonts): wait for fonts to be fully loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Jun 20, 2024
1 parent 0da820e commit 3281d79
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions decktape.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ async function exportSlides(page, plugin, pdf, options) {
let hasNext = await hasNextSlide(plugin, context);
while (hasNext && context.currentSlide < maxSlide) {
await nextSlide(plugin, context);
await fontsLoaded(page);
await pause(options.pause);
if (options.slides && !options.slides[context.currentSlide]) {
process.stdout.write('\r' + await progressBar(plugin, context, { skip: true }));
Expand Down Expand Up @@ -566,6 +567,12 @@ async function nextSlide(plugin, context) {
return plugin.nextSlide();
}

async function fontsLoaded(page) {
await page.evaluate(async () => {
await document.fonts?.ready
});
}

async function writePdf(filename, pdf) {
const pdfDir = path.dirname(filename);
try {
Expand Down

0 comments on commit 3281d79

Please sign in to comment.