cmap

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllPredefined = []string{}/* 181 elements not displayed */

Functions

func ExtractRaw added in v0.3.5

func ExtractRaw(r pdf.Getter, ref pdf.Object) (postscript.Dict, error)

ExtractRaw extract the raw PostScript data of a CMap from a PDF file.

func IsPredefined added in v0.3.5

func IsPredefined(cmap *Info) bool

func OpenPredefined added in v0.3.5

func OpenPredefined(name string) (io.ReadCloser, error)

func ReadRaw added in v0.3.5

func ReadRaw(r io.Reader) (postscript.Dict, error)

ReadRaw reads the raw PostScript data of a CMap from an io.Reader.

Types

type CIDEncoder

type CIDEncoder interface {
	// AppendEncoded appends the character code for the given glyph ID
	// to the given PDF string (allocating new codes as needed).
	// It also records the fact that the character code corresponds to the
	// given unicode string.
	AppendEncoded(pdf.String, glyph.ID, []rune) pdf.String

	// CMap returns the mapping from character codes to CID values.
	// This can be used to construct a PDF CMap.
	CMap() map[charcode.CharCode]type1.CID

	// ToUnicode returns the mapping from character codes to unicode strings.
	// This can be used to construct a PDF ToUnicode CMap.
	ToUnicode() map[charcode.CharCode][]rune

	// CodeSpaceRange returns the range of character codes
	// used by this encoder.
	CodeSpaceRange() charcode.CodeSpaceRange

	// UsedGIDs is the set of all GIDs which have been used with AppendEncoded.
	// The returned slice is sorted and always starts with GID 0.
	UsedGIDs() []glyph.ID
}

CIDEncoder constructs and stores mappings from character codes to CID values and from character codes to unicode strings.

func NewIdentityEncoder added in v0.3.5

func NewIdentityEncoder(g2c GIDToCID) CIDEncoder

NewIdentityEncoder returns an encoder where two-byte codes are used directly as CID values.

func NewUTF8Encoder added in v0.3.5

func NewUTF8Encoder(g2c GIDToCID) CIDEncoder

NewUTF8Encoder returns an encoder where character codes equal the UTF-8 encoding of the text content, where possible.

type GIDToCID added in v0.3.5

type GIDToCID interface {
	CID(glyph.ID) type1.CID

	ROS() *type1.CIDSystemInfo

	GIDToCID(numGlyph int) []type1.CID
}

GIDToCID encodes a mapping from Glyph Identifier (GID) values to Character Identifier (CID) values.

func NewIdentityGIDToCID added in v0.3.5

func NewIdentityGIDToCID() GIDToCID

func NewSequentialGIDToCID added in v0.3.5

func NewSequentialGIDToCID() GIDToCID

NewSequentialGIDToCID returns a GIDToCID which assigns CID values sequentially, starting with 1.

type Info added in v0.3.3

type Info struct {
	Name     string
	Version  float64
	ROS      *type1.CIDSystemInfo
	CS       charcode.CodeSpaceRange
	CSFile   charcode.CodeSpaceRange
	WMode    int
	UseCMap  string
	Singles  []Single
	Ranges   []Range
	Comments bool
}

func Extract added in v0.3.5

func Extract(r pdf.Getter, obj pdf.Object) (*Info, error)

func New added in v0.3.5

func Read added in v0.3.5

func Read(r io.Reader, other map[string]*Info) (*Info, error)

func (*Info) Embed added in v0.3.5

func (info *Info) Embed(w pdf.Putter, ref pdf.Reference, other map[string]pdf.Reference) error

func (*Info) GetMapping added in v0.3.5

func (info *Info) GetMapping() map[charcode.CharCode]type1.CID

func (*Info) IsIdentity added in v0.3.5

func (info *Info) IsIdentity() bool

IsIdentity returns true if all codes are equal to the corresponding CID.

func (*Info) MaxCID added in v0.3.5

func (info *Info) MaxCID() type1.CID

func (*Info) SetMapping added in v0.3.5

func (info *Info) SetMapping(m map[charcode.CharCode]type1.CID)

SetMapping overwrites the mapping information in info with the given mapping.

To make efficient use of range entries, the generated mapping may be a superset of the original mapping, i.e. it may contain entries for charcodes which were not mapped in the original mapping.

func (*Info) Write added in v0.3.5

func (info *Info) Write(w io.Writer) error

type Range added in v0.3.5

type Range struct {
	First charcode.CharCode
	Last  charcode.CharCode
	Value type1.CID
}

Range describes a range of character codes with consecutive CIDs. First and Last are the first and last code points in the range. Value is the CID of the first code point in the range.

type SimpleEncoder

type SimpleEncoder struct {
	// 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) AppendEncoded added in v0.3.5

func (e *SimpleEncoder) AppendEncoded(s pdf.String, gid glyph.ID, rr []rune) pdf.String

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

func (*SimpleEncoder) Encoding

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

Encoding returns the glyph ID corresponding to each character code.

func (*SimpleEncoder) Overflow

func (e *SimpleEncoder) Overflow() bool

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

func (*SimpleEncoder) ToUnicode added in v0.3.5

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.

type Single added in v0.3.5

type Single struct {
	Code  charcode.CharCode
	Value type1.CID
}

Single specifies that character code Code represents the given CID.

Jump to

Keyboard shortcuts

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