type3

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: GPL-3.0 Imports: 17 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 Font added in v0.3.5

type Font struct {
	// Glyphs is a list of glyphs in the font.
	// An empty glyph without a name must be included at index 0,
	// to replace the ".notdef" glyph.
	Glyphs []*Glyph

	// Resources (optional) holds named resources shared by all glyph content
	// streams that don't have their own resource dictionary. This is embedded
	// in the Type 3 font dictionary.
	Resources *content.Resources

	// FontMatrix transforms glyph space units to text space units.
	FontMatrix matrix.Matrix

	// PostScriptName (optional) is the PostScript name of the font.
	PostScriptName string

	// FontFamily (optional) is the name of the font family.
	FontFamily string

	// FontStretch (optional) is the font stretch value.
	FontStretch os2.Width

	// FontWeight (optional) is the font weight value.
	FontWeight os2.Weight

	IsFixedPitch bool
	IsSerif      bool
	IsScript     bool
	IsAllCap     bool
	IsSmallCap   bool

	ItalicAngle float64

	Ascent    float64 // Type 3 glyph space units
	Descent   float64 // Type 3 glyph space units
	Leading   float64 // Type 3 glyph space units
	CapHeight float64 // Type 3 glyph space units
	XHeight   float64 // Type 3 glyph space units

	UnderlinePosition  float64
	UnderlineThickness float64
}

Font represents a Type 3 font with user-defined glyph procedures.

func (*Font) New added in v0.7.0

func (f *Font) New() (font.Layouter, error)

New creates a new Type 3 font instance from a font definition.

type Glyph

type Glyph struct {
	// Name is the PostScript name of the glyph.
	Name string

	// Content is the glyph's content stream.
	// It must start with either the d0 or d1 operator.
	// Use [content/builder.Builder] to construct content streams.
	Content content.Stream

	// Resources (optional) holds named resources used by this glyph's content
	// stream. If set, the resources are embedded in the glyph's stream
	// dictionary. If nil, resources are looked up from the font's resource
	// dictionary or inherited from the page.
	Resources *content.Resources
}

Glyph represents a single glyph in a Type 3 font.

func (*Glyph) BBox added in v0.3.5

func (g *Glyph) BBox() rect.Rect

BBox returns the glyph's bounding box in glyph coordinate units. For d1 glyphs, the bounding box is taken from the operator arguments. For d0 glyphs, the bounding box is computed from path control points.

func (*Glyph) Width added in v0.6.0

func (g *Glyph) Width() float64

Width returns the glyph's advance width in glyph coordinate units. The width is extracted from the first operator (d0 or d1).

Jump to

Keyboard shortcuts

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