-
Notifications
You must be signed in to change notification settings - Fork 806
feat: support embed fonts #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
As it pointed out in #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:
|
|
I faced the same problem where PPTX generated by pptxgenjs could not embed custom fonts. GitHub: pptx-embed-fonts Exampleimport pptxgenjs from "pptxgenjs";
import { withPPTXEmbedFonts } from "pptx-embed-fonts/pptxgenjs";
const pptxgen = withPPTXEmbedFonts(pptxgenjs);
const pptx = new pptxgen();
const fontFile = await fetch("/font.ttf").then((res) => res.arrayBuffer());
const fontInfo = pptx.getFontInfo(fontFile);
const fontFace =
fontInfo.names.fontFamily.en || fontInfo.names.fontFamily.zh;
pptx.addFont({
fontFace: fontFace,
fontType: "ttf",
fontFile: fontFile,
});
const slide = pptx.addSlide();
slide.addText("Hello World 你好啊", {
x: 0,
y: 1,
w: "100%",
h: 2,
align: "center",
color: "0088CC",
fontSize: 24,
fit: "shrink",
fontFace: fontFace,
});
const pptxFile = await pptx.writeFile({
fileName: "example.pptx",
}); |
|
We need it |

Through the new API addFonts, support embedding fonts into .ppt file.