Rendering glyph and save in files

I’m trying to render a font and save to file but the result every glyph looks like this:

var font = lime.text.Font.fromFile("assets/Lato-Regular.ttf");
var images = [for (glyph in font.getGlyphs('textTEXT')) font.renderGlyph(glyph, 44) ];

var i = 0;
for (image in images) {
    trace('Wrinting glyph${i}.png');
    var file ='pasta/glyph${i}.png', true);
    var encode = image.encode();
    file.writeBytes(encode, 0, encode.length);

What I’m doing wrong?

I suspect that the problem is in either font.renderGlyph() or image.encode(). To see which it is, you’ll want to test the result of renderGlyph(), to see what it looks like at that point.

var bitmapData = BitmapData.fromImage(images[0]);
var bitmap = new Bitmap(bitmapData);

Is the result a lowercase t, or a bunch of bars?

Encode works. I’m using it for other stuff.

The result is this:

Btw, saving from the bitmap gives the same result as the bars.

The TextRendering sample of Lime don’t work too but text drawing works in OpenFL…
I don’t understand how OpenFL handles fonts.

Alright. I get it.
Freetype renders 8 bit grayscale bitmap and lime.text.Font.renderGlyph just put it in an image without any convertion. Something like this:

var color = 0xffffff;
var r = color & 0xff;
var g = (color & 0xffff) >> 8;
var b = (color & 0xffffff) >> 16;

var i = 0;
for (image in images) {
    var data = [];
    for (i in {
        var alpha =;

    image.buffer = new ImageBuffer(new UInt8Array(data), image.width, image.height);


Still no clue how OpenFL create those eot, woff and svg fonts and use it, though…