loader

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FontLoader

type FontLoader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A FontLoader can load fonts, in case fonts are not embedded in the PDF file. Every FontLoader contains the 14 standard fonts required by the PDF specification. Other external fonts can be added using AddFontMap and AddFont.

It is safe to use a FontLoader concurrently from multiple goroutines.

func NewFontLoader

func NewFontLoader() *FontLoader

NewFontLoader creates a new font loader. The loader is initialized with the 14 standard fonts required by the PDF specification.

func (*FontLoader) AddFont

func (l *FontLoader) AddFont(postscriptName string, tp FontType, fname string)

AddFont adds a font to the loader. Any previous mapping for the same PostScript name and font type is overwritten.

func (*FontLoader) AddFontMap

func (l *FontLoader) AddFontMap(r io.Reader) error

AddFontMap reads a font map from r and adds it to the loader. A font map consists of lines of the form

<name> <type> <path>

where <name> is the PostScript name of the font, <type> is either "type1", "afm" or "sfnt", and <path> is the path to the font file. The fields must be separated by single spaces. Lines starting with '#' or '%' are ignored.

Any previous mapping for (<name>, <type>) is overwritten.

func (*FontLoader) Open

func (l *FontLoader) Open(postscriptName string, tp FontType) (io.ReadCloser, error)

Open opens the font with the given PostScript name. The returned io.ReadCloser must be closed by the caller.

type FontType

type FontType int

FontType is the type of a font.

const (
	FontTypeType1 FontType = iota + 1
	FontTypeAFM
	FontTypeSfnt
)

Supported font types.

Jump to

Keyboard shortcuts

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