iphone - @font-face 在移动 Webkit 中不工作

标签 iphone android css font-face mobile-webkit

我无法让 @font-face 在我测试过的任何移动 Webkit 浏览器中运行——iPhone 3GS 上的 Safari、默认的 Android 2.2 浏览器和 Android 上的 Dolphin 浏览器.

它适用于所有桌面浏览器,从 IE7 到 IE9、FF3.5、Safari 4 和 Opera。

字体和 CSS 来自 FontSquirrel:

@font-face {
    font-family: 'LeagueGothicRegular';
    src: url('../fonts/League_Gothic-webfont.eot');
    src: local('☺'),
        url('../fonts/League_Gothic-webfont.woff') format('woff'),
        url('../fonts/League_Gothic-webfont.ttf') format('truetype'),
        url('../fonts/League_Gothic-webfont.svg#webfontFHzvtkso') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'LatinModernRoman10Bold';
    src: url('../fonts/lmroman10-bold-webfont.eot');
    src: local('☺'),
        url('../fonts/lmroman10-bold-webfont.woff') format('woff'),
        url('../fonts/lmroman10-bold-webfont.ttf') format('truetype'),
        url('../fonts/lmroman10-bold-webfont.svg#webfonthCDr6KZk') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'LatinModernRoman10BoldItalic';
    src: url('../fonts/lmroman10-bolditalic-webfont.eot');
    src: local('☺'),
        url('../fonts/lmroman10-bolditalic-webfont.woff') format('woff'),
        url('../fonts/lmroman10-bolditalic-webfont.ttf') format('truetype'),
        url('../fonts/lmroman10-bolditalic-webfont.svg#webfontegrLi3sm') format('svg');
    font-weight: normal;
    font-style: normal;
}

我检查了 SVG 字体源中的 SVG ID,它们都匹配。

会不会是因为我后来在 CSS 中有一些字母间距规则?

谢谢!

最佳答案

事实证明,语法是错误的。我通过 Twitter 偶然发现了这个解决方案:

http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax

它工作得很好。只需检查所有主要浏览器,我的字体就会显示出来,包括在 Android 和 iOS 上。

现在,我的 CSS 是这样写的:

@font-face {
    font-family: 'LeagueGothicRegular';
    src: url('../fonts/League_Gothic-webfont.eot#') format('eot'),
        url('../fonts/League_Gothic-webfont.woff') format('woff'),
        url('../fonts/League_Gothic-webfont.ttf') format('truetype'),
        url('../fonts/League_Gothic-webfont.svg#webfontFHzvtkso') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'LatinModernRoman10Bold';
    src: url('../fonts/lmroman10-bold-webfont.eot#') format('eot'),
        url('../fonts/lmroman10-bold-webfont.woff') format('woff'),
        url('../fonts/lmroman10-bold-webfont.ttf') format('truetype'),
        url('../fonts/lmroman10-bold-webfont.svg#webfonthCDr6KZk') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'LatinModernRoman10BoldItalic';
    src: url('../fonts/lmroman10-bolditalic-webfont.eot#') format('eot'),
        url('../fonts/lmroman10-bolditalic-webfont.woff') format('woff'),
        url('../fonts/lmroman10-bolditalic-webfont.ttf') format('truetype'),
        url('../fonts/lmroman10-bolditalic-webfont.svg#webfontegrLi3sm') format('svg');
    font-weight: normal;
    font-style: normal;
}

很高兴知道有比该死的笑脸黑客更好的防弹解决方案。

希望这对某些人有帮助!

关于iphone - @font-face 在移动 Webkit 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4856308/

相关文章:

android - 是否可以每隔 x 分钟自动打开 Android 应用程序?

javascript - 如何使用javascript删除css属性?

html - 如何在 Bootstrap 中获得列之间的边距?

iphone - 如何在iphonesdk中获取unsigned char数据类型的字节数

ios - 应用商店网址在 Safari 中打开,但在 Chrome 中打不开。可能是什么问题?

java - HttpUrl newBuilder(String) 用法

android - 绑定(bind)返回null

iphone - 在两个 Sprite 之间创建距离缓冲区

iPhone - 我如何隐藏一个 View 并让它的空间被其他 View 使用(例如android可见性=消失)

javascript - 使用 javascript 内联样式 div