Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / phenx / php-font-lib / src / FontLib / Table / Type / hmtx.php
diff --git a/vendor/phenx/php-font-lib/src/FontLib/Table/Type/hmtx.php b/vendor/phenx/php-font-lib/src/FontLib/Table/Type/hmtx.php
new file mode 100644 (file)
index 0000000..2458e20
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @package php-font-lib
+ * @link    https://github.com/PhenX/php-font-lib
+ * @author  Fabien Ménager <fabien.menager@gmail.com>
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ */
+
+namespace FontLib\Table\Type;
+use FontLib\Table\Table;
+
+/**
+ * `hmtx` font table.
+ *
+ * @package php-font-lib
+ */
+class hmtx extends Table {
+  protected function _parse() {
+    $font   = $this->getFont();
+    $offset = $font->pos();
+
+    $numOfLongHorMetrics = $font->getData("hhea", "numOfLongHorMetrics");
+    $numGlyphs           = $font->getData("maxp", "numGlyphs");
+
+    $font->seek($offset);
+
+    $data = array();
+    $metrics = $font->readUInt16Many($numOfLongHorMetrics * 2);
+    for ($gid = 0, $mid = 0; $gid < $numOfLongHorMetrics; $gid++) {
+      $advanceWidth    = $metrics[$mid++];
+      $leftSideBearing = $metrics[$mid++];
+      $data[$gid]      = array($advanceWidth, $leftSideBearing);
+    }
+
+    if ($numOfLongHorMetrics < $numGlyphs) {
+      $lastWidth = end($data);
+      $data      = array_pad($data, $numGlyphs, $lastWidth);
+    }
+
+    $this->data = $data;
+  }
+
+  protected function _encode() {
+    $font   = $this->getFont();
+    $subset = $font->getSubset();
+    $data   = $this->data;
+
+    $length = 0;
+
+    foreach ($subset as $gid) {
+      $length += $font->writeUInt16($data[$gid][0]);
+      $length += $font->writeUInt16($data[$gid][1]);
+    }
+
+    return $length;
+  }
+}
\ No newline at end of file