Unicode CMap Resources
Text handling, Fonts, Unicode
Description
Unicode extraction and exact replacement resolve UseCMap through the bundled Adobe ToUnicode resources, honour dictionary-over-body precedence and child overrides, and snapshot every inherited stream so a commit stays bound to the CMap sources it planned against. Use it when a missing or inherited Unicode base must be resolved without substituting an Identity encoding.
Verified inheritance
Unicode extraction and exact content replacement resolve a ToUnicode stream dictionary's UseCMap entry when it references another ToUnicode stream or a supported predefined name
A dictionary base takes precedence over a body-level usecmap name. Without a dictionary base, a named body reference is resolved from the bundled ToUnicode resources
Child mappings override the same source codes in the base, while other base mappings remain available. A child without local codespace declarations inherits the verified base codespaces; all effective source codes must satisfy the declared byte bounds
Code lengths, Unicode sequences, ligatures, supplementary characters, and local overrides are preserved without changing the shared base stream. Unknown base names, cycles, excessive depth, malformed source ranges, invalid UTF-16, and conflicting local mappings cannot authorise exact editing
Bundled names
Adobe-CNS1-UCS2Adobe-GB1-UCS2Adobe-Japan1-UCS2Adobe-Korea1-UCS2Adobe-KR-UCS2
These are ToUnicode mapping resources. Encoding CMaps such as Identity-H and Identity-V do not imply Unicode identity and are not substituted for a missing Unicode base
The resources are compiled into the library; conversion does not download maps or open profile or mapping paths. Data is pinned to Adobe's published ToUnicode resources, with source sizes and SHA-256 values retained in Lib/resources/ToUnicode/manifest.json
Exact-editing source checks
Before building a transaction's Unicode map, exact replacement captures the font's ToUnicode reference, every inherited stream and UseCMap reference, resolved indirect targets and reference numbers, stream dictionary identities, and complete decoded CMap bytes
The transaction checks these snapshots after map construction and again before committing selected page or Form changes. A changed stream, name, array, reference, or dictionary rejects the transaction, including replacement by an object with identical contents
For simple fonts without ToUnicode, snapshots retain the absent ToUnicode entry and the mapping's font subtype and base font, base encoding, Differences array items and glyph names, and relevant symbolic-font flags
Unicode source snapshots share the existing 512 MiB transaction source budget. Captures allow up to 65536 source records, 32768 items per encoding array, 32 indirect-reference hops, and the parser's configured decoded CMap and token byte limits
These checks verify Unicode mapping sources. Embedded TrueType and CFF1 glyph selection and additional vertical exact editing are described in Composite Font Glyph Sources; external-font glyph qualification remains a separate boundary
Limits and editing boundaries
The default verified parser allows 32 inheritance levels, 4 MiB of decoded CMap data, 65536 expanded mapping entries, 2 Mi UTF-16 target units, and 256 declared codespace ranges across the complete chain. Expansion budgets include entries that are later overridden or deduplicated
Each individual target is limited to 4096 UTF-16 units, and each token to 65536 bytes. Lower limits supplied through TPDFlibUnicodeFontMapLimits apply across inherited streams and bundled names as well
Different character codes may map to the same Unicode sequence. Exact replacement continues to reject an ambiguous reverse encoding, unsupported font advances, or a source location that cannot be verified
Use GetPageText with a Unicode extraction mode, such as mode 4, to inspect inherited Unicode mappings. Legacy extraction modes retain their established behaviour
Attribution
Bundled mapping files contain Adobe copyright notices for 1990-2019, 1990-2020, and 1990-2023; the original notices are retained with the source files and embedded data
Copyright 1990-2019 Adobe. All rights reserved
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution
Neither the name of Adobe nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
See also
GetPageText, ExtractPageTextBlocks, SearchAndReplaceTextInContentEx