View Full Version : Embedded font in TextField.htmlText
ar34z
September 24th, 2009, 12:01 PM
Hi,
I've been searching all day and haven't found a proper solution for this.
I have 3 embedded fonts in my library and I have given them a class name.
Now I would like to use these fonts in HTML in a TextField object.
How do I do this? I created a stylesheet and entered the font name, but
it still picks it from my harddrive, because it doesn't work on other computers
where the font is not installed.
I have a font embedded named "Edo", and gave it the classname Edo.
styleSheet = new StyleSheet();
var body:Object = new Object;
body.fontFamily = Font(new Edo()).fontName;
body.fontSize = "12px";
body.color = "#ff0000";
body.fontStyle = "italic";
styleSheet.setStyle("body", body);
textField.styleSheet = styleSheet;
textField.htmlText = "<body><i>asfdasfdasdf</i></body>";
Yet, it shows up as Times New Roman on PC's without the font.
Can anybody help?
Felixz
September 24th, 2009, 02:17 PM
textField.embedFonts = true;And make sure that italic font is embedded too.
ar34z
September 24th, 2009, 06:41 PM
That only works for normal text, not htmlText. I need to dispaly my text as HTML text.
If I set embedFonts to true, the HTML text is not displayed.
Felixz
September 24th, 2009, 06:49 PM
there is no difference ntml or not, just make sure that italic checkbox is selected when embedding
ar34z
September 25th, 2009, 08:39 AM
Then how come my text is now showing up in the selected font?
Also, when i rotate the textField, the text disappears, hence it's not embedded.
Anyone else can help me?
Felixz
September 25th, 2009, 08:57 AM
When text is not showing it means that required characters are unavailable.
Make sure that proper font family is selected, the size matches, and bold/italic style is chosen accordingly.
If you want to embed normal font, bold, italic and bolditalic you must embed 4 fonts from chosen family and size.
ar34z
September 25th, 2009, 09:01 AM
I know that, but that doesn't apply to HTML text.
HTML renders text as italic when you place text between <i> and </i>
I don't want to embed 4 fonts and not all my fonts have a bold/italic version.
All I need to know is how to refer to my embedded font in htmlText or in a Stylesheet object.
Felixz
September 25th, 2009, 10:59 AM
For me, I have 3 fonts on my homepage and all textfields use htmlText. I have mixed <b/> and <i/> tags all is handled flawlessly by flash.
ar34z
September 25th, 2009, 11:16 AM
Yeah, but did you use non-standard fonts? Or did you enter font names like "verdana, arial, helvetica, sans-serif" (or _serif). That makes a difference.
I need custom fonts to work on every machine.
Felixz
September 25th, 2009, 11:39 AM
When embedFonts is set to true even casual fonts won't show.
I use this textFormat with html text.
new TextFormat("Segoe UI", 14, 0x000000, null, null, null, null, null, TextFormatAlign.JUSTIFY);
I keep fonts in external swf and load them.
["SegoeUI14", "SegoeUI14Bold", "SegoeUI14Italic"]
Font.registerFont(Class(getDefinitionByName(every-of-name-above)))
ar34z
September 25th, 2009, 12:04 PM
Ok, so you have fonts in an external file. That might work and then I wont need htmlText.
If I set Italic or Bold to true, will it automatically search for the font version? Like, if I have "Arial" as regular text, will it then search for "ArialBold", or do I need to change the fontname myself?
Settings it myself will defeat the purpose of 'bold' then... so that sounds stupid.
This is the first time for me I work with fonts in AS3, so to make things clear for myself:
- You have an external SWF with normal, bold, italic, bolditalic type of 1 font.
- They are exported and have a proper classname (like SegoeUI14, SegoeUI14Bold etc.)
Then, in the main SWF you type
Font.registerFont(Class(getDefinitionByName("SegoeUI14")))
Font.registerFont(Class(getDefinitionByName("SegoeUI14Bold")))
Font.registerFont(Class(getDefinitionByName("SegoeUI14Italic")))
etc.
Then, when using a font I enter for the textFormat:
textFormat.font = "SegoeUI14".
It will then show as the normal SegoeUI14 font. When I set textFormat.bold=true, will it then automatically use "SegoeUI14Bold"?
Please let me know :)
Felixz
September 25th, 2009, 12:17 PM
Use just the font family name: "Segoe UI"; as in TextFormat constructor.
uyangaa
August 25th, 2010, 06:04 AM
i might sound dumb.. but how do you keep the font.ttf file in external swf?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.