font

package module
v0.0.0-...-205964d Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2017 License: MIT Imports: 5 Imported by: 0

README

Bitmap fonts

This uses bitmap fonts, as found in many (EEP)ROM based "chargen" - short for character generation- ROMs.

Check the rom folder for more details.

Documentation

Overview

Package font is for handling (bitmap) fonts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	// Data is the raw bitmap data bytes
	Data []uint16

	// Size is the size per glyph, in pixels
	Size image.Point

	// Advance size
	Advance int

	// VerticalSpacing
	VerticalSpacing int

	// Alpha 8-bit alpha value
	Alpha color.Alpha

	// CodePoints for glyphs in the font
	CodePoint []rune

	// Encoding name
	Encoding string

	// Replacement character
	Replacement rune
	// contains filtered or unexported fields
}

func (*Bitmap) AlphaAt

func (bmp *Bitmap) AlphaAt(x, y int) color.Alpha

AlphaAt returns the alpha value at (x, y)

func (*Bitmap) At

func (bmp *Bitmap) At(x, y int) color.Color

At is an alias for AlphaAt, to satisfy the image.Image interface

func (*Bitmap) Bounds

func (bmp *Bitmap) Bounds() image.Rectangle

Bounds of the image

func (*Bitmap) ColorModel

func (bmp *Bitmap) ColorModel() color.Model

func (*Bitmap) DataOffset

func (bmp *Bitmap) DataOffset(x, y int) int

DataOffset returns the byte offset for a pixel at (x, y)

func (*Bitmap) Face

func (bmp *Bitmap) Face(width, height int) (face Face, ok bool)

func (*Bitmap) Glyph

func (bmp *Bitmap) Glyph(p image.Point, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance int, ok bool)

func (*Bitmap) GlyphSize

func (bmp *Bitmap) GlyphSize() image.Point

func (*Bitmap) Glyphs

func (bmp *Bitmap) Glyphs() int

func (*Bitmap) Scale

func (bmp *Bitmap) Scale() (*Bitmap, error)

Scale up by factor 2

func (*Bitmap) Sizes

func (bmp *Bitmap) Sizes() []image.Point

func (*Bitmap) Smooth

func (bmp *Bitmap) Smooth() *Bitmap

Smooth edge transitions

This smooths hard edges using a simple algorithm. It finds diagonal transitions and fills the gaps. Eg:

#.                      ##
.#  -> smoothed to ->   ##

Or:

.#                      ##
#.  -> smoothed to ->   ##

This is to smooth after scaling up the font, so the resulting effect will be as follows:

  #.                      ##..                     ##..
	.#  -> scaled up to ->  ##..  -> smoothed to ->  ###.
	                        ..##                     .###
													..##                     ..##

Or:

.#                      ..##                     ..##
#.  -> scaled up to ->  ..##  -> smoothed to ->  .###
												##..                     ###.
												##..                     ##..

type BitmapFont

type BitmapFont []*Bitmap

BitmapFont is a Font implementation using bitmap fonts

func (BitmapFont) Face

func (font BitmapFont) Face(width, height int) (face Face, ok bool)

Face returns the face for the given font size

func (BitmapFont) Sizes

func (font BitmapFont) Sizes() []image.Point

Sizes returns the available face sizes

type Draw

type Draw struct {
	// Dst is the destination image
	Dst draw.Image

	// Src is the source image
	Src image.Image

	// Cursor is the drawing position in the destination image
	Cursor image.Point

	// Face is our font face
	Face Face
}

Draw font glyphs onto an image

func (*Draw) Rune

func (d *Draw) Rune(r rune)

func (*Draw) String

func (d *Draw) String(s string)

type Face

type Face interface {
	// Glyph returns a mask image suitable for using in draw.DrawMask
	Glyph(p image.Point, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance int, ok bool)

	// GlyphSize is the size of a glyph, in pixels
	GlyphSize() image.Point

	// Glyphs returns the number of glyphs in the mask
	Glyphs() int
}

Face implements a font face

type Font

type Font interface {
	// Face returns the face for the given font size, ok indicates if the face is
	// available.
	Face(width, height int) (face Face, ok bool)

	// Sizes returns the available face sizes
	Sizes() []image.Point
}

Font implements a font

Directories

Path Synopsis
cmd
fontmap
Command to dump a font to PNG
Command to dump a font to PNG
rom
Package rom contains tools to convert character ROMS to Go source files This package is mainly for internal use in textmod.es/font/gen.go, used by "go generate" in the containing package.
Package rom contains tools to convert character ROMS to Go source files This package is mainly for internal use in textmod.es/font/gen.go, used by "go generate" in the containing package.
ibm

Jump to

Keyboard shortcuts

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