cff

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cff allows to embed CFF fonts into a PDF file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewComposite

func NewComposite(info *sfnt.Font, opt *font.Options) (font.Font, error)

NewComposite allocates a new CFF font for embedding into a PDF file as a composite font. The font `info` is allowed but not required to be CID-keyed.

func NewSimple

func NewSimple(info *sfnt.Font, opt *font.Options) (font.Font, error)

NewSimple allocates a new CFF font for embedding in a PDF file as a simple font. Info must be an OpenType font with CFF outlines. If info is CID-keyed, the function will attempt to convert it to a simple font. If the conversion fails (because more than one private dictionary is used after subsetting), an error is returned.

Types

type EmbedInfoComposite

type EmbedInfoComposite 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
}

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

func ExtractComposite

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

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

func (*EmbedInfoComposite) Embed

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

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

type EmbedInfoSimple

type EmbedInfoSimple 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).
	// Together with the font's built-in encoding, this is used to determine
	// the `Encoding` entry of the PDF font dictionary.
	Encoding []glyph.ID

	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
}

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

func ExtractSimple

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

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

func (*EmbedInfoSimple) Embed

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

Embed adds the font to a PDF file.

type FontComposite

type FontComposite struct {
	*font.Geometry
	// contains filtered or unexported fields
}

FontComposite is a CFF font for embedding into a PDF file as a composite font.

func (*FontComposite) Embed

func (f *FontComposite) Embed(w pdf.Putter, resName pdf.Name) (font.Embedded, error)

Embed implements the font.Font interface.

func (*FontComposite) Layout

func (f *FontComposite) Layout(s string, ptSize float64) glyph.Seq

Layout implements the font.Font interface.

Jump to

Keyboard shortcuts

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