Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

bold/italic tags embedded fonts don't work

Contributor ,
Apr 22, 2013 Apr 22, 2013

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:

pic1.png

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.

pic2.png

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.

pic3.png

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.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2013 Apr 22, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2013 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2013 Apr 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 22, 2013 Apr 22, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines