SkillAgentSearch skills...

Firetype

Actionscript 3 library to parse OpenType fonts and render them using Stage3D

Install / Use

/learn @MaxDidIt/Firetype
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

firetype

Please help me to maintain firetype. If you found firetype useful or used it in one of your products, consider making a donation: Donate

Table of Contents

License

firetype is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

firetype is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You can find a copy of the GNU Lesser General Public License along with firetype in the LICENSE.md file or at http://www.gnu.org/licenses/.

Where Do I Get firetype?

Download firetype-1.6.0.swc

  • Closed #5: You can now set the HardwareCharacterCache used by FiretypeStarlingTextField. Either pass a cache as a parameter to the constructor or set the respective cache property.
  • Closed #6: HardwareCharacterCache can now explictly cache characters from a String. This can be used to pre-cache characters during the initialization of the application. Use either the cacheHardwareCharacters or cacheHardwareCharactersByTextFormat functions to let a HardwareCharacterCache explicitly cache characters.
  • Fixed #7: Fixed a bug in HardwareCharacterCache where adding new characters after invalidating the cache would overwrite old characters. This caused render glitches when changing the text of a HardwareText object unless the HardwareCharacterCache was cleared each time. This is not necessary anymore.
  • Fixed #8: The width and height properties of FiretypeStarlingTextField are now updated correctly.
  • Closed #9: Implemented layouting without caching for faster text dimensions measurement. The update method of HardwareText and FiretypeStarlingTextField now accept a Boolean parameter indicating whether glyphs should be cached or only layouting should be performed.
  • HardwareText and FiretypeStarlingTextField now exposes the textWidth and textHeight properties which store the measured dimensions of the contained, layouted text.

Download firetype-1.5.1.swc


Download firetype-1.4.0.swc


Download firetype-1.3.0.swc

  • API change: SingleGlyphRenderer, BatchedGlyphRenderer, SingleGlyphRendererFactory and BatchedGlyphRendererFactory don't require an ITriangulator parameter anymore.

Download firetype-1.2.5.swc

What Does firetype Do?

firetype is an Open Source Actionscript 3 library that parses OpenType fonts, converts the contained vector glyphs into polygon shapes and renders them using Stage3D via the GPU.

The text rendered with firetype.

One example for a similar technology would be Scaleform which is used in many big-budget productions to render hardware accelerated text and UI elements.

firetype aims to make similar functionality available for Actionscript 3 developers using Stage3D.

Check out the live demo showing firetype in action.

Advantages

Resolution Independence

One major advantage of using firetype is that it makes it easier to handle the resolutions of different versions of your Flash or AIR application.

You can arbitrarily scale the texts without worrying about texture resolutions or the performance impact of software rendering on mobile devices.

Rendering Does Not Have Any Impact On CPU Performance</h3>

Each character handled by firetype is rendered entirely on the graphics hardware. This makes it several magnitudes faster than classic software rendered text objects in Flash.

This can be especially interesting for mobile devices, where rendering via the CPU can noticeably slow down performance.

Only Renders Pixels Actually Occupied By Characters</h3>

When rendering texts with the help of textures, there are usually significant amounts of transparent space between lines and characters which still cause calls to the pixel shader and texture lookups for each pixel.

This is not an issue with firetype. Since characters are polygon objects, only pixels actually covered by the triangles are rendered.

Drawbacks

Moving Texts Still Impacts CPU Performance

While rendering does not cause any calculations on the processor, moving any text in firetype requires the transformation matrices of each character to be recalculated.

In my experience, this still takes up only a fraction of your CPU budget in a frame. However, due to this firetype is basically on par with software rendered texts which have been cached as bitmaps.

firetype still wins if you scale or rotate said texts.

Noticable Lag When Initializing the First Text

firetype caches the polygon data of any character that has been already used.

The first text that you render with a certain font and level of detail will cause firetype to cache each character it encounters for the first time.

This can cause a short lag, which should be below a second in duration, but is still noticeable.

Every subsequent text using the same font and level of detail should cause no lag at all.

How Do I Use firetype?

Table of Contents

Preliminaries

As with any Stage3D project, you will need to set up a couple of things first. Basically, firetype expects the following things in order to run:

  1. A Context3D object.
  2. A Matrix3D object containing a view/projection matrix.

You can get a quick overview of a basic document class setting up Stage3D and using firetype by looking at the code of the first firetype tutorial.

How Do I Display Text With firetype?

These are the basic steps needed to display text using firetype. You can find an implementation of this tutorial at FiretypeTutorial1.as.

Create a HardwareText object and pass it the Context3D object in the constructor.

_hardwareText = new HardwareText(_context3d);

You can assign a String via the text property.

_hardwareText.text = "Hello World!\nThis text is being rendered using firetype!";

You can set the position of the HardwareText object via the x and y properties. You can set the scale of the HardwareText with the scaleX and scaleY properties.

_hardwareText.scaleX = _hardwareText.scaleY = 0.02;
_hardwareText.x = -320;

Note: firetype makes no assumptions about the scale you want to render the text in. It renders the characters with their original measurements, as they are stored in the font file. Because of this, a character is usually 500-1500 units tall. You will probably need to either scale down the HardwareText via the scaleX and scaleY properties or zoom out via the view/projection matrix.

In order to be rendered properly, the HardwareText object needs a projection matrix.

_hardwareText.calculateTransformations(viewProjection, true);

The second parameter needs to be true to signal the HardwareText that it needs to recalculate it's transformations based on the matrix passed to it.

This function needs to be called everytime the view or projection changes.

Finally, we can rende

View on GitHub
GitHub Stars99
CategoryDevelopment
Updated2mo ago
Forks11

Languages

ActionScript

Security Score

95/100

Audited on Jan 15, 2026

No findings