bon j'ai pas le temps de tout détailler mais voici un petit recap
pour AS3 avec compil MXMLC (voir avec Flash CS3/CS4)
quelques petites regles
- toujours séparer l'inclusion du regular/bold/italic
- idéalement utiliser un nom "custom" pour la font
- idéalement gérer les fonts avec des classes
- si les font doivent charger dynamiquement
toujours utiliser le ApplicationDomain.currentDomain
et toujours utiliser Font.registerFont()
dans un post séparé je met un exemple de FontLoader
sinon voic mes notes en vrac et en english ;)
-----
/* note:
We organize fonts this way
* always remember to do a force import if you want to use
FontLoader.loadClass()
----
import fonts.Tahoma; Tahoma;
----
for load() and loadBytes() off course as you load external
files
you don't need to do that
* we always define the font name/family as the class name
----
public class Tahoma
{
}
----
* we define style as static properties of the class
----
public class Tahoma
{
public static var regular:Class;
public static var bold:Class;
public static var italic:Class;
}
----
* language
We consider the english the default language.
For other languages we'll use 2 letter "fr", "es", etc.
ideally you want to keep the class path the same,
but export the files to different SWF names
exports to /fonts/tahoma.swf
----
public class Tahoma
{
public static var regular:Class;
public static var bold:Class;
public static var italic:Class;
}
----
exports to
/fonts/tahoma_fr.swf
/fonts/fr_tahoma.swf
/fonts/fr/tahoma.swf
/fonts/tahoma.fr
etc.
----
public class Tahoma
{
public static var regular:Class;
public static var bold:Class;
public static var italic:Class;
}
----
the only case where you would want to load more of the same
font
at the same time would be if you want to display different
languages
at the same time
for example you want to display both en and fr of the font
Tahoma
----
package fonts.en
{
//...
public class Tahoma
{
public static var regular:Class;
public static var bold:Class;
public static var italic:Class;
}
----
----
package fonts.fr
{
//...
public class Tahoma
{
public static var regular:Class;
public static var bold:Class;
public static var italic:Class;
}
----
how to embed a font in a swf
the basic
----
[Embed(source="tahoma.ttf", fontName="Tahoma")]
public static var regular:Class;
----
how to define the name of the font
choice 1: you specify your own name
----
[Embed(source="tahomabd.ttf", fontFamily="Tahoma",
fontName="TahomaBold", fontWeight= "bold")]
public static var bold:Class;
//...
mytext.defaultTextFormat = new TextFormat( "TahomaBold" );
----
choice 2: you let flash pick the font name fron the font file
----
[Embed(source="tahomabd.ttf", fontFamily="Tahoma",
fontName="Tahoma", fontWeight= "bold")]
public static var bold:Class;
//...
mytext.defaultTextFormat = new TextFormat( "Tahoma Bold" );
----
note:
to find this name under Windows
open the font and read the first line (the big one in bold)
you'll see for ex: "Tahoma Bold (Open Type)"
so for flash the font name is "Tahoma Bold"
trick:
* if in Flash IDE you select the font "Tahoma" and then tick
"bold"
your TextField will be set to use the font "Tahoma", not
"Tahoma Bold"
so you will still have to force the name of the font in the
textfield
* but the good thing is that you only have to redefine the
name of the font
not its size, or other parameters (those one are kept from
Flash IDE)
how to define the character to embed in the font
you have to use the "unicode range" property
----
[Embed(source="tahomabd.ttf", fontFamily="Tahoma",
fontName="Tahoma", 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;
----
trick:
you can find those code range in the Flex SDK
C:\Flex SDK 3.3.0\frameworks\flash-unicode-table.xml
usage1:
create your assets in Flash IDE but DO NOT EMBED the font
and then in your class do
----
mytext = _skin.getChildByName("my_text") as TextField;
mytext.embedFonts = true; //force the embed
mytext.defaultTextFormat = new TextFormat( "TahomaBold" ); //
use the fontName= of the lib
----
note:
You can not use the regular name of the font like "Tahoma"
usage2:
If you want to use the font with stylesheet in HTML
----
var _style:StyleSheet = new StyleSheet();
_style.setStyle( "body", { fontFamily: "TahomaBold",
fontWeight: "bold" } );
mytext = _skin.getChildByName("my_text") as TextField;
mytext.embedFonts = true;
mytext.styleSheet = _style;
mytext.htmlText = "<body>" + message + "</body>";
----
*/
-----
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---