Documentation
¶
Overview ¶
Package bdf is a standalone reader for BDF (Glyph Bitmap Distribution Format) bitmap fonts. It parses a BDF file into a set of decoded glyphs and rasterises each glyph into a full-cell RGBA pixmap, ink-coloured on a transparent ground.
BDF is the classic X11 bitmap font format. Each glyph is a block:
STARTCHAR <name> ENCODING <codepoint> DWIDTH <dx> <dy> ; device advance width BBX <w> <h> <xoff> <yoff> ; bitmap bounding box + offset from origin BITMAP <hexrow> ... ; h rows, each ceil(w/8)*2 hex digits, byte-aligned ENDCHAR
A BDF font also carries a global FONTBOUNDINGBOX that, together with FONT_ASCENT / FONT_DESCENT, fixes the cell box every glyph is placed into.
This package has no dependency beyond the standard library. It was lifted from the subterm terminal renderer's bdf.go, with the buffer/registry coupling removed so it can be reused on its own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Font ¶
type Font struct {
Name string
CellWidth int // glyph advance (DWIDTH) — the true monospace cell width
CellHeight int // FONT_ASCENT+FONT_DESCENT — the cell height
// contains filtered or unexported fields
}
Font holds a parsed BDF font: its cell metrics and decoded glyphs.
func (*Font) GlyphImage ¶
GlyphImage renders one glyph into a full-cell RGBA pixmap, placing the glyph's bitmap at the correct offset within the cell box (using BBX offsets and the font ascent), ink-coloured on a transparent ground. Pixels outside the cell box are clipped. If the font has no glyph for r, a blank (fully transparent) cell-sized image is returned and ok is false.