afm

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: GPL-3.0 Imports: 7 Imported by: 3

Documentation

Overview

Package afm provides a parser for Adobe Font Metrics (AFM) files.

The AFM file format is documented in Adobe technical note #5004, "Adobe Font Metrics File Format Specification".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlyphInfo added in v0.4.0

type GlyphInfo struct {
	WidthX    float64
	BBox      funit.Rect16
	Ligatures map[string]string
}

type KernPair added in v0.4.0

type KernPair struct {
	Left, Right string
	Adjust      funit.Int16 // negative = move glyphs closer together
}

KernPair represents a kerning pair.

type Metrics added in v0.4.1

type Metrics struct {
	Glyphs   map[string]*GlyphInfo
	Encoding []string

	// PostScript language name (FontName or CIDFontName) of the font.
	FontName string

	// FullName is a unique, human-readable name for an individual font.
	FullName string

	CapHeight float64
	XHeight   float64
	Ascent    float64
	Descent   float64 // negative

	// UnderlinePosition is the recommended distance from the baseline for
	// positioning underlining strokes. This number is the y coordinate (in the
	// glyph coordinate system) of the center of the stroke.
	UnderlinePosition float64

	// UnderlineThickness is the recommended stroke width for underlining, in
	// units of the glyph coordinate system.
	UnderlineThickness float64

	// ItalicAngle is the angle, in degrees counterclockwise from the vertical,
	// of the dominant vertical strokes of the font.
	ItalicAngle float64

	// IsFixedPitch is a flag indicating whether the font is a fixed-pitch
	// (monospaced) font.
	IsFixedPitch bool

	Kern []*KernPair
}

Metrics contains the information from an AFM file.

func Read

func Read(fd io.Reader) (*Metrics, error)

Read reads an AFM file.

func (*Metrics) GlyphList added in v0.4.1

func (f *Metrics) GlyphList() []string

GlyphList returns a list of all glyph names in the font. The list starts with the ".notdef" glyph, followed by the glyphs in the Encoding vector, followed by the remaining glyphs in alphabetical order of their names.

Jump to

Keyboard shortcuts

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