让网页字体与phonegap工作,以及如何



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

生成的

谢谢:)Joel

我在使用Woff格式的自定义字体时有一个问题。然后我把它从Woff转换成Ttf,在我的安卓设备上也能运行。所以使用Woff格式可能会有问题。

因此,将。woff转换为。ttf可能会解决这个问题。

我让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;

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

最新更新