This content has been marked as final. Show 4 replies
embed all the fonts you need in your library, give them distinct linkage ids, create a textformat object for each font and assign the font property to your textformat objects to establish the correspondence between your textformat objects and your fonts. finally use setTextFormat() to assign the desired format to your textfield's htmlText property.
or use css with your embedded fonts with distinct linkage ids.
Okay, i think i got it.. it works, but it sure takes a lot of work..
Is this now the correct way to do it?
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "csverdana";
my_fmt.size = 16;
my_fmt.align = "left";
veldje_txt.border = false;
veldje_txt.wordWrap = true;
veldje_txt.multiline = true;
veldje_txt.embedFonts = true; //turn this of and on to see the difference..
veldje_txt.selectable = false;
veldje_txt.antiAliasType = "advanced";
veldje_txt.thickness = 100;
veldje_txt.sharpness = 10;
veldje_txt.styleSheet = astyles;
veldje_txt.html = true;
veldje_txt.selectable = true;
veldje_txt.type = "dynamic";
veldje_txt.htmlText = "<b>This </b>should be bold";
veldje_txt.htmlText += "<font face='csverdana'><b>This should be boldt</b><i> and this should be italic</i></font>";
veldje_txt.htmlText +="<font face='csverdanavet'>Displays as either Times or Times New Roman...</font>";
veldje_txt.htmlText +="<font face='csverdanaitalic'>Dit is schuine tekst</font>";
veldje_txt.htmlText +="<font face='csverdanaitalicvet'>Dit is vet en schuine tekst</font>";
and in my library i have all the kind of same fonts.
So it is a lot of work ... if you use one font, in this case i have to make
4 types. ..But if i want to use more.. then do the Math!
I don't think this should be so much work.. but this is the price you
have to pay if you want people to change there own tekst in a simple html editor.... :(
that's a little messier than necessary, but there's no way that will decrease the number of fonts you have to embed. and overall you'll have the same amount of code or more if you use a cleaner, more modularized approach. if i were you, i'd stick with that because it's working.
Today I got the same problem and I found a simple solution to parse the text.
You can use split and join to add the another things, form example:
var tempText = myString;
tempText = tempText.split("<b>").join("<FONT FACE='bodyBold'><B>");
tempText = tempText.split("</b>").join("</B></FONT>");
- Only work with setNewTextFormat when you set the default font
- You must have the 2 fonts in the library.