视觉工作室不渲染@font-face,可能是相对路径问题吗?

发布于 2024-12-01 00:21:36 字数 1834 浏览 2 评论 0原文

请有人通过@font-face 帮助我解决这个问题。我已经多次使用这种技术,由于某种原因,我一生都无法弄清楚为什么字体没有渲染。

因此,我在 Visual Studio 中有一个名为 Web.Ui.Store 的项目,其中包含两个重要的子目录。 1./Content/css/Typography.css 2./Content/font/UTILITY-webfont.eot (我拥有 FontSquirrel 提供的所有字体,但为了解释,只是标记命名此扩展。)

现在在 Typography.css 中,我有这些代码行。

 @font-face {
font-family: 'UtilityBoldCondensed';
    src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot#iefix');
    src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot?') format('embedded-opentype'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.woff') format('woff'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.ttf') format('truetype'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.svg#UtilityBoldCondensed') format('svg');
font-weight: bold;
font-style: normal;
 }

 @font-face {
font-family: 'LeagueGothicRegular';
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot');
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot?#iefix') format('embedded-opentype'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.woff') format('woff'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.ttf') format('truetype'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.svg#LeagueGothicRegular') format('svg');
font-weight: normal;
font-style: normal;

 }

 .UtilityBoldCondensed { font-family: 'UtilityBoldCondensed', Arial, Sans-Serif; }
 .LeagueGothicRegular { font-family: 'LeagueGothicRegular', Arial, Sans-Serif; }

我很困惑为什么我的“特殊”字体无法加载到我的项目中。我今天已经多次更改相对路径,但仍然无法渲染它。我已将问题范围缩小到文件位置的相对路径问题。有人可以帮助确定这是否正确。

Someone please help me on this issue with @font-face. I have used this technique multiple times and for some reason I can not for the life of me figure out why the font-face is not rendering.

So I have a project called Web.Ui.Store in Visual Studio with two important subdirectories.
1. /Content/css/Typography.css
2. /Content/font/UTILITY-webfont.eot
(I have all the fonts provided by FontSquirrel but for explanation just labeling naming this extension.)

Now within the Typography.css I have these lines of code.

 @font-face {
font-family: 'UtilityBoldCondensed';
    src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot#iefix');
    src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot?') format('embedded-opentype'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.woff') format('woff'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.ttf') format('truetype'),
    url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.svg#UtilityBoldCondensed') format('svg');
font-weight: bold;
font-style: normal;
 }

 @font-face {
font-family: 'LeagueGothicRegular';
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot');
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot?#iefix') format('embedded-opentype'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.woff') format('woff'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.ttf') format('truetype'),
     url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.svg#LeagueGothicRegular') format('svg');
font-weight: normal;
font-style: normal;

 }

 .UtilityBoldCondensed { font-family: 'UtilityBoldCondensed', Arial, Sans-Serif; }
 .LeagueGothicRegular { font-family: 'LeagueGothicRegular', Arial, Sans-Serif; }

I am confused as to why my "special"fonts won't load on my project. I have changed the relative path so many times today and still can not get it to render. I have narrowed the problem down to it being an issue with the relative paths for the locations of the files. Can someone help determine if this is correct.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瑶 2024-12-08 00:21:36

正如我在谷歌的网络字体上看到的; @font-face 始终位于 @media screen {} 内...

查看一下:
http://fonts.googleapis.com/css?family =PT+Sans:常规、斜体、粗体、粗斜体

As I can see on google's web-font; the @font-face is always inside a @media screen {}...

Check this out:
http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文