图标字体不适用于RubyMotion应用程序

时间:2013-05-26 07:54:58

标签: ios rubymotion

尝试在RubyMotion(ios)应用程序中使用图标字体表示可缩放图标时遇到问题。

我从icomoon创建了一小组图标,并将字符设置为'A','B'和'C'。

enter image description here

我将其导入到字体书中,它似乎尊重'A','B'和'C'字符:

enter image description here

为了测试,我启动了一个word文档并键入“A”,“B”和“C”,它似乎显示正常:

enter image description here

现在,在RubyMotion应用程序上 - 我将字体包含在/resources

enter image description here

(从子目录加载Lobster和Open Sans工作)

然后我引用Rakefile中的字体:

Motion::Project::App.setup do |app|
   # Use `rake config' to see complete project settings.
   app.name = 'myapp'
   app.fonts = ["OpenSans-Bold.ttf", "icomoon.ttf"]  
end

在我的控制器中,我使用icomoon字体在屏幕上添加标签:

@lblIcon = UILabel.alloc.initWithFrame([[0,0],[100,100]])
@lblIcon.text = "A"
@lblIcon.backgroundColor = UIColor.clearColor
@lblIcon.color = "#ffffff".to_color
ico_font = UIFont.fontWithName("icomoon", size:48)
@lblIcon.font = ico_font
self.view.addSubview @lblIcon

现在,当我运行rake clean强制刷新并rake启动模拟器时,字体似乎不起作用:

enter image description here

如果我使用RubyMotion检查器/ REPL并向下钻取字体,它会说它正在加载Helvetica,而不是{I}的icomoon

enter image description here

我在这里不知道为什么我无法应用icomoon字体系列而是出现helvetica

有任何建议或想法吗?

1 个答案:

答案 0 :(得分:2)

我已在'resources'文件夹中添加了我的字体并成功直接使用它们而无需操作app.fonts:

b.titleLabel.font = UIFont.fontWithName('Entypo', size: barHeight*1.1)

(我使用的字体叫做Entypo.ttf)

否则,您粘贴的代码对我来说没问题。

相关问题