setasign\SetaPDF2\Core\Font\Cmap

Cmap Class representing a CMAP.

File: /SetaPDF v2/Core/Font/Cmap/Cmap.php
Old class name (alias): \SetaPDF_Core_Font_Cmap

This class includes a very simple parser for CID data. The extracted data are limited to unicode and cid mappings.

Class hierarchy

Implements

Summary

Static Properties

$cmapDirectory

static public Cmap::$cmapDirectory = '/app/library/SetaPDF/Core/Font/Cmap/_cmaps'

$namedInstances

static public array Cmap::$namedInstances = array()

Cache for named instances.


Properties

$_cidMap

A separate CMAP instance of only CID mappings.

$_codeSpaceRanges

protected array Cmap::$_codeSpaceRanges = array()

Code space ranges.

$_lookUps

protected array Cmap::$_lookUps = array(...)

Resolved data for an optimization of a reverse lookup.

$_mappings

protected array Cmap::$_mappings = array(...)

CID and Unicode mappings.

$_name

protected string Cmap::$_name

The name resolved from the CMAP file.


Static Methods

_ensureCMapInstance()

protected static Cmap::_ensureCMapInstance (
mixed &$cmap
): void

Helper method that ensures an instance of self.

Parameters
$cmap : mixed
 

_readValue()

protected static Cmap::_readValue (): array|string|false

Read the next value via the tokenizer instance.

Parameters
$tokenizer : \SetaPDF_Core_Tokenizer
 

cleanUpNamedInstanceCache()

public static Cmap::cleanUpNamedInstanceCache (
?string $name = null
): void

Remove named cmap instances from the local cache.

Parameters
$name : ?string

The name or null for all cached instances

create()

Create an instance based on CMAP data through an reader instance.

Parameters
$reader : \SetaPDF_Core_Reader_ReaderInterface
 
Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

createNamed()

public static Cmap::createNamed (
string $name,
bool $cache = false
): mixed|null|\SetaPDF_Core_Font_Cmap

Creates an instance of an existing CMAP.

Existing CMAPs can be found in /SetaPDF/Font/Cmap/_cmaps/. A named instance will be cached. To remove it from memory you will need to call Cmap::cleanUpNamedInstanceCache().

Parameters
$name : string
 
$cache : bool

This parameter will write a serialized version into the cmaps folder.

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception


Methods

_lookup()

protected Cmap::_lookup (
string $type,
string $src
): false|int|string

Lookup by a type.

Parameters
$type : string
 
$src : string
 

_reverseLookup()

protected Cmap::_reverseLookup (
string $dest,
string $type
): false|int|string

Do a reverse lookup by a specific type.

Parameters
$dest : string
 
$type : string
 

addCidRangeMapping()

public Cmap::addCidRangeMapping (
int $src1,
int $src2,
int $dst,
int $size
): void

Add a cid range mapping.

Parameters
$src1 : int
 
$src2 : int
 
$dst : int
 
$size : int
 

addCidSingleMapping()

public Cmap::addCidSingleMapping (
string $src,
int $dst
): void

Add a single cid mapping.

Parameters
$src : string
 
$dst : int
 

addCodeSpaceRange()

public Cmap::addCodeSpaceRange (
string $start,
string $end
): void

Add a codespace range.

Parameters
$start : string
 
$end : string
 

addRangeMapping()

public Cmap::addRangeMapping (
int $src1,
int $src2,
string $dst,
int $size
): void

Add a range mapping.

Parameters
$src1 : int
 
$src2 : int
 
$dst : string
 
$size : int
 

addSingleMapping()

public Cmap::addSingleMapping (
string $src,
string $dst
): void

Add a single mapping.

Parameters
$src : string
 
$dst : string
 

getCidMap()

Get the separate CID Map.

getName()

public Cmap::getName (
void
): string

Get the name of the CID map.

lookup()

public Cmap::lookup (
string $src
): false|int|string

Lookup a unicode value.

Parameters
$src : string
 

lookupCid()

public Cmap::lookupCid (
string $src
): false|int|string

Lookup for a CID.

Parameters
$src : string
 

reverseCidLoopkup()

public Cmap::reverseCidLoopkup (
string $dest
): false|int|string

Do a reverse CID lookup.

Parameters
$dest : string
 

reverseLookup()

public Cmap::reverseLookup (
string $dest
): false|int|string

Do a reverse lookup.

Parameters
$dest : string
 

setCidMap()

public Cmap::setCidMap (): void

Set the CID map instance.

Parameters
$cidMap : \SetaPDF_Core_Font_Cmap