如何在一个应用程序集成的自定义字体? [英] How do you integrate custom fonts in an app?

查看:117
本文介绍了如何在一个应用程序集成的自定义字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从以下网站自定义字体(Imperator.ttf和goodfish.ttf)融入我的电晕应用程序:
http://www.1001freefonts.com/top-fonts.php

I am trying to integrate custom fonts (Imperator.ttf and goodfish.ttf) from the following website into my corona app:
http://www.1001freefonts.com/top-fonts.php

我下面仔细教程这里找到电晕的官方网站:
http://www.coronalabs.com/blog/ 2013/01/16 /常见问题解答 - 周三 - 自定义的字体/

I am following carefully the tutorial found here on Corona's official website:
http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

我跟踪整个过程MacOSX的集成(安装双击字体等),并没有得到任何错误。我还增加了字体文件名以我build.settings文件:

I follow the whole procedure for macosx integration (installing the font by double clicking etc) and do not get any error. I also added the font file name to my build.settings file:

 UIAppFonts =
 {
       "Imperator.ttf"
 },

每当我启动模拟器和调试当前加载的字体,新的没有出现。

Whenever i launch the simulator and debug the currently loaded fonts, the new one doesn't appear.

有没有一种简单的方法来调试电晕模拟器的问题,在OSX,解决为什么字体不加载?

Is there an easy way to debug the issue on corona simulator, on osx, to troubleshoot why the font doesn't load ?

感谢

推荐答案

在安装自定义字体您电晕的应用程序,你必须遵循以下步骤:

While installing custom fonts to your corona application, you have to follow the following steps:

  • 在系统中安装的字体。
  • 复制并粘贴到字体文件(如: Imperator.ttf )的应用程序文件夹,你的的main.lua 的存在。
  • 然后为iPhone(仅适用于iPhone,Android的不需要此),以下行添加到您的 build.settings
  • Install the font in your system.
  • Copy and paste the font file(such as: Imperator.ttf) to the application folder where your main.lua exists.
  • Then for iPhone(only for iPhone, Android doesn't need this), add the following lines to your build.settings:
iphone =
    {
        plist =
        {
            UIAppFonts =
            {
                "Imperator.ttf"  -- Font file name
            },
            UIApplicationExitsOnSuspend = true
        },
    }


  • 调试并获得支持的字体名称使用以下系统:

    • Debug and get the supported Font Names by the system using the following:
    • local fonts = native.getFontNames()
      for i,fontname in ipairs(fonts) do
          print(fonts[i])
      end
      


      从上面的调试,就可以得到确切的字体名称(此处为:大将军),您必须在创建文本/标签使用。有时,这可能不同于字体文件的名称。您也可以从它像Photoshop(它的文本工具的字体名称)等应用程序。


      From the above debugging, you can get the exact Font Name (here: Imperator) that you have to use while creating the text/label. Sometimes this may differ from the name of the font file. You can also get it from applications like photoshop(it's text tool font name), etc.

      local myText = display.newText("Label with custom font",150,100,"Imperator",20)
      

      最后,您将得到的输出为:

      Then finally, you will get the output as:

      这篇关于如何在一个应用程序集成的自定义字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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