Tuesday, November 10, 2009

Flex Embedded Fonts, Images, and Compile Times

A couple of recent projects that I've worked on have had the requirement to add special fonts, and generally this means adding them via CSS, and every time I clean or build my project for testing, the compile speed becomes horrendous (read - compile times went from just a few seconds up to a minute in some cases).  This was horrible, especially if all I did was change something simple in the app, like spacing between labels.  Other problems included running out of memory in my eclipse environment and CPU consumption.  For my own efficiencies, that was just too annoying and aggrevating to deal with.

I dug around the internet and found a few resources that made some suggestions.  Two I found here.   They include changing the heap size of Eclipse and turning off auto-spell checking.  While this didn't alleviate everything, it at least has kept my MacBook from freezing up and my workbench from vomiting everywhere.

The next option I found comes from axelscript.  His suggestion to improve compile time by getting the font (and possibly images - although he admittedly didn't have time/nor need to test) into a separate project, then compiling it into a swf that would build into the current project's folder.  This helps compile times, but it does require a few extra steps and maybe a good look at Flex's StyleManager.

One more option I found very convenient (especially if you pre-initialise a few fonts or want to lazy-load some fonts) comes from this Russian site.  It provides an excellent loader that allows you to load fonts dynamically (although again, nothing about embedding images) from anywhere, locally or remotely.  The setup is extremely easy and can be incorporated dynamically add fonts at runtime.

What I would really like to know from Adobe is why compile times turn horrendous when adding new fonts.  And why do they need to be included in every build, shouldn't there be a simple way to introduce and embed multiple fonts without bloating an app and without killing my compile times?  Nothing in Jira points to this as being a bug, just a standard feature.  Will these same problems exist in FB4, Catalyst, or FP10?

No comments:

Post a Comment