unifont

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

README

unifont

A go library for using GNU Unifont with Go. Implements the golang.org/x/image/font.Face interface for using with that package.

Use

import "github.com/steelseries/unifont"

...

uf, err := unifont.ParseHexFile("unifont.hex")
if err != nil {
    panic(err)
}

face, err := unifont.NewFace(uf, 1)
if err != nil {
    panic(err)
}

// use face like any other font.Face, with font.Drawer/etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFace

func NewFace(u *Unifont, multipler int) (font.Face, error)

NewFace returns a new font.Face for the given Unifont. The multiplier parameter defines the output size of the font face. 1 means the default 16px height, 2 means 32px height, and so on.

Types

type Unifont

type Unifont struct {
	// contains filtered or unexported fields
}

Unifont is a pared Unifont .hex file. It is safe to use concurrently with multiple font faces as long as no methods are called on it after being supplied to a font face.

func ParseHex

func ParseHex(s io.Reader, options ...UnifontOptions) (*Unifont, error)

Parses the supplied Unifont .hex file from an input stream

func ParseHexFile

func ParseHexFile(filename string, options ...UnifontOptions) (*Unifont, error)

Parses the supplied Unifont .hex file from a file

func ParseHexGzFile

func ParseHexGzFile(filename string, options ...UnifontOptions) (*Unifont, error)

Parses the supplied Unifont .hex file from a gzipped file

func (*Unifont) CombiningInfo

func (u *Unifont) CombiningInfo(s io.Reader) error

Parse combining info from a combining.txt input stream.

To get the data from the Unifont project to supply here, you can use this command on the command line in a copy of the Unicode source release:

shopt -s globstar
sort -u **/*-combining.txt > combining.txt

This will generate a combined.txt file containing all the combining character offsets.

func (*Unifont) CombiningInfoFile

func (u *Unifont) CombiningInfoFile(filename string) error

Parse combining info from a combining.txt file.

func (*Unifont) CombiningInfoGzFile

func (u *Unifont) CombiningInfoGzFile(filename string) error

Parse combining info from a combining.txt.gz stream.

type UnifontOptions

type UnifontOptions int

Optional flags to supply to the Unifont parsing functions

const (
	// Skip parsing characters in the Private Use Areas.
	NoPAUs UnifontOptions = iota
)

Jump to

Keyboard shortcuts

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