Hello,
J'ai juste une question qui me transforme en sous abruti de première
je crois (j'ai du rien comprendre):
import fonts.Tahoma; Tahoma; //22K in file size
Pourquoi faire l'import de la classe si nous chargeons le SWF ?
++
Cedric
> le code est pas mal commenté
> mais voici un petit usage
>
> font.Tahoma.as
> --------
> package fonts
> {
> import flash.display.Sprite;
> public class Tahoma extends Sprite
> {
> [Embed(source="../../gfx/font/tahoma.ttf",
> fontFamily="Tahoma", fontName="TahomaRegular", fontWeight= "normal",
> unicodeRange="U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U
> +005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E")]
> public static var regular:Class;
>
> [Embed(source="../../gfx/font/tahomabd.ttf",
> fontFamily="Tahoma", fontName="TahomaBold", fontWeight= "bold",
> unicodeRange="U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U
> +005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E")]
> public static var bold:Class;
> }
> }
> --------
>
> Main.as
> --------
> package
> {
> import com.test.fonts.FontLoader;
>
> import flash.display.Sprite;
> import flash.text.Font;
> import flash.text.FontStyle;
>
> import fonts.Tahoma; Tahoma; //22K in file size
>
> [SWF(width="550", height="400", backgroundColor='0xffffff',
> frameRate='24', pageTitle='test', scriptRecursionLimit='1000',
> scriptTimeLimit='60')]
> public class Main extends Sprite
> {
>
> public function Main()
> {
> _init();
> }
>
> private function _init():void
> {
>
> //Fonts definition
> FontLoader.fontPackageName = "fonts";
> FontLoader.addEventListener( Event.COMPLETE, onFontLoaded,
> false, 0, true );
>
> //embed font
> FontLoader.loadClass( "Tahoma" );
>
> }
>
> private function main():void
> {
>
> //MAIN ENTRY POINT
> //...
> }
>
> private function onFontLoaded( event:Event = null ):void
> {
> FontLoader.removeEventListener( Event.COMPLETE,
> onFontLoaded );
>
> var allfonts:Array = Font.enumerateFonts();
>
> trace( "---- ALL FONT DEBUG
> ---------------------------------START" );
> for( var i:uint=0; i<allfonts.length; i++ )
> {
> trace( i+")--" );
> _traceFont( allfonts[i] );
> trace( "----" );
> }
> trace( "---- ALL FONT DEBUG
> ---------------------------------END" );
>
> _debugFont( "Tahoma", FontStyle.REGULAR );
> _debugFont( "Tahoma", FontStyle.BOLD );
> //_debugFont( "Arial", FontStyle.ITALIC ); //test non-
> existing font
>
> main();
> }
>
> private function _traceFont( ref:Font ):void
> {
> trace( "name: " + ref.fontName );
> trace( "style: " + ref.fontStyle );
> trace( "type: " + ref.fontType );
> }
>
> private function _debugFont( name:String, style:String ):void
> {
> trace( "---- FONT DEBUG
> ---------------------------------START" );
> var f:Font = FontLoader.getFont( name, style );
> var test:String =
> "abcdefghijklmnopqrstuvwxyz_-?!.<>,\"()0123456789";
>
> if( f )
> {
> _traceFont( f );
> trace( "can display [" + test + "] : " + f.hasGlyphs
> ( test ) );
> }
> else
> {
> trace( "font ref: " + f );
> }
> trace( "---- FONT DEBUG
> ---------------------------------END" );
> }
>
>
>
> }
> }
> --------
>
> zwetan
>
> >
> <fontloader.zip>
--~--~---------~--~----~------------~-------~--~----~
Vous avez reçu ce message, car vous êtes abonné au groupe Groupe "FCNG" de
Google Groupes.
Pour transmettre des messages à ce groupe, envoyez un e-mail à
l'adresse [email protected]
Pour résilier votre abonnement à ce groupe, envoyez un e-mail à
l'adresse [email protected]
Pour afficher d'autres options, visitez ce groupe à l'adresse
http://groups.google.com/group/fcng?hl=fr
-~----------~----~----~----~------~----~------~--~---