burnfont

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: BSD-3-Clause Imports: 8 Imported by: 1

README

burnfont Build Go Report Card License GoDoc

This is a hand-crafted 6x6 pixel font, defined by code, originally created in 1997.

Here is a generated image with all available letters in this font:

letters

Here is the same image, but scaled up 4x:

scaled

The font is a bit nostalgic to me, and was used in my small DOS drawing program named Burn. The palette that came with Burn is available here. The GUI was drawn with 320x200 pixels, 256 indexed colors (mode 13h), and looked like this:

burn screenshot

The font definition looks like this:

case 'k':
    fontLine("***", x, y)
    fontLine("-**", x, y+1)
    fontLine("**-**", x+1, y+2)
    fontLine("****-", x+1, y+3)
    fontLine("-**-**", x, y+4)
    fontLine("*** **", x, y+5)

* is a 100% opaque pixel, while - is a 25% opaque one (mostly transparent).

Contents

This Go package has a slice Available that lists all available runes. There is also a Draw function that takes an *image.RGBA value, a rune, a position (x and y) and a color (r, g and b) and draws a letter at that position in the image.

  • The cmd/scaled example outputs an image where each "pixel" of the font is 4x4 pixels.
  • The cmd/letters example outputs an image where each pixel is a pixel.
  • The cmd/txt2png example can render text as a PNG image.

Generating an image

The scaled utility can be built and run like this:

cd cmd/scaled
go build
./scaled

General information

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Available = []rune{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Æ', 'Ø', 'Å', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'æ', 'ø', 'å', '.', ';', ',', '\'', '"', '*', '+', '!', '?', '-', '=', '_', '/', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '(', ')', '→', '{', '}', '[', ']', '<', '>', '&', '|', '\\'}

Available is a slice with all available runes, for this package

Functions

func Draw

func Draw(d Drawable, l rune, x, y int, r, g, b byte) error

Draw will draw an image of the selected rune at (x,y). If the rune is not available, an error will be returned. r,g,b is the main color of the rune.

func DrawString

func DrawString(d Drawable, x, y int, s string, c color.NRGBA) int

DrawString draws the given string using this font

func SavePNG added in v1.2.3

func SavePNG(text, filename string) error

SavePNG will render the given text to an image and save it as a .png image (using the given filename).

Types

type Drawable

type Drawable interface {
	Set(x, y int, c color.Color)
}

Drawable is an interface for anything that has a Set function, for drawing

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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