bitedutils

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 13 Imported by: 0

README

bited-utils

Go Reference FlakeHub

Pipeline helpers and utilities for building fonts from bited BDFs. Built with Go and Nix flakes.

  • bited-build: A command that generates vector (TTF, WOFF2) and bitmap (BDF, PCF, OTB, DFONT) fonts from bited BDFs. Supports integer scaling and Nerd Font patching.
  • bited-img: A command that generates image specimens for bited BDFs. Features Base16 color support.
  • bited-clr: A TUI tool for fine-tuned coloring of TXT/CLR pairs.
  • bited-scale: A command for scaling bited BDFs.
  • bited-bbl: A command for proportionalizing bited BDFs.

Built with bited-utils

kirsch

kirsch

ANAKRON

ANAKRON

Nix flake template

In a blank directory where you want your font project to reside, run:

nix flake init --template github:molarmanful/bited-utils

This will create an annotated template project with Nix scaffolding around bited-utils to help get your font project up and running.

TXT/CLR files

To generate colorful images, bited-img accepts pairs of .txt and .clr files. For example, if you have a file test.txt that you wish to color, you would include test.clr containing your desired color codes in the same directory.

A .clr file is really just lines of spaces and color codes. The color codes are as follows:

Code Definition
0-9, A-F Set color to a Base16 color
. Reset to foreground color

All other characters are treated as no-ops and simply pass on the current color.

Codes are interpreted left-to-right, top-to-bottom. The position of a code matches a position in the TXT file where you wish to color. Say you have the following TXT:

Hello, world!
Testing Testing 123

And the following CLR:

A    . D    .
5       6       BCE

Would produce:

TXT/CLR output

Why TXT/CLR?

When designing the pipeline for creating color specimens for my fonts (what would eventually become bited-img), I initially considered several existing approaches to creating the specimen sources:

  • Writing Pango markup directly, which would make passing them to ImageMagick super easy.
  • Creating ANSI via an editor and then generating the Pango markup.

Both of these approaches suffer from a rather important flaw, however: because they embed color data alongside content in the same file, their source files are difficult to read and/or write in a text editor. So my caveman solution was to just separate the color data into its own file, which preserves a readable TXT source.

My workflow for creating these TXT/CLR files goes something like:

  1. Create the TXT file with uncolored contents.
  2. Copy the TXT file to CLR.
  3. Block out the CLR file with color codes. Neovim's visual block mode is especially well-suited for this.
  4. Remove extraneous text and use bited-clr for finer adjustments if necessary.

Documentation

Overview

bited-utils is a set of pipeline helpers and utilities for building fonts from bited BDFs.

Documentation for each utility:

Index

Constants

View Source
const (
	PRE = iota
	X
	PROPS
	CHARS
	CHAR
	BM
	POST
)

Variables

View Source
var NerdFont = &unicode.RangeTable{
	R16: []unicode.Range16{
		{0x23fb, 0x23fe, 1},
		{0x2b58, 0x2b58, 1},
		{0xe000, 0xe00a, 1},
		{0xe0a0, 0xe0a3, 1},
		{0xe0b0, 0xe0c8, 1},
		{0xe0ca, 0xe0ca, 1},
		{0xe0cc, 0xe0d7, 1},
		{0xe200, 0xe2a9, 1},
		{0xe300, 0xe3e3, 1},
		{0xe5fa, 0xe6b7, 1},
		{0xe700, 0xe8ef, 1},
		{0xea60, 0xec1e, 1},
		{0xed00, 0xefce, 1},
		{0xf000, 0xf381, 1},
		{0xf400, 0xf533, 1},
	},
	R32: []unicode.Range32{
		{0xf0001, 0xf1af0, 1},
	},
}

Functions

func Check

func Check(err error)

Check panics if error is non-nil.

func PropString added in v1.2.1

func PropString(v any) string

func WcWidth added in v1.2.1

func WcWidth(r rune, nerd bool) int

Types

type BDF added in v1.2.1

type BDF struct {
	*XLFD

	Props  *orderedmap.OrderedMap[string, any]
	Glyphs []*Glyph
	// contains filtered or unexported fields
}

func R2BDF added in v1.2.1

func R2BDF(r io.Reader) (*BDF, error)

func (*BDF) BDF2W added in v1.2.1

func (bdf *BDF) BDF2W(w io.Writer) error

func (*BDF) CleanProps added in v1.2.1

func (bdf *BDF) CleanProps()

func (*BDF) Scale added in v1.2.1

func (bdf *BDF) Scale(scale int) error

func (*BDF) WriteChars added in v1.2.1

func (bdf *BDF) WriteChars(w io.Writer) error

func (*BDF) WriteProps added in v1.2.1

func (bdf *BDF) WriteProps(w io.Writer) error

type BmI added in v1.2.1

type BmI[T any] struct {
	I        T
	IsRowEnd bool
}

type Glyph added in v1.2.1

type Glyph struct {
	Code   int
	DWidth int

	X int
	Y int
	// contains filtered or unexported fields
}

func (*Glyph) Bits added in v1.2.1

func (glyph *Glyph) Bits() iter.Seq2[BmI[[2]int], bool]

func (*Glyph) Bytes added in v1.2.1

func (glyph *Glyph) Bytes() iter.Seq2[BmI[[2]int], byte]

func (*Glyph) Copy added in v1.2.1

func (glyph *Glyph) Copy() *Glyph

func (*Glyph) Flip added in v1.2.1

func (glyph *Glyph) Flip(i int, j int)

func (*Glyph) Get added in v1.2.1

func (glyph *Glyph) Get(i int, j int) (bool, bool)

func (*Glyph) H added in v1.2.1

func (glyph *Glyph) H() int

func (*Glyph) Hex2Row added in v1.2.1

func (glyph *Glyph) Hex2Row(i int, s string) error

func (*Glyph) Name added in v1.2.1

func (glyph *Glyph) Name() string

func (*Glyph) NewBm added in v1.2.1

func (glyph *Glyph) NewBm(w int, h int)

func (*Glyph) Row32 added in v1.2.1

func (glyph *Glyph) Row32() int

func (*Glyph) Row8 added in v1.2.1

func (glyph *Glyph) Row8() int

func (*Glyph) Rows added in v1.2.1

func (glyph *Glyph) Rows() iter.Seq2[int, []uint32]

func (*Glyph) SWidth added in v1.2.1

func (glyph *Glyph) SWidth(bdf *BDF) int

func (*Glyph) Scale added in v1.2.1

func (glyph *Glyph) Scale(scale int)

func (*Glyph) Set added in v1.2.1

func (glyph *Glyph) Set(i int, j int, b bool) bool

func (*Glyph) SetRect added in v1.2.1

func (glyph *Glyph) SetRect(oi int, oj int, w int, h int, b bool)

func (*Glyph) Uints added in v1.2.1

func (glyph *Glyph) Uints() iter.Seq2[BmI[[2]int], uint32]

func (*Glyph) W added in v1.2.1

func (glyph *Glyph) W() int

func (*Glyph) Write added in v1.2.1

func (glyph *Glyph) Write(bdf *BDF, w io.Writer) error

func (*Glyph) WriteBm added in v1.2.1

func (glyph *Glyph) WriteBm(w io.Writer) error

type XLFD added in v1.2.1

type XLFD struct {
	Foundry  string
	Family   string
	Weight   string
	Slant    string
	Setwidth string
	AddStyle string
	PxSize   int
	Res      struct {
		X int
		Y int
	}
	Spacing string
	// contains filtered or unexported fields
}

func ParseXLFD added in v1.2.1

func ParseXLFD(s string) (*XLFD, error)

func (*XLFD) Props added in v1.2.1

func (xlfd *XLFD) Props() *orderedmap.OrderedMap[string, any]

func (*XLFD) PtSize added in v1.2.1

func (xlfd *XLFD) PtSize() int

func (*XLFD) String added in v1.2.1

func (xlfd *XLFD) String() string

func (*XLFD) ValidateSlant added in v1.2.1

func (xlfd *XLFD) ValidateSlant() error

func (*XLFD) ValidateSpacing added in v1.2.1

func (xlfd *XLFD) ValidateSpacing() error

Directories

Path Synopsis
bited-bbl is a command for proportionalizing bited BDFs.
bited-bbl is a command for proportionalizing bited BDFs.
bited-build generates vector (TTF, WOFF2) and bitmap (BDF, PCF, OTB, DFONT) fonts from bited BDFs.
bited-build generates vector (TTF, WOFF2) and bitmap (BDF, PCF, OTB, DFONT) fonts from bited BDFs.
lib
Package bitedbuild is the backing library for bited-build.
Package bitedbuild is the backing library for bited-build.
bited-clr is a TUI tool for fine-tuned coloring of TXT/CLR pairs.
bited-clr is a TUI tool for fine-tuned coloring of TXT/CLR pairs.
bited-img generates image specimens for bited BDFs.
bited-img generates image specimens for bited BDFs.
lib
Package bitedimg is the backing library for bited-img.
Package bitedimg is the backing library for bited-img.
bited-scale is a command for scaling bited BDFs.
bited-scale is a command for scaling bited BDFs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL