views:

799

answers:

1

While there are ways to load fonts as swf files, what I am more looking at is a way to load the font file itself, say the user uploads a font file , how can i use that font file in the application itself?

Thanks, Faisal Abid

+1  A: 

Unfortunately I am quite sure this is not possible, in any normal way at least. You can't load in a bytearray of a ttf-file and pass it to Font.registerFont(), which needs to be called in order to use the font.

However, even though I do not possess all of the knowledge to do it, I know it is definitely not impossible.

As you said, fonts can be loaded from swf's, and swf's can be created dynamically as a byteArray and loaded in.

I don't know if this would be an option at all for you, and I'm not sure how hard it would really be. I would read up on the swf file format spec available here: http://www.adobe.com/devnet/swf/ Then study the bytecode of an empty swf, and then the bytecode of a swf with a single font embedded, and find where the data of the font is, that's what has to be replaced with the font supplied by the user. I wonder if all of the file-content is untouched when embedded in the swf. In that case it's practically just a matter of inserting the font-data in the right place of the template swf, which shouldn't be too hard. But it probably be a bit harder than that, and I suspect it gets compressed as well... There might be some info about creating swf's programmatically if you google around..

Sorry I couldn't give you a more convenient answer =)

Clox
Well that gave me an idea. Maybe what I can do (since were hosting this on our vps) is create a template as file and use ColdFusion to fill out the template and pass it to mxmlc and get that swf loaded into our app.Theoretically that should workThanks Man!
Faisal Abid
Glad it helped =)Heh, I like your idea, of course that would be slower, and there will be more work for the server, but it's definitely a lot easier and faster to implement.
Clox
Yea its a little slower, but were using this internally to build some stuff. So itll suffice
Faisal Abid