render

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooMuchData = errors.New("too much data to fit the label width")
View Source
var ErrTooWide = errors.New("text is too wide")

Functions

func AlignNames

func AlignNames() []string

func Barcode

func Barcode(data string, sym Symbology, o BarcodeOptions) (*image.Gray, error)

func FontNames

func FontNames() []string

func Gray

func Gray(img image.Image) *image.Gray

alpha lands on white paper, luma per ITU-R BT.601 like pillow's "L"

func LevelNames

func LevelNames() []string

func Pad

func Pad(g *image.Gray, left, top, right, bottom int) *image.Gray

func QR

func QR(data string, level Level, maxSide int) (*image.Gray, error)

2 modules of quiet zone like the python driver, ISO/IEC 18004 asks for 4 (the paper margin makes up the rest)

func SymbologyNames

func SymbologyNames() []string

func Text

func Text(s string, o TextOptions) (*image.Gray, error)

antialiased, threshold it before packing

func White

func White(w, h int) *image.Gray

Types

type Align

type Align uint8
const (
	Left Align = iota
	Center
	Right
)

func ParseAlign

func ParseAlign(s string, def Align) (Align, bool)

func (Align) String

func (a Align) String() string

type BarcodeOptions

type BarcodeOptions struct {
	MaxWidth int // dots
	Height   int // bar height in dots, 1D only
	Text     bool
	Checksum bool // code39 and code93, the others always carry one
}

type Font

type Font uint8
const (
	SansBold Font = iota
	Sans
	SansMedium
	SansItalic
	SansBoldItalic
	Mono
	MonoBold
	SmallCaps
)

func ParseFont

func ParseFont(s string) (Font, bool)

func (Font) Face

func (f Font) Face(size int) (font.Face, error)

size in dots, same meaning as pillow's truetype(path, size)

func (Font) String

func (f Font) String() string

type Level

type Level uint8

QR error correction, ISO/IEC 18004 recovers ~7, 15, 25 and 30% of the symbol

const (
	LevelL Level = iota
	LevelM
	LevelQ
	LevelH
)

func ParseLevel

func ParseLevel(s string) (Level, bool)

func (Level) String

func (l Level) String() string

type Symbology

type Symbology uint8
const (
	Code128 Symbology = iota
	Code39
	Code93
	EAN13
	EAN8
	UPCA
	Codabar
	ITF
	DataMatrix
	PDF417
	Aztec
)

func ParseSymbology

func ParseSymbology(s string) (Symbology, bool)

func (Symbology) String

func (s Symbology) String() string

func (Symbology) TwoD

func (s Symbology) TwoD() bool

type TextOptions

type TextOptions struct {
	Font        Font
	Size        int
	Align       Align
	Width       int // ignored with NoWrap, the canvas is then as wide as the longest line
	Margin      int
	LineSpacing int
	NoWrap      bool
	MaxWidth    int // NoWrap only, 0 = no limit
}

sizes in dots

Jump to

Keyboard shortcuts

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