【问题标题】:Custom Font not working in Phonegap自定义字体在 Phonegap 中不起作用
【发布时间】:2016-03-25 19:55:10
【问题描述】:

我已经花了 5 小时尝试了所有其他线程的每个解决方案,但仍然无法正常工作。

Custom Fonts in Android PhoneGap

Phonegap : Custom font is not working

How to add custom font in PhoneGap

以上所有这些都无济于事。自定义字体在我笔记本电脑上的浏览器上工作,但是当我将它打包到应用程序中时,它不起作用。 Phonegap 3.7,它不适用于任何设备,只能在笔记本电脑浏览器上运行。

@font-face {
       font-family:'AppleMyungjo';
 src: url("/font/AppleMyungjo.ttf");
      src:url("/font/AppleMyungjo.ttf") format("truetype");
        }

#open{
    position:absolute;
    margin-left:1%;
color:white;
    top:10%;
        font-size: 150%;

font-family: 'AppleMyungjo';
    font-weight: lighter;
    text-shadow: none;

}

我检查了日志我有一个错误file:///font/AppleMyungjo.ttf Failed to load resource: net::ERR_FILE_NOT_FOUND

但我确实有一个名为 font 的文件夹,其中包含 ttf。 ttf 喜欢这样吗?

我只是尝试引用所有这些仍然不起作用

 @font-face {
       font-family:'AppleMyungjo';
 src: url("/font/AppleMyungjo.ttf");
           src:url("/css/font/AppleMyungjo.ttf") format("opentype");
          src:url("/css/font/AppleMyungjo.ttf") format("truetype");
           src:url("../font/AppleMyungjo.ttf") format("opentype");
          src:url("../font/AppleMyungjo.ttf") format("truetype");

      src:url("../css/font/AppleMyungjo.ttf") format("opentype");
          src:url("../css/font/AppleMyungjo.ttf") format("truetype");  }

解码下载的字体失败: 我该怎么办?

【问题讨论】:

  • 现在我有错误无法解码下载的字体:
  • 你把字体放在哪里了?
  • 我设法找出了原因,tff 由于某种原因损坏了。感谢您的帮助

标签: cordova phonegap-plugins font-size


【解决方案1】:

试试这个:问题出在通过外部 css 文件提供字体时所采用的路径。要解决此问题,请在 index.html 的正文中声明字体 URL 内联

<div>
      <style scoped>
        @font-face {
          font-family: Monotype Corsiva;
          src: url('fonts/Monotype_Corsiva.ttf') format('truetype');
        }
      </style>
</div>

以这种方式声明字体 URL 后,它起作用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 2014-07-22
    相关资源
    最近更新 更多