tests/font: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:51:09 -05:00
1 parent 7672980c65
commit 9d80ee11b9
12 files changed
+15 -69

No files matched your search

+1 -6
View File
@@ -1,6 +1,4 @@
-- font/bdf tests: Spleen BDF fonts against FreeType's renders (bitmaps, offsets, advances), properties and metrics; our
-- BDF output (of BDF, PCF and outline fonts) read back by FreeType identically (fixture step) and round-tripping; an
-- outline font written as BDF; errors; the fuzz pass. Fixtures: tools/fixtures/bitmapfonts.py, tools/fixtures/fonts.py.
-- font/bdf tests: Spleen BDF fonts against FreeType's renders (tools/fixtures/bitmapfonts.py, tools/fixtures/fonts.py).
local T = require("@tests/T")
local F = require("@rosetta")
local Bdf = require("@rosetta/font/bdf")
@@ -25,7 +23,6 @@ for _, c in Fx.fonts do
t:eq(font.ascent, c.ref.ascent, c.name .. ": ascent")
t:eq(-font.descent, c.ref.descent, c.name .. ": descent")
t:eq(font.info.family, "Spleen", c.name .. ": family")
-- round trip through our writer
local out = Bdf.encode(font) :: buffer
local back = Bdf.decode(Bytes.reader(out)) :: any
t:check(back and #back.bitmap.glyphs == #font.bitmap.glyphs, c.name .. ": round trip glyph count")
@@ -38,14 +35,12 @@ for _, c in Fx.fonts do
end
end
-- an outline font as BDF
local ttf = Ttf.decode(Bytes.reader(buffer.fromstring(Fonts.fonts[1].data)))
local out, err = Bdf.encode(ttf, { px = 14, chars = "Hello" })
t:check(out, "ttf -> bdf: " .. tostring(err))
local back = Bdf.decode(Bytes.reader(out :: buffer)) :: any
t:check(back and back:glyphIndex(72) > 0 and back.unitsPerEm == 14 and back:rasterize(back:glyphIndex(72), 14).width > 3, "ttf -> bdf glyphs")
-- errors
local function code(s: string): string?
local _, e = Bdf.decode(Bytes.reader(buffer.fromstring(s)))
return e and e.code