gpt4 book ai didi

html - 另一个@font-face 问题

转载 作者:太空宇宙 更新时间:2023-11-04 07:37:16 25 4
gpt4 key购买 nike

我正在构建一个网站,并希望使用一种奇特的非标准字体。所以我得到了 .ttf 并通过基于网络的转换器运行它以生成一个(更小的).woff2 文件。

他们还提供了一个小页面来测试 html、css 和字体。 (我对其进行了一些修改,将其转换为 .aspx 并让它抽出服务器时间,这样我就可以确定它会自行刷新。

结果是,当我在本地预览此文件时(我使用 Visual Studio 2017)一切正常。然后我将 .aspx、.css 和 .woff2 文件通过 FTP 传输到(远程)测试服务器(在与开发中完全相同的位置),但字体不显示。

所以我的问题是,本地站点和远程站点之间有什么不同,本地站点会正确显示页面,而远程站点不会?

浏览器恰好是 Firefox Quantum v58,但我不确定这有什么不同,因为在本地,一切正常。我明白本地和远程在安全设置方面可能存在差异,但我在关闭防火墙 (Zonealarm) 的情况下进行这些测试。

一些片段:

/* font converted using font-converter.net. thank you! */
@font-face {
font-family: 'ad';
src: url('Fonts/ActionDisplay.woff2') format('woff2');
}

<html>
<head>
<title>You converted a font!</title>

<link rel="stylesheet" href="stroke.css" type="text/css" media="all" />

<style>
.thankyou, .notes {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
}

.sample {
font-family: 'ad', Courier;
font-size: 24px;
border: 1px solid #ddd;
display: inline-block;
padding: 10px;
}
</style>
</head>
<body>
<p class="thankyou">
Thank you for using <a href="http://www.font-converter.net">font-converter.net</a>!<br />
We really appreciate you for using our little service. We hope we can help you with our services again soon.
<br /><br />
And there it is, your lovely converted web font:
</p>

<p class="sample">
The quick brown fox jumps over the lazy dog
</p>

<p class="notes">
<b>CSS Stylesheet:</b> You'll find the stylesheet in this folder (if selected). The file is called <code>style.css</code><br />
<b>web fonts:</b> You'll find all converted fonts in a subdirectory called <code>fonts</code> in this folger<br />
<% Response.Write(DateTime.Now.AddHours(8)) %>
</p>
</body>
</html>

和工作页面:

local

最佳答案

您的开发工具的网络选项卡显示什么?字体加载了吗?

本地开发服务器和远程服务器之间的一个区别可能是远程服务器提供了错误的 mime-type(需要是 font/woff2)。

如果您发现 404,则路径不正确。请注意,网络服务器通常具有区分大小写的文件系统。因此,您可以让两个目录 fontsFonts 和平共处。文件名也是如此。 Windows 没有区分大小写的文件系统(这是 Windows 的众多缺点之一)。

关于html - 另一个@font-face 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48841313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com