EOT
3 years ago
Exception
3 years ago
Glyph
3 years ago
OpenType
3 years ago
Table
3 years ago
TrueType
3 years ago
WOFF
3 years ago
AdobeFontMetrics.php
3 years ago
Autoloader.php
3 years ago
BinaryStream.php
3 years ago
EncodingMap.php
3 years ago
Font.php
3 years ago
Header.php
3 years ago
EncodingMap.php
36 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 | */ |
| 9 | namespace IAWP\FontLib; |
| 10 | |
| 11 | /** |
| 12 | * Encoding map used to map a code point to a Unicode char. |
| 13 | * |
| 14 | * @package php-font-lib |
| 15 | */ |
| 16 | class EncodingMap |
| 17 | { |
| 18 | private $f; |
| 19 | function __construct($file) |
| 20 | { |
| 21 | $this->f = \fopen($file, "r"); |
| 22 | } |
| 23 | function parse() |
| 24 | { |
| 25 | $map = array(); |
| 26 | while ($line = \fgets($this->f)) { |
| 27 | if (\preg_match('/^[\\!\\=]([0-9A-F]{2,})\\s+U\\+([0-9A-F]{2})([0-9A-F]{2})\\s+([^\\s]+)/', $line, $matches)) { |
| 28 | $unicode = (\hexdec($matches[2]) << 8) + \hexdec($matches[3]); |
| 29 | $map[\hexdec($matches[1])] = array($unicode, $matches[4]); |
| 30 | } |
| 31 | } |
| 32 | \ksort($map); |
| 33 | return $map; |
| 34 | } |
| 35 | } |
| 36 |