Wednesday, February 10, 2010

Embedding font family in AS3

While trying to embed font in AS3 ran into problem. I was trying to embed MyriadPro font into my AS3 application and got error "exception during transcoding: Font for alias 'MyriadPro' with plain weight and style was not found at: file" and like always Googling provided the solution.



This was what i was using
[Embed(source = "../../../assets/fonts/MyriadPro-Regular.otf", fontName = "_MyriadPro", mimeType = "application/x-font")]
public static var FONT_MYRIAD_PRO:Class;

[Embed(source = "../../../assets/fonts/MyriadPro-Bold.otf", fontName = "_MyriadPro", mimeType = "application/x-font")]
public static var FONT_MYRIAD_PRO_B:Class;

The correct method is add the weight and/ or style property.
[Embed(source = "../../../assets/fonts/MyriadPro-Regular.otf", fontName = "_MyriadPro",fontWeight="normal",  mimeType = "application/x-font")]
public static var FONT_MYRIAD_PRO:Class;

[Embed(source = "../../../assets/fonts/MyriadPro-Bold.otf", fontName = "_MyriadPro", fontWeight="bold", mimeType = "application/x-font")]
public static var FONT_MYRIAD_PRO_B:Class;

Same way if you want to embed italics version of the font, you will have to add "fontStyle='italics'" to the code.

2 comments:

  1. doing good.. though quite bored... missing KA though.. trying to play the normal worlds but it just aint much fun... :-(

    ReplyDelete