ws-arch2: font/bdf (read / write; FreeType reads our output identically) and font/pcf (every pad / unit / order, .pcf.gz via the api), shared bitmap-font fixtures vs FreeType
init.luau unwrap: a single-stream archive whose entry is a .pcf / .psf / .bdf loads as that font (category font).
This commit is contained in:
1 parent
f1c2c6ed06
commit
87cbc62fb6
11 files changed
+913
-2
No files matched your search
@@ -0,0 +1,30 @@
|
||||
-- tools/fixtures/_bitmapfonts_ours.luau: our bitmap font writers' output for FreeType to read back (run by
|
||||
-- tools/fixtures/bitmapfonts.py after it wrote tests/gen/bitmapfonts_src.luau): decodes each source font with its
|
||||
-- format and prints "<case> <hex of our BDF>" lines.
|
||||
local F = require("@formats")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Deflate = require("@formats/codecs/compress/Deflate")
|
||||
local Src = require("@tests/gen/bitmapfonts_src")
|
||||
|
||||
local function hex(b: buffer): string
|
||||
local t = table.create(buffer.len(b))
|
||||
for i = 0, buffer.len(b) - 1 do
|
||||
t[i + 1] = string.format("%02x", buffer.readu8(b, i))
|
||||
end
|
||||
return table.concat(t)
|
||||
end
|
||||
|
||||
for _, c in Src.fonts do
|
||||
local data = buffer.fromstring(c.data)
|
||||
if c.gz then
|
||||
data = Deflate.gunzip(data, 0, buffer.len(data)) :: buffer
|
||||
end
|
||||
local mod = F.format(c.format) :: any
|
||||
local font = if mod then mod.decode(Bytes.reader(data)) else nil
|
||||
if font and F.format("bdf") then
|
||||
local out = (F.format("bdf") :: any).encode(font)
|
||||
if out then
|
||||
print(c.name .. " " .. hex(out))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user