views:

1479

answers:

2

I'm using an external swf containing a number of font classes to load and register the fonts for my flash site at runtime. (exported in the library panel Flash IDE then registered in the frame script)

In this particular case the swf contains a number of different weights of the same family. eg. font roman, font italic, font light, font heavy, etc...

The fonts appear to register fine, but when I try to use the fonts some of the fontName properties of these fonts are identical. Three are showing up as Roman and two as light and one is light sc... So I went searching for some silly coding errors, but to my dismay I didn't find any. The correct font objects were loading in the right order.

After quite a bit of testing I checked my fonts folder (vista). When I opened the file for Heavy the title in font viewer shows Roman; the titles in font viewer matched what I was getting in flash. This behaviour appears to be unique to this font.

Since fontName is the only way i know how to assign a font to a TextField I'm stumped as to how I can use that lovely heavy font for my dynamic headings!

It's a type 1 font

Can anyone suggest a cause, solution or a workaround?

A: 

It sounds like that is a problem with the font rather that your software(Flash).

If it's a free font, it is quite possible that the author of the font-family used one font as a base and edited copies of it for different styles of the face. They may have just changed the filename, and forgot to change the internal name.

You might be able to edit the names yourself somehow, but I am not too sure about this.

TandemAdam
+1  A: 

Thanks, i think your right about that.

I did however find a way of embedding the font and setting the name.

First of all I used CrossFont to convert the Type 1 postscript font to an .otf

Using the [embed()] feature now available in cs4, I was able to use the fontFamily attribute to set the fontName property of the embedded font.

In the code below you can see I set the name to "BlaaDeeBlaa" and the TextFormat will accept it and display the embedded font.

[Embed(source="assets/FontFileName.otf",
                            fontFamily="BlaaDeeBlaa",
                            mimeType="application/x-font")]
var BlaaDeeBlaa:Class;

var CH:Font = new BlaaDeeBlaa();

var testTxt:TextField =  new TextField();
testTxt.defaultTextFormat = new TextFormat("BlaaDeeBlaa",28,0x000000,true);
testTxt.embedFonts = true;
testTxt.text = Font.enumerateFonts(false)[0].fontName;
testTxt.autoSize = "left";
addChild(testTxt);

n.b. Only OpenType(.OTF) and Truetype (.TTF) can be embedded using this method

I was put onto this technique by Lee Brimelows' tutorial at gotoandlearn

rur