Create Font SWFs easily in FDT
August 19th, 2009 • ActionScript, Flash, General
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:
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)
-
-
Holy crap! An Ant task to aspire to….
-
what’s short for PDT
-
brilliant, as always ;)
thanks for beeing patient with my font-misspelling problem ;) -
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.
-
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.
-
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 :)
-
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 -
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 :(
-
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.
-
heh. Very, very nice, but how about even easier than that?
Step 1) Upload Font
Step 2) There is no step 2. -
@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!
-
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 :(
-
Frederik May 19, 2010at 10:52 am
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
Danke für dein HowTo :)