truetype

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

Documentation

Overview

Package truetype implements TrueType fonts embedded into PDF files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractEncoding

func ExtractEncoding(r pdf.Getter, encodingDict pdf.Object, ttf *sfnt.Font) []glyph.ID

ExtractEncoding tries to extract an encoding vector from the given encoding dictionary. See section 9.6.5.4 of ISO 32000-2:2020.

TODO(voss): revisit this, once https://github.com/pdf-association/pdf-issues/issues/316 is resolved.

func New added in v0.4.0

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

New makes a PDF TrueType font from a sfnt.Font. The font info must be an OpenType/TrueType font with glyf outlines. The font can be embedded as a simple font or as a composite font.

Types

type FontDictComposite added in v0.4.2

type FontDictComposite 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

	CID2GID []glyph.ID

	ForceBold 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 TrueType font as a composite PDF font.

func ExtractComposite

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

ExtractComposite extracts information about a composite TrueType font. 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 TrueType 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 *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

	ForceBold 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 TrueType font.

func ExtractSimple

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

ExtractSimple extracts information about a simple TrueType font. 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