无法在iOS应用中使用自定义字体 [英] Can't use custom font in iOS app

查看:128
本文介绍了无法在iOS应用中使用自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的iOS应用使用自定义字体。这是我的工作

I'm trying to use custom font for my iOS app. Here is what I do

我将自定义字体(m.tff)添加到Xcode支持文件目录。此外,我创建了一个名为Fonts的条目,由myApp.plist中的字体(m.tff)的值名称提供。

I added my custom font (m.tff) to Xcode Supporting files directory. Also I create entry called Fonts provided by application with value name of the font (m.tff) in myApp.plist

在我的视图中我有一个标签

In my view I have a label

UILabel *label = [[UILabel alloc]initWithFrame:CGRect(10, 20, 230, 30)];
label.font = [UIFont fontWithName:@"My custom font" size:15];

等...

问题就是当我启动应用程序时,标签中的文字是使用默认字体而不是使用特定字体。

The problem is that when I launch the app the text in label is with default font instead of using the specific one.

我想念的是什么?

EDITED

好吧现在看起来很有效,但字体只适用于像?但不是信件。
我正在使用西里尔文btw。

Well it seem works now, but the font applies only for characters like , ? but not for letters. I'm using cyrillic btw.

推荐答案

用它来获取所有可用的字体

Use this to get all the fonts available

  // List all fonts on iPhone
  NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
  for(NSString *familyName in familyNames)
  {
    NSLog(@"family: %@", familyName);

    NSArray *fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:familyName]];
    for(NSString *fontName in fontNames)
    {
      NSLog(@"    font: %@", fontName);
    }
  }

查找嵌入的字体,看看它是否是名字是一样的。

Look for the font you embedded and see if it is the name is the same.

这篇关于无法在iOS应用中使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆