CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
447
airtime_mvc/library/Zend/Pdf/Cmap/ByteEncoding.php
Normal file
447
airtime_mvc/library/Zend/Pdf/Cmap/ByteEncoding.php
Normal file
|
@ -0,0 +1,447 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ByteEncoding.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "byte encoding" character map (type 0).
|
||||
*
|
||||
* This is the (legacy) Apple standard encoding mechanism and provides coverage
|
||||
* for characters in the Mac Roman character set only. Consequently, this cmap
|
||||
* type should be used only as a last resort.
|
||||
*
|
||||
* The mapping from Mac Roman to Unicode can be found at
|
||||
* {@link http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT}.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_ByteEncoding extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores the actual glyph numbers. The array keys are
|
||||
* the translated Unicode code points.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
if (! isset($this->_glyphIndexArray[$characterCode])) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$characterCode];
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
if (! isset($this->_glyphIndexArray[$characterCode])) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
return $this->_glyphIndexArray[$characterCode];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
return array_keys($this->_glyphIndexArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
return $this->_glyphIndexArray;
|
||||
}
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: This table must be exactly 262 bytes long.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength != 262) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_BYTE_ENCODING) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
/* The mapping between the Mac Roman and Unicode characters is static.
|
||||
* For simplicity, just put all 256 glyph indices into one array keyed
|
||||
* off the corresponding Unicode character.
|
||||
*/
|
||||
$i = 6;
|
||||
$this->_glyphIndexArray[0x00] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x01] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x04] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x05] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x06] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x07] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x08] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x09] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x10] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x11] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x12] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x13] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x14] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x15] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x16] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x17] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x18] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x19] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x1f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x20] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x21] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x22] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x23] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x24] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x25] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x26] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x27] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x28] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x29] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x30] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x31] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x32] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x33] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x34] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x35] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x36] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x37] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x38] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x39] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x3f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x40] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x41] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x42] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x43] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x44] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x45] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x46] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x47] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x48] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x49] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x4f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x50] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x51] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x52] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x53] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x54] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x55] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x56] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x57] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x58] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x59] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x5f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x60] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x61] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x62] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x63] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x64] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x65] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x66] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x67] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x68] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x69] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x6f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x70] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x71] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x72] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x73] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x74] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x75] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x76] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x77] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x78] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x79] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x7f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xea] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xeb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xed] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xec] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xee] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xef] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfa] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2020] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2022] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xae] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2122] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2260] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x221e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2264] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2265] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2202] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2211] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x220f] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03c0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x222b] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xaa] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xba] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x03a9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xe6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xbf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xac] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x221a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0192] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2248] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2206] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xab] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xbb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2026] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xa0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc0] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd5] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0152] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0153] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2013] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2014] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201c] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201d] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2018] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2019] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x25ca] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xff] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0178] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2044] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x20ac] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2039] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x203a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb01] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xfb02] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2021] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb7] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201a] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x201e] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x2030] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xca] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc1] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xc8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcd] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xce] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xcc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd3] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd4] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xf8ff] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd2] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xda] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xdb] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xd9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x0131] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02c6] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02dc] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xaf] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02d8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02d9] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02da] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0xb8] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02dd] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02db] = ord($cmapData[$i++]);
|
||||
$this->_glyphIndexArray[0x02c7] = ord($cmapData[$i]);
|
||||
}
|
||||
|
||||
}
|
62
airtime_mvc/library/Zend/Pdf/Cmap/ByteEncoding/Static.php
Normal file
62
airtime_mvc/library/Zend/Pdf/Cmap/ByteEncoding/Static.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Static.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap_ByteEncoding */
|
||||
require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
|
||||
|
||||
|
||||
/**
|
||||
* Custom cmap type used for the Adobe Standard 14 PDF fonts.
|
||||
*
|
||||
* Just like {@link Zend_Pdf_Cmap_ByteEncoding} except that the constructor
|
||||
* takes a predefined array of glyph numbers and can cover any Unicode character.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_ByteEncoding_Static extends Zend_Pdf_Cmap_ByteEncoding
|
||||
{
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param array $cmapData Array whose keys are Unicode character codes and
|
||||
* values are glyph numbers.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
if (! is_array($cmapData)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Constructor parameter must be an array',
|
||||
Zend_Pdf_Exception::BAD_PARAMETER_TYPE);
|
||||
}
|
||||
$this->_glyphIndexArray = $cmapData;
|
||||
}
|
||||
|
||||
}
|
407
airtime_mvc/library/Zend/Pdf/Cmap/SegmentToDelta.php
Normal file
407
airtime_mvc/library/Zend/Pdf/Cmap/SegmentToDelta.php
Normal file
|
@ -0,0 +1,407 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SegmentToDelta.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "segment mapping to delta values" character map (type 4).
|
||||
*
|
||||
* This is the Microsoft standard mapping table type for OpenType fonts. It
|
||||
* provides the ability to cover multiple contiguous ranges of the Unicode
|
||||
* character set, with the exception of Unicode Surrogates (U+D800 - U+DFFF).
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_SegmentToDelta extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* The number of segments in the table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_segmentCount = 0;
|
||||
|
||||
/**
|
||||
* The size of the binary search range for segments.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchRange = 0;
|
||||
|
||||
/**
|
||||
* The number of binary search steps required to cover the entire search
|
||||
* range.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchIterations = 0;
|
||||
|
||||
/**
|
||||
* Array of ending character codes for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableEndCodes = array();
|
||||
|
||||
/**
|
||||
* The ending character code for the segment at the end of the low search
|
||||
* range.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_searchRangeEndCode = 0;
|
||||
|
||||
/**
|
||||
* Array of starting character codes for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableStartCodes = array();
|
||||
|
||||
/**
|
||||
* Array of character code to glyph delta values for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableIdDeltas = array();
|
||||
|
||||
/**
|
||||
* Array of offsets into the glyph index array for each segment.
|
||||
* @var array
|
||||
*/
|
||||
protected $_segmentTableIdRangeOffsets = array();
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores glyph numbers, used with range offset.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
/* These tables only cover the 16-bit character range.
|
||||
*/
|
||||
if ($characterCode > 0xffff) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Determine where to start the binary search. The segments are
|
||||
* ordered from lowest-to-highest. We are looking for the first
|
||||
* segment whose end code is greater than or equal to our character
|
||||
* code.
|
||||
*
|
||||
* If the end code at the top of the search range is larger, then
|
||||
* our target is probably below it.
|
||||
*
|
||||
* If it is smaller, our target is probably above it, so move the
|
||||
* search range to the end of the segment list.
|
||||
*/
|
||||
if ($this->_searchRangeEndCode >= $characterCode) {
|
||||
$searchIndex = $this->_searchRange;
|
||||
} else {
|
||||
$searchIndex = $this->_segmentCount;
|
||||
}
|
||||
|
||||
/* Now do a binary search to find the first segment whose end code
|
||||
* is greater or equal to our character code. No matter the number
|
||||
* of segments (there may be hundreds in a large font), we will only
|
||||
* need to perform $this->_searchIterations.
|
||||
*/
|
||||
for ($i = 1; $i <= $this->_searchIterations; $i++) {
|
||||
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
|
||||
$subtableIndex = $searchIndex;
|
||||
$searchIndex -= $this->_searchRange >> $i;
|
||||
} else {
|
||||
$searchIndex += $this->_searchRange >> $i;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the segment's start code is greater than our character code,
|
||||
* that character is not represented in this font. Move on.
|
||||
*/
|
||||
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
|
||||
/* This segment uses a simple mapping from character code to
|
||||
* glyph number.
|
||||
*/
|
||||
$glyphNumbers[$key] = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
|
||||
|
||||
} else {
|
||||
/* This segment relies on the glyph index array to determine the
|
||||
* glyph number. The calculation below determines the correct
|
||||
* index into that array. It's a little odd because the range
|
||||
* offset in the font file is designed to quickly provide an
|
||||
* address of the index in the raw binary data instead of the
|
||||
* index itself. Since we've parsed the data into arrays, we
|
||||
* must process it a bit differently.
|
||||
*/
|
||||
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
|
||||
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
|
||||
$subtableIndex - 1);
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
/* This code is pretty much a copy of glyphNumbersForCharacters().
|
||||
* See that method for inline documentation.
|
||||
*/
|
||||
|
||||
if ($characterCode > 0xffff) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
|
||||
if ($this->_searchRangeEndCode >= $characterCode) {
|
||||
$searchIndex = $this->_searchRange;
|
||||
} else {
|
||||
$searchIndex = $this->_segmentCount;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $this->_searchIterations; $i++) {
|
||||
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
|
||||
$subtableIndex = $searchIndex;
|
||||
$searchIndex -= $this->_searchRange >> $i;
|
||||
} else {
|
||||
$searchIndex += $this->_searchRange >> $i;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
|
||||
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
|
||||
$glyphNumber = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
|
||||
} else {
|
||||
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
|
||||
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
|
||||
$subtableIndex - 1);
|
||||
$glyphNumber = $this->_glyphIndexArray[$glyphIndex];
|
||||
}
|
||||
return $glyphNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
$characterCodes = array();
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++) {
|
||||
for ($code = $this->_segmentTableStartCodes[$i]; $code <= $this->_segmentTableEndCodes[$i]; $code++) {
|
||||
$characterCodes[] = $code;
|
||||
}
|
||||
}
|
||||
return $characterCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
|
||||
for ($segmentNum = 1; $segmentNum <= $this->_segmentCount; $segmentNum++) {
|
||||
if ($this->_segmentTableIdRangeOffsets[$segmentNum] == 0) {
|
||||
$delta = $this->_segmentTableIdDeltas[$segmentNum];
|
||||
|
||||
for ($code = $this->_segmentTableStartCodes[$segmentNum];
|
||||
$code <= $this->_segmentTableEndCodes[$segmentNum];
|
||||
$code++) {
|
||||
$glyphNumbers[$code] = ($code + $delta) % 65536;
|
||||
}
|
||||
} else {
|
||||
$code = $this->_segmentTableStartCodes[$segmentNum];
|
||||
$glyphIndex = $this->_segmentTableIdRangeOffsets[$segmentNum] - ($this->_segmentCount - $segmentNum) - 1;
|
||||
|
||||
while ($code <= $this->_segmentTableEndCodes[$segmentNum]) {
|
||||
$glyphNumbers[$code] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
$code++;
|
||||
$glyphIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: The table should be at least 23 bytes in size.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength < 23) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
/* These two values are stored premultiplied by two which is convienent
|
||||
* when using the binary data directly, but we're parsing it out to
|
||||
* native PHP data types, so divide by two.
|
||||
*/
|
||||
$this->_segmentCount = $this->_extractUInt2($cmapData, 6) >> 1;
|
||||
$this->_searchRange = $this->_extractUInt2($cmapData, 8) >> 1;
|
||||
|
||||
$this->_searchIterations = $this->_extractUInt2($cmapData, 10) + 1;
|
||||
|
||||
$offset = 14;
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableEndCodes[$i] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
$this->_searchRangeEndCode = $this->_segmentTableEndCodes[$this->_searchRange];
|
||||
|
||||
$offset += 2; // reserved bytes
|
||||
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableStartCodes[$i] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableIdDeltas[$i] = $this->_extractInt2($cmapData, $offset); // signed
|
||||
}
|
||||
|
||||
/* The range offset helps determine the index into the glyph index array.
|
||||
* Like the segment count and search range above, it's stored as a byte
|
||||
* multiple in the font, so divide by two as we extract the values.
|
||||
*/
|
||||
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
|
||||
$this->_segmentTableIdRangeOffsets[$i] = $this->_extractUInt2($cmapData, $offset) >> 1;
|
||||
}
|
||||
|
||||
/* The size of the glyph index array varies by font and depends on the
|
||||
* extent of the usage of range offsets versus deltas. Some fonts may
|
||||
* not have any entries in this array.
|
||||
*/
|
||||
for (; $offset < $length; $offset += 2) {
|
||||
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
/* Sanity check: After reading all of the data, we should be at the end
|
||||
* of the table.
|
||||
*/
|
||||
if ($offset != $length) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
|
||||
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
231
airtime_mvc/library/Zend/Pdf/Cmap/TrimmedTable.php
Normal file
231
airtime_mvc/library/Zend/Pdf/Cmap/TrimmedTable.php
Normal file
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: TrimmedTable.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_Cmap */
|
||||
require_once 'Zend/Pdf/Cmap.php';
|
||||
|
||||
|
||||
/**
|
||||
* Implements the "trimmed table mapping" character map (type 6).
|
||||
*
|
||||
* This table type is preferred over the {@link Zend_Pdf_Cmap_SegmentToDelta}
|
||||
* table when the Unicode characters covered by the font fall into a single
|
||||
* contiguous range.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Fonts
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Cmap_TrimmedTable extends Zend_Pdf_Cmap
|
||||
{
|
||||
/**** Instance Variables ****/
|
||||
|
||||
|
||||
/**
|
||||
* The starting character code covered by this table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_startCode = 0;
|
||||
|
||||
/**
|
||||
* The ending character code covered by this table.
|
||||
* @var integer
|
||||
*/
|
||||
protected $_endCode = 0;
|
||||
|
||||
/**
|
||||
* Glyph index array. Stores the actual glyph numbers.
|
||||
* @var array
|
||||
*/
|
||||
protected $_glyphIndexArray = array();
|
||||
|
||||
|
||||
|
||||
/**** Public Interface ****/
|
||||
|
||||
|
||||
/* Concrete Class Implementation */
|
||||
|
||||
/**
|
||||
* Returns an array of glyph numbers corresponding to the Unicode characters.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumberForCharacter()}.
|
||||
*
|
||||
* @param array $characterCodes Array of Unicode character codes (code points).
|
||||
* @return array Array of glyph numbers.
|
||||
*/
|
||||
public function glyphNumbersForCharacters($characterCodes)
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
foreach ($characterCodes as $key => $characterCode) {
|
||||
|
||||
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
|
||||
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
continue;
|
||||
}
|
||||
|
||||
$glyphIndex = $characterCode - $this->_startCode;
|
||||
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
|
||||
|
||||
}
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the glyph number corresponding to the Unicode character.
|
||||
*
|
||||
* If a particular character doesn't exist in this font, the special 'missing
|
||||
* character glyph' will be substituted.
|
||||
*
|
||||
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
|
||||
* operations.
|
||||
*
|
||||
* @param integer $characterCode Unicode character code (code point).
|
||||
* @return integer Glyph number.
|
||||
*/
|
||||
public function glyphNumberForCharacter($characterCode)
|
||||
{
|
||||
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
|
||||
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
|
||||
}
|
||||
$glyphIndex = $characterCode - $this->_startCode;
|
||||
return $this->_glyphIndexArray[$glyphIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the Unicode characters that have entries in
|
||||
* this character map.
|
||||
*
|
||||
* @return array Unicode character codes.
|
||||
*/
|
||||
public function getCoveredCharacters()
|
||||
{
|
||||
$characterCodes = array();
|
||||
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
|
||||
$characterCodes[] = $code;
|
||||
}
|
||||
return $characterCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing the glyphs numbers that have entries in this character map.
|
||||
* Keys are Unicode character codes (integers)
|
||||
*
|
||||
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
* @return array Array representing <Unicode character code> => <glyph number> pairs.
|
||||
*/
|
||||
public function getCoveredCharactersGlyphs()
|
||||
{
|
||||
$glyphNumbers = array();
|
||||
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
|
||||
$glyphNumbers[$code] = $this->_glyphIndexArray[$code - $this->_startCode];
|
||||
}
|
||||
|
||||
return $glyphNumbers;
|
||||
}
|
||||
|
||||
|
||||
/* Object Lifecycle */
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* Parses the raw binary table data. Throws an exception if the table is
|
||||
* malformed.
|
||||
*
|
||||
* @param string $cmapData Raw binary cmap table data.
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($cmapData)
|
||||
{
|
||||
/* Sanity check: The table should be at least 9 bytes in size.
|
||||
*/
|
||||
$actualLength = strlen($cmapData);
|
||||
if ($actualLength < 9) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Insufficient table data',
|
||||
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
|
||||
}
|
||||
|
||||
/* Sanity check: Make sure this is right data for this table type.
|
||||
*/
|
||||
$type = $this->_extractUInt2($cmapData, 0);
|
||||
if ($type != Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong cmap table type',
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
|
||||
}
|
||||
|
||||
$length = $this->_extractUInt2($cmapData, 2);
|
||||
if ($length != $actualLength) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
|
||||
}
|
||||
|
||||
/* Mapping tables should be language-independent. The font may not work
|
||||
* as expected if they are not. Unfortunately, many font files in the
|
||||
* wild incorrectly record a language ID in this field, so we can't
|
||||
* call this a failure.
|
||||
*/
|
||||
$language = $this->_extractUInt2($cmapData, 4);
|
||||
if ($language != 0) {
|
||||
// Record a warning here somehow?
|
||||
}
|
||||
|
||||
$this->_startCode = $this->_extractUInt2($cmapData, 6);
|
||||
|
||||
$entryCount = $this->_extractUInt2($cmapData, 8);
|
||||
$expectedCount = ($length - 10) >> 1;
|
||||
if ($entryCount != $expectedCount) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Entry count is wrong; expected: $expectedCount; actual: $entryCount",
|
||||
Zend_Pdf_Exception::CMAP_WRONG_ENTRY_COUNT);
|
||||
}
|
||||
|
||||
$this->_endCode = $this->_startCode + $entryCount - 1;
|
||||
|
||||
$offset = 10;
|
||||
for ($i = 0; $i < $entryCount; $i++, $offset += 2) {
|
||||
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
|
||||
}
|
||||
|
||||
/* Sanity check: After reading all of the data, we should be at the end
|
||||
* of the table.
|
||||
*/
|
||||
if ($offset != $length) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
|
||||
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue