encoding

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescribeEncodingType1

func DescribeEncodingType1(encoding, builtin []string) pdf.Object

DescribeEncodingType1 returns the /Encoding entry for the font dictionary of a Type 1 font. The arguments are the encoding used by the client, and the font's builtin encoding.

See section 9.6.1 and 9.6.5 of ISO 32000-2:2020.

func UndescribeEncodingType1

func UndescribeEncodingType1(r pdf.Getter, desc pdf.Object, builtin []string) ([]string, error)

UndescribeEncodingType1 returns the encoding used by the client, given the /Encoding entry for the font dictionary of a Type 1 font and the font's builtin encoding.

This function is nearly the inverse of DescribeEncodingType1: if the name assigned to a code is not `.notdef`, then DescribeEncodingType1 followed by UndescribeEncodingType1 will return the same name.

Types

type SimpleEncoder

type SimpleEncoder struct {
	Encoding []glyph.ID
	// contains filtered or unexported fields
}

SimpleEncoder constructs and stores mappings from one-byte character codes to GID values and from one-byte character codes to unicode strings.

func NewSimpleEncoder

func NewSimpleEncoder() *SimpleEncoder

NewSimpleEncoder allocates a new SimpleEncoder.

func (*SimpleEncoder) CodeIsUsed added in v0.4.0

func (e *SimpleEncoder) CodeIsUsed(code byte) bool

CodeIsUsed returns true if the given code has already been allocated. This can be used to distinguish between codes which have explicitly been mapped to GID 0 and codes which are not used.

func (*SimpleEncoder) GIDToCode added in v0.4.0

func (e *SimpleEncoder) GIDToCode(gid glyph.ID, rr []rune) byte

GIDToCode returns the character code for the given glyph ID (allocating new codes as needed). It also records the fact that the character code corresponds to the given unicode string.

func (*SimpleEncoder) Overflow

func (e *SimpleEncoder) Overflow() bool

Overflow returns true if the encoder has run out of codes.

func (*SimpleEncoder) Subset

func (e *SimpleEncoder) Subset() []glyph.ID

Subset returns the subset of glyph IDs which are used by this encoder. The result is sorted and always include the glyph ID 0.

func (*SimpleEncoder) ToUnicode

func (e *SimpleEncoder) ToUnicode() map[charcode.CharCode][]rune

ToUnicode returns the mapping from character codes to unicode strings. This can be used to construct a PDF ToUnicode CMap.

func (*SimpleEncoder) ToUnicodeNew added in v0.4.0

func (e *SimpleEncoder) ToUnicodeNew() map[string][]rune

ToUnicodeNew returns the mapping from character codes to unicode strings. This can be used to construct a PDF ToUnicode CMap.

func (*SimpleEncoder) WritingMode added in v0.4.0

func (e *SimpleEncoder) WritingMode() int

WritingMode implements the [font.NewFont] interface.

Jump to

Keyboard shortcuts

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