Paket | mx.core |
Klass | public class FontAsset |
Arv | FontAsset Font Object |
Implementerar | IFlexAsset |
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
The font that you embed can be TrueType (TTF) or OpenType (OTF). You can also embed a system font or a font that is in a SWF file produced by Flash. In each of these cases, the MXML compiler autogenerates a class that extends FontAsset to represent the embedded font.
You do not generally use the FontAsset class directly
when you write a Flex application.
For example, you can embed a font by using the font-face
CSS selector
without having to understand that the MXML compiler has created
a subclass of FontAsset for you.
However, it might be useful to understand what is happening
at the ActionScript level.
To embed a font in ActionScript, you declare a variable
of type Class, and put [Embed]
metadata on it.
For example, you embed a TTF file like this:
[Embed(source="Fancy.ttf", fontName="Fancy")] var fancyClass:Class;
The MXML compiler transcodes the TTF data
into the font format that the player uses, autogenerates
a subclass of the FontAsset class, and sets your variable
to be a reference to this autogenerated class.
You can then use this class reference to create instances of the
FontAsset by using the new
operator, and you can use
APIs of the Font class on them; for example:
var fancyFont:FontAsset = FontAsset(new fancyClass()); var hasDigits:Boolean = fancyFont.hasGlyphs("0123456789");
However, you rarely need to create FontAsset instances yourself
because you use the fontName
that you specify
in the [Embed]
metadata to refer to the font; for example,
you set the fontFamily
CSS style to the font name
(in this example, "Fancy"
), and not to a FontAsset instance such as
fancyFont
or to the fancyClass
class reference. For example:
<mx:Label text="Thank you for your order." fontFamily="Fancy"/>
Fler exempel
Relaterade API-element
Metod | Definieras med | ||
---|---|---|---|
Constructor. | FontAsset | ||
[statisk]
Anger om en lista med de tillgängliga inbäddade teckensnitten ska visas. | Font | ||
Anger om en angiven sträng kan visas med det tilldelade teckensnittet. | Font | ||
Anger om det finns en egenskap angiven för ett objekt. | Object | ||
Anger om en instans av klassen Object finns i prototypkedjan för objektet som anges som parameter. | Object | ||
Anger om den angivna egenskapen finns och är uppräkningsbar. | Object | ||
[statisk]
Registrerar en teckensnittsklass i den globala teckensnittslistan. | Font | ||
Anger tillgänglighet för en dynamisk egenskap för slingåtgärder. | Object | ||
Returnerar det här objektets strängrepresentation, formaterad i enlighet med språkspecifika konventioner. | Object | ||
Returnerar det angivna objektets strängbeteckning. | Object | ||
Returnerar det angivna objektets primitiva värde. | Object |
FontAsset | () | Konstruktor |
public function FontAsset()
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Constructor.
Tue Jun 12 2018, 01:40 PM Z