开发者

AIR Mobile: Loading custom fonts in iOS at runtime

Our application downloads and renders external, custom content which includes custom, proprietary fonts. For web, desktop, and Android we simply use external SWF files that have the fonts embedded. It makes technical sense why this method wouldn't work for iOS, but I haven't been able to find any alternatives. Is this simply not possible? I hope that's not the case as it would mean 开发者_JS百科our application isn't possible for iOS using the AIR mobile technologies.

Eric

Edit for Details:

Let me go into a bit more detail on this process. On the server a PDF is uploaded. We then parse and extract content from the PDF, including fonts for each page. These fonts are often completely custom and prioprietary to the content owner, as they store symbols for math and other non-standard characters. When we extract these fonts, we assign the font to a unique identifier, embed it, and compile it into a SWF. When that content is requested from the client, we have a list of fonts for it. We download all SWF files that contain those fonts and then load and register the fonts. Here is an example of the SWF we are pulling down. This is the entirety of the compiled SWF being pulled down.

package {
    import flash.display.Sprite;
    import flash.text.Font;
    import flash.system.Security;

    public class F9471cf2d10924f87820ae61a30dd4b8f extends Sprite
    {

      [Embed(source='TempF9471cf2d10924f87820ae61a30dd4b8f.swf',symbol='F9471cf2d10924f87820ae61a30dd4b8f')]
      public static var F9471cf2d10924f87820ae61a30dd4b8f:Class;



      public function F9471cf2d10924f87820ae61a30dd4b8f()
      {
          Security.allowDomain("*");
          Security.allowInsecureDomain("*");

          Font.registerFont(F9471cf2d10924f87820ae61a30dd4b8f);
      }
    }
}

We don't have a collection of these fonts to store in any libraries before hand. This is all dynamically generated content, so we need to be able to download and register fonts on demand, without any beforehand knowledge of the font.


If I understand it correctly, you want to handle custom fonts at runtime. Check this out: https://github.com/zynga/FontLabel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜