Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Emded fonts into SWF

This is a discussion on Emded fonts into SWF within the Tutorials forums, part of the Flash English category; When developing with Adobe Flash, you often come across the need to use some fonts that are not part of ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-10-07, 19:41
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Emded fonts into SWF

When developing with Adobe Flash, you often come across the need to use some fonts that are not part of the standard set loaded with the OS, therefore the developer is never sure if the font used will be displayed or not.
More so if using pixel-fonts.
A solution to this dilemma is to incorporate the fonts within the SWF itself.
Let's see how'
As usual I create an FLA and save it as ' fonts.fla ' .
I create the Document Class, an AS file saved as ' Fonts.as ' .
What I write in the Fonts class:
Code:
package
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFieldAutoSize;
	
	public class Fonts extends MovieClip
	{
		private const testo:String='Lorem ipsum dolor sit amet,consectetuer adipiscing elit.\n'+
		'Aliquam ac felis. Pellentesque varius adipiscing ligula.'+
		'Duis porttitor, libero ut fringilla pellentesque,\n'+
		'nunc nisl hendrerit tellus, nec dignissim mauris pede at risus\n'+
		'nunc nisl hendrerit tellus, nec dignissim mauris pede at risus.';
		private var field:TextField;
		
		public function Fonts()
		{
			createField();
		}
		
		private function createField():void
		{
			field=new TextField();
			field.autoSize=TextFieldAutoSize.LEFT;
			field.defaultTextFormat=getFormat();
			field.text=testo;
			addChild(field);
		}
		
		private function getFormat():TextFormat
		{
			var format:TextFormat=new TextFormat();
			format.font='FFF Aquarius';
			format.color=0x333333;
			format.size=8;
			return format;
		}
	}
}
And here is the result:







This class has only created a text field and assigned a format and some text to it.
Now we go back to our FLA and create an empty dynamic text field.
With the empty text highlighted, I assign the preferred font and then click on 'embed' as in the pic below:

Flash CS3 embed fonts


In the open window, you can select the char sets you want to use.
This way we have the certainty that at the moment of publishing, our SWF will avail all the characters we've used to display during the application execution. The text field is only used as an intermediary, therefore I'd suggest you kept it unavailable, hence invisible and just outside the stage.
If instead I wanted to create my text fields to be able to write text on them, you can just perform an operation very similar to the previous one and, maintaining the text field highlighted (still dynamically) and opening the char sets window, click on the ' auto fill' button and Flash will expert to the SWF only the characters contained in the text field.

Stay tuned !
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !

Last edited by Flep; 28-08-08 at 06:56..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Flash CS3 Embedd Fonts - aiuto! Fox+ Actionscript 3.0 avanzato 3 29-08-08 21:59
Actionscript 3 Embed Fonts da capogiro... Baro Actionscript 3.0 avanzato 6 24-08-08 17:56
How to share fonts in between more SWF with flash CS3 Flep Tutorials 35 23-07-08 21:23
Come condividere le fonts tra più SWF con Flash CS3 Flep Articoli e tutorials 1 08-06-08 15:25
Incorporare fonts nell' SWF con Flash CS3 Flep Articoli e tutorials 4 21-04-08 00:15


All times are GMT. The time now is 12:27.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap