type1

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: 17 Imported by: 1

Documentation

Overview

Package type1 implements Type 1 fonts embedded into PDF files.

Index

Constants

This section is empty.

Variables

Standard contains the standard 14 PDF fonts.

All of these fonts implement the font.Font interface.

Functions

func New

func New(psFont *type1.Font, metrics *afm.Metrics) (font.Font, error)

New creates a new Type 1 PDF font from a Type 1 PostScript font.

At least one of `psFont` and `metrics` must be non-nil. The font program is embedded, if and only if `psFont` is non-nil. If metrics is non-nil, information about kerning and ligatures is extracted, and the corresponding fields in the PDF font descriptor are filled.

Types

type Builtin

type Builtin string

Builtin is one of the 14 built-in PDF fonts.

const (
	Courier              Builtin = "Courier"
	CourierBold          Builtin = "Courier-Bold"
	CourierBoldOblique   Builtin = "Courier-BoldOblique"
	CourierOblique       Builtin = "Courier-Oblique"
	Helvetica            Builtin = "Helvetica"
	HelveticaBold        Builtin = "Helvetica-Bold"
	HelveticaBoldOblique Builtin = "Helvetica-BoldOblique"
	HelveticaOblique     Builtin = "Helvetica-Oblique"
	TimesRoman           Builtin = "Times-Roman"
	TimesBold            Builtin = "Times-Bold"
	TimesBoldItalic      Builtin = "Times-BoldItalic"
	TimesItalic          Builtin = "Times-Italic"
	Symbol               Builtin = "Symbol"
	ZapfDingbats         Builtin = "ZapfDingbats"
)

The 14 built-in PDF fonts.

All of these fonts implement the font.Font interface.

func (Builtin) AFM added in v0.4.0

func (f Builtin) AFM() (*afm.Metrics, error)

AFM returns the font metrics for this builtin font.

func (Builtin) Embed

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

Embed implements the font.Font interface.

func (Builtin) StandardWidths added in v0.4.0

func (f Builtin) StandardWidths(encoding []string) []float64

StandardWidths returns the widths of the encoded glyphs.

type FontDict added in v0.4.2

type FontDict struct {
	// Font (optional) is the (subsetted as needed) font to embed.
	// This is non-nil, if and only if the font program is embedded.
	// At least one of `Font` and `Metrics` must be non-nil.
	Font *type1.Font

	// Metrics (optional) are the font metrics for the font.
	// At least one of `Font` and `Metrics` must be non-nil.
	Metrics *afm.Metrics

	// SubsetTag should be a unique tag for the font subset,
	// or the empty string if this is the full font.
	SubsetTag string

	// Encoding (a slice of length 256) is the encoding vector used by the client.
	// When embedding a font, this is used to determine the `Encoding` entry in
	// the PDF font dictionary.
	Encoding []string

	// ResName is the resource name for the font (only used for PDF-1.0).
	ResName pdf.Name

	IsSerif  bool
	IsScript bool

	IsAllCap   bool
	IsSmallCap bool

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

FontDict is the information needed to embed a Type 1 font.

func Extract

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

Extract extracts information about a Type 1 font from a PDF file.

The `Font` field in the result is only filled if the font program is included in the file. `Metrics` is always present, and contains all information available in the PDF file.

func (*FontDict) BuiltinEncoding added in v0.4.2

func (info *FontDict) BuiltinEncoding() []string

BuiltinEncoding returns the builtin encoding vector for this font.

func (*FontDict) Embed added in v0.4.2

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

Embed implements the font.Dict interface.

func (*FontDict) GetWidths added in v0.4.2

func (info *FontDict) GetWidths() []float64

GetWidths returns the widths of the 256 encoded characters. The returned widths are given in PDF text space units.

func (*FontDict) GlyphList added in v0.4.2

func (info *FontDict) GlyphList() []string

GlyphList returns the list of glyph names, in a standardised order. Glyph IDs, where used, are indices into this list.

func (*FontDict) IsStandard added in v0.4.2

func (info *FontDict) IsStandard() bool

IsStandard returns true if the font is one of the 14 standard PDF fonts.

func (*FontDict) PostScriptName added in v0.4.2

func (info *FontDict) PostScriptName() string

PostScriptName returns the PostScript name of the font.

Jump to

Keyboard shortcuts

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