opentype

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

Documentation

Overview

Package opentype implements OpenType fonts embedded into PDF files.

Use of this package should be avoided when creating new documents: If the given font contains CFF glyphs, then it is more efficient to embed the font via cff.NewSimple or cff.NewComposite instead. If the given font contains TrueType glyphs, truetype.NewSimple or truetype.NewComposite should be used instead of the function from this package.

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 makes a PDF font from an OpenType/TrueType font. The font can be embedded as a simple font or as a composite font.

If the font has CFF outlines, it is often more efficient to embed the CFF glyph data without the OpenType wrapper. Consider using seehuhn.de/go/pdf/font/cff.New instead of this function. If the font has TrueType outlines, it is often more efficient to embed the font as a TrueType font instead of an OpenType font. Consider using seehuhn.de/go/pdf/font/truetype.New instead of this function.

Types

type FontDictCFFComposite added in v0.4.2

type FontDictCFFComposite struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *sfnt.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

	IsAllCap   bool
	IsSmallCap bool

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

FontDictCFFComposite is the information needed to embed a composite OpenType/CFF font.

func ExtractCFFComposite

func ExtractCFFComposite(r pdf.Getter, dicts *font.Dicts) (*FontDictCFFComposite, error)

ExtractCFFComposite extracts information about a composite OpenType/CFF font from a PDF file. This is the inverse of FontDictCFFComposite.Embed.

func (*FontDictCFFComposite) Embed added in v0.4.2

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

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

type FontDictCFFSimple added in v0.4.2

type FontDictCFFSimple struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *sfnt.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

	IsAllCap   bool
	IsSmallCap bool

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

FontDictCFFSimple is the information needed to embed a simple OpenType/CFF font.

func ExtractCFFSimple

func ExtractCFFSimple(r pdf.Getter, dicts *font.Dicts) (*FontDictCFFSimple, error)

ExtractCFFSimple extracts information about a simple OpenType/CFF font. This is the inverse of FontDictCFFSimple.Embed.

func (*FontDictCFFSimple) Embed added in v0.4.2

func (info *FontDictCFFSimple) 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 ExtractCFFSimple

type FontDictGlyfComposite added in v0.4.2

type FontDictGlyfComposite struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *sfnt.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

	CIDToGID []glyph.ID

	ForceBold bool

	IsAllCap   bool
	IsSmallCap bool

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

FontDictGlyfComposite is the information needed to embed a composite OpenType/glyf font.

func ExtractGlyfComposite

func ExtractGlyfComposite(r pdf.Getter, dicts *font.Dicts) (*FontDictGlyfComposite, error)

ExtractGlyfComposite extracts information for a composite OpenType/glyf font.

func (*FontDictGlyfComposite) Embed added in v0.4.2

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

Embed adds the font to the PDF file.

This implements the font.Dict interface.

type FontDictGlyfSimple added in v0.4.2

type FontDictGlyfSimple struct {
	// Font is the font to embed (already subsetted, if needed).
	Font *sfnt.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

	ForceBold bool

	IsAllCap   bool
	IsSmallCap bool

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

FontDictGlyfSimple is the information needed to embed a simple OpenType/glyf font.

func ExtractGlyfSimple

func ExtractGlyfSimple(r pdf.Getter, dicts *font.Dicts) (*FontDictGlyfSimple, error)

ExtractGlyfSimple extracts information about a simple OpenType font.

func (*FontDictGlyfSimple) Embed added in v0.4.2

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

Embed adds the font to a PDF file.

This implements the font.Dict interface.

Jump to

Keyboard shortcuts

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