SetaPDF_Core_Font_Cmap Class representing a CMAP.

File: /SetaPDF v2/Core/Font/Cmap.php

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

$namedInstances

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

Cache for named instances.


Properties

$_cidMap

A separate CMAP instance of only CID mappings.

$_codeSpaceRanges

protected array SetaPDF_Core_Font_Cmap::$_codeSpaceRanges = array()

Code space ranges.

$_lookUps

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

Resolved data for an optimization of a reverse lookup.

$_mappings

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

CID and uncidoe mappings.

$_name

protected string SetaPDF_Core_Font_Cmap::$_name

The name resolved from the CMAP file.


Static Methods

_ensureCMapInstance()

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

Helper method that ensures an instance of self.

Parameters
$cmap : mixed
 

_readValue()

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

Read the next value via the tokenizer instance.

Parameters
$tokenizer : SetaPDF_Core_Tokenizer
 

cleanUpNamedInstanceCache()

public static SetaPDF_Core_Font_Cmap::cleanUpNamedInstanceCache (
[ string|null $name = null ]
): void

Remove named cmap instances from the local cache.

Parameters
$name : string|null

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 SetaPDF_Core_Font_Exception

createNamed()

public static SetaPDF_Core_Font_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 SetaPDF_Core_Font_Cmap::cleanUpNamedInstanceCache().

Parameters
$name : string
 
$cache : bool

This parameter will write a serialized version into the cmaps folder (only on PHP >= 7).

Exceptions

Throws SetaPDF_Core_Font_Exception


Methods

_lookup()

protected SetaPDF_Core_Font_Cmap::_lookup (
string $type, string $src
): false|integer|string

Lookup by a type.

Parameters
$type : string
 
$src : string
 

_reverseLookup()

protected SetaPDF_Core_Font_Cmap::_reverseLookup (
string $dest, string $type
): false|integer|string

Do a reverse lookup by a specific type.

Parameters
$dest : string
 
$type : string
 

addCidRangeMapping()

public SetaPDF_Core_Font_Cmap::addCidRangeMapping (
integer $src1, integer $src2, integer $dst, integer $size
): void

Add a cid range mapping.

Parameters
$src1 : integer
 
$src2 : integer
 
$dst : integer
 
$size : integer
 

addCidSingleMapping()

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

Add a single cid mapping.

Parameters
$src : string
 
$dst : int
 

addCodeSpaceRange()

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

Add a codespace range.

Parameters
$start : string
 
$end : string
 

addRangeMapping()

public SetaPDF_Core_Font_Cmap::addRangeMapping (
integer $src1, integer $src2, string $dst, integer $size
): void

Add a range mapping.

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

addSingleMapping()

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

Add a single mapping.

Parameters
$src : string
 
$dst : string
 

getCidMap()

Get the separate CID Map.

getName()

public SetaPDF_Core_Font_Cmap::getName (
void
): string

Get the name of the CID map.

lookup()

public SetaPDF_Core_Font_Cmap::lookup (
string $src
): false|integer|string

Lookup a unicode value.

Parameters
$src : string
 

lookupCid()

public SetaPDF_Core_Font_Cmap::lookupCid (
string $src
): false|integer|string

Lookup for a CID.

Parameters
$src : string
 

reverseCidLoopkup()

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

Do a reverse CID lookup.

Parameters
$dest : string
 

reverseLookup()

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

Do a reverse lookup.

Parameters
$dest : string
 

setCidMap()

Set the CID map instance.

Parameters
$cidMap : SetaPDF_Core_Font_Cmap