설명 없음

EncodingMap.php 835B

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