Create Font SWFs easily in FDT

I created an ANT build file which lets you create font SWFs easily, it takes a class template as input, generates the actual class for the chosen font and compiles the corresponding swf. but enough talking … give it a try.

Download:

fontcreator.zip

Setup:

  • import the zip file via “Import > Existing Projects.. > Select archive file”
  • add flash nature: AS3, Flex 3/4 SDK
  • run the ant build (don’t forget to select “Run in the same JRE as the workspace” in External Tools > JRE)

Steps:

select class template (you can create an own class template, save it in the template directory und select it here)

select font file (has to be in the assets/fonts directory)

specify a class name for your font class

the name for the font (thats the name you’ll use with TextFormat.font later on)

font weight

font style

mime type, normally ‘application/x-font’ should do the job

specifiy the chars to want to embed

 

That’s it. Now your font should get generated and afterwards be available in the deploy/fonts directory.



24 Responses (Add Your Comment)

  1. Danke für dein HowTo :)

  2. Holy crap! An Ant task to aspire to….

  3. what’s short for PDT

  4. @yunzhong: What do you mean?

    Maybe what FDT stands for? In this case: http://fdt.powerflasher.de

  5. brilliant, as always ;)
    thanks for beeing patient with my font-misspelling problem ;)

  6. This will be a very handy tool. I am currently getting the error:

    BUILD FAILED
    /Users/dr/Documents/workspace/fontcreator/build.xml:86: java.lang.RuntimeException: Error during compiling!

    Has anyone seen this when trying this ant script. I tried removing and re-adding the flash nature to no avail.

  7. just a quick note for the fix. You will need to create the deploy/fonts folder in your project. Simple enough fix, this is great. thank you.

  8. I get the error:
    Buildfile: D:\ProjectWork\fontcreator\build.xml
    1. input:
    2. create class file:
    3. compile font:

    BUILD FAILED
    D:\ProjectWork\fontcreator\build.xml:86: Problem: failed to create task or type fdt.launch.application
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any / declarations have taken place.

    Total time: 6 seconds

    Any ideas to why?

    Thanks :)

  9. Tom’s problem was that he didn’t select “Run in the same JRE as the workspace” in External Tools > JRE

  10. there is a problem with import from zip in the newer fdt versions.

    fdt cant find the linked SWCs.

    Fix 1: change them in as3_classpath
    Fix 2: unzip the project and copy the folders manually in a seupted fdt flash project

  11. Given the number of dialogues to fill in, a simple AS3 script would be equally complex to compile.

    I’d add a direct link here, but it appears you can’t, it returns a blank page :(

  12. Trying again: Embed system fonts with Flex SDK http://tekkie.flashbit.net/flash/as/embed-system-fonts-with-flex-sdk

    That you can do using even the open-source AXDT on Eclipse with Flex SDK.

  13. sure the ANT script does exactly the same thing, but you can compile fonts without having to know AS3 code and syntax and the generated fonts are ready for loading at runtime

  14. heh. Very, very nice, but how about even easier than that?

    Step 1) Upload Font
    Step 2) There is no step 2.

    http://karoshiethos.com/2010/03/03/flash-and-kerning/

  15. Hey Jon … your font to swf compiler is easy, but the user doesn’t have any influence on the output (embedded chars, font weight, font style, …) or the class used for compiling the font. that’s probably insufficient for most use cases.

    btw. there are loads of smart tools out there for font to swf compiling. use the one which fits to your workflow best

    http://www.squidder.com/fontswfcreator/
    http://kevincao.com/app/font/

  16. @Martin: Ah, but it will soon :) Definitely plan to add character ranges and an override on the font name.

    Influencing the font weight/style works a bit differently than expected — most individual font files only contain the outlines for one weight/style pair, and if your embed code doesn’t match, the compiler will throw a transcoding error. My tool introspects the font and determines this info automatically.

    No, I probably won’t ever let you upload a class template, but in practice I’ve found this isn’t actually necessary. (Lucky for me, I control the template, eh?)

    And totally agreed — use what works best for your flow.

    By the way, I’ve been digging deep into ANT this week, and you’ve exposed me to a whole world of new goodies. Thanks!

  17. Oh, and if you care about kerning pairs (you might not), your only choices (that I’m aware of) are my tool or the Windows Flash IDE :(

  18. @Jon cool … I’m very much looking forward to it

  19. Hey Martin,

    excellent Tool! Can you provide a short snippet on how to use fonts embedded in swfs which are embedded themselves?

    Such as:

    package framework.font
    {
    public class MyFontLib
    {
    [Embed(source="../../../lib/font/MyFont.swf", fontName="MyFont", fontWeight="normal")]
    private var myFont : Class;
    }
    }

    When I now iterate over my enumeratedFonts, I see the embedded font but it is not showing up in my textfields. Any hints?

    Thanks in Advance!

    Frederik

  20. It’s not very straightforward to get a class out of an embedded swf, but it’s possible … I put an example here:
    http://blog.formatlos.de/wp-content/uploads/2010/05/EmbedFontSWF.as

Trackbacks:

Leave a Reply

Formatting: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Other Entries

About

Martin Rädlinger is an Interactive Developer & Designer. He specializes in interactive coding predominantly with ActionScript, but every new challenge is welcome. If you like his work feel free to get in touch with him. At the moment he's available for freelance work.

Contact

Martin Rädlinger
mail: mr [at] formatlos.de
web: www.formatlos.de
xing: Martin Rädlinger
linkedin: Martin Rädlinger
skype: martinraedlinger