Thursday, August 14, 2008

Embedding PFM / PFB fonts

If you embed a PFM you will get this compiler error:
"Error: exception during transcoding: Font for alias 'AdLibICG_Font' with plain weight and style was not found at:"

That is because PFM is a supporting font file, it does not contain the real data. PFB does.
You don't need the PFM font, just embed the PFB font.

[Embed(source="../assets/AdLibICG.PFB", fontName="AdLibICG_Font", mimeType="application/x-font-truetype")]
private const EMBED_ADLIBICG:Class;

You must prov
ide the mimeType or else this compiler error occurs:
"Error: '../assets/AdLibICG.PFB' does not have a recognized extension, and a mimeType was not provided"

More info on PFM/ PFB here.

5 comments:

X.D. said...

Hoping you are still watching your blog from time to time...

I too managed to do this, through trial and error, with the cmr10.pfb font from TeX.

It looks nearly like what can be seen with adobe acrobat, excepted in B&W, and when sized at 13.

Anyway, it works fine for standard characters (0-9 a-z A-Z and some others too), but I can't get to the greek characters for example. These are placed at the beginning, from 00 to 0A. It will simply not show them when typing something like "\x0A" to get an Omega.

Any ideas if this is at all possible ? Or does flash do some things with the input that would prevent me from ever getting access to these ?

Anonymous said...

You just saved me. Thanks :)

Blake said...

Uggh! I hate to admit it, but I probably would have never thought to simply use the PFB file over the PFM while trying to embed Type 1 fonts! I guess what I'm trying to say is: Thank you sooo much!!!

Rob said...

Glad I could help. Haven't posted in a while. Finding out that people find this info helpful might get me started again.

@X.D.
Sorry for not posting sooner...
The greek characters have to be in the character set. If you can verify that they are in there then using character codes should work.

Lucas said...

Thx for the tip ! worked great :)