Parse(ReadOnlySpan, CMapContext?) Method

Definition

Namespace Broadside.Fonts
Assembly Broadside.dll

Parses a CMap file, such as the data of an embedded CMap stream.

public static CMap Parse(ReadOnlySpan<byte> data, CMapContext? context = null)

Parameters

data
ReadOnlySpan<Byte>

The CMap file, decoded.

context
CMapContext

Limits, reading mode and the diagnostics sink; null for a lenient stand-alone parse.

Returns

CMap
The CMap. Damage never fails the parse in lenient mode: what can be read is kept and each repair recorded.

Remarks

Adobe TN 5014 §7 (lexical elements, operators, file order) and ISO 32000-2 §9.7.5.4: begincodespacerange, begincidrange, begincidchar, beginnotdefrange, beginnotdefchar, usecmap, CMapName, WMode and CIDSystemInfo. beginbfchar and beginbfrange are not allowed in a CMap used as an encoding (§9.7.5.4 c): their destinations are read as CIDs, as viewers do, with a diagnostic. The block counts are not trusted: each block runs to its end operator. Operators glued to what follows them (endcidchar1) are split.

A usecmap standing alone can only resolve Identity-H or Identity-V; another name of Table 116 is recorded as unavailable and only its codespace is used, and any other name is recorded and the CMap read without a parent. Inside a document, predefined CMaps come from the engine's font resolvers (the Broadside.Fonts.Cmaps package), and the stream's UseCMap entry may name another embedded CMap stream.