Skip to main content
Inspiring
April 22, 2013
Question

bold/italic tags embedded fonts don't work

  • April 22, 2013
  • 1 reply
  • 1218 views

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.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 22, 2013

you must use setTextFormat or stylesheets to use more than one font in textfield.

jiggy1965Author
Inspiring
April 22, 2013

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.

kglad
Community Expert
Community Expert
April 22, 2013

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?