【问题标题】:Getting web fonts to work with phonegap and android - how?让 web 字体与 phonegap 和 android 一起工作 - 如何?
【发布时间】:2011-04-17 13:45:31
【问题描述】:

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 生成的可能会有所帮助

谢谢 :) 乔尔

【问题讨论】:

    标签: android css cordova webfonts


    【解决方案1】:

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

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

    【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • @AdonisK。 Web 字体在 Android 4.1 上运行良好。我拥有一台 4.1 设备(Galaxy Note 2)并定期将其用于开发,其中我定期使用 webfonts。
      • 这是一个远程 url 问题
      猜你喜欢
      • 2015-12-16
      • 1970-01-01
      • 2023-03-30
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      相关资源
      最近更新 更多