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 viaPdf.Reader.ObjectResolver.
Spec references
- PDF 1.7 (ISO 32000-1) § 9.7 — Composite Fonts: https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf
- PDF 1.7 § 9.7.4 — CIDFonts (/CIDToGIDMap key description)
- PDF 1.7 § 9.7.5 — Predefined CMaps (Identity-H/V context)
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 atcid * 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