11ty / api-screenshot

A service to add web page screenshots to your Eleventy sites.
https://v1.screenshot.11ty.dev
111 stars 39 forks source link

I found that Chinese characters cannot be displayed correctly in screenshots while using. #19

Closed rebron1900 closed 6 months ago

rebron1900 commented 1 year ago

I found that Chinese characters cannot be displayed correctly in screenshots while using. I tried to make some modifications based on the prompts from ChatGPT (downloaded a Chinese font and placed it in the same directory as the script), but it doesn't seem to work.

我在使用过程中发现中文字符在截图中无法正常显示, 我尝试着通过 ChatGPT 的提示做了一些修改(下载了一个中文字体放在脚本的同目录下),但是似乎并不起作用。

await page.evaluate(() => {
    const font = new FontFace('Microsoft YaHei', 'url(./微软雅黑.ttf)'); // 这里使用相对路径引用字体文件
    document.fonts.add(font);
    document.body.style.fontFamily = 'Microsoft YaHei,sans-serif !important'; // 设置使用自定义字体
});
liruifengv commented 7 months ago

你好,这个问题后续有解决吗

rebron1900 commented 7 months ago

你好,这个问题后续有解决吗

没有。