Help us shape the future of Go! Take the 2026 Go Developer Survey

font

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 20 Imported by: 41

Documentation

Overview

Package font creates and manages PDF font dictionaries and resources.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrCorruptFontDict signals a malformed font dictionary.
	ErrCorruptFontDict = errors.New("corrupt fontDict")
)

Functions

func CIDFontDescriptor

func CIDFontDescriptor(c context.Context, xRefTable *model.XRefTable, ttf font.TTFLight, fontName, baseFontName, fontLang string, embed bool) (*types.IndirectRef, error)

CIDFontDescriptor returns a CIDFont descriptor and supports cancellation.

func CIDFontDict

func CIDFontDict(c context.Context, xRefTable *model.XRefTable, ttf font.TTFLight, fontName, baseFontName, lang string, parms *cjk) (*types.IndirectRef, error)

CIDFontDict returns the descendant font dictionary for a Type0 font and supports cancellation.

func CIDFontFile

func CIDFontFile(c context.Context, xRefTable *model.XRefTable, fontName string, subFont bool) (*types.IndirectRef, error)

CIDFontFile returns a TrueType font file or subfont file for fontName and supports cancellation.

func CIDSet

func CIDSet(xRefTable *model.XRefTable, ttf font.TTFLight, fontName string, indRef *types.IndirectRef) (*types.IndirectRef, error)

CIDSet computes a CIDSet for used glyphs and updates or returns a new object.

func CIDWidths

func CIDWidths(xRefTable *model.XRefTable, ttf font.TTFLight, fontName string, subFont bool, indRef *types.IndirectRef) (*types.IndirectRef, error)

CIDWidths returns the value for W in a CIDFontDict.

func CJK

func CJK(script, lang string) bool

CJK returns true if script and lang imply a CJK font.

func CJKEncoding

func CJKEncoding(s string) bool

CJKEncoding returns true for supported encodings.

func CoreFontDict added in v0.12.0

func CoreFontDict(xRefTable *model.XRefTable, coreFontName string) (*types.IndirectRef, error)

CoreFontDict returns an indirect reference to a Type 1 font.

func Embedded added in v0.10.0

func Embedded(xRefTable *model.XRefTable, fontDict types.Dict, objNr int) (bool, error)

Embedded returns true if the font represented by fontDict is embedded.

func EnsureCoreFontMetrics added in v0.16.2

func EnsureCoreFontMetrics(xRefTable *model.XRefTable, d types.Dict) (*types.IndirectRef, error)

EnsureCoreFontMetrics completes omitted standard-font metrics for PDF 2.0 and returns any new descriptor reference. Complete metrics are preserved; partial metrics and unsupported encodings return an error.

func EnsureFontDict

func EnsureFontDict(c context.Context, xRefTable *model.XRefTable, fontName, lang, script string, field bool, indRef *types.IndirectRef) (*types.IndirectRef, error)

EnsureFontDict ensures a font dictionary for fontName and supports cancellation.

func FontDescriptor

func FontDescriptor(xRefTable *model.XRefTable, fontDict types.Dict, objNr int) (types.Dict, error)

FontDescriptor gets the font descriptor for this font.

func FontResources

func FontResources(c context.Context, xRefTable *model.XRefTable, fm model.FontMap) (types.Dict, error)

FontResources returns a font resource dictionary for a font map and supports cancellation.

func IndRefsForUserfontUpdate

func IndRefsForUserfontUpdate(xRefTable *model.XRefTable, d types.Dict, lang string, font *model.FontResource) error

IndRefsForUserfontUpdate detects used indirect references for a possible user font update.

func Lang

func Lang(xRefTable *model.XRefTable, fontDict types.Dict) (string, error)

Lang detects the optional language indicator in a font dict.

func Name

func Name(xRefTable *model.XRefTable, fontDict types.Dict, objNumber int) (prefix, fontName string, err error)

Name evaluates the font name for a given font dict.

func NewFontDescriptor added in v0.10.0

func NewFontDescriptor(c context.Context, xRefTable *model.XRefTable, ttf font.TTFLight, fontName, fontLang string) (*types.IndirectRef, error)

NewFontDescriptor returns a TrueType font descriptor and supports cancellation.

func PDFDocEncoding added in v0.7.0

func PDFDocEncoding(xRefTable *model.XRefTable) (*types.IndirectRef, error)

PDFDocEncoding returns an indirect reference to a new PDF doc encoding dict.

func RTL

func RTL(lang string) bool

RTL returns true if lang implies a right-to-left script.

func ScriptForEncoding added in v0.11.0

func ScriptForEncoding(enc string) string

ScriptForEncoding returns the script for encoding.

func SupportedScript added in v0.7.0

func SupportedScript(s string) bool

SupportedScript returns true if s is a supported script.

func UpdateUserfont

func UpdateUserfont(c context.Context, xRefTable *model.XRefTable, fontName string, f model.FontResource) error

UpdateUserfont updates the fontdict for fontName and supports cancellation.

func UpdateUserfonts added in v0.12.0

func UpdateUserfonts(c context.Context, xRefTable *model.XRefTable, fonts map[string]types.IndirectRef) error

UpdateUserfonts updates referenced fonts and supports cancellation.

func Widths

func Widths(xRefTable *model.XRefTable, ttf font.TTFLight, first, last int) (*types.IndirectRef, error)

Widths returns the WinAnsiEncoding widths for a TrueType FontDict.

Types

This section is empty.

Jump to

Keyboard shortcuts

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