cff

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: 18 Imported by: 0

Documentation

Overview

Package cff implements CFF font data embedded into PDF files.

CFF fonts can be embedded into a PDF file either as "simple fonts" or as "composite fonts".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New added in v0.4.0

func New(info *sfnt.Font) (font.Font, error)

New turns a sfnt.Font into a PDF CFF font. The font info must be an OpenType font with CFF outlines. The font can be embedded as a simple font or as a composite font, depending on the options used in the Embed method.

Types

type FontDictComposite added in v0.4.2

type FontDictComposite struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *cff.Font

	// SubsetTag should be a unique tag for the font subset,
	// or the empty string if this is the full font.
	SubsetTag string

	CMap *cmap.Info

	UnitsPerEm uint16 // TODO(voss): get this from the font matrix instead?

	Ascent    funit.Int16
	Descent   funit.Int16
	CapHeight funit.Int16
	IsSerif   bool
	IsScript  bool

	IsAllCap   bool
	IsSmallCap bool

	// ToUnicode (optional) is a map from character codes to unicode strings.
	ToUnicode *cmap.ToUnicode
}

FontDictComposite is the information needed to embed a CFF font as a composite PDF font.

func ExtractComposite

func ExtractComposite(r pdf.Getter, dicts *font.Dicts) (*FontDictComposite, error)

ExtractComposite extracts information about a composite CFF font from a PDF file. This is the reverse of FontDictComposite.Embed.

func (*FontDictComposite) Embed added in v0.4.2

func (info *FontDictComposite) Embed(w pdf.Putter, fontDictRef pdf.Reference) error

Embed adds a composite CFF font to a PDF file. This implements the font.Dict interface. This is the reverse of ExtractComposite

type FontDictSimple added in v0.4.2

type FontDictSimple struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *cff.Font

	// SubsetTag should be a unique tag for the font subset,
	// or the empty string if this is the full font.
	SubsetTag string

	// Encoding is the encoding vector used by the client (a slice of length 256).
	// This may be different from the font's built-in encoding.
	Encoding []glyph.ID

	// TODO(voss): use PDF text space units
	Ascent    funit.Int16
	Descent   funit.Int16
	CapHeight funit.Int16

	IsSerif  bool
	IsScript bool

	IsAllCap   bool
	IsSmallCap bool

	// ToUnicode (optional) is a map from character codes to unicode strings.
	ToUnicode *cmap.ToUnicode
}

FontDictSimple is the information needed to embed a simple CFF font.

func ExtractSimple

func ExtractSimple(r pdf.Getter, dicts *font.Dicts) (*FontDictSimple, error)

ExtractSimple extracts information about a simple CFF font from a PDF file. This is the inverse of FontDictSimple.Embed.

func (*FontDictSimple) Embed added in v0.4.2

func (info *FontDictSimple) Embed(w pdf.Putter, fontDictRef pdf.Reference) error

Embed adds the font to a PDF file. This implements the font.Dict interface. This is the reverse of ExtractSimple

Jump to

Keyboard shortcuts

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