Actionscript 3: Bold not working on external fonts in a font family.

There was an issue with compiling external font swf made up of a font family in flex builder. For example when trying to generate a set of AkzidenzGrotesk regular, light, bold and black the bold will now show up.

Here is a typical font embedding code in an actionscript project.

package {

	import flash.display.Sprite;

	public class AkzidenzGrotesqueBold extends Sprite
	{

		[Embed(source='assets/AkzidenzGrotesk-Bold.otf',  fontName='AkzidenzGrotesqueBold')]
		public static var AkzidenzGrotesqueBold:Class;

	}
}

Every font will compile and generate a corresponding swf except bold.

To get around this issue make sure to define the font weight.

package {

	import flash.display.Sprite;

	public class AkzidenzGrotesqueBold extends Sprite
	{

		[Embed(source='assets/AkzidenzGrotesk-Bold.otf',  fontWeight='bold' fontName='AkzidenzGrotesqueBold')],
		public static var AkzidenzGrotesqueBold:Class;

	}
}

Don’t bother defining the fontFamily=”AkizidenzGrotesk”, CSS in flash will ignore it. It only uses the fontName=”blah”.
Bold font should have fontWeight=”bold”, italic font should have fontStyle=”italic” and a bold italic should define both.

Hope that helps
~mark

[ad#Google Adsense]

Author: mark

Creative technologist

Leave a Reply

Your email address will not be published. Required fields are marked *