FontReader, convert TrueType fonts in graphics with Flex

In the last period I was trying to find a way to convert a TrueType font character into graphics for a new Flex project.
First I found a way using TTX which can convert a font file into an XML with all the Glyph informations needed to recreate the font outline.

But this process requires that all the .ttf files should be converted using TTX before thay can be used in Flash.
So I investigated a bit more and I found a really useful and really well done java project: TypeCast.
What I’ve done next was just to do a porting of the available java code into Actionscript 3 and it works like a charm! It can read a .ttf file and extracts all the font informations, including all the glyph outlines.

See a Academic Writing Help Center demonstration of thie Flex application.

Here you can download the source code:

Source files for the FontRenderer flex project
Title: FontRenderer Source (0 click)
Caption: Source files for the FontRenderer flex project
High Quality Writing Customer Service Filename: fontrenderer-3.zip
Size: 552 kB

senocular.com TransformTool modification

Recently I used the great senocular Transform Tool for a Flex2 project.
We just needed to made a little modification to the way the scale transformation worked. Something like the Photoshop’s Transform tool, where the registration point only affects rotation, while all the scale controls are independent from the registration point.
For this reason I modified a bit the TransformTool code to allow this feature to be set on/off (I called this scaleWithRegistration)

Hold down SHIFT key while rotating or scaling to constrain transformation
Double click to complete transformation.

Get Adobe Flash player

This is the code used in the mxml Application file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
< ?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" backgroundGradientColors="[#ffffff,#ffffff]" viewSourceURL="/test/flex/2/transform_tool/srcview/index.html">
   <mx:image x="10" y="45" source="http://farm2.static.flickr.com/1437/560413557_04318cdc39_m.jpg" id="image" complete="onImageComplete(event)"/>
   <mx:script>
      < ![CDATA[
         import com.senocular.display.TransformTool;
         [Bindable]
         private var tool:TransformTool;
         private function init():void
         {
         }
         private function onImageComplete(event:Event):void
         {
            var timer:Timer = new Timer(1000,1);
            timer.addEventListener(TimerEvent.TIMER, function(evt:TimerEvent):void
            {
               createTool(null);
            });
            timer.start();
            image.addEventListener(MouseEvent.CLICK, createTool);
         }
         private function onDoubleClick(event:MouseEvent):void
         {
            removeChild(tool);
            tool = null;
         }
         private function createTool(event:MouseEvent):void
         {
            if(!tool)
            {
               tool = new TransformTool();
               tool.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
               tool.target = image;
               tool.scaleWithRegistration = scale_registration.selected;
               addChild(tool);
            }
         }
      ]]>
   </mx:script>
   <mx:checkbox x="10" y="10" id="scale_registration" label="scale with registration" selected="{tool.scaleWithRegistration}" click="{tool.scaleWithRegistration = event.target.selected}" enabled="{tool != null}"/>
</mx:application>
Source file of the modified senocular's transform tool
Title: Transform Tool (0 click)
Essay On My Dream Goal Caption: Source file of the modified senocular's transform tool
Filename: sephiroth-components.zip
Size: 449 kB

New Firefox search plugins!

Thanks to Ofir Shemesh here are some new Firefox search plugins for Flex developers.

P. S. Click on the search plugin title to install for your Firefox