简体   繁体   English

CSS:@ font-face导入不起作用

[英]CSS: @font-face import not working

I don't understand how to get this to work, any help would be appreciated; 我不明白如何让这个工作,任何帮助将不胜感激;

I'm going off of what I got from this website: http://alistapart.com/article/cssatten 我将从这个网站上得到的内容: http//alistapart.com/article/cssatten

from my style.css 来自我的style.css

@font-face {
 font-family: "JSL";
 src: url(http://ff.static.1001fonts.net/j/s/jsl-ancient.normal.ttf) format("truetype");
}

font {
 color: #000000;
 font-size: 120%;
 font-family: "JSL";
}

Neither is the plus sign the issue (tested with my renamed fonts), nor do you have to import a separate css file at the top of your main css file. 问题的加号(用我的重命名字体测试)也没有,你也不必在主css文件的顶部导入一个单独的css文件。

However, you may need to have more versions of your font than just the true type. 但是,您可能需要拥有更多版本的字体而不仅仅是真实类型。 Have a look at Bulletproof @font-face Syntax . 看看Bulletproof @ font-face语法

You may use FontSquirrel's generator to achieve this. 您可以使用FontSquirrel的生成器来实现此目的。

Here is an example of a @font-face embed in my application, which is pinned right at the top of my main css stylesheet. 下面是我的应用程序中嵌入的@font-face的示例,它固定在我的主要css样式表的顶部。

@font-face {
    font-family: 'JustVector';
    src: url('../fonts/justvectorv2+webfont.eot');
    src: url('../fonts/justvectorv2+webfont.eot?') format('eot'),
        url('../fonts/justvectorv2+webfont.woff') format('woff'),
        url('../fonts/justvectorv2+webfont.ttf') format('truetype'),
        url('../fonts/justvectorv2+webfont.svg#webfontkw9J4lGf') format('svg');
    font-weight: normal;
    font-style: normal;
}

no 没有

@font-face

Try get inport it: 尝试进入它:

@import_your_new_cssfile.css

whre you put: 你放了什么:

font-face {
 font-family: "JSL";
 src: url(http://www.fontyukle.net/en/DownLoad-JSL+Ancient.ttf) format("truetype");
}

font {
 color: #000000;
 font-size: 120%;
 font-family: "JSL";
}

Is perhaps the "+" sign in the font URL a problem? 或许字体URL中的“+”符号出现问题? You might want to URL encode it. 您可能希望对其进行URL编码。

Edit - after hitting the font URL, it looks like you should try to download the ttf file, and refer to it locally, rather than from a remote source. 编辑 - 在点击字体URL之后,看起来您应该尝试下载ttf文件,并在本地引用它,而不是从远程源引用它。 It's prompting me for a Captcha in order to download the file, which is probably why it's not working. 它提示我使用Captcha来下载文件,这可能就是为什么它无法正常工作。

你需要下载文件并在本地引用它,支持的链接有一个下载链接,需要下载一个Captcha,这意味着它不是TTF文件的直接链接。

Depending on the Font you may need to use: 根据您可能需要使用的字体:

@font-face {
font-family: 'someFont';
src: url('path/to/font/someFont.eot');
src: url('path/to/font/someFont.eot?#iefix'), format('embedded-opentype'), 
     url('path/to/font/someFont.woff'), format('woff'), 
     url('path/to/font/someFont.ttf'), format('truetype'), 
     url('path/to/font/someFont.svg'), format('svg');
font-weight: normal;
font-style: normal;
}

and in CSS: 在CSS中:

BODY 
{
    font-family: 'someFont', Fallback, sans-serif;
    font-size: 12px;
    ... 
}

This worked for me when I had issues wityh embedding a custom font. 当我有问题嵌入自定义字体时,这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM