| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package php-font-lib |
| 5 |
* @link https://github.com/dompdf/php-font-lib |
| 6 |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
| 7 |
* @version $Id: Font_Table_glyf.php 46 2012-04-02 20:22:38Z fabien.menager $ |
| 8 |
*/ |
| 9 |
namespace WCPOS\Vendor\FontLib\Glyph; |
| 10 |
|
| 11 |
use WCPOS\Vendor\FontLib\Table\Type\glyf; |
| 12 |
use WCPOS\Vendor\FontLib\TrueType\File; |
| 13 |
use WCPOS\Vendor\FontLib\BinaryStream; |
| 14 |
/** |
| 15 |
* `glyf` font table. |
| 16 |
* |
| 17 |
* @package php-font-lib |
| 18 |
*/ |
| 19 |
class Outline extends BinaryStream |
| 20 |
{ |
| 21 |
/** |
| 22 |
* @var \FontLib\Table\Type\glyf |
| 23 |
*/ |
| 24 |
protected $table; |
| 25 |
protected $offset; |
| 26 |
protected $size; |
| 27 |
// Data |
| 28 |
public $numberOfContours; |
| 29 |
public $xMin; |
| 30 |
public $yMin; |
| 31 |
public $xMax; |
| 32 |
public $yMax; |
| 33 |
/** |
| 34 |
* @var string|null |
| 35 |
*/ |
| 36 |
public $raw; |
| 37 |
/** |
| 38 |
* @param glyf $table |
| 39 |
* @param $offset |
| 40 |
* @param $size |
| 41 |
* |
| 42 |
* @return Outline |
| 43 |
*/ |
| 44 |
static function init(glyf $table, $offset, $size, BinaryStream $font) |
| 45 |
{ |
| 46 |
$font->seek($offset); |
| 47 |
if ($size === 0 || $font->readInt16() > -1) { |
| 48 |
/** @var OutlineSimple $glyph */ |
| 49 |
$glyph = new OutlineSimple($table, $offset, $size); |
| 50 |
} else { |
| 51 |
/** @var OutlineComposite $glyph */ |
| 52 |
$glyph = new OutlineComposite($table, $offset, $size); |
| 53 |
} |
| 54 |
$glyph->parse($font); |
| 55 |
return $glyph; |
| 56 |
} |
| 57 |
/** |
| 58 |
* @return File |
| 59 |
*/ |
| 60 |
function getFont() |
| 61 |
{ |
| 62 |
return $this->table->getFont(); |
| 63 |
} |
| 64 |
function __construct(glyf $table, $offset = null, $size = null) |
| 65 |
{ |
| 66 |
$this->table = $table; |
| 67 |
$this->offset = $offset; |
| 68 |
$this->size = $size; |
| 69 |
} |
| 70 |
function parse(BinaryStream $font) |
| 71 |
{ |
| 72 |
$font->seek($this->offset); |
| 73 |
$this->raw = $font->read($this->size); |
| 74 |
} |
| 75 |
function parseData() |
| 76 |
{ |
| 77 |
$font = $this->getFont(); |
| 78 |
$font->seek($this->offset); |
| 79 |
$this->numberOfContours = $font->readInt16(); |
| 80 |
$this->xMin = $font->readFWord(); |
| 81 |
$this->yMin = $font->readFWord(); |
| 82 |
$this->xMax = $font->readFWord(); |
| 83 |
$this->yMax = $font->readFWord(); |
| 84 |
} |
| 85 |
function encode() |
| 86 |
{ |
| 87 |
$font = $this->getFont(); |
| 88 |
return $font->write($this->raw, \mb_strlen((string) $this->raw, '8bit')); |
| 89 |
} |
| 90 |
function getSVGContours() |
| 91 |
{ |
| 92 |
// Inherit |
| 93 |
} |
| 94 |
function getGlyphIDs() |
| 95 |
{ |
| 96 |
return array(); |
| 97 |
} |
| 98 |
} |
| 99 |
|