Share on Google+Share on Google+

Embedded font with multiple typefaces in Flex4

Advertisement
In this example you can see how we can use a type faces font in multiple form.

Embedded font with multiple typefaces in Flex4:

In this example you can see how we can use a type faces font in multiple form. In this example we use a three font file: simple, bold and italic font.

Example:

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

minWidth="955" minHeight="600">

<!-- Embedded font using multiple faces -->

<fx:Style>

@font-face {

src:url("MyriadWebPro.ttf");

fontFamily: fontfamily1;

embedAsCFF: true;

}

@font-face {

src:url("MyriadWebPro-Bold.ttf");

fontFamily: fontfamily1;

fontWeight: bold;

embedAsCFF: true;

}

@font-face {

src:url("MyriadWebPro-Italic.ttf");

fontFamily: fontfamily1;

fontStyle: italic;

embedAsCFF: true;

}

.plainStyle {

fontSize: 30px;

fontFamily: fontfamily1;

color:red;

}

.boldStyle {

fontSize: 30px;

fontFamily: fontfamily1;

fontWeight: bold;

color:green;

}

.italicStyle {

fontSize: 30px;

fontFamily: fontfamily1;

fontStyle: italic;

color:blue;

}

</fx:Style>

<s:Panel title="Embedded font with multiple faces Example" width="297" height="164">

<s:VGroup x="12" y="13">

<s:Label text="This is a Plain Text" styleName="plainStyle"/>

<s:Label text="This is a Bold Text" styleName="boldStyle"/>

<s:Label text="This is a Italic Text" styleName="italicStyle"/>

</s:VGroup>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Advertisements

Posted on: June 24, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.