Created
July 6, 2010 21:29
-
-
Save trxcllnt/465944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var css:String = | |
"global{ | |
fontName: Calibri; | |
fontSize: 26; | |
} | |
#font1{ | |
color: #00FF00; | |
} | |
#font1 #special1{ | |
fontWeight: bold; | |
} | |
b{ | |
fontWeight: bold; | |
} | |
i{ | |
fontPosture: italic; | |
}"; | |
var str:String = <_> | |
<p> | |
This is | |
<font fontName="OsakaMono" fontSize="20"> | |
< | |
<font color="0xCC9900">XHTML</font>/> | |
</font> | |
text rendered with the | |
<b style="fontName:Times">Flash Text Engine</b> | |
and | |
<a href="http://github.com/guyinthechair/tinytlf/" fontSize="32">tinytlf | |
</a> | |
. The | |
<b style="fontName:Times">Flash Text Engine</b> | |
is a new font rendering engine in | |
<a href="http://www.adobe.com/products/flashplayer/">Flash Player 10</a> | |
. | |
<a href="http://github.com/guyinthechair/tinytlf/" fontSize="32">tinytlf | |
</a> | |
is an advanced | |
<span color="0x990000" backgroundColor="0xFF9999" backgroundAlpha="0.2"> | |
text | |
<i>layout</i> | |
framework | |
</span> | |
for | |
<b> | |
<span color="0xCC0000" fontSize="30">Flash</span> | |
</b> | |
and | |
<b fontSize="30">Flex</b> | |
applications. | |
</p> | |
<p> | |
While the | |
<b style="fontName:Times">Flash Text Engine</b> | |
renders | |
<i fontName="Times">fonts,</i> | |
<a href="http://github.com/guyinthechair/tinytlf/" fontSize="32">tinytlf | |
</a> | |
does the heavy lifting of applying layouts, rendering decorations (like | |
<u>underline</u> | |
, | |
<strike>strikethrough</strike> | |
, and | |
<span style="backgroundColor:0x66DE66">background color</span> | |
), parsing | |
<font fontName="OsakaMono" fontSize="20"> | |
< | |
<font color="0x99CC00">XML</font>/> | |
</font> | |
and | |
<font fontName="OsakaMono" fontSize="20"> | |
< | |
<font color="0xCC9900">XHTML</font>/> | |
</font> | |
, applying CSS stylesheets, inline styles, and handling | |
<b> | |
<span style="backgroundColor:0x003399;backgroundAlpha:0.2">text selection</span> | |
<cursor /> | |
</b> | |
. | |
</p> | |
<p fontSize="22"> | |
<a href="http://github.com/guyinthechair/tinytlf/" fontSize="32">tinytlf | |
</a> | |
, for all your text formatting needs, | |
<span fontSize="18"> | |
a project by | |
<a href="http://guyinthechair.com/">Paul Taylor</a> | |
. | |
</span> | |
</p> | |
</_>.toString(); | |
var tf:TextField = new TextField(); | |
tf.width = 400; | |
//Pass in the CSS text as the style for the TextField, he'll figure out the rest. | |
tf.style = css; | |
var engine:ITextEngine = tf.engine; | |
//Styles for the custom nodes I decided to invent for this demo :) | |
engine.styler.mapStyle('u', {underline:true}); | |
engine.styler.mapStyle('strike', {strikethrough:true}); | |
engine.styler.mapStyle('cursor', {cursor:true, layer:3}); | |
//Tell the cursor style to render w/ the CaretDecoration class. | |
engine.decor.mapDecoration('cursor', CaretDecoration); | |
//Apply special layout properties to the TextBlocks | |
engine.blockFactory.blockAdapter = new TestBlockAdapter(); | |
tf.text = str; | |
addChild(tf); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment