font formats: comments are specs only

This commit is contained in:
4DBug committed 2026-11-01 01:52:57 -05:00
1 parent 0452f26eef
commit d91dc6c597
14 files changed
+64 -167

No files matched your search

+5 -12
View File
@@ -1,13 +1,7 @@
--!strict
-- font/hershey: Hershey vector fonts in the JHF text layout (James Hurt's distribution of the Hershey glyphs: per glyph
-- a 5-column id, a 3-column vertex count, the left / right extents and the vertices as character pairs offset by "R",
-- " R" lifting the pen; records continue over 72-column lines) as the standard Font: outlines are open stroke paths
-- (moveTo / lineTo, no close; meta.strokes = true), rasterize strokes them through codecs/image/Raster
-- (opts.strokeWidth, default 2 units). Units are Hershey units (unitsPerEm 32, y up, baseline at the Hershey y = 9 of
-- the Roman fonts: ascent 21, descent 7 for capitals / descenders). Code points: opts.map = "ascii" (default: glyph i
-- of the file is code point 32 + i, as the romans / futural / ... .jhf files are laid out) or "id" (the Hershey glyph
-- number is the code point). Written from the JHF layout notes of the Hershey font distribution. Not supported:
-- writing, the Hershey "occidental" index files (.hmp), filled rendering.
-- font/hershey: Hershey vector fonts, JHF layout (5-column id, 3-column vertex count, extents, vertices as character
-- pairs offset by "R", " R" lifts the pen; records continue over 72-column lines). Units: unitsPerEm 32, y up.
-- Not supported: writing, .hmp index files, filled rendering.
-- ------------------------------------------------------------------------------------------------ requires
local Err = require("@rosetta/core/Err")
@@ -26,8 +20,8 @@ local Hershey = {
}
export type DecodeOptions = {
map: ("ascii" | "id")?, -- how glyphs map to code points (default "ascii")
strokeWidth: number?, -- stroke width in font units for rasterize (default 2)
map: ("ascii" | "id")?, -- default "ascii"
strokeWidth: number?, -- font units; default 2
maxGlyphs: number?, -- default 65536
}
@@ -93,7 +87,6 @@ function Face.outline(self: any, g: number): { any }?
return out
end
-- rasterize(g, px) -> alpha8 Image of the stroked glyph (img.meta.left / top / advance in pixels)
function Face.rasterize(self: any, g: number, px: number): Types.Image?
local gl = self._glyphs[g + 1]
if not gl or type(px) ~= "number" or not (px > 0) or px > 4096 then