mirror of
https://github.com/JOYCEQL/magic-resume.git
synced 2026-07-03 14:07:11 +02:00
test: severless font
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
|
||||
FONTCONFIG_PATH=/var/task/fonts
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
<fontconfig>
|
||||
<dir>/var/task/fonts/</dir>
|
||||
<cachedir>/tmp/fonts-cache/</cachedir>
|
||||
<config></config>
|
||||
</fontconfig>
|
||||
@@ -29,17 +29,12 @@ export async function POST(req: Request) {
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
|
||||
await page.setContent(content);
|
||||
|
||||
const marginPx = margin + "px";
|
||||
|
||||
await page.addStyleTag({
|
||||
content:
|
||||
'@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");'
|
||||
});
|
||||
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
|
||||
const pdf = await page.pdf({
|
||||
format: "A4",
|
||||
printBackground: true,
|
||||
@@ -55,6 +50,18 @@ export async function POST(req: Request) {
|
||||
waitUntil: ["domcontentloaded", "networkidle0"]
|
||||
});
|
||||
|
||||
// 加入fonts文件夹加入的字体
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
@font-face {
|
||||
font-family: 'GeistMonoVF';
|
||||
src: url('/fonts/GeistMonoVF.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
`
|
||||
});
|
||||
|
||||
await page.evaluateHandle("document.fonts.ready");
|
||||
|
||||
await browser.close();
|
||||
|
||||
Reference in New Issue
Block a user