Open Maxpsc opened 8 months ago
As it pointed out in https://github.com/gitbrent/PptxGenJS/issues/176, PowerPoint convert TTF/OTF font to it's own format FntData. So, as I tested, this PR doesn't work with TTF/OTF directly (there's error when opening presentation), but works with .fntdata files extracted from created manually PPTX with embedded fonts. Sadly, it's impossible to "embed only used symbols" in advance. And also embedded fonts work only in PowerPoint (and Aspose.Slides)
But if you still want to embed full font using this PR, here's instruction:
const fontBase64 = '...';
fetch(`data:application/octet-stream;base64,${fontBase64}`)
.then(res => res.blob())
.then(blob =>
this.presentation.addFont({
typeface: 'My Font Name',
fontBlob: blob,
})
);
setTimeout(() =>
this.presentation.write('base64')
.then((data) => {
// open index.html to get presentation
const downloadLink = document.createElement('a');
downloadLink.href = `data:application/octet-stream;base64,${data}`;
downloadLink.download = `TEST - ${new Date().toISOString()}.pptx`;
downloadLink.click();
})
.catch((err) => {
console.error(err);
})
, 0);
Through the new API addFonts, support embedding fonts into .ppt file.