【发布时间】:2020-12-24 18:25:43
【问题描述】:
我想在pywebview 应用程序中使用自定义字体,但添加 CSS 后,仅使用备用字体。字体文件位于/css/fonts 目录中,但相对路径或绝对路径都不起作用。
我的 CSS:
@font-face {
font-family: 'Retro Gaming';
src: url('fonts/retro_gaming.ttf') format('truetype'),
url('fonts/retro_gaming-webfont.woff2') format('woff2'),
url('fonts/retro_gaming-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
body {
font-family: 'Courier New', Courier, monospace;
}
.menu {
font-family: 'Retro Gaming', Courier, monospace;
}
我的 HTML:
<html>
<body>
<p class="menu">This font should be Retro Gaming</p>
<p>This font should be Courier New</p>
</body>
</html>
我在启动应用程序时看到的消息是:
127.0.0.1 - - [24/Dec/2020 18:13:11] "GET / HTTP/1.1" 200 200
127.0.0.1 - - [24/Dec/2020 18:13:11] "GET /fonts/retro_gaming.ttf HTTP/1.1" 404 42
127.0.0.1 - - [24/Dec/2020 18:13:11] "GET /fonts/retro_gaming-webfont.woff2 HTTP/1.1" 404 52
127.0.0.1 - - [24/Dec/2020 18:13:11] "GET /fonts/retro_gaming-webfont.woff HTTP/1.1" 404 51
编辑: 带有字体文件路径的图像:
【问题讨论】: