View Source Pdf.Reader.CID.CIDToGIDMap (ExPDF v1.0.1)

Parser and lookup for the PDF /CIDToGIDMap entry in Type2 CIDFont dicts.

/CIDToGIDMap maps CIDs to GIDs (glyph indices) in the referenced CIDFont program. This module parses it and stores the result for future glyph-rendering work. It is NOT used in the Unicode resolution cascade — the cascade goes CID → Unicode directly via the registry tables.

Supported forms

  • {:name, "Identity"} — GID == CID for all characters.
  • {:stream, dict, raw_bytes} — FlateDecode-decoded binary of uint16-BE pairs.
  • {:ref, n, g} — indirect reference resolved via Pdf.Reader.ObjectResolver.

Spec references

Summary

Functions

Look up a CID in a parsed CIDToGIDMap.

Parse a /CIDToGIDMap PDF value into an internal representation.

Functions

@spec lookup(:identity | {:stream_map, binary()}, non_neg_integer()) ::
  {:ok, non_neg_integer()} | :error

Look up a CID in a parsed CIDToGIDMap.

Returns {:ok, gid} or :error.

  • :identity — GID == CID always.
  • {:stream_map, bytes} — binary offset at cid * 2, decoded as big-endian uint16.
@spec parse(any(), Pdf.Reader.Document.t()) ::
  {:ok, :identity | {:stream_map, binary()}, Pdf.Reader.Document.t()}
  | {:error, :malformed}

Parse a /CIDToGIDMap PDF value into an internal representation.

Returns:

  • {:ok, :identity, doc} for {:name, "Identity"}
  • {:ok, {:stream_map, binary}, doc} for stream values (decoded)
  • {:error, :malformed} for unrecognised values