14

PhoneGap 是否支持网络字体,如果支持,您如何使用它们。我目前在我的页面中有此代码,但它在加载到模拟器时不起作用(在 android 应用程序中,我没有尝试通过浏览器加载页面)...

@font-face {
    font-family: 'HelveticrapRegular';
    src: url('fonts/helveticrap-webfont.eot');
    src: url('fonts/helveticrap-webfont.woff') format('woff'), url('fonts/helveticrap-webfont.ttf') format('truetype'), url('fonts/helveticrap-webfont.svg#webfontHlJ0Jib3') format('svg');
    font-weight: normal;
    font-style: normal;
}
body {
    font-family: "HelveticrapRegular", "Helvetica", "Arial", "sans serif";
}

当我在 Firefox 中加载我的页面时,它确实有效,所以我不确定我做错了什么。

说字体 CSS 是由 fontsquirrel 生成的可能会有所帮助

谢谢 :) 乔尔

4

3 回答 3

8

我在使用 Woff 格式的自定义字体时遇到了问题。然后我将它从 Woff 转换为 Ttf 并在我的 Android 设备上运行。所以使用 Woff 格式可能会有问题。

因此,从 .woff 转换为 .ttf 可能会解决问题。

于 2012-09-17T20:56:09.913 回答
5

我让 PhoneGap 识别网络字体没有问题。如果 WebKit 会这样做,那么 Android 和 iOS 也会这样做。在我现在正在进行的一个项目中,目前仅在 Android 上进行了测试:

@font-face{
 font-family: MyFont; 
 src: url('../fonts/my_font.ttf') format('truetype');
 src: url('../fonts/my_font.otf') format('opentype');

然后在风格上

font-family:MyFont, arial, sans-serif;
于 2011-06-30T05:41:58.710 回答
1

Webfonts 在 android 2.1 中被破坏,不幸的是,这是一个已知的错误。

于 2011-11-13T02:20:26.870 回答