Font streaming

Update: Now the project is on google code

A promise is a promise 😉 Now you can download sources of my library handling progressive download of fonts for Flash.

I clean up all to separate different works.

1. Waterfall demo

Font stream waterfall demo

Main demo proof of concept. Demonstrate the system with non embed fonts where chars are loaded when them entered. Also give an example to the usage with Flex on custom components (through Text.fontContext)

2. Font cache generator

An AS3 Command line executable (made with redtamarin) allow quickly generate fonts cache. A binary file format used to serve fast small amount of font data (optionaly a format used to storage data).

Use it to add more supported fonts for build in test (Waterfall demo). For generate font cache files simply use console: fcgen embed_fonts.swf (or use --help for display help), put generated files (by default *.foncache) in fontcache folder and update fontlist.xml

This contains also 2 others version, an old version in AS3/SWF by passing the SWF file by clicking on stage first and save the result by click second, and an not working flex alternative (read only some information about the SWF file passing through the button “open”).

3. SWF template base

Not realy important but used for generated the template used in library for generate dynamically SWF file contain fonts data.

Here miss an other part used to modify the SWF template for keep only needed informations (remove debug, metadata …)

And finally an example to embed font with Flex SDK.

Notice

I’m currently work on a big multilingual project which use it. But the server get in trouble (we suppose) with PHP when handling huge file like for Arial Unicode MS for CJK texts. We use a (temporary ?) solution by caching requested files and serve again for same requests. This not include in sources.

Beyond, is hard to get styles applied on HTML text. This for what, I had create a class handling HTML text and parsing it to know used text/fonts, improve HTML support by TextField (by some hack and HTML transformations). Is not yet include in souces.

  • Can have memory impact or CPU time when intensive usage for large range of chars (need be more tested)
  • Not all font information supported, but maybe no real impact (Small text ? and language code ? )
  • Server performance (PHP parsing and generating are time consumer) (need enhance by optimizing the script or use an other language like C/C++ or use a DB for stocking gyphs data instead a unique file)
  • Only TextField can use it, not supported by new Flash 10 TextEngine, it use an other way to embed font (CFF Fonts) (need support DefineFont4 tag)
  • The font embedded by Flash are cleaner than Flex SDK, but Flash CS3 allow generate fake italic and bold whereas Flash CS4 allow used real font styles (Light, Condensed, Heavy …)

No licence explicitly declared but sure i think as GPL, no AS3 package, more examples, SVN, dedicated page, real name, logo … this will come.

Download it ~50Mo Download it on google code

7 Comments

  1. Reply
    Polguere Gil July 19, 2009

    Awesome Memmie! I’ll take a look at it as soon as I have more time! This sounds pretty cool! 😉

  2. Reply
    Twitted by zwetan July 21, 2009

    […] This post was Twitted by zwetan […]

  3. Reply
    Vincent Helwig August 11, 2009

    Salut Memmie !
    Joli boulot, félicitation ! J’essaye d’utiliser tes sources pour tester tout ca.
    Est-ce qu’on est obliger de passer par le fichier fontcache ? ou est-ce qu’il serait possible que le php appel directement un fichier ttf ? D’après ce que je comprends le fichier est plus rapide à lire, donc préférable…
    Merci d’avance, et bravo pour ton boulot !
    Vincent ( anciennement Sqli Agency )

  4. Reply
    Mem's August 15, 2009

    Hi Vincent,
    avec un script PHP tu peux sans problème le faire. Le soucis c’est que c’est du traitement lourd (une sorte de compilation).

  5. Reply
    serge September 25, 2009

    Hi good job,

    Do you think we can make the same thing but for the server side used “Blaze DS” or “Granit DS” ?

    Actually I work on a project with the same problematic for the mulitlinguism with Java server.

  6. Reply
    Mem's September 29, 2009

    Yes but i think you need to make the server-side by rewriting fontstream.php in java. (receive font & chars needed and output fontcache file filtered)

  7. Reply
    Casandra Mcallister August 17, 2010

    Thank you for this tutorial. Will you be writing a fresh HTML tutorial soon?

Leave a Reply

Your email address will not be published. Required fields are marked *