Skip to main content
Inspiring
February 1, 2007
Answered

embedFonts woes

  • February 1, 2007
  • 6 replies
  • 884 views
Sorry, I posted this on the tail end of another topic but was worried it wouldn't get looked at because it was marked as answered.

I have had this problem in the past and just gotten around it by manually drawing a dynamic text field and embedding fonts in it. Now I need to use differend styles that are assigned in loaded text. But I can't even get this simple test working. Can anyone please tell me what i'm doing wrong? If I comment out the embedFonts line, the text shows but in a default font. Otherwise, I only get a blank text field.

Just so you know, I've added 3 fonts to my library and named the linkage IDs: "bodyID", italicID" and "headerID". The font type and sizes all match what I've specified in my CSS styles.
This topic has been closed for replies.
Correct answer kglad
here's your corrected file. i changed the fonts and style colors so it's obvious you're seeing the different styles and fonts applied to the same textfield.

i also used more common fonts that look significantly different from each other because i wasn't sure i had the fonts you were using and i couldn't tell what fonts they were. i used library font names that are the same as the system names so you can determine if you have those fonts on your system and if not, change them.

http://www.gladstien.com/Files/formatText.fla

6 replies

kglad
Community Expert
Community Expert
February 1, 2007
you're welcome.

i noticed a few problems with your code. one you had used

vDynamic_txt.htmlText="..." // and that won't work

and you had no linkage id for, i think, italicID.

and then there was the more significant problem that i think is perpetuated in the flash help docs and tricked me (again) when i posted my above message with the setting of text styles using class='headerID' etc.

i'd forgotten that i worked my way past that problem long ago using the tags that you showed above. and those tags are the key to setting different styles in one textfield using stylesheets.

i've even used stylesheets to tween the text properties of textfields in one project i did for a client.
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 1, 2007
here's your corrected file. i changed the fonts and style colors so it's obvious you're seeing the different styles and fonts applied to the same textfield.

i also used more common fonts that look significantly different from each other because i wasn't sure i had the fonts you were using and i couldn't tell what fonts they were. i used library font names that are the same as the system names so you can determine if you have those fonts on your system and if not, change them.

http://www.gladstien.com/Files/formatText.fla
aniebelAuthor
Inspiring
February 1, 2007
That's great! I was sure I tried that exact combination of syntax but apparently I had not. Thanks again!

Participating Frequently
February 1, 2007
You can apply the styles, but I believe the issue of embedding a mix of font family glyphs into a single TextField is not implemented for the itty bitty Flash player.

What needs to happen for embedded fonts is at publish time they need to be in the Flash movie or one that is loaded. Then each TextField can only have one embedded font assigned as you see it being done in design mode.

With a style sheet you can specify one or more fonts to a style id and it works like an HTML style or stylesheet.
aniebelAuthor
Inspiring
February 1, 2007
Ok, let's say I have this dynamic text field with nothing embedded in it BUT... I've got 3 other text fields with the 3 fonts in question that are embedded in them (or I've added them to the library... or both). Now, the SWF should contain those fonts, right?

What do I need to do then to get these styles to show up in the original dynamic text box? What I've done is set the XML attribute to match the style name and the linkage name of the font in the library. I'm still getting default font.

Thanks for your time. I just don't know how to fix this.
kglad
Community Expert
Community Expert
February 1, 2007
you can have multiple fonts in one textfield.

and amy, to assign your one of your styles to your text you should have something like:

Participating Frequently
February 1, 2007
I do not think you can have multiple embedded fonts in the same TextField.

You need to plan your page layout with multiple TextFields say one for header, one for subtitle, one for body.
aniebelAuthor
Inspiring
February 1, 2007
awwww, SNAP!

:)

wow, I was sure there was a way to set a text field to do this. What's the point of a style sheet if you can't apply it to text that way? Weird.

Thanks for you input and help!
Participating Frequently
February 1, 2007
Mixing TextField.Stylesheet and TextFormat may be the issue. The runtime embedFonts property requires the font from a TextFormat object and not from a style sheet.

To get the embedFont from a StyleSheet you need to create the TextField at design time with the Font embedded from the properties window.

If you want a dynamic environment you can create a swf with a MovieClip containing one or more dynamic TextFields with embedded fonts done in design time. Then on the main timeline at 0,0 you need the dynamic TextField with an instance name you will use in coding. Then you can use MovieClip.loadMovie or more likely MovieClipLoader to load in the swf and apply your style sheet to the TextField on the main timeline.

A general principle is that the font must be embedded when you publish and cannot be embedded at runtime.
aniebelAuthor
Inspiring
February 1, 2007
Thanks! I only added that last bit with the text format this last round of changes as a last resort. I had, in the past (as the first post indicates) manually created my dynamic text field at authoring but then was stuck with whatever font was embedded in that field. My issue is that I want to use one dynamic text field which utilizes CSS (imported or not) to format various elements individually within one text field. These elements match up to XML attribute names.. ie: bodyID, headerID, italicID.

I have even created dynamic text fields off stage with all the fonts I need embedded into those. In addition, I've added the fonts to the library and set the linkage up to match the CSS style font name AND the xml attribute name. This still does not work.

I can use the movieclip method you mentioned but I don't want several fields for each different embedded font. Isn't there a way to do what I want? I hope this makes sense.
aniebelAuthor
Inspiring
February 1, 2007
P.S. I read in the Help that a font will have an asterisk next to it in the font list (Properties panel) if it has been embedded. Now, I've embedded these fonts in the library and in the dynamic text boxes off stage (by using embed in the Properties panel) and I still see no asterisk. Could this be part of the problem? How does one check to see if it's, in fact, been embedded?
kglad
Community Expert
Community Expert
February 1, 2007
you're assigning your style sheet to your textfield before your style sheet is defined. and you're not assigning a style to your text.

correct those problems and see if everything works.
aniebelAuthor
Inspiring
February 1, 2007
Not sure what you mean by assigning a style to the text. How is that different than assigning a style sheet to the instance name of the text box? I've tried assigning a text format to it if that's what you mean.

I have to say that this whole process is very hard to understand. I "get" that you have to do one thing before doing another but it seems that if you set up a style sheet and assigned that to something, it would inherit those properties. I really would love to understand this text field bit more.

This is not working yet.