font formats: comments are specs only
This commit is contained in:
1 parent
0452f26eef
commit
d91dc6c597
14 files changed
+64
-167
No files matched your search
@@ -1,13 +1,7 @@
|
||||
--!strict
|
||||
-- font/bdf: Glyph Bitmap Distribution Format 2.1 (and 2.2's METRICSSET 0) bitmap fonts, read and written, as the
|
||||
-- standard Font with a bitmap strike (codecs/font/Bitmap): FONT / SIZE / FONTBOUNDINGBOX, the properties (all kept in
|
||||
-- meta.properties; FONT_ASCENT / FONT_DESCENT / PIXEL_SIZE / DEFAULT_CHAR / FAMILY_NAME / WEIGHT_NAME / SLANT used),
|
||||
-- glyphs with STARTCHAR names, ENCODING (-1 for unencoded, "-1 n" non-standard codes), DWIDTH / BBX (falling back to
|
||||
-- the font's) and hex BITMAP rows. Code points: ENCODING is the Unicode code point for CHARSET_REGISTRY ISO10646, for
|
||||
-- ISO8859-1 and for fonts without a registry; fonts in other charsets keep their glyphs unmapped (glyph names and
|
||||
-- meta.encodings keep the codes). Writing takes any Font (Bitmap.strike: a bitmap font as it is, an outline font
|
||||
-- rasterized at opts.px) and writes Unicode (ISO10646-1) BDF 2.1. Written from Adobe's BDF 2.1 specification.
|
||||
-- Not supported: vertical metrics (SWIDTH1 / DWIDTH1 / VVECTOR are read and ignored).
|
||||
-- font/bdf: Glyph Bitmap Distribution Format 2.1 (and 2.2's METRICSSET 0), read and written, from Adobe's BDF 2.1
|
||||
-- spec. ENCODING is Unicode for ISO10646, ISO8859-1 and registry-less fonts; other charsets stay unmapped. Writes
|
||||
-- Unicode (ISO10646-1) BDF 2.1 from any Font. Not supported: vertical metrics (SWIDTH1 / DWIDTH1 / VVECTOR ignored).
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ requires
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -27,9 +21,9 @@ local Bdf = {
|
||||
|
||||
export type DecodeOptions = { maxGlyphs: number? } -- default 1114112
|
||||
export type EncodeOptions = {
|
||||
px: number?, -- pixel size for outline fonts (default 16)
|
||||
chars: (string | { number })?, -- code points for outline fonts (default printable ASCII)
|
||||
name: string?, -- the FONT (XLFD) name (default built from the font's family / style)
|
||||
px: number?, -- default 16
|
||||
chars: (string | { number })?, -- default printable ASCII
|
||||
name: string?, -- XLFD; default built from the family / style
|
||||
}
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ sniff
|
||||
@@ -223,7 +217,6 @@ function Bdf.encode(font: any, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
local bold = string.find(string.lower(tostring(info.style or "")), "bold") ~= nil
|
||||
local italic = string.find(string.lower(tostring(info.style or "")), "italic") ~= nil
|
||||
local px = strike.size
|
||||
-- the font bounding box
|
||||
local x0, y0, x1, y1 = math.huge, math.huge, -math.huge, -math.huge
|
||||
for _, g in strike.glyphs do
|
||||
if g.width > 0 and g.height > 0 then
|
||||
@@ -244,7 +237,6 @@ function Bdf.encode(font: any, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
string.format("SIZE %d 75 75", px),
|
||||
string.format("FONTBOUNDINGBOX %d %d %d %d", x1 - x0, y1 - y0, x0, y0),
|
||||
}
|
||||
-- the default glyph: the strike's default, else glyph 0
|
||||
local defaultIndex = (strike.default or 0) + 1
|
||||
local props: { { any } } = {
|
||||
{ "FAMILY_NAME", quote(family) },
|
||||
|
||||
Reference in new issue
Block a user