Hiya,
Sorry if this is a dumb question - I'm not an expert with Flash.
I'm adapting an off the shelf mp3 player and would like to make some text bold - namely [see: http://www.stevedrake.net/music_09] the text that shows the current artist/song at the top.
This is dynamic text from an XML file. I've embedded the fonts [Verdana regular and bold - OpenType] in Flash CS5 but the bold won't display even though the special characters do display [Jónsi].
Ta
steve
Thanks for the reply.
With the text selected: selecting Verdana Bold and then hitting the Embed button [Properties Panel] which brings up the Font Embedding dialogue box. I named it Verdana Bold and selected the desired character ranges.
Both Verdana Regular and Bold are in the Library and these fonts have an asterisk next to their name in any font menu.
I notice that the Bold displays fine if the text is Static text [not dynamic].
Yes, I think I also encountered this bug, and it's really a bad one. Do the folks at Adobe realize that fonts are a MAJOR aspect of this form of media? I have tried every trick in the book to get the Bold style of Univers 45 LT Light to show up on an exported .swf. It seems it's just not possible.
Can htmlText support fonts that are not necessarily for the web such as Univers?
Any suggestions and / or pointers are greatly appreciated! Thank you for your time and help!
I got around this CS5 bug without using htmlText or ActionScript, as follows:
In the font view, give your font a name, e.g. "VerdanaBold". Now go back to your TextField. Select it and view Properties. Under Character/Family, you should be able to enter "VerdanaBold*" (the name you gave your font, with the asterisk).
Now the TextField should use the correct embedded font, with its proper weight.
Was anybody able to solve it or find a workaround? Seems like I have a very similar (if not exactly the same) problem with CS6 as well. In my FLA I am embedding all the fonts and variations I want, which means:
Arial
Arial Bold
Arial Italic
Arial Bold Italic
They all have their Linkage set to unique names, etc. I am not using them in manually created textfields but in textfields created with code (so no auto-kern). I am setting the variations with TextFormat - well, I would, if it was working. What I see is always only "Arial". The font variations appear as simple Arial as well, no bold, no italic, nada... If I change the font, for example, to Times New Roman, it is the same story. I see all the text in Times New Roman despite the fact that it should be Times New Roman Bold. This happens on my Macbook Pro.
If I try to open the very same file on the other Mac or I use Windows to publish it -> voila! it works just fine without any modifications. So what's going on here?
I am having the same issue dealing with the Arial Bold embedded font. I want the classic dynamic textfield to only display bold text. So here is what I have figure out.
1) Set the textfield with the Arial Bold font embedded for the textfield.
2) Creat code similar to the following:
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.bold = true;
3) Now set your text to your textfield first
4) After you have updated your textfield with new text. Now set the format to the textfield something like this:
myTXT.setTextFormat(myTextFormat);
Everytime you change the text in the textfield, just apply the format immediately afterwards and the textfield will be bold.
If you only want part of the textfield bold, then you will need to use the htmlText with the html tags.
I found what make this bug.
The text format of flash.text.TextField is changing when setting text.
The work around I found is AS3 only. Wasn't been able to find another solution yet.
Here is what you can do:
public static function setText(target:TextField, text:String):void{
var textFormat:TextFormat = target.getTextFormat();
target.text = text;
target.setTextFormat(textFormat);
}
i actually think this is a bug. i can't embed arial regular and arial bold in the same fla unless i use style sheets or static text.
it doesn't matter whether i use a textfield created in the ide or with code. it doesn't matter whether i try to use both weights in one textfield or in two different textfields.
there's no problem embedding two different font families in one or more textfields. but using the same font family with different weights/styles is a problem.
here's sample code that displays part of the problem:
import flash.text.TextFormat;
import flash.events.FocusEvent;
import flash.text.TextField;
var n:int=0;
var tf:TF = new TF();
tf.width=400;
tf.border=true;
tf.embedFonts=true;
addChild(tf);
var tf_startText:String="this is a test: ";
var tf_endText:String="textformat change.";
tf.text=tf_startText+tf_endText;
var tfor1:TextFormat = new TextFormat();
var tfor2:TextFormat = new TextFormat();
var tfor3:TextFormat = new TextFormat();
// three fonts need to be embedded. the first two should be from the same font family to show a problem. the third, from a different font family, confirms the code used for embedding and changing textformats is correct.
var arialBold:Font = new Bold();
var arialReg:Font = new Reg();
var comicSans:Font = new CS();
tfor1.font=arialReg.fontName;
tfor2.font=arialBold.fontName;
tfor3.font=comicSans.fontName;
tf.setTextFormat(tfor1,0,tf_startText.length);
tf.addEventListener(FocusEvent.FOCUS_IN,f);
function f(e:FocusEvent):void {
if (n%2==0) {
tf.setTextFormat(tfor2,tf_startText.length,tf.text.length);
} else {
tf.setTextFormat(tfor3,tf_startText.length,tf.text.length);
}
n++;
}
Just use a TLFTextField. I embedded fonts in my library: Garamond Bold (exported for actionscript as GBold, type: TLF) and Garamond Regular (exported for actionscript as GRegular, type: TLF). Just numbers/letters embedded.
I added a stage handler for click and on click it just formats a portion of the text with bold or no bold, works fine for me.
Open new AS3 doc in Flash Pro. Embed any fonts like mentioned above and adjust the class name as needed below:
import flash.events.MouseEvent;
import fl.text.TLFTextField;
import flash.text.Font;
import flash.text.TextFormat;
var useBold:Boolean = false;
// fonts
var gRegFont:Font = new GRegular();
var gBoldFont:Font = new GBold();
// handler
stage.addEventListener(MouseEvent.CLICK, handleClick);
function handleClick(e:MouseEvent):void
{
useBold = !useBold;
tf.bold = useBold;
tf.font = useBold ? gBoldFont.fontName : gRegFont.fontName;
myTLFTextField.setTextFormat(tf, 17, myTLFTextField.length);
}
// TLFTextField init
var myTLFTextField:TLFTextField = new TLFTextField();
addChild(myTLFTextField);
myTLFTextField.x = 10;
myTLFTextField.y = 10;
myTLFTextField.width = 400;
myTLFTextField.height = 100;
myTLFTextField.text = "This is my text: This is affected by format";
var tf:TextFormat = new TextFormat(gRegFont.fontName,16,0x0,false);
myTLFTextField.setTextFormat(tf,0,myTLFTextField.length);
If I don't initially speecify a range on my setTextFormat() I was getting an oddity but it was fixed by always specifying a start/end index which is why my initial set does that.
Click the stage and a portion of the text goes back and forth between Bold and Regular, no CSS needed.
For the record I also did it with a regular flash.text.TextField. just change the class from TLFTextField to TextField and import flash.text.TextField. Works just fine as well.
that's another work-around, in addition to using stylesheets.
it looks most like the stylesheet solution where applying a fontWeight property allows the use of a bold font but you're not really referencing the bold font name using actionscript. the key part of your code is tf.bold which should not be needed if the fonts were embedded correctly (by flash). this should be enough:
tf.font = useBold ? gBoldFont.fontName : gRegFont.fontName;
actually, you don't even need to explicitly reference the embedded bold font in the library. just referencing the regular font is enough if you use the bold property of your textformat and i suspect the same is true using stylesheets.
here's your edited code that doesn't need to reference the two embedded font names:
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.Font;
import flash.text.TextFormat;
var useBold:Boolean=false;
// fonts
var gRegFont:Font = new GRegular();
//var gBoldFont:Font = new GBold();
// handler
stage.addEventListener(MouseEvent.CLICK, handleClick);
function handleClick(e:MouseEvent):void {
useBold=! useBold;
tf.bold=useBold;
//tf.font=useBold?gBoldFont.fontName:gRegFont.fontName;
tf.font = gRegFont.fontName;
myTLFTextField.setTextFormat(tf, 17, myTLFTextField.length);
}
// TLFTextField init
var myTLFTextField:TextField = new TextField();
myTLFTextField.rotation = 3;
myTLFTextField.embedFonts = true
addChild(myTLFTextField);
myTLFTextField.x=10;
myTLFTextField.y=10;
myTLFTextField.width=400;
myTLFTextField.height=100;
myTLFTextField.text="This is my text: This is affected by format";
var tf:TextFormat=new TextFormat(gRegFont.fontName,16,0x0,false);
myTLFTextField.setTextFormat(tf,0,myTLFTextField.length);
and there's still a problem using the code i suggested and there's a problem if you create two textfields in the ide and embed a regular font in one and bold font in the other using the properties panel to embed the fonts.
I know what you mean, the outlines embedded should be thicker because we "think" it's embedding the fonts as 2 separate classes. I don't think it's this simple internally. You can see in the font manager it groups fonts variants (regular/bold/italic all under the same font name). Internally it's actually keeping track.
This is actually behavior I don't mind. My example was more complex than it needed to be. I like when fonts just map properly and actually all you need to do is set the .bold flag and it will automatically use the bold version of the font that's embedded. That tells me they're internally linked.
e.g.:
import flash.events.MouseEvent;
import fl.text.TLFTextField;
import flash.text.AntiAliasType;
import flash.text.Font;
import flash.text.TextFormat;
var useBold:Boolean = false;
// fonts
var gRegFont:Font = new GRegular();
// handler
stage.addEventListener(MouseEvent.CLICK, handleClick);
function handleClick(e:MouseEvent):void
{
useBold = !useBold;
// fix Flash's desire to mass-apply, set twice
tf.bold = false;
myTLFTextField.setTextFormat(tf, 0, 16);
// now handle bolding
tf.bold = useBold;
myTLFTextField.setTextFormat(tf, 17, myTLFTextField.length);
}
// TLFTextField init
var myTLFTextField:TLFTextField = new TLFTextField();
addChild(myTLFTextField);
myTLFTextField.x = 10;
myTLFTextField.y = 10;
myTLFTextField.width = 400;
myTLFTextField.height = 100;
myTLFTextField.embedFonts = true;
myTLFTextField.antiAliasType = AntiAliasType.ADVANCED;
myTLFTextField.text = "This is my text: This is affected by format";
var tf:TextFormat = new TextFormat(gRegFont.fontName,16,0x0,false);
myTLFTextField.setTextFormat(tf,0,myTLFTextField.length);
I don't even need to set the .font property at all. Internally it's linked and that works fine. I'm not even instantiating the bolded version, it's precompiled and available. I also forgot to set embedFont=true and some antialiasing but it works if you do or don't anyhow.
Edit:
Haha I see you were editing your post too. I think we're both on the same page seeing we said the same exact thing. Although I do need to set the non-bold TextFormat like I did setting from char 0-16 or the entire TextField (or TLFTextField) goes to bold. Setting both formats every time fixes the issue. I don't even need to keep setting a font, it's already saved in the formatting object. I just turn bold on and off.
North America
Europe, Middle East and Africa
Asia Pacific