PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.18
Independent Analytics – WordPress Analytics Plugin v1.18
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / phenx / php-font-lib / src / FontLib / Glyph / OutlineComposite.php
independent-analytics / vendor / phenx / php-font-lib / src / FontLib / Glyph Last commit date
Outline.php 3 years ago OutlineComponent.php 3 years ago OutlineComposite.php 3 years ago OutlineSimple.php 3 years ago
OutlineComposite.php
196 lines
1 <?php
2
3 /**
4 * @package php-font-lib
5 * @link https://github.com/PhenX/php-font-lib
6 * @author Fabien Ménager <fabien.menager@gmail.com>
7 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
8 * @version $Id: Font_Table_glyf.php 46 2012-04-02 20:22:38Z fabien.menager $
9 */
10 namespace IAWP\FontLib\Glyph;
11
12 /**
13 * Composite glyph outline
14 *
15 * @package php-font-lib
16 */
17 class OutlineComposite extends Outline
18 {
19 const ARG_1_AND_2_ARE_WORDS = 0x1;
20 const ARGS_ARE_XY_VALUES = 0x2;
21 const ROUND_XY_TO_GRID = 0x4;
22 const WE_HAVE_A_SCALE = 0x8;
23 const MORE_COMPONENTS = 0x20;
24 const WE_HAVE_AN_X_AND_Y_SCALE = 0x40;
25 const WE_HAVE_A_TWO_BY_TWO = 0x80;
26 const WE_HAVE_INSTRUCTIONS = 0x100;
27 const USE_MY_METRICS = 0x200;
28 const OVERLAP_COMPOUND = 0x400;
29 /**
30 * @var OutlineComponent[]
31 */
32 public $components = array();
33 function getGlyphIDs()
34 {
35 if (empty($this->components)) {
36 $this->parseData();
37 }
38 $glyphIDs = array();
39 foreach ($this->components as $_component) {
40 $glyphIDs[] = $_component->glyphIndex;
41 $_glyph = $this->table->data[$_component->glyphIndex];
42 if ($_glyph !== $this) {
43 $glyphIDs = \array_merge($glyphIDs, $_glyph->getGlyphIDs());
44 }
45 }
46 return $glyphIDs;
47 }
48 /*function parse() {
49 //$this->parseData();
50 }*/
51 function parseData()
52 {
53 parent::parseData();
54 $font = $this->getFont();
55 do {
56 $flags = $font->readUInt16();
57 $glyphIndex = $font->readUInt16();
58 $a = 1.0;
59 $b = 0.0;
60 $c = 0.0;
61 $d = 1.0;
62 $e = 0.0;
63 $f = 0.0;
64 $point_compound = null;
65 $point_component = null;
66 $instructions = null;
67 if ($flags & self::ARG_1_AND_2_ARE_WORDS) {
68 if ($flags & self::ARGS_ARE_XY_VALUES) {
69 $e = $font->readInt16();
70 $f = $font->readInt16();
71 } else {
72 $point_compound = $font->readUInt16();
73 $point_component = $font->readUInt16();
74 }
75 } else {
76 if ($flags & self::ARGS_ARE_XY_VALUES) {
77 $e = $font->readInt8();
78 $f = $font->readInt8();
79 } else {
80 $point_compound = $font->readUInt8();
81 $point_component = $font->readUInt8();
82 }
83 }
84 if ($flags & self::WE_HAVE_A_SCALE) {
85 $a = $d = $font->readInt16();
86 } elseif ($flags & self::WE_HAVE_AN_X_AND_Y_SCALE) {
87 $a = $font->readInt16();
88 $d = $font->readInt16();
89 } elseif ($flags & self::WE_HAVE_A_TWO_BY_TWO) {
90 $a = $font->readInt16();
91 $b = $font->readInt16();
92 $c = $font->readInt16();
93 $d = $font->readInt16();
94 }
95 //if ($flags & self::WE_HAVE_INSTRUCTIONS) {
96 //
97 //}
98 $component = new OutlineComponent();
99 $component->flags = $flags;
100 $component->glyphIndex = $glyphIndex;
101 $component->a = $a;
102 $component->b = $b;
103 $component->c = $c;
104 $component->d = $d;
105 $component->e = $e;
106 $component->f = $f;
107 $component->point_compound = $point_compound;
108 $component->point_component = $point_component;
109 $component->instructions = $instructions;
110 $this->components[] = $component;
111 } while ($flags & self::MORE_COMPONENTS);
112 }
113 function encode()
114 {
115 $font = $this->getFont();
116 $gids = $font->getSubset();
117 $size = $font->writeInt16(-1);
118 $size += $font->writeFWord($this->xMin);
119 $size += $font->writeFWord($this->yMin);
120 $size += $font->writeFWord($this->xMax);
121 $size += $font->writeFWord($this->yMax);
122 foreach ($this->components as $_i => $_component) {
123 $flags = 0;
124 if ($_component->point_component === null && $_component->point_compound === null) {
125 $flags |= self::ARGS_ARE_XY_VALUES;
126 if (\abs($_component->e) > 0x7f || \abs($_component->f) > 0x7f) {
127 $flags |= self::ARG_1_AND_2_ARE_WORDS;
128 }
129 } elseif ($_component->point_component > 0xff || $_component->point_compound > 0xff) {
130 $flags |= self::ARG_1_AND_2_ARE_WORDS;
131 }
132 if ($_component->b == 0 && $_component->c == 0) {
133 if ($_component->a == $_component->d) {
134 if ($_component->a != 1.0) {
135 $flags |= self::WE_HAVE_A_SCALE;
136 }
137 } else {
138 $flags |= self::WE_HAVE_AN_X_AND_Y_SCALE;
139 }
140 } else {
141 $flags |= self::WE_HAVE_A_TWO_BY_TWO;
142 }
143 if ($_i < \count($this->components) - 1) {
144 $flags |= self::MORE_COMPONENTS;
145 }
146 $size += $font->writeUInt16($flags);
147 $new_gid = \array_search($_component->glyphIndex, $gids);
148 $size += $font->writeUInt16($new_gid);
149 if ($flags & self::ARG_1_AND_2_ARE_WORDS) {
150 if ($flags & self::ARGS_ARE_XY_VALUES) {
151 $size += $font->writeInt16($_component->e);
152 $size += $font->writeInt16($_component->f);
153 } else {
154 $size += $font->writeUInt16($_component->point_compound);
155 $size += $font->writeUInt16($_component->point_component);
156 }
157 } else {
158 if ($flags & self::ARGS_ARE_XY_VALUES) {
159 $size += $font->writeInt8($_component->e);
160 $size += $font->writeInt8($_component->f);
161 } else {
162 $size += $font->writeUInt8($_component->point_compound);
163 $size += $font->writeUInt8($_component->point_component);
164 }
165 }
166 if ($flags & self::WE_HAVE_A_SCALE) {
167 $size += $font->writeInt16($_component->a);
168 } elseif ($flags & self::WE_HAVE_AN_X_AND_Y_SCALE) {
169 $size += $font->writeInt16($_component->a);
170 $size += $font->writeInt16($_component->d);
171 } elseif ($flags & self::WE_HAVE_A_TWO_BY_TWO) {
172 $size += $font->writeInt16($_component->a);
173 $size += $font->writeInt16($_component->b);
174 $size += $font->writeInt16($_component->c);
175 $size += $font->writeInt16($_component->d);
176 }
177 }
178 return $size;
179 }
180 public function getSVGContours()
181 {
182 $contours = array();
183 /** @var \FontLib\Table\Type\glyf $glyph_data */
184 $glyph_data = $this->getFont()->getTableObject("glyf");
185 /** @var Outline[] $glyphs */
186 $glyphs = $glyph_data->data;
187 foreach ($this->components as $component) {
188 $_glyph = $glyphs[$component->glyphIndex];
189 if ($_glyph !== $this) {
190 $contours[] = array("contours" => $_glyph->getSVGContours(), "transform" => $component->getMatrix());
191 }
192 }
193 return $contours;
194 }
195 }
196