tinyfont

package module
v0.0.0-...-a02e449 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

README

TinyFont

TinyFont is a font/text package for TinyGo displays. It's heavily based on Adafruit's GFX library.

example

This package is experimental and may change in the future. It has not been optimized for speed or memory..

Faster compilation

During compilation, tinygo will go through all the font files in a package and them discard them if not used. To improve compilation time considerably, move the files you are going to use to a new package.

About the fonts

The fonts compiled here were just converted or made compatible, and the original authors should be given proper credit. Each font is under its own license, and while most of them are under an open license, there might be differences in its usage and conditions.

License

This project is licensed under the BSD 3-clause license, just like the Go project itself.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Org01 = Font{
	Org01Bitmaps,
	Org01Glyphs,
	0x20, 0x7E, 7}
View Source
var Org01Bitmaps = []byte{}/* 271 elements not displayed */
View Source
var Org01Glyphs = []Glyph{
	{0, 0, 0, 6, 0, 1},
	{0, 1, 5, 2, 0, -4},
	{1, 3, 1, 4, 0, -4},
	{2, 5, 5, 6, 0, -4},
	{6, 5, 5, 6, 0, -4},
	{10, 5, 5, 6, 0, -4},
	{14, 5, 5, 6, 0, -4},
	{18, 1, 1, 2, 0, -4},
	{19, 2, 5, 3, 0, -4},
	{21, 2, 5, 3, 0, -4},
	{23, 3, 3, 4, 0, -3},
	{25, 3, 3, 4, 0, -3},
	{27, 1, 2, 2, 0, 0},
	{28, 4, 1, 5, 0, -2},
	{29, 1, 1, 2, 0, 0},
	{30, 5, 5, 6, 0, -4},
	{34, 5, 5, 6, 0, -4},
	{38, 1, 5, 2, 0, -4},
	{39, 5, 5, 6, 0, -4},
	{43, 5, 5, 6, 0, -4},
	{47, 5, 5, 6, 0, -4},
	{51, 5, 5, 6, 0, -4},
	{55, 5, 5, 6, 0, -4},
	{59, 5, 5, 6, 0, -4},
	{63, 5, 5, 6, 0, -4},
	{67, 5, 5, 6, 0, -4},
	{71, 1, 4, 2, 0, -3},
	{72, 1, 4, 2, 0, -3},
	{73, 3, 5, 4, 0, -4},
	{75, 4, 3, 5, 0, -3},
	{77, 3, 5, 4, 0, -4},
	{79, 5, 5, 6, 0, -4},
	{83, 5, 5, 6, 0, -4},
	{87, 5, 5, 6, 0, -4},
	{91, 5, 5, 6, 0, -4},
	{95, 5, 5, 6, 0, -4},
	{99, 5, 5, 6, 0, -4},
	{103, 5, 5, 6, 0, -4},
	{107, 5, 5, 6, 0, -4},
	{111, 5, 5, 6, 0, -4},
	{115, 5, 5, 6, 0, -4},
	{119, 5, 5, 6, 0, -4},
	{123, 5, 5, 6, 0, -4},
	{127, 5, 5, 6, 0, -4},
	{131, 5, 5, 6, 0, -4},
	{135, 5, 5, 6, 0, -4},
	{139, 5, 5, 6, 0, -4},
	{143, 5, 5, 6, 0, -4},
	{147, 5, 5, 6, 0, -4},
	{151, 5, 5, 6, 0, -4},
	{155, 5, 5, 6, 0, -4},
	{159, 5, 5, 6, 0, -4},
	{163, 5, 5, 6, 0, -4},
	{167, 5, 5, 6, 0, -4},
	{171, 5, 5, 6, 0, -4},
	{175, 5, 5, 6, 0, -4},
	{179, 5, 5, 6, 0, -4},
	{183, 5, 5, 6, 0, -4},
	{187, 5, 5, 6, 0, -4},
	{191, 2, 5, 3, 0, -4},
	{193, 5, 5, 6, 0, -4},
	{197, 2, 5, 3, 0, -4},
	{199, 3, 2, 4, 0, -4},
	{200, 5, 1, 6, 0, 1},
	{201, 1, 1, 2, 0, -4},
	{202, 4, 4, 5, 0, -3},
	{204, 4, 5, 5, 0, -4},
	{207, 4, 4, 5, 0, -3},
	{209, 4, 5, 5, 0, -4},
	{212, 4, 4, 5, 0, -3},
	{214, 3, 5, 4, 0, -4},
	{216, 4, 5, 5, 0, -3},
	{219, 4, 5, 5, 0, -4},
	{222, 1, 4, 2, 0, -3},
	{223, 2, 5, 3, 0, -3},
	{225, 4, 5, 5, 0, -4},
	{228, 1, 5, 2, 0, -4},
	{229, 5, 4, 6, 0, -3},
	{232, 4, 4, 5, 0, -3},
	{234, 4, 4, 5, 0, -3},
	{236, 4, 5, 5, 0, -3},
	{239, 4, 5, 5, 0, -3},
	{242, 4, 4, 5, 0, -3},
	{244, 4, 4, 5, 0, -3},
	{246, 5, 5, 6, 0, -4},
	{250, 4, 4, 5, 0, -3},
	{252, 4, 4, 5, 0, -3},
	{254, 5, 4, 6, 0, -3},
	{257, 4, 4, 5, 0, -3},
	{259, 4, 5, 5, 0, -3},
	{262, 4, 4, 5, 0, -3},
	{264, 3, 5, 4, 0, -4},
	{266, 1, 5, 2, 0, -4},
	{267, 3, 5, 4, 0, -4},

	{269, 5, 3, 6, 0, -3}} // 0x7E '~'
View Source
var Picopixel = Font{
	PicopixelBitmaps,
	PicopixelGlyphs,
	0x20, 0x7E, 7}
View Source
var PicopixelBitmaps = []byte{}/* 180 elements not displayed */
View Source
var PicopixelGlyphs = []Glyph{
	{0, 0, 0, 2, 0, 1},
	{0, 1, 5, 2, 0, -4},
	{1, 3, 2, 4, 0, -4},
	{2, 5, 5, 6, 0, -4},
	{6, 3, 6, 4, 0, -4},
	{9, 3, 5, 4, 0, -4},
	{11, 4, 5, 5, 0, -4},
	{14, 1, 2, 2, 0, -4},
	{15, 2, 5, 3, 0, -4},
	{17, 2, 5, 3, 0, -4},
	{19, 3, 3, 4, 0, -3},
	{21, 3, 3, 4, 0, -3},
	{23, 2, 2, 3, 0, 0},
	{24, 3, 1, 4, 0, -2},
	{25, 1, 1, 2, 0, 0},
	{26, 3, 5, 4, 0, -4},
	{28, 3, 5, 4, 0, -4},
	{30, 2, 5, 3, 0, -4},
	{32, 3, 5, 4, 0, -4},
	{34, 3, 5, 4, 0, -4},
	{36, 3, 5, 4, 0, -4},
	{38, 3, 5, 4, 0, -4},
	{40, 3, 5, 4, 0, -4},
	{42, 3, 5, 4, 0, -4},
	{44, 3, 5, 4, 0, -4},
	{46, 3, 5, 4, 0, -4},
	{48, 1, 3, 2, 0, -3},
	{49, 2, 4, 3, 0, -3},
	{50, 2, 3, 3, 0, -3},
	{51, 3, 3, 4, 0, -3},
	{53, 2, 3, 3, 0, -3},
	{54, 3, 5, 4, 0, -4},
	{56, 3, 5, 4, 0, -4},
	{58, 3, 5, 4, 0, -4},
	{60, 3, 5, 4, 0, -4},
	{62, 3, 5, 4, 0, -4},
	{64, 3, 5, 4, 0, -4},
	{66, 3, 5, 4, 0, -4},
	{68, 3, 5, 4, 0, -4},
	{70, 3, 5, 4, 0, -4},
	{72, 3, 5, 4, 0, -4},
	{74, 1, 5, 2, 0, -4},
	{75, 3, 5, 4, 0, -4},
	{77, 3, 5, 4, 0, -4},
	{79, 3, 5, 4, 0, -4},
	{81, 5, 5, 6, 0, -4},
	{85, 4, 5, 5, 0, -4},
	{88, 3, 5, 4, 0, -4},
	{90, 3, 5, 4, 0, -4},
	{92, 3, 6, 4, 0, -4},
	{95, 3, 5, 4, 0, -4},
	{97, 3, 5, 4, 0, -4},
	{99, 3, 5, 4, 0, -4},
	{101, 3, 5, 4, 0, -4},
	{103, 3, 5, 4, 0, -4},
	{105, 5, 5, 6, 0, -4},
	{109, 3, 5, 4, 0, -4},
	{111, 3, 5, 4, 0, -4},
	{113, 3, 5, 4, 0, -4},
	{115, 2, 5, 3, 0, -4},
	{117, 3, 5, 4, 0, -4},
	{119, 2, 5, 3, 0, -4},
	{121, 3, 2, 4, 0, -4},
	{122, 4, 1, 4, 0, 1},
	{123, 2, 2, 3, 0, -4},
	{124, 3, 4, 4, 0, -3},
	{126, 3, 5, 4, 0, -4},
	{128, 3, 3, 4, 0, -2},
	{130, 3, 5, 4, 0, -4},
	{132, 3, 4, 4, 0, -3},
	{134, 2, 5, 3, 0, -4},
	{136, 3, 5, 4, 0, -3},
	{138, 3, 5, 4, 0, -4},
	{140, 1, 5, 2, 0, -4},
	{141, 2, 6, 3, 0, -4},
	{143, 3, 5, 4, 0, -4},
	{145, 2, 5, 3, 0, -4},
	{147, 5, 3, 6, 0, -2},
	{149, 3, 3, 4, 0, -2},
	{151, 3, 3, 4, 0, -2},
	{153, 3, 4, 4, 0, -2},
	{155, 3, 4, 4, 0, -2},
	{157, 2, 3, 3, 0, -2},
	{158, 3, 4, 4, 0, -3},
	{160, 2, 5, 3, 0, -4},
	{162, 3, 3, 4, 0, -2},
	{164, 3, 3, 4, 0, -2},
	{166, 5, 3, 6, 0, -2},
	{168, 3, 3, 4, 0, -2},
	{170, 3, 4, 4, 0, -2},
	{172, 3, 4, 4, 0, -3},
	{174, 3, 5, 4, 0, -4},
	{176, 1, 6, 2, 0, -4},
	{177, 3, 5, 4, 0, -4},

	{179, 4, 2, 5, 0, -3}} // 0x7E '~'
View Source
var Tiny3x3a2pt7b = Font{
	Tiny3x3a2pt7bBitmaps,
	Tiny3x3a2pt7bGlyphs,
	0x20, 0x7E, 4}
View Source
var Tiny3x3a2pt7bBitmaps = []byte{}/* 142 elements not displayed */
View Source
var Tiny3x3a2pt7bGlyphs = []Glyph{
	{0, 0, 0, 4, 0, 1},
	{0, 1, 2, 3, 1, -2},
	{1, 3, 2, 4, 0, -2},
	{2, 3, 3, 4, 0, -2},
	{4, 3, 3, 4, 0, -2},
	{6, 3, 3, 4, 0, -2},
	{8, 3, 3, 4, 0, -2},
	{10, 1, 1, 3, 1, -2},
	{11, 2, 3, 3, 0, -2},
	{12, 2, 3, 4, 1, -2},
	{13, 2, 2, 4, 1, -2},
	{14, 3, 3, 4, 0, -2},
	{16, 1, 2, 2, 0, 0},
	{17, 3, 1, 4, 0, -1},
	{18, 1, 1, 2, 0, 0},
	{19, 3, 3, 4, 0, -2},
	{21, 3, 3, 4, 0, -2},
	{23, 2, 3, 3, 0, -2},
	{24, 3, 3, 4, 0, -2},
	{26, 3, 3, 4, 0, -2},
	{28, 3, 3, 4, 0, -2},
	{30, 3, 3, 4, 0, -2},
	{32, 3, 3, 4, 0, -2},
	{34, 3, 3, 4, 0, -2},
	{36, 3, 3, 4, 0, -2},
	{38, 3, 3, 4, 0, -2},
	{40, 1, 3, 3, 1, -2},
	{41, 2, 3, 3, 0, -1},
	{42, 2, 3, 3, 0, -2},
	{43, 3, 3, 4, 0, -2},
	{45, 2, 3, 4, 1, -2},
	{46, 2, 3, 4, 1, -2},
	{47, 3, 3, 4, 0, -2},
	{49, 3, 3, 4, 0, -2},
	{51, 3, 3, 4, 0, -2},
	{53, 3, 3, 4, 0, -2},
	{55, 3, 3, 4, 0, -2},
	{57, 3, 3, 4, 0, -2},
	{59, 3, 3, 4, 0, -2},
	{61, 3, 3, 4, 0, -2},
	{63, 3, 3, 4, 0, -2},
	{65, 1, 3, 3, 1, -2},
	{66, 3, 3, 4, 0, -2},
	{68, 3, 3, 4, 0, -2},
	{70, 3, 3, 4, 0, -2},
	{72, 3, 3, 4, 0, -2},
	{74, 3, 3, 4, 0, -2},
	{76, 3, 3, 4, 0, -2},
	{78, 3, 3, 4, 0, -2},
	{80, 3, 3, 4, 0, -2},
	{82, 3, 3, 4, 0, -2},
	{84, 3, 3, 4, 0, -2},
	{86, 3, 3, 4, 0, -2},
	{88, 3, 3, 4, 0, -2},
	{90, 3, 3, 4, 0, -2},
	{92, 3, 3, 4, 0, -2},
	{94, 3, 3, 4, 0, -2},
	{96, 3, 3, 4, 0, -2},
	{98, 3, 3, 4, 0, -2},
	{100, 2, 3, 3, 0, -2},
	{101, 3, 3, 4, 0, -2},
	{103, 2, 3, 4, 1, -2},
	{104, 3, 2, 4, 0, -2},
	{105, 3, 1, 4, 0, 0},
	{106, 2, 2, 3, 0, -2},
	{107, 2, 2, 3, 0, -1},
	{108, 2, 3, 3, 0, -2},
	{109, 2, 2, 3, 0, -1},
	{110, 2, 3, 3, 0, -2},
	{111, 2, 2, 3, 0, -1},
	{112, 2, 3, 3, 0, -2},
	{113, 2, 3, 3, 0, -1},
	{114, 2, 3, 3, 0, -2},
	{115, 1, 2, 2, 0, -1},
	{116, 2, 3, 3, 0, -1},
	{117, 3, 3, 4, 0, -2},
	{119, 2, 3, 3, 0, -2},
	{120, 3, 2, 4, 0, -1},
	{121, 3, 2, 4, 0, -1},
	{122, 2, 2, 3, 0, -1},
	{123, 2, 3, 3, 0, -1},
	{124, 2, 3, 3, 0, -1},
	{125, 2, 2, 3, 0, -1},
	{126, 2, 2, 3, 0, -1},
	{127, 3, 3, 4, 0, -2},
	{129, 3, 2, 4, 0, -1},
	{130, 3, 2, 4, 0, -1},
	{131, 3, 2, 4, 0, -1},
	{132, 2, 2, 3, 0, -1},
	{133, 3, 3, 4, 0, -1},
	{135, 2, 2, 3, 0, -1},
	{136, 3, 3, 4, 0, -2},
	{138, 1, 4, 3, 1, -2},
	{139, 3, 3, 4, 0, -2},

	{141, 3, 2, 4, 0, -2}} // 0x7E '~'
View Source
var TomThumb = Font{
	TomThumbBitmaps,
	TomThumbGlyphs,
	0x20, 0x7E, 6}
View Source
var TomThumbBitmaps = []byte{}/* 904 elements not displayed */
View Source
var TomThumbGlyphs = []Glyph{}/* 204 elements not displayed */

{offset, Width, Height, advance cursor, x offset, y offset}

Functions

func DrawChar

func DrawChar(display drivers.Displayer, font *Font, x int16, y int16, char byte, color color.RGBA)

DrawChar sets a single char in the buffer of the display

func DrawCharRotated

func DrawCharRotated(display drivers.Displayer, font *Font, x int16, y int16, char byte, color color.RGBA, rotation Rotation)

DrawCharRotated sets a single char in the buffer of the display

func LineWidth

func LineWidth(font *Font, text []byte) (innerWidth uint32, outboxWidth uint32)

func WriteLine

func WriteLine(display drivers.Displayer, font *Font, x int16, y int16, text []byte, color color.RGBA)

WriteLine writes a string in the selected font in the buffer

func WriteLineColors

func WriteLineColors(display drivers.Displayer, font *Font, x int16, y int16, text []byte, colors []color.RGBA)

WriteLineColors writes a string in the selected font in the buffer. Each char is in a different color if not enough colors are defined, colors are cycled.

func WriteLineColorsRotated

func WriteLineColorsRotated(display drivers.Displayer, font *Font, x int16, y int16, text []byte, colors []color.RGBA, rotation Rotation)

WriteLineColorsRotated writes a string in the selected font in the buffer. Each char is in a different color if not enough colors are defined, colors are cycled.

func WriteLineRotated

func WriteLineRotated(display drivers.Displayer, font *Font, x int16, y int16, text []byte, color color.RGBA, rotation Rotation)

WriteLineRotated writes a string in the selected font in the buffer

Types

type Font

type Font struct {
	Bitmaps  []byte
	Glyphs   []Glyph
	First    byte
	Last     byte
	YAdvance uint8
}

type Glyph

type Glyph struct {
	BitmapIndex uint16
	Width       uint8
	Height      uint8
	XAdvance    uint8
	XOffset     int8
	YOffset     int8
}

type Rotation

type Rotation uint8
const (
	NO_ROTATION  Rotation = 0
	ROTATION_90  Rotation = 1 // 90 degrees clock-wise rotation
	ROTATION_180 Rotation = 2
	ROTATION_270 Rotation = 3
)

Directories

Path Synopsis
examples
epd
* ** Gophers by Jaana B. Dogan - @rakyll is ** licensed under a Creative Commons Attribution Non-commercial 4.0 International (CC BY-NC 4.0) ** (https://creativecommons.org/licenses/by-nc/4.0/).
* ** Gophers by Jaana B. Dogan - @rakyll is ** licensed under a Creative Commons Attribution Non-commercial 4.0 International (CC BY-NC 4.0) ** (https://creativecommons.org/licenses/by-nc/4.0/).

Jump to

Keyboard shortcuts

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