📄 cidfont.php
字号:
}
}
/* Create the Zend_Pdf_Element_Array object and add it to the font's
* object factory and resource dictionary.
*/
$widthsArrayElement = new Zend_Pdf_Element_Array($pdfCharsWidths);
$widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
$this->_resource->W = $widthsObject;
/* CIDSystemInfo dictionary */
$cidSystemInfo = new Zend_Pdf_Element_Dictionary();
$cidSystemInfo->Registry = new Zend_Pdf_Element_String('Adobe');
$cidSystemInfo->Ordering = new Zend_Pdf_Element_String('UCS');
$cidSystemInfo->Supplement = new Zend_Pdf_Element_Numeric(0);
$cidSystemInfoObject = $this->_objectFactory->newObject($cidSystemInfo);
$this->_resource->CIDSystemInfo = $cidSystemInfoObject;
}
/**
* 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)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* 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)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
/* Convert the string to UTF-16BE encoding so we can match the string's
* character codes to those found in the cmap.
*/
if ($charEncoding != 'UTF-16BE') {
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
$charCount = iconv_strlen($string, 'UTF-16BE');
if ($charCount == 0) {
return 0;
}
/* Calculate the score by doing a lookup for each character.
*/
$score = 0;
$maxIndex = strlen($string);
for ($i = 0; $i < $maxIndex; $i++) {
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$charCode = (ord($string[$i]) << 8) | ord($string[++$i]);
/* This could probably be optimized a bit with a binary search...
*/
if (isset($this->_charWidths[$charCode])) {
$score++;
}
}
return $score / $charCount;
}
/**
* Returns the widths of the Chars.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForChar()}.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
*/
public function widthsForChars($charCodes)
{
$widths = array();
foreach ($charCodes as $key => $charCode) {
if (!isset($this->_charWidths[$charCode])) {
$widths[$key] = $this->_missingCharWidth;
} else {
$widths[$key] = $this->_charWidths[$charCode];
}
}
return $widths;
}
/**
* Returns the width of the character.
*
* Like {@link widthsForChars()} but used for one char at a time.
*
* @param integer $charCode
* @return integer
*/
public function widthForChar($charCode)
{
if (!isset($this->_charWidths[$charCode])) {
return $this->_missingCharWidth;
}
return $this->_charWidths[$charCode];
}
/**
* Returns the widths of the glyphs.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws Zend_Pdf_Exception
*/
public function widthsForGlyphs($glyphNumbers)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string to the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
* @throws Zend_Pdf_Exception
* */
public function encodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string from the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
* @throws Zend_Pdf_Exception
*/
public function decodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -