hate-no-d/tests/cases/08c_font_atlas.lua
pedro-bento 449be4c4b7
Some checks failed
release / linux/x86_64 (pull_request) Failing after 1m54s
release / freebsd/x86_64 (pull_request) Successful in 5m1s
release / linux/aarch64 (pull_request) Failing after 1m54s
release / linux/armv7 (pull_request) Failing after 2m12s
release / linux/i686 (pull_request) Failing after 1m59s
release / android (pull_request) Successful in 2m54s
release / windows/i686 (pull_request) Successful in 2m3s
release / windows/x86_64 (pull_request) Successful in 2m15s
probe
2026-10-24 22:20:01 +01:00

36 lines
970 B
Lua

-- 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")