/** * Get encoding tables */ protected function getOS2Metrics() { $this->offset = $this->fdt['table']['OS/2']['offset']; $this->offset += 2; // skip version // xAvgCharWidth $this->fdt['AvgWidth'] = round($this->fbyte->getFWord($this->offset) * $this->fdt['urk']); $this->offset += 2; // usWeightClass $usWeightClass = round($this->fbyte->getUFWord($this->offset) * $this->fdt['urk']); // estimate StemV and StemH (400 = usWeightClass for Normal - Regular font) $this->fdt['StemV'] = round(70 * $usWeightClass / 400); $this->fdt['StemH'] = round(30 * $usWeightClass / 400); $this->offset += 2; $this->offset += 2; // usWidthClass $fsType = $this->fbyte->getShort($this->offset); $this->offset += 2; if ($fsType == 2) { throw new FontException('This Font cannot be modified, embedded or exchanged in any manner' . ' without first obtaining permission of the legal owner.'); } }
/** * Add composite glyphs * * @param array $new_sga * @param int $key * * @return array */ protected function findCompositeGlyphs($new_sga, $key) { if (isset($this->fdt['indexToLoc'][$key])) { $this->offset = $this->fdt['table']['glyf']['offset'] + $this->fdt['indexToLoc'][$key]; $numberOfContours = $this->fbyte->getShort($this->offset); $this->offset += 2; if ($numberOfContours < 0) { // composite glyph $this->offset += 8; // skip xMin, yMin, xMax, yMax do { $flags = $this->fbyte->getUShort($this->offset); $this->offset += 2; $glyphIndex = $this->fbyte->getUShort($this->offset); $this->offset += 2; if (!isset($this->subglyphs[$glyphIndex])) { // add missing glyphs $new_sga[$glyphIndex] = true; } // skip some bytes by case if ($flags & 1) { $this->offset += 4; } else { $this->offset += 2; } if ($flags & 8) { $this->offset += 2; } elseif ($flags & 64) { $this->offset += 4; } elseif ($flags & 128) { $this->offset += 8; } } while ($flags & 32); } } return $new_sga; }