My font hell - Dynamic HTML text + embedded fonts

[font=Arial]Hi there,

I am trying to create a text box with actionscript, using an embedded font, and populating it with HTML text. It seems I can either use an embedded font, or HTML formatted text, but not both. To illustrate the problem, I have created a little test.

  1. Create a font symbol in the library. Export it for actionscript as “_mainFont”.

  2. Create a dynamic text box on the stage using _mainFont and type some random text in it, including the use of bold and italics. Set the font size and colour to whatever you like. Name the instance “templateText”.

  3. On the first frame, type in these actions:

[/font]


with (_root.templateText) {
	 html = true;
	 wordWrap = true;
	 multiline = true;
	 autoSize = true;
	 htmlText = "Hi there. <font color='#FFFFFF'>This is a test. </font><br/><br/>Blah blah <b>bold</b> blah <u>underline</u> blah blah <i>italic</i>.";
	 embedFonts = true;
}

[font=Arial]
[/font]
[font=Arial]The textbox should display correctly, using the correct font, colour and all the HTML formatting. Unfortunately, I need to create text on the fly. So modify the actionscript to create a new text field instead of using the template text:

[/font]


_root.createTextField("textBox", 3, 0, 0, 250, 100);
with (_root.textBox) {
	 html = true;
	 wordWrap = true;
	 multiline = true;
	 autoSize = true;
	 htmlText = "Hi there. < font color='#FFFFFF' >This is a test. </font><br/><br/>Blah blah <b>bold</b> blah <u>underline</u> blah blah <i>italic</i>.";
	 var textBoxFormat = new TextFormat();
	 textBoxFormat.font = "_mainFont";
	 setTextFormat(textBoxFormat);
	 embedFonts = true;
}

[font=Arial]
[/font]
[font=Arial]What happens? I get the right font. The < font color > tag works OK, I get the breaks and the underline, but I get no bold and no italics. Finally, let’s make some use of the templateText box by using its formatting. Replace the line:

var textBoxFormat = new TextFormat(); with
var textBoxFormat = _root.templateText.getTextFormat();

Now the text is formatted with the right font, the same colour and size of the templateText box, but I’ve lost the HTML font colour and underline in addition to the bold and italics.

If I take out the Embed Fonts, I get back bold and italics, but loose font colour and underline, as well as the wrong font.

I’m really tearing my hair out on this one - it’s taken nearly a whole days work just trying to fix this hugely annoying problem. Please help!

Thanks,

Scott [/font]**

**