package cff

import "github.com/go-text/typesetting/font/cff"

Index

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 opentype.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) ([]ot.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) ([]ot.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

Source Files

cff2.go cff_gen.go cff_src.go charsets.go charstring.go parser.go

Directories

PathSynopsis
font/cff/interpreterPackage psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.
Version
v0.3.0 (latest)
Published
Feb 21, 2025
Platform
linux/amd64
Imports
6 packages
Last checked
15 hours ago

Tools for package owners.