-- 08c: GenImageFontAtlas attaches the Rectangle* output to the returned Image; -- both must be freed exactly once (run under valgrind for the real proof). local M = dofile("tests/helpers.lua") local ffi = require("ffi") local R = M.load() M.reset() local b = M.snapshot() local keep = {} local glyphs = ffi.new("GlyphInfo[2]") for i = 0, 1 do local im = R.GenImageColor(4, 4, R.WHITE) keep[#keep + 1] = im glyphs[i].value = 65 + i glyphs[i].offsetX = 0 glyphs[i].offsetY = 0 glyphs[i].advanceX = 4 glyphs[i].image = im end local atlas, recs = R.GenImageFontAtlas(glyphs, 2, 8, 1, 0) M.ok(atlas ~= nil, "font atlas returned") M.ok(atlas.data ~= nil, "font atlas has pixel data") M.ok(recs ~= nil, "glyph rectangles returned") atlas, recs = nil, nil keep = nil glyphs = nil M.gc(3) M.ok(M.delta(b, "released") >= 1, "atlas Image and attached Rectangle* were released") M.eq(M.delta(b, "errors"), 0, "no finalizer errors") print("ok 08c_font_atlas")