font_info.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * @package php-font-lib
  4. * @link http://php-font-lib.googlecode.com/
  5. * @author Fabien Ménager <fabien.menager@gmail.com>
  6. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  7. * @version $Id$
  8. */
  9. ?><!DOCTYPE html>
  10. <html>
  11. <head>
  12. <link rel="stylesheet" href="css/style.css" />
  13. <link rel="stylesheet" href="css/blitzer/jquery-ui-1.8.14.custom.css" />
  14. <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
  15. <script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
  16. <script type="text/javascript" src="js/glyph.js?v=2"></script>
  17. <script type="text/javascript">
  18. $(function() {
  19. $("#tabs").tabs({
  20. select: function(event, ui) {
  21. if (ui.panel.id == "tabs-unicode-map") {
  22. $(ui.panel).load("<?php echo $_SERVER['REQUEST_URI']; ?>&unicodemap=1");
  23. }
  24. }
  25. });
  26. });
  27. </script>
  28. </head>
  29. <body>
  30. <?php
  31. require_once "../classes/font.cls.php";
  32. $fontfile = @$_GET["fontfile"];
  33. $unicodemap = @$_GET["unicodemap"];
  34. $t = microtime(true);
  35. $font = Font::load($fontfile);
  36. if ($font instanceof Font_TrueType_Collection) {
  37. $font = $font->getFont(0);
  38. }
  39. if ($unicodemap) {
  40. ?>
  41. <style type="text/css">
  42. @font-face {
  43. font-family: unicode-map;
  44. font-weight: normal;
  45. font-style: normal;
  46. font-variant: normal;
  47. src: url('<?php echo $fontfile; ?>');
  48. }
  49. </style>
  50. <div class="unicode-map">
  51. <?php
  52. $subtable = null;
  53. foreach($font->getData("cmap", "subtables") as $_subtable) {
  54. if ($_subtable["platformID"] == 3 && $_subtable["platformSpecificID"] == 1) {
  55. $subtable = $_subtable;
  56. break;
  57. }
  58. }
  59. $empty = 0;
  60. $names = $font->getData("post", "names");
  61. for($c = 0; $c <= 0xFFFF; $c++) {
  62. if (($c % 256 == 0 || $c == 0xFFFF) && $empty > 0) {
  63. echo "<b style=\"width:".($empty*3)."px\"></b>";
  64. $empty = 0;
  65. }
  66. if (isset($subtable["glyphIndexArray"][$c])) {
  67. $g = $subtable["glyphIndexArray"][$c];
  68. if ($empty > 0) {
  69. echo "<b style=\"width:".($empty*3)."px\"></b>";
  70. $empty = 0;
  71. }
  72. echo "<i><s>&#$c;<br /><div class=\"info\">$c<br />".(isset($names[$g]) ? $names[$g] : sprintf("uni%04x", $c))."</div></s></i>";
  73. }
  74. else {
  75. $empty++;
  76. }
  77. } ?>
  78. </div>
  79. <?php
  80. }
  81. else {
  82. $font->parse();
  83. //$font->saveAdobeFontMetrics("$fontfile.ufm");
  84. $records = $font->getData("name", "records");
  85. ?>
  86. <span style="float: right;">
  87. File size: <?php echo round(filesize($fontfile) / 1024, 3); ?>KB &mdash;
  88. Memory: <?php echo (memory_get_peak_usage(true) / 1024); ?>KB &mdash;
  89. Time: <?php echo round(microtime(true) - $t, 4); ?>s
  90. <br />
  91. <a href="make_subset.php?fontfile=<?php echo $fontfile; ?>&amp;name=<?php echo urlencode($records[3]); ?>">Make a subset of this font</a>
  92. </span>
  93. <h1><?php echo $records[3]; ?></h1>
  94. <h3><?php echo $records[5]; ?></h3>
  95. <hr />
  96. <div id="tabs">
  97. <ul>
  98. <?php foreach($font->getTable() as $entry) {
  99. $tag = $entry->tag;
  100. $data = $font->getData($tag);
  101. ?>
  102. <li>
  103. <a <?php if (!$data) { ?> style="color: #ccc;" <?php } ?> href="#tabs-<?php echo preg_replace("/[^a-z0-9]/i", "_", $tag); ?>"><?php echo $tag; ?></a>
  104. </li>
  105. <?php } ?>
  106. <li><a href="#tabs-unicode-map">Unicode map</a></li>
  107. </ul>
  108. <?php foreach($font->getTable() as $table) {
  109. $tag = $table->tag;
  110. $data = $font->getData($tag);
  111. ?>
  112. <div id="tabs-<?php echo preg_replace("/[^a-z0-9]/i", "_", $tag); ?>">
  113. <?php
  114. if ($data) {
  115. echo $font->getTableObject($tag)->toHTML();
  116. }
  117. else {
  118. echo "Not yet implemented";
  119. }
  120. ?>
  121. </div>
  122. <div id="tabs-unicode-map"></div>
  123. <?php } ?>
  124. </div>
  125. <?php } ?>
  126. </body>
  127. </html>