Copy link to clipboard
Copied
I've added all 3 variations of the same font 'EuroComic' into the Library. Regular, bold and Italic. Flash sees them as belonging to the same font family:
Now I'm using this code to place a dynamic textfield on screen.
import flash.text.*;
var myTextBox:TextField = new TextField();
var myText:String; myText = "<font size='30' face='EuroComic'>This sentence is in regular font<br/>";
myText += "<b>This sentence is in bold font</b><br/>";
myText += "<i>This sentence is in italic font</i></font>";
myTextBox.width = 500;
myTextBox.height = 200;
myTextBox.multiline = true;
myTextBox.embedFonts = true;
myTextBox.wordWrap = true;
myTextBox.border = true;
addChild(myTextBox);
myTextBox.htmlText = myText;
I'm using the bold and italic tags inside the htmltext string for the 2nd and 3rd sentence which should turn bold and italic, but they don't all text remains in the regular style font.
It should turn into this, which I got after commenting the embedFonts line, but then of course it's not using the embedded fonts but the fonts activated on my machine.
What is wrong with my code? I know I could use css, but I'd like to know why my code isn't working like I expect it to. When not using embedded fonts the bold/italic tags work, but then a default font is used. Why won't they work when I want to use them on embedded fonts?
The used font and flash file can be downloaded from: http://pastelink.me/dl/a43c74 so you can try it yourself.
Using CS6 for Mac.
Copy link to clipboard
Copied
you must use setTextFormat or stylesheets to use more than one font in textfield.
Copy link to clipboard
Copied
I know I can use setTextFormat or css, but still wondering why html formatting doesn't work. Why are <b> and <i> tags supported, when they clearly don't in this case? Documentation says it should. As long as I import all font variations into my library so Flash knows which to use when it encounteres bold and italic tags.
Copy link to clipboard
Copied
flash doesn't know which fonts in your library to use. and where does it say you can use those tags WITH an embedded font?
Copy link to clipboard
Copied
Bold tag ()
The bold tag renders text as bold. If you use embedded fonts, a boldface font must be available for the font or no text appears. If you use fonts that you expect to reside on the local system of your users, their system may approximate a boldface font if none exists, or it may substitute the normal font face instead of boldface. In either case, the text inside the bold tags will appear.
Flash does know which fonts in my library to use cause when I test the movie, then deactivate the font and run the swf again, it still uses the embedded fonts which were embedded while making the swf. Just the regular variation of the font. It's just ignoring the bold and italic tags and is not using those variations of the same font family.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now