Is it possible to get the fonts embedded when using htmlText? Took me a long time to track it down to being embedfonts that was making my text disappear
facepalms
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Author had a Free File of the Month
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
What code are you using to embed font?
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
yes you can use embedded fonts… are you using CSS as well?
What code are you using to embed font?
[Embed(source = "C:/Windows/Fonts/arial.ttf", fontName = "Arial", fontWeight = "normal", advancedAntiAliasing = "true", mimeType = "application/x-font")] public var ARIAL:Class
I’ve also tried embedding in library in the flash IDE . I can embed fonts and have some htmlText set once, but when I try to update the text it disappears unless I set embedfonts=false. I am using CSS too but I’ve tried testing without and the problem remains.
Here is the code I used that does’nt work with embedfonts set to true:
import flash.text.TextFormat import flash.text.TextField import flash.text.AntiAliasType var format1:TextFormat = new TextFormat(); var textfield:TextField format1.font= "Arial"; format1.size=12; format1.color = 0x888888 textfield = new TextField(); textfield.x=0 textfield.y =0; textfield.width = 100 textfield.height = 30 textfield.embedFonts=true; textfield.antiAliasType=AntiAliasType.ADVANCED; textfield.htmlText = "text" textfield.setTextFormat(format1); textfield.border = true textfield.wordWrap = true addChild(textfield) textfield.htmlText = "newText"
textfield.setTextFormat(format1);
or you can try:
textfield.defaultTextFormat = format1;
Small change that’s all base on your code ….
var format1:TextFormat = new TextFormat(); var textfield:TextField ///////////////////////////// var _Font:MyFont= new MyFont();/////Libary font format1.font= _Font.fontName; ///name the Libary font and you are set ///////////////////////////// format1.size=12; format1.color = 0x888888 textfield = new TextField(); textfield.x=50 textfield.y =50; textfield.width = 100 textfield.height = 30 textfield.embedFonts=true; textfield.antiAliasType=AntiAliasType.ADVANCED; textfield.htmlText = "text" textfield.setTextFormat(format1); textfield.border = true textfield.wordWrap = true addChild(textfield)
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
What code are you using to embed font?[Embed(source = "C:/Windows/Fonts/arial.ttf", fontName = "Arial", fontWeight = "normal", advancedAntiAliasing = "true", mimeType = "application/x-font")] public var ARIAL:Class
isn’t that the flex embed method, not sure if it works within flash?
i’d follow tsafi’s change in code.. you have to initialise the font from the library at runtime…
http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Author had a Free File of the Month
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
Yes, it works in flash cs4:
http://www.adobe.com/devnet/flash/articles/embed_metadata_04.html
and komapeb already gave the answer, he needs to re-apply textFormat after updating text.
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
isn’t that the flex embed method, not sure if it works within flash?
yeah I think that only works in Flex. But here’s a cool workaround:
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
Yes, it works in flash cs4:http://www.adobe.com/devnet/flash/articles/embed_metadata_04.html
and komapeb already gave the answer, he needs to re-apply textFormat after updating text.
nice!
