cff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause, Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CFF

type CFF struct {

	// Charstrings contains the actual glyph definition.
	// It has a length of numGlyphs and is indexed by glyph ID.
	// See `LoadGlyph` for a way to intepret the glyph data.
	Charstrings [][]byte
	// contains filtered or unexported fields
}

CFF represents a parsed CFF font, as found in the 'CFF ' Opentype table.

func Parse

func Parse(file []byte) (*CFF, error)

Parse parses a .cff font file. Although CFF enables multiple font or CIDFont programs to be bundled together in a single file, embedded CFF font file in PDF or in TrueType/OpenType fonts shall consist of exactly one font or CIDFont. Thus, this function returns an error if the file contains more than one font.

func (*CFF) GlyphName

func (f *CFF) GlyphName(glyph api.GID) string

GlyphName returns the name of the glyph or an empty string if not found.

func (*CFF) LoadGlyph

func (f *CFF) LoadGlyph(glyph tables.GlyphID) ([]api.Segment, ps.PathBounds, error)

LoadGlyph parses the glyph charstring to compute segments and path bounds. It returns an error if the glyph is invalid or if decoding the charstring fails.

type CFF2

type CFF2 struct {

	// Charstrings contains the actual glyph definition.
	// It has a length of numGlyphs and is indexed by glyph ID.
	// See `LoadGlyph` for a way to intepret the glyph data.
	Charstrings [][]byte

	VarStore tables.ItemVarStore // optional
	// contains filtered or unexported fields
}

CFF2 represents a parsed 'CFF2' Opentype table.

func ParseCFF2

func ParseCFF2(src []byte) (*CFF2, error)

ParseCFF2 parses 'src', which must be the content of a 'CFF2' Opentype table.

See also https://learn.microsoft.com/en-us/typography/opentype/spec/cff2

func (*CFF2) LoadGlyph

func (f *CFF2) LoadGlyph(glyph tables.GlyphID, coords []tables.Coord) ([]api.Segment, ps.PathBounds, error)

LoadGlyph parses the glyph charstring to compute segments and path bounds. It returns an error if the glyph is invalid or if decoding the charstring fails.

[coords] must either have the same length as the variations axis, or be empty, and be normalized

Directories

Path Synopsis
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.

Jump to

Keyboard shortcuts

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