How to deal with Lucida Grande Regular & Lucida Grande Bold font in ActionScript3

Published by Igor Khrupin on

To embed Lucida Grande Regular &/or Lucida Grande Bold font in ActionScript3 you need to do next:

....
....
....
// declaring fonts
[Embed(source="fonts/Lucida_Grande_Regular.ttf", fontFamily="Lucida_Grande_Regular", fontWeight="normal", mimeType="application/x-font-truetype", embedAsCFF="false")]
private var LucidaGrandeRegular:Class;
[Embed(source="fonts/Lucida_Grande_Bold.ttf", fontFamily="Lucida_Grande_Bold", fontWeight="normal", mimeType="application/x-font-truetype", embedAsCFF="false")]
private var LucidaGrandeBold:Class;
....
....
....
....
// For Regular Font
// Create TextFormat with embeded font
var format:TextFormat = new TextFormat();
format.size = 17;
format.font = "Lucida_Grande_Regular";
format.bold = false;
format.italic = false;
format.color = 0xFFFFFF;
format.align = TabAlignment.CENTER;
// Use TextFormat
var text:TextField = new TextField();
text.embedFonts = true;
text.defaultTextFormat = format;

....
....
....

// For Bold Font
// Create TextFormat with embeded font
var format2:TextFormat = new TextFormat();
format2.size = 17;
format2.font = "Lucida_Grande_Bold";
format2.bold = false;
format2.italic = false;
format2.color = 0xFFFFFF;
format2.align = TabAlignment.CENTER;
// Use TextFormat
var text2:TextField = new TextField();
text2.embedFonts = true;
text2.defaultTextFormat = format2;

That’s it :).
Please, write questions in comments.
Don’t forget share this post 🙂


0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.