basicfont

package
v0.0.0-...-2824937 Latest Latest
Warning

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

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

Documentation

Overview

Package basicfont provides fixed-size font faces.

Index

Constants

This section is empty.

Variables

View Source
var Face7x13 = &Face{
	Advance: 7,
	Width:   6,
	Height:  13,
	Ascent:  11,
	Mask:    mask7x13,
	Ranges: []Range{
		{'\u0020', '\u007f', 0},
		{'\ufffd', '\ufffe', 95},
	},
}

Face7x13 is a Face derived from the public domain X11 misc-fixed font files.

At the moment, it holds the printable characters in ASCII starting with space, and the Unicode replacement character U+FFFD.

Its data is entirely self-contained and does not require loading from separate files.

Functions

This section is empty.

Types

type Face

type Face struct {
	// Advance is the glyph advance, in pixels.
	Advance int
	// Width is the glyph width, in pixels.
	Width int
	// Height is the glyph height, in pixels.
	Height int
	// Ascent is the glyph ascent, in pixels.
	Ascent int

	// Mask contains all of the glyph masks. Its width is typically the Face's
	// Width, and its height a multiple of the Face's Height.
	Mask image.Image
	// Ranges map runes to sub-images of Mask. The rune ranges must not
	// overlap, and must be in increasing rune order.
	Ranges []Range
}

Face is a basic font face whose glyphs all have the same metrics.

It is safe to use concurrently.

func (*Face) Close

func (f *Face) Close() error

func (*Face) Glyph

func (f *Face) Glyph(dot fixed.Point26_6, r rune) (
	dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool)

func (*Face) GlyphAdvance

func (f *Face) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)

func (*Face) GlyphBounds

func (f *Face) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)

func (*Face) Kern

func (f *Face) Kern(r0, r1 rune) fixed.Int26_6

type Range

type Range struct {
	Low, High rune
	Offset    int
}

Range maps a contiguous range of runes to vertically adjacent sub-images of a Face's Mask image. The rune range is inclusive on the low end and exclusive on the high end.

If Low <= r && r < High, then the rune r is mapped to the sub-image of Face.Mask whose bounds are image.Rect(0, y, Face.Width, y+Face.Height), where y equals (int(r-Low) + Offset) * Face.Height.

Jump to

Keyboard shortcuts

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