package psinterpreter

Import Path
	github.com/go-text/typesetting/font/cff/interpreter (on go.dev)

Dependency Relation
	imports 6 packages, and imported by one package

Involved Source Files charstrings.go Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings. This package provides the low-level mechanisms needed to read such formats; the data is consumed in higher level packages, which implement `PsOperatorHandler`. It also provides helpers to interpret glyph outline descriptions, shared between Type1 and CFF font formats. See https://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf
Package-Level Type Names (total 8)
/* sort by: | */
Effecive size currently in use. The first value to pop is at index Top-1 // we have to use float64 to properly store floats and int32 values Clear clears the stack Pop returns the top level value and decrease `Top` It will panic if the stack is empty. PopN check and remove the n top levels entries. Passing a negative `numPop` clears all the stack. Uint16 returns the top level value as uint16, without popping the stack.
CharstringReader provides implementation of the operators found in a font charstring. Acumulated bounds for the glyph outlines CurrentPoint Point Acumulated segments for the glyph outlines ClosePath closes the current contour, adding a segment to the first point if needed. (*CharstringReader) Flex(state *Machine) error (*CharstringReader) Flex1(state *Machine) error (*CharstringReader) Hflex(state *Machine) error (*CharstringReader) Hflex1(state *Machine) error (*CharstringReader) Hhcurveto(state *Machine) (*CharstringReader) Hintmask(state *Machine) (*CharstringReader) Hlineto(state *Machine) (*CharstringReader) Hmoveto(state *Machine) error (*CharstringReader) Hstem(state *Machine) (*CharstringReader) Hvcurveto(state *Machine) (*CharstringReader) Rcurveline(state *Machine) error RelativeCurveTo draws a curve with controls points computed from the current point and `arg1`, `arg2`, `arg3` (*CharstringReader) Rlinecurve(state *Machine) error (*CharstringReader) Rlineto(state *Machine) (*CharstringReader) Rmoveto(state *Machine) error (*CharstringReader) Rrcurveto(state *Machine) (*CharstringReader) Vhcurveto(state *Machine) (*CharstringReader) Vlineto(state *Machine) (*CharstringReader) Vmoveto(state *Machine) error (*CharstringReader) Vstem(state *Machine) (*CharstringReader) Vvcurveto(state *Machine)
Context is the flavour of the Postcript language. func OperatorHandler.Context() Context const PrivateDict const TopDict const Type1Charstring const Type2Charstring
Machine is a PostScript interpreter. A same interpreter may be re-used using muliples `Run` calls. ArgStack ArgStack CallSubroutine calls the subroutine, identified by its index, as found in the instructions (that is, before applying the subroutine biased). `isLocal` controls whether the local or global subroutines are used. No argument stack modification is performed. Return returns from a subroutine call. Run runs the instructions in the PostScript context asked by `handler`. `localSubrs` and `globalSubrs` contains the subroutines that may be called in the instructions. SkipBytes skips the next `count` bytes from the instructions, and clears the argument stack. It does nothing if `count` exceed the length of the instructions. func GlobalSubr(state *Machine) error func LocalSubr(state *Machine) error func (*CharstringReader).Flex(state *Machine) error func (*CharstringReader).Flex1(state *Machine) error func (*CharstringReader).Hflex(state *Machine) error func (*CharstringReader).Hflex1(state *Machine) error func (*CharstringReader).Hhcurveto(state *Machine) func (*CharstringReader).Hintmask(state *Machine) func (*CharstringReader).Hlineto(state *Machine) func (*CharstringReader).Hmoveto(state *Machine) error func (*CharstringReader).Hstem(state *Machine) func (*CharstringReader).Hvcurveto(state *Machine) func (*CharstringReader).Rcurveline(state *Machine) error func (*CharstringReader).Rlinecurve(state *Machine) error func (*CharstringReader).Rlineto(state *Machine) func (*CharstringReader).Rmoveto(state *Machine) error func (*CharstringReader).Rrcurveto(state *Machine) func (*CharstringReader).Vhcurveto(state *Machine) func (*CharstringReader).Vlineto(state *Machine) func (*CharstringReader).Vmoveto(state *Machine) error func (*CharstringReader).Vstem(state *Machine) func (*CharstringReader).Vvcurveto(state *Machine) func OperatorHandler.Apply(state *Machine, operator Operator) error
Operator is a postcript command, which may be escaped. IsEscaped bool Operator byte ( Operator) String() string Operator : expvar.Var Operator : fmt.Stringer func OperatorHandler.Apply(state *Machine, operator Operator) error
OperatorHandler defines the behaviour of an operator. Apply implements the operator defined by `operator` (which is the second byte if `escaped` is true). Returning `ErrInterrupt` stop the parsing of the instructions, without reporting an error. It can be used as an optimization. Context defines the precise behaviour of the interpreter, which has small nuances depending on the context. func (*Machine).Run(instructions []byte, localSubrs, globalSubrs [][]byte, handler OperatorHandler) error
PathBounds represents a control bounds for a glyph outline (in font units). Max Point Min Point Enlarge enlarges the bounds to include pt ToExtents converts a path bounds to the corresponding glyph extents. func github.com/go-text/typesetting/font/cff.(*CFF).LoadGlyph(glyph tables.GlyphID) ([]ot.Segment, PathBounds, error) func github.com/go-text/typesetting/font/cff.(*CFF2).LoadGlyph(glyph tables.GlyphID, coords []tables.Coord) ([]ot.Segment, PathBounds, error)
Point is a 2D Point in font units. X float64 Y float64 Move translates the Point. func (*CharstringReader).RelativeCurveTo(arg1, arg2, arg3 Point) func (*PathBounds).Enlarge(pt Point)
Package-Level Functions (total 2)
GlobalSubr pops the subroutine index and call it
LocalSubr pops the subroutine index and call it
Package-Level Variables (only one)
ErrInterrupt signals the interpreter to stop early, without erroring.
Package-Level Constants (total 4)
const PrivateDict Context = 1 // Private dict in CFF files
const TopDict Context = 0 // Top dict in CFF files
const Type1Charstring Context = 3 // Charstring in Type1 font files
const Type2Charstring Context = 2 // Charstring in CFF files