如何添加自定义字体中的PhoneGap(How to add custom font in Phon

2019-10-19 12:37发布

我想自定义字体添加到我的PhoneGap的应用程序,我尝试了两种方法,我发现在互联网上,他们不使用PhoneGap的3和5的Xcode工作。

  • 使用使用CSS 字体面的方法:

     @font-face { font-family: 'Droid Arabic Kufi'; src: url('fonts/DroidKufi-Regular.ttf'); } body { font-family: 'Droid Arabic Kufi'; } 

    使用Xcode中的Info.plist文件的方法:

    1. 首先,我在项目资源文件夹添加DroidKufi-Regular.ttf。

    2. 然后,在名为Info.plist文件增加了一个新的行Fonts provided by application与所谓的项目DroidKufi-Regular.ttf 。 而仍然无法正常工作。

    3. 所以,在viewDidLoad方法我加入这行代码[UIFont fontWithName:@"Droid Arabic Kufi" size:10.0]; 但仍然没有工作。

Answer 1:

这部作品在我的应用程序。 “字体”与CSS文件的目录的子目录。

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

h1 {
    font-family: "grenouille";
}

我不知道你需要所有这些文件,但可以使用该网站产生他们http://www.fontsquirrel.com/tools/webfont-generator

如果您还有问题,检查信的情况下,从名称中删除空格和尝试应用预装的字体系列,以确保您的问题是字体,而不是CSS规则。



文章来源: How to add custom font in PhoneGap