如何为所有浏览器以ttf格式嵌入自定义网站字体?

Sam*_*ida 28 css fonts truetype font-face

在我的网站上,我使用的是我上传的自定义字体.它似乎是选择何时间歇工作.它适用于某些计算机/浏览器,但不适用于其他计算机/浏 它也正确映射.

这是我的代码:

<style type="text/css">
@font-face {
    font-family: 'AgencyFBRegular';
    src: url('agencyr.eot');
    src: url('agencyr.eot?#iefix') format('embedded-opentype'),
         url('agencyr.woff') format('woff'),
         url('AGENCYR.TTF') format('truetype'),
         url('agencyr.svg#AgencyFBRegular') format('svg');
}


h3 {    font-family: 'Agency FB', sans-serif; font-size: 26px; font-weight:normal; text-align: left; line-height: 100%;
    border-bottom: 1px solid #484848; padding-bottom: 5px; margin-bottom:7px; 
</style>
Run Code Online (Sandbox Code Playgroud)

在我用朋友的笔记本电脑查看之前,我认为它无处不在.

你能看出我出错的地方吗?

更新:我已经更新了字体CSS.它似乎工作,但现在不在iOS上.

小智 35

以下代码应该有效:

@font-face {
    font-family:"AgencyFBRegular";
    src: url("agencyr.eot") /* EOT file for IE */
}
@font-face {
    font-family:"AgencyFBRegular";
    src: url("agencyr.ttf") /* TTF file for CSS3 browsers */
}

h3 {
    font-family:'Agency FB', sans-serif;
    font-size: 26px;
    font-weight:normal;
    text-align: left;
    line-height: 100%;
    border-bottom: 1px solid #484848;
    padding-bottom: 5px;
    margin-bottom:7px;
}
Run Code Online (Sandbox Code Playgroud)


Sak*_*oki 7

您需要更改字体的文件名而不使用大写字母.像这样:从.AGENCYR.TTFagencyr.ttf

并在您的CSS文件中:

src: url('agencyr.ttf');
Run Code Online (Sandbox Code Playgroud)