type3

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package type3 implements Type 3 fonts embedded into PDF files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbedInfo added in v0.3.5

type EmbedInfo struct {
	Glyphs map[string]*Glyph

	FontMatrix [6]float64

	// Encoding (a slice of length 256) is the encoding vector used by the client.
	// This is used to construct the `Encoding` entry of the PDF font dictionary.
	Encoding []string

	// ResName is the resource name for the font.
	// This is only used for PDF version 1.0.
	ResName pdf.Name

	// Resources is the resource dictionary for the font.
	Resources *pdf.Resources

	ItalicAngle float64

	IsFixedPitch bool
	IsSerif      bool
	IsScript     bool
	ForceBold    bool

	IsAllCap   bool
	IsSmallCap bool

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

EmbedInfo contains the information needed to embed a type 3 font into a PDF document.

func Extract added in v0.3.5

func Extract(r pdf.Getter, dicts *font.Dicts) (*EmbedInfo, error)

Extract extracts information about a type 3 font from a PDF file.

func (*EmbedInfo) Embed added in v0.3.5

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

Embed implements the font.Font interface.

type Font added in v0.3.5

type Font struct {
	Glyphs     map[string]*Glyph
	FontMatrix [6]float64

	Ascent       funit.Int16
	Descent      funit.Int16
	BaseLineSkip funit.Int16

	ItalicAngle  float64
	IsFixedPitch bool
	IsSerif      bool
	IsScript     bool
	IsAllCap     bool
	IsSmallCap   bool
	ForceBold    bool

	Resources *pdf.Resources

	NumOpen int // -1 if the font is embedded, otherwise the number of glyphs not yet closed
}

Font is a PDF Type 3 font.

func New

func New(unitsPerEm uint16) *Font

New creates a new type 3 font. Initally the font does not contain any glyphs. Use Font.AddGlyph to add glyphs to the font. Once the font is embedded the first time, no more glyphs can be added.

func (*Font) AddGlyph added in v0.3.5

func (f *Font) AddGlyph(name string, widthX funit.Int16, bbox funit.Rect16, shapeOnly bool) (*GlyphBuilder, error)

AddGlyph adds a new glyph to the type 3 font.

If shapeOnly is true, a call to the "d1" operator is added at the start of the glyph description. In this case, the glyph description may only specify the shape of the glyph, but not its color. Otherwise, a call to the "d0" operator is added at the start of the glyph description. In this case, the glyph description may specify both the shape and the color of the glyph.

func (*Font) Embed added in v0.3.5

func (f *Font) Embed(w pdf.Putter, opt *font.Options) (font.Layouter, error)

Embed implements the font.Font interface.

type Glyph

type Glyph struct {
	WidthX funit.Int16
	BBox   funit.Rect16
	Data   []byte
}

Glyph is a glyph in a type 3 font.

type GlyphBuilder added in v0.3.5

type GlyphBuilder struct {
	*graphics.Writer
	// contains filtered or unexported fields
}

GlyphBuilder is used to write a glyph description as described in section 9.6.5 of PDF 32000-1:2008. The .Close() method must be called after the description has been written.

func (*GlyphBuilder) Close added in v0.3.5

func (g *GlyphBuilder) Close() error

Close most be called after the glyph description has been written.

Jump to

Keyboard shortcuts

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