font_dump_OTL.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. $family = 'khmeros';
  3. //////////////////////////////////
  4. $style = ''; // '','B','I','BI'; // At present only works for Regular style
  5. //////////////////////////////////
  6. //////////////////////////////////
  7. $script = '';
  8. $lang = '';
  9. if (isset($_REQUEST['script'])) { $script = $_REQUEST['script']; }
  10. if (isset($_REQUEST['lang'])) { $lang = $_REQUEST['lang']; }
  11. if ($script && strlen($script )<4) { $script = str_pad($script , 4, ' '); }
  12. if ($lang && strlen($lang)<4) { $lang = str_pad($lang, 4, ' '); }
  13. //////////////////////////////////
  14. //////////////////////////////////
  15. //////////////////////////////////
  16. set_time_limit(1200);
  17. ini_set("memory_limit","512M");
  18. //==============================================================
  19. $overrideTTFFontRestriction = true;
  20. //==============================================================
  21. include("../mpdf.php");
  22. $mpdf=new mPDF('');
  23. $mpdf->simpleTables = true;
  24. //==============================================================
  25. // This generates a .mtx.php file if not already generated
  26. $mpdf->SetFont($family,$style);
  27. //==============================================================
  28. //==============================================================
  29. //==============================================================
  30. //==============================================================
  31. $ff = array();
  32. $ffs = '';
  33. if ($lang && $script) {
  34. $GSUBFeatures = $mpdf->CurrentFont['GSUBFeatures'][$script][$lang];
  35. if (is_array($GSUBFeatures)) {
  36. foreach($GSUBFeatures AS $tag=>$v) {
  37. $ff[] = '"'.$tag.'" 0';
  38. }
  39. }
  40. $GPOSFeatures = $mpdf->CurrentFont['GPOSFeatures'][$script][$lang];
  41. if (is_array($GPOSFeatures )) {
  42. foreach($GPOSFeatures AS $tag=>$v) {
  43. $ff[] = '"'.$tag.'" 0';
  44. }
  45. }
  46. $ffs = implode(', ',$ff);
  47. }
  48. //==============================================================
  49. $html = '
  50. <style>
  51. body {
  52. font-family: DejaVuSansCondensed;
  53. font-weight: normal;
  54. font-size: 11pt;
  55. font-feature-settings: '.$ffs.';
  56. }
  57. h5 {
  58. font-size: 1rem;
  59. color: #000066;
  60. margin-bottom: 0.3em;
  61. }
  62. .glyphs {
  63. font-family: '.$family.';
  64. }
  65. .subtable {
  66. font-size: 0.7rem;
  67. }
  68. h5.level2 {
  69. font-size: 0.85rem;
  70. color: #6666AA;
  71. }
  72. .lookuptype {
  73. font-size: 0.7rem;
  74. color: #888888;
  75. text-transform: uppercase;
  76. }
  77. .lookuptypesub {
  78. font-size: 0.7rem;
  79. color: #888888;
  80. text-transform: uppercase;
  81. }
  82. span.unicode {
  83. color: #888888;
  84. font-size: 0.7rem;
  85. }
  86. span.changed {
  87. font-family: '.$family.';
  88. font-size: 1.5rem;
  89. color: #FF4444;
  90. font-feature-settings: '.$ffs.';
  91. }
  92. span.unchanged {
  93. font-family: '.$family.';
  94. font-size: 1.5rem;
  95. color: #4444FF;
  96. font-feature-settings: '.$ffs.';
  97. }
  98. span.backtrack {
  99. font-family: '.$family.';
  100. font-size: 1.5rem;
  101. color: #66aa66;
  102. font-feature-settings: '.$ffs.';
  103. }
  104. span.lookahead {
  105. font-family: '.$family.';
  106. font-size: 1.5rem;
  107. color: #66aa66;
  108. font-feature-settings: '.$ffs.';
  109. }
  110. span.inputother {
  111. font-family: '.$family.';
  112. font-size: 1.5rem;
  113. color: #006688;
  114. font-feature-settings: '.$ffs.';
  115. }
  116. div.context {
  117. font-size: 0.7rem;
  118. color: #888888;
  119. text-transform: uppercase;
  120. }
  121. div.sequenceIndex {
  122. font-size: 0.7rem;
  123. }
  124. div.rule {
  125. font-size: 0.7rem;
  126. }
  127. .ignore {
  128. color: #888888;
  129. font-size: 0.7rem;
  130. }
  131. div.level2 {
  132. margin-left: 5em;
  133. }
  134. </style>
  135. <body>
  136. <h1 style="text-align:center;">'.strtoupper($family.$style).'</h1>
  137. ';
  138. if ($lang && $script) {
  139. $html .= '<h2 style="text-align:center;">'.$script.' '.$lang.'</h2>';
  140. }
  141. $mpdf->WriteHTML($html);
  142. //==============================================================
  143. //==============================================================
  144. //==============================================================
  145. //==============================================================
  146. $mpdf->debugfonts = false;
  147. $family = strtolower($family);
  148. $style=strtoupper($style);
  149. if($style=='IB') $style='BI';
  150. $fontkey = $family.$style;
  151. $stylekey = $style;
  152. if (!$style) { $stylekey = 'R'; }
  153. //==============================================================
  154. $mpdf->overrideOTLsettings[$fontkey]['script'] = $script;
  155. $mpdf->overrideOTLsettings[$fontkey]['lang'] = $lang;
  156. //==============================================================
  157. //include(_MPDF_TTFONTDATAPATH.$fontkey.'.mtx.php');
  158. $ttffile = '';
  159. if (defined('_MPDF_SYSTEM_TTFONTS')) {
  160. $ttffile = _MPDF_SYSTEM_TTFONTS.$mpdf->fontdata[$family][$stylekey];
  161. if (!file_exists($ttffile)) { $ttffile = ''; }
  162. }
  163. if (!$ttffile) {
  164. $ttffile = _MPDF_TTFONTPATH.$mpdf->fontdata[$family][$stylekey];
  165. if (!file_exists($ttffile)) { die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile); }
  166. }
  167. $ttfstat = stat($ttffile);
  168. if (isset($mpdf->fontdata[$family]['TTCfontID'][$stylekey])) { $TTCfontID = $mpdf->fontdata[$family]['TTCfontID'][$stylekey]; }
  169. else { $TTCfontID = 0; }
  170. $BMPonly = false;
  171. if (in_array($family,$mpdf->BMPonly)) { $BMPonly = true; }
  172. $useOTL = $mpdf->fontdata[$family]['useOTL'];
  173. include(_MPDF_PATH .'classes/otl_dump.php');
  174. $ttf = new OTLdump($mpdf);
  175. $mpdf->OTLscript = $script;
  176. $mpdf->OTLlang = $lang;
  177. //==============================================================
  178. //==============================================================
  179. //==============================================================
  180. //==============================================================
  181. //==============================================================
  182. //==============================================================
  183. if($lang && $script) {
  184. $ttf->getMetrics($ttffile, $fontkey, $TTCfontID, $mpdf->debugfonts, $BMPonly, true, $useOTL, 'detail');
  185. }
  186. //==============================================================
  187. //==============================================================
  188. //==============================================================
  189. //==============================================================
  190. else { // IF lang and script not defined
  191. $ttf->getMetrics($ttffile, $fontkey, $TTCfontID, $mpdf->debugfonts, $BMPonly, true, $useOTL, 'summary');
  192. }
  193. //==============================================================
  194. //==============================================================
  195. //==============================================================
  196. //==============================================================
  197. //==============================================================
  198. //==============================================================
  199. $mpdf->Output();
  200. exit;
  201. //==============================================================
  202. //==============================================================
  203. //==============================================================
  204. //==============================================================