本文整理汇总了PHP中TCPDF_STATIC::_getSHORT方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::_getSHORT方法的具体用法?PHP TCPDF_STATIC::_getSHORT怎么用?PHP TCPDF_STATIC::_getSHORT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_STATIC
的用法示例。
在下文中一共展示了TCPDF_STATIC::_getSHORT方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getTrueTypeFontSubset
/**
* Returns a subset of the TrueType font data without the unused glyphs.
* @param $font (string) TrueType font data.
* @param $subsetchars (array) Array of used characters (the glyphs to keep).
* @return (string) A subset of TrueType font data without the unused glyphs.
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getTrueTypeFontSubset($font, $subsetchars) {
ksort($subsetchars);
$offset = 0; // offset position of the font data
if (TCPDF_STATIC::_getULONG($font, $offset) != 0x10000) {
// sfnt version must be 0x00010000 for TrueType version 1.0.
return $font;
}
$offset += 4;
// get number of tables
$numTables = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
// skip searchRange, entrySelector and rangeShift
$offset += 6;
// tables array
$table = array();
// for each table
for ($i = 0; $i < $numTables; ++$i) {
// get table info
$tag = substr($font, $offset, 4);
$offset += 4;
$table[$tag] = array();
$table[$tag]['checkSum'] = TCPDF_STATIC::_getULONG($font, $offset);
$offset += 4;
$table[$tag]['offset'] = TCPDF_STATIC::_getULONG($font, $offset);
$offset += 4;
$table[$tag]['length'] = TCPDF_STATIC::_getULONG($font, $offset);
$offset += 4;
}
// check magicNumber
$offset = $table['head']['offset'] + 12;
if (TCPDF_STATIC::_getULONG($font, $offset) != 0x5F0F3CF5) {
// magicNumber must be 0x5F0F3CF5
return $font;
}
$offset += 4;
// get offset mode (indexToLocFormat : 0 = short, 1 = long)
$offset = $table['head']['offset'] + 50;
$short_offset = (TCPDF_STATIC::_getSHORT($font, $offset) == 0);
$offset += 2;
// get the offsets to the locations of the glyphs in the font, relative to the beginning of the glyphData table
$indexToLoc = array();
$offset = $table['loca']['offset'];
if ($short_offset) {
// short version
$tot_num_glyphs = floor($table['loca']['length'] / 2); // numGlyphs + 1
for ($i = 0; $i < $tot_num_glyphs; ++$i) {
$indexToLoc[$i] = TCPDF_STATIC::_getUSHORT($font, $offset) * 2;
$offset += 2;
}
} else {
// long version
$tot_num_glyphs = ($table['loca']['length'] / 4); // numGlyphs + 1
for ($i = 0; $i < $tot_num_glyphs; ++$i) {
$indexToLoc[$i] = TCPDF_STATIC::_getULONG($font, $offset);
$offset += 4;
}
}
// get glyphs indexes of chars from cmap table
$subsetglyphs = array(); // glyph IDs on key
$subsetglyphs[0] = true; // character codes that do not correspond to any glyph in the font should be mapped to glyph index 0
$offset = $table['cmap']['offset'] + 2;
$numEncodingTables = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
$encodingTables = array();
for ($i = 0; $i < $numEncodingTables; ++$i) {
$encodingTables[$i]['platformID'] = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
$encodingTables[$i]['encodingID'] = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
$encodingTables[$i]['offset'] = TCPDF_STATIC::_getULONG($font, $offset);
$offset += 4;
}
foreach ($encodingTables as $enctable) {
// get all platforms and encodings
$offset = $table['cmap']['offset'] + $enctable['offset'];
$format = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2;
switch ($format) {
case 0: { // Format 0: Byte encoding table
$offset += 4; // skip length and version/language
for ($c = 0; $c < 256; ++$c) {
if (isset($subsetchars[$c])) {
$g = TCPDF_STATIC::_getBYTE($font, $offset);
$subsetglyphs[$g] = true;
}
++$offset;
}
break;
}
case 2: { // Format 2: High-byte mapping through table
$offset += 4; // skip length and version/language
//.........这里部分代码省略.........