Documentation ¶
Overview ¶
Implements a CMap parser (both for ToUnicode and CID CMaps)
Index ¶
Constants ¶
const ( // MissingCodeRune replaces runes that can't be decoded. '\ufffd' = �. Was '?'. MissingCodeRune = '\ufffd' // � )
Variables ¶
var ErrBadCMap = errors.New("bad cmap")
CMap parser errors.
Functions ¶
func WriteAdobeIdentityUnicodeCMap ¶
WriteAdobeIdentityUnicodeCMap dumps the given mapping to a Cmap ressource, ready to be embedded in a PDF file.
Types ¶
type CIDRange ¶
type CIDRange struct { Codespace CIDStart model.CID // CID code for the first character code in range }
CIDRange is an increasing number of CIDs, associated from Low to High.
type CMap ¶
type CMap struct { Name model.ObjName UseCMap model.ObjName CIDSystemInfo model.CIDSystemInfo Codespaces []Codespace CIDs []CIDRange Type int // contains filtered or unexported fields }
CMap map character code to CIDs. It is either predefined, or embedded in PDF as a stream.
func ParseCIDCMap ¶
ParseCIDCMap parses the in-memory cmap `data` and returns the resulting CMap. See 9.7.5.3 Embedded CMap Files
func (*CMap) BytesToCharcodes ¶
BytesToCharcodes attempts to convert the entire byte array `data` to a list of character codes from the ranges specified by `cmap`'s codespaces. Returns:
character code sequence (if there is a match complete match) matched?
NOTE: A partial list of character codes will be returned if a complete match
is not possible.
func (CMap) CharCodeToCID ¶
CharCodeToCID accumulate all the CID ranges into one map
type CharCode ¶
type CharCode int32
CharCode is a compact representation of 1 to 4 bytes, as found in PDF content streams.
type Codespace ¶
type Codespace struct { NumBytes int // how many bytes should be read to match this code (between 1 and 4) Low, High CharCode // compact version of [4]byte }
Codespace represents a single codespace range used in the CMap.
type ToUnicodeArray ¶
ToUnicodeArray is a compact mapping of [From, To] to Runes
type ToUnicodePair ¶
type ToUnicodeTranslation ¶
ToUnicodeTranslation is a compact mapping of [From,To] to [Dest,Dest+To-From]. It can also represent a simple mapping by taking From = To
type UnicodeCMap ¶
type UnicodeCMap struct { UseCMap model.ObjName // base this cmap on `UseCMap` if `UseCMap` is not empty. Mappings []ToUnicode // compact representation }
UnicodeCMap maps from CID to Unicode points. Note that it differs from CID Cmap in the sense that the origin of the mapping are CID and not CharCode.
func ParseUnicodeCMap ¶
func ParseUnicodeCMap(data []byte) (UnicodeCMap, error)
ParseUnicodeCMap parses the cmap `data` and returns the resulting CMap. See 9.10.3 ToUnicode CMaps
func (UnicodeCMap) ProperLookupTable ¶
func (u UnicodeCMap) ProperLookupTable() map[model.CID][]rune
ProperLookupTable returns a convenient form of the mapping, without resolving a potential UseCMap.