Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-24-2008, 06:52 PM   #1
lucidmedia
Member
 
Join Date: Jun 2007
Location: Norton, MA
Posts: 57
Default Runtime Embedding of Regular and Bold OpenType fonts with Actionscript

Hi all,

I have been tussling with this all morning. Any suggestions?

Writing all actionscript in Flex 3 editor.

I am embedding fonts in an SWF then downloading the swf and registering fonts at runtime.

Its working fine with different typefaces, but I cannot get access to a regular and bold version of the same font.

Below I am embedding the fonts. I have also tried to use "FontFamily" instead of "FontName" option, with no luck.

ActionScript Code:
package {     import flash.display.Sprite;     public class EDC_fonts extends Sprite     {         // embed two fonts into an SWF         [Embed(source="/fonts/MeliorLTStd.otf", fontName='emMelior', mimeType='application/x-font')]         public static var MeliorFont:Class;                 [Embed(source="/fonts/DINOT-Regular.otf", fontStyle = 'regular', fontName='emDIN', mimeType='application/x-font')]         public static var DinFont:Class;                [Embed(source="/fonts/DINOT-Bold.otf", fontStyle = 'bold', fontName='emDINbold', mimeType='application/x-font')]         public static var DinBoldFont:Class;     } }

once the SWF has downloaded, I pull the fonts in like this (this is part of a loader):

ActionScript Code:
var EDC_fonts:Class = event.target.applicationDomain.getDefinition("EDC_fonts") as Class;                          Font.registerFont(EDC_fonts.MeliorFont);                    Font.registerFont(EDC_fonts.DinBoldFont);          Font.registerFont(EDC_fonts.DinFont);

I have been unable to get access to both normal and bold weights of DIN. Whichever weight is registered last becomes the "regular" weight of the type, make sense?

I can't seem to find much documentation on this, so any help would be greatly appreciated!!
lucidmedia is offline   Reply With Quote
Old 03-24-2008, 07:09 PM   #2
lucidmedia
Member
 
Join Date: Jun 2007
Location: Norton, MA
Posts: 57
Default

ok, I swapped out FontStyle with FontWeight, but this has led to a more challenging problem:

the following code pulls an error saying the bold font cannot be found!

Is there a different technique for embedding opentype fonts?


ActionScript Code:
package {     import flash.display.Sprite;     public class EDC_fonts extends Sprite     {         // embed two fonts into an SWF         [Embed(source="/fonts/MeliorLTStd.otf", fontName='emMelior', mimeType='application/x-font')]         public static var MeliorFont:Class;                 [Embed(source="/fonts/DINOT-Regular.otf", fontFamily='emDIN', mimeType='application/x-font')]         public static var DinFont:Class;                [Embed(source="/fonts/DINOT-Bold.otf",  fontWeight = 'bold', fontFamily='emDIN', mimeType='application/x-font')]         public static var DinBoldFont:Class;     } }

I get the same issue whether I use the FontFamily or FontName directive
lucidmedia is offline   Reply With Quote
Old 03-24-2008, 07:24 PM   #3
lucidmedia
Member
 
Join Date: Jun 2007
Location: Norton, MA
Posts: 57
Default

the following works: Opentype fonts with multiple weights have to be embedded by name as a system font -- I could not load it from the font file.

ActionScript Code:
package {     import flash.display.Sprite;     public class EDC_fonts extends Sprite     {         // embed two fonts into an SWF         [Embed(source="/fonts/MeliorLTStd.otf", fontName='emMelior', mimeType='application/x-font')]         public static var MeliorFont:Class;                 [Embed(systemFont='DINOT-Regular', fontFamily='emDIN', mimeType='application/x-font')]         public static var DinFont:Class;                [Embed(systemFont="DINOT-Bold", fontWeight='bold', fontFamily='emDIN', mimeType='application/x-font')]         public static var DinBoldFont:Class;     } }
lucidmedia is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Text and Fonts ksb43 ActionScript 2.0 13 11-17-2009 04:04 AM
to chat component how to add styles, that italic, bold regular advika Flash Media Server 0 05-26-2006 11:18 AM
Embedding fonts in a dynamic text box & formatting with css zymosan ActionScript 2.0 1 04-19-2006 08:35 PM


All times are GMT. The time now is 05:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.