The backend library

The backend library is used to manipulate nodes.

Keywords (TODO): line breaking, hpack, vpack, scaled points, text shaping, logging


  • Glue x

  • Lengths, basic length is scaled points

  • Faces, fonts



boxes and glue users the ZAP (sugared) logger. By default, it outputs JSON lines. To change that to something more readable, you can use the following function:

func newLogger(verbose bool) (*zap.SugaredLogger, error) {
	cfg := zap.Config{
		Encoding:    "console",
		OutputPaths: []string{"stdout"},
		EncoderConfig: zapcore.EncoderConfig{
			EncodeLevel: zapcore.LowercaseColorLevelEncoder,
			LevelKey:    "level",
			MessageKey:  "message",
	if verbose {
		cfg.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
	} else {
		cfg.Level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
	logger, err := cfg.Build()
	if err != nil {
		return nil, err
	return logger.Sugar(), nil

and call it like

if bag.Logger, err = newLogger(true); err != nil {
	return err