composer package updates
[openemr.git] / vendor / phenx / php-font-lib / src / FontLib / Glyph / Outline.php
blob330db0918761e38c74943d5e975353f3d8eb7522
1 <?php
2 /**
3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
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 FontLib\Glyph;
11 use FontLib\Table\Type\glyf;
12 use FontLib\TrueType\File;
13 use FontLib\BinaryStream;
15 /**
16 * `glyf` font table.
18 * @package php-font-lib
20 class Outline extends BinaryStream {
21 /**
22 * @var \FontLib\Table\Type\glyf
24 protected $table;
26 protected $offset;
27 protected $size;
29 // Data
30 public $numberOfContours;
31 public $xMin;
32 public $yMin;
33 public $xMax;
34 public $yMax;
36 public $raw;
38 /**
39 * @param glyf $table
40 * @param $offset
41 * @param $size
43 * @return Outline
45 static function init(glyf $table, $offset, $size, BinaryStream $font) {
46 $font->seek($offset);
48 if ($font->readInt16() > -1) {
49 /** @var OutlineSimple $glyph */
50 $glyph = new OutlineSimple($table, $offset, $size);
52 else {
53 /** @var OutlineComposite $glyph */
54 $glyph = new OutlineComposite($table, $offset, $size);
57 $glyph->parse($font);
59 return $glyph;
62 /**
63 * @return File
65 function getFont() {
66 return $this->table->getFont();
69 function __construct(glyf $table, $offset = null, $size = null) {
70 $this->table = $table;
71 $this->offset = $offset;
72 $this->size = $size;
75 function parse(BinaryStream $font) {
76 $font->seek($this->offset);
78 if (!$this->size) {
79 return;
82 $this->raw = $font->read($this->size);
85 function parseData() {
86 $font = $this->getFont();
87 $font->seek($this->offset);
89 $this->numberOfContours = $font->readInt16();
90 $this->xMin = $font->readFWord();
91 $this->yMin = $font->readFWord();
92 $this->xMax = $font->readFWord();
93 $this->yMax = $font->readFWord();
96 function encode() {
97 $font = $this->getFont();
99 return $font->write($this->raw, strlen($this->raw));
102 function getSVGContours() {
103 // Inherit
106 function getGlyphIDs() {
107 return array();