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.
So what I've done was just 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.
You can see a demonstration of thie Flex application here:
www.sephiroth.it/test/flex/2/fontreader/bin/FontRenderer.html
sources can be downloaded here: www.sephiroth.it/file_detail.php?id=159
@param factor a 16.16 fixed value */
public function scale( factor:int ):void
{
for (var i:uint = 0; i {
GlyphPoint(_points[i]).x = ((GlyphPoint(_points[i]).x > 26;
GlyphPoint(_points[i]).y = ((GlyphPoint(_points[i]).y > 26;
}
_leftSideBearing = (( _leftSideBearing * factor) >> 6);
_advanceWidth = (_advanceWidth * factor) >> 6;
}
What does it mean by 16.16 (in comment) as I use it like scale(16) or scale(8)?
Its not working for me as points are converted into 0.
Sorry, you're right. Anyway I can post the code from the parser, but not the vector renderer (because it's part of a commercial project).
If you want I can send you by mail
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)
Type the characters you see in the picture above.
TrackBack URL for this entry: www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/216