font

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// sfnt2Woff offset
	SFNT_OFFSET_TAG      = 0
	SFNT_OFFSET_CHECKSUM = 4
	SFNT_OFFSET_OFFSET   = 8
	SFNT_OFFSET_LENGTH   = 12

	// sfnt2Woff entry offset
	SFNT_ENTRY_OFFSET_FLAVOR              = 0
	SFNT_ENTRY_OFFSET_VERSION_MAJ         = 4
	SFNT_ENTRY_OFFSET_VERSION_MIN         = 6
	SFNT_ENTRY_OFFSET_CHECKSUM_ADJUSTMENT = 8

	// woff offset
	WOFF_OFFSET_MAGIC            = 0
	WOFF_OFFSET_FLAVOR           = 4
	WOFF_OFFSET_SIZE             = 8
	WOFF_OFFSET_NUM_TABLES       = 12
	WOFF_OFFSET_RESERVED         = 14
	WOFF_OFFSET_SFNT_SIZE        = 16
	WOFF_OFFSET_VERSION_MAJ      = 20
	WOFF_OFFSET_VERSION_MIN      = 22
	WOFF_OFFSET_META_OFFSET      = 24
	WOFF_OFFSET_META_LENGTH      = 28
	WOFF_OFFSET_META_ORIG_LENGTH = 32
	WOFF_OFFSET_PRIV_OFFSET      = 36
	WOFF_OFFSET_PRIV_LENGTH      = 40

	// woff entry offset
	WOFF_ENTRY_OFFSET_TAG          = 0
	WOFF_ENTRY_OFFSET_OFFSET       = 4
	WOFF_ENTRY_OFFSET_COMPR_LENGTH = 8
	WOFF_ENTRY_OFFSET_LENGTH       = 12
	WOFF_ENTRY_OFFSET_CHECKSUM     = 16

	// magic
	MAGIC_WOFF                uint32 = 0x774f4646
	MAGIC_CHECKSUM_ADJUSTMENT uint32 = 0xb1b0afba

	// sizes
	SIZE_OF_WOFF_HEADER      = 44
	SIZE_OF_WOFF_ENTRY       = 20
	SIZE_OF_SFNT_HEADER      = 12
	SIZE_OF_SFNT_TABLE_ENTRY = 16
)

Functions

func FullWOFF added in v0.10.0

func FullWOFF(face []byte) ([]byte, error)

FullWOFF losslessly encodes a complete SFNT face for embedding. The stronger compression is intended for full fonts encoded once and reused.

func Sfnt2Woff

func Sfnt2Woff(fontBuf []byte) ([]byte, error)

func SubsetWOFF added in v0.10.0

func SubsetWOFF(face []byte, chars string) ([]byte, error)

SubsetWOFF produces a self-contained font for an SVG. The compact subset drops redundant SFNT entries, retains every selected glyph and its metrics, and uses the same WOFF container as the full-font fallback.

func UTF8CutFont

func UTF8CutFont(inBuf []byte, cutset string) (outBuf []byte)

UTF8CutFont is a utility function that generates a TrueType font composed only of the runes included in cutset. The rune glyphs are copied from This function is demonstrated in ExampleUTF8CutFont().

Types

type TableEntry

type TableEntry struct {
	Tag      []byte
	CheckSum uint32
	Offset   uint32
	Length   uint32
}

Jump to

Keyboard shortcuts

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