makefont.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <?php
  2. //============================================================+
  3. // File name : makefont.php
  4. // Begin : 2004-12-31
  5. // Last Update : 2010-12-03
  6. // Version : 1.2.007
  7. // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
  8. // ----------------------------------------------------------------------------
  9. // Copyright (C) 2008-2010 Nicola Asuni - Tecnick.com S.r.l.
  10. //
  11. // This file is part of TCPDF software library.
  12. //
  13. // TCPDF is free software: you can redistribute it and/or modify it
  14. // under the terms of the GNU Lesser General Public License as
  15. // published by the Free Software Foundation, either version 3 of the
  16. // License, or (at your option) any later version.
  17. //
  18. // TCPDF is distributed in the hope that it will be useful, but
  19. // WITHOUT ANY WARRANTY; without even the implied warranty of
  20. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. // See the GNU Lesser General Public License for more details.
  22. //
  23. // You should have received a copy of the GNU Lesser General Public License
  24. // along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
  25. //
  26. // See LICENSE.TXT file for more information.
  27. // ----------------------------------------------------------------------------
  28. //
  29. // Description : Utility to generate font definition files fot TCPDF
  30. //
  31. // Authors: Nicola Asuni, Olivier Plathey, Steven Wittens
  32. //
  33. // (c) Copyright:
  34. // Nicola Asuni
  35. // Tecnick.com S.r.l.
  36. // Via della Pace, 11
  37. // 09044 Quartucciu (CA)
  38. // ITALY
  39. // www.tecnick.com
  40. // info@tecnick.com
  41. //============================================================+
  42. /**
  43. * @file
  44. * Utility to generate font definition files fot TCPDF.
  45. * @author Nicola Asuni, Olivier Plathey, Steven Wittens
  46. * @package com.tecnick.tcpdf
  47. */
  48. /**
  49. * Convert a Font for TCPDF
  50. * @param $fontfile (string) path to font file (TTF, OTF or PFB).
  51. * @param $fmfile (string) font metrics file (UFM or AFM).
  52. * @param $embedded (boolean) Set to false to not embed the font, true otherwise (default).
  53. * @param $enc (string) Name of the encoding table to use. Omit this parameter for TrueType Unicode, OpenType Unicode and symbolic fonts like Symbol or ZapfDingBats.
  54. * @param $patch (array) Optional modification of the encoding
  55. */
  56. function MakeFont($fontfile, $fmfile, $embedded=true, $enc='cp1252', $patch=array()) {
  57. //Generate a font definition file
  58. if(!defined('PHP_VERSION_ID')) {
  59. $version = PHP_VERSION;
  60. define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
  61. }
  62. if (PHP_VERSION_ID < 50300) {
  63. @set_magic_quotes_runtime(0);
  64. }
  65. ini_set('auto_detect_line_endings', '1');
  66. if (!file_exists($fontfile)) {
  67. die('Error: file not found: '.$fontfile);
  68. }
  69. if (!file_exists($fmfile)) {
  70. die('Error: file not found: '.$fmfile);
  71. }
  72. $cidtogidmap = '';
  73. $map = array();
  74. $diff = '';
  75. $dw = 0; // default width
  76. $ffext = strtolower(substr($fontfile, -3));
  77. $fmext = strtolower(substr($fmfile, -3));
  78. if ($fmext == 'afm') {
  79. if (($ffext == 'ttf') OR ($ffext == 'otf')) {
  80. $type = 'TrueType';
  81. } elseif ($ffext == 'pfb') {
  82. $type = 'Type1';
  83. } else {
  84. die('Error: unrecognized font file extension: '.$ffext);
  85. }
  86. if ($enc) {
  87. $map = ReadMap($enc);
  88. foreach ($patch as $cc => $gn) {
  89. $map[$cc] = $gn;
  90. }
  91. }
  92. $fm = ReadAFM($fmfile, $map);
  93. if (isset($widths['.notdef'])) {
  94. $dw = $widths['.notdef'];
  95. }
  96. if ($enc) {
  97. $diff = MakeFontEncoding($map);
  98. }
  99. $fd = MakeFontDescriptor($fm, empty($map));
  100. } elseif ($fmext == 'ufm') {
  101. $enc = '';
  102. if (($ffext == 'ttf') OR ($ffext == 'otf')) {
  103. $type = 'TrueTypeUnicode';
  104. } else {
  105. die('Error: not a TrueType font: '.$ffext);
  106. }
  107. $fm = ReadUFM($fmfile, $cidtogidmap);
  108. $dw = $fm['MissingWidth'];
  109. $fd = MakeFontDescriptor($fm, false);
  110. }
  111. //Start generation
  112. $s = '<?php'."\n";
  113. $s .= '$type=\''.$type."';\n";
  114. $s .= '$name=\''.$fm['FontName']."';\n";
  115. $s .= '$desc='.$fd.";\n";
  116. if (!isset($fm['UnderlinePosition'])) {
  117. $fm['UnderlinePosition'] = -100;
  118. }
  119. if (!isset($fm['UnderlineThickness'])) {
  120. $fm['UnderlineThickness'] = 50;
  121. }
  122. $s .= '$up='.$fm['UnderlinePosition'].";\n";
  123. $s .= '$ut='.$fm['UnderlineThickness'].";\n";
  124. if ($dw <= 0) {
  125. if (isset($fm['Widths'][32]) AND ($fm['Widths'][32] > 0)) {
  126. // assign default space width
  127. $dw = $fm['Widths'][32];
  128. } else {
  129. $dw = 600;
  130. }
  131. }
  132. $s .= '$dw='.$dw.";\n";
  133. $w = MakeWidthArray($fm);
  134. $s .= '$cw='.$w.";\n";
  135. $s .= '$enc=\''.$enc."';\n";
  136. $s .= '$diff=\''.$diff."';\n";
  137. $basename = substr(basename($fmfile), 0, -4);
  138. if ($embedded) {
  139. //Embedded font
  140. if (($type == 'TrueType') OR ($type == 'TrueTypeUnicode')) {
  141. CheckTTF($fontfile);
  142. }
  143. $f = fopen($fontfile,'rb');
  144. if (!$f) {
  145. die('Error: Unable to open '.$fontfile);
  146. }
  147. $file = fread($f, filesize($fontfile));
  148. fclose($f);
  149. if ($type == 'Type1') {
  150. //Find first two sections and discard third one
  151. $header = (ord($file{0}) == 128);
  152. if ($header) {
  153. //Strip first binary header
  154. $file = substr($file, 6);
  155. }
  156. $pos = strpos($file, 'eexec');
  157. if (!$pos) {
  158. die('Error: font file does not seem to be valid Type1');
  159. }
  160. $size1 = $pos + 6;
  161. if ($header AND (ord($file{$size1}) == 128)) {
  162. //Strip second binary header
  163. $file = substr($file, 0, $size1).substr($file, $size1+6);
  164. }
  165. $pos = strpos($file, '00000000');
  166. if (!$pos) {
  167. die('Error: font file does not seem to be valid Type1');
  168. }
  169. $size2 = $pos - $size1;
  170. $file = substr($file, 0, ($size1 + $size2));
  171. }
  172. $basename = strtolower($basename);
  173. if (function_exists('gzcompress')) {
  174. $cmp = $basename.'.z';
  175. SaveToFile($cmp, gzcompress($file, 9), 'b');
  176. $s .= '$file=\''.$cmp."';\n";
  177. print "Font file compressed (".$cmp.")\n";
  178. if (!empty($cidtogidmap)) {
  179. $cmp = $basename.'.ctg.z';
  180. SaveToFile($cmp, gzcompress($cidtogidmap, 9), 'b');
  181. print "CIDToGIDMap created and compressed (".$cmp.")\n";
  182. $s .= '$ctg=\''.$cmp."';\n";
  183. }
  184. } else {
  185. $s .= '$file=\''.basename($fontfile)."';\n";
  186. print "Notice: font file could not be compressed (zlib extension not available)\n";
  187. if (!empty($cidtogidmap)) {
  188. $cmp = $basename.'.ctg';
  189. $f = fopen($cmp, 'wb');
  190. fwrite($f, $cidtogidmap);
  191. fclose($f);
  192. print "CIDToGIDMap created (".$cmp.")\n";
  193. $s .= '$ctg=\''.$cmp."';\n";
  194. }
  195. }
  196. if($type == 'Type1') {
  197. $s .= '$size1='.$size1.";\n";
  198. $s .= '$size2='.$size2.";\n";
  199. } else {
  200. $s.='$originalsize='.filesize($fontfile).";\n";
  201. }
  202. } else {
  203. //Not embedded font
  204. $s .= '$file='."'';\n";
  205. }
  206. $s .= '// --- EOF ---';
  207. SaveToFile($basename.'.php',$s);
  208. print "Font definition file generated (".$basename.".php)\n";
  209. }
  210. /**
  211. * Read the specified encoding map.
  212. * @param $enc (string) map name (see /enc/ folder for valid names).
  213. */
  214. function ReadMap($enc) {
  215. //Read a map file
  216. $file = dirname(__FILE__).'/enc/'.strtolower($enc).'.map';
  217. $a = file($file);
  218. if (empty($a)) {
  219. die('Error: encoding not found: '.$enc);
  220. }
  221. $cc2gn = array();
  222. foreach ($a as $l) {
  223. if ($l{0} == '!') {
  224. $e = preg_split('/[ \\t]+/',rtrim($l));
  225. $cc = hexdec(substr($e[0],1));
  226. $gn = $e[2];
  227. $cc2gn[$cc] = $gn;
  228. }
  229. }
  230. for($i = 0; $i <= 255; $i++) {
  231. if(!isset($cc2gn[$i])) {
  232. $cc2gn[$i] = '.notdef';
  233. }
  234. }
  235. return $cc2gn;
  236. }
  237. /**
  238. * Read UFM file
  239. */
  240. function ReadUFM($file, &$cidtogidmap) {
  241. //Prepare empty CIDToGIDMap
  242. $cidtogidmap = str_pad('', (256 * 256 * 2), "\x00");
  243. //Read a font metric file
  244. $a = file($file);
  245. if (empty($a)) {
  246. die('File not found');
  247. }
  248. $widths = array();
  249. $fm = array();
  250. foreach($a as $l) {
  251. $e = explode(' ',chop($l));
  252. if(count($e) < 2) {
  253. continue;
  254. }
  255. $code = $e[0];
  256. $param = $e[1];
  257. if($code == 'U') {
  258. // U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
  259. //Character metrics
  260. $cc = (int)$e[1];
  261. if ($cc != -1) {
  262. $gn = $e[7];
  263. $w = $e[4];
  264. $glyph = $e[10];
  265. $widths[$cc] = $w;
  266. if($cc == ord('X')) {
  267. $fm['CapXHeight'] = $e[13];
  268. }
  269. // Set GID
  270. if (($cc >= 0) AND ($cc < 0xFFFF) AND $glyph) {
  271. $cidtogidmap{($cc * 2)} = chr($glyph >> 8);
  272. $cidtogidmap{(($cc * 2) + 1)} = chr($glyph & 0xFF);
  273. }
  274. }
  275. if((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) {
  276. $fm['MissingWidth'] = $w;
  277. }
  278. } elseif($code == 'FontName') {
  279. $fm['FontName'] = $param;
  280. } elseif($code == 'Weight') {
  281. $fm['Weight'] = $param;
  282. } elseif($code == 'ItalicAngle') {
  283. $fm['ItalicAngle'] = (double)$param;
  284. } elseif($code == 'Ascender') {
  285. $fm['Ascender'] = (int)$param;
  286. } elseif($code == 'Descender') {
  287. $fm['Descender'] = (int)$param;
  288. } elseif($code == 'UnderlineThickness') {
  289. $fm['UnderlineThickness'] = (int)$param;
  290. } elseif($code == 'UnderlinePosition') {
  291. $fm['UnderlinePosition'] = (int)$param;
  292. } elseif($code == 'IsFixedPitch') {
  293. $fm['IsFixedPitch'] = ($param == 'true');
  294. } elseif($code == 'FontBBox') {
  295. $fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
  296. } elseif($code == 'CapHeight') {
  297. $fm['CapHeight'] = (int)$param;
  298. } elseif($code == 'StdVW') {
  299. $fm['StdVW'] = (int)$param;
  300. }
  301. }
  302. if(!isset($fm['MissingWidth'])) {
  303. $fm['MissingWidth'] = 600;
  304. }
  305. if(!isset($fm['FontName'])) {
  306. die('FontName not found');
  307. }
  308. $fm['Widths'] = $widths;
  309. return $fm;
  310. }
  311. /**
  312. * Read AFM file
  313. */
  314. function ReadAFM($file,&$map) {
  315. //Read a font metric file
  316. $a = file($file);
  317. if(empty($a)) {
  318. die('File not found');
  319. }
  320. $widths = array();
  321. $fm = array();
  322. $fix = array(
  323. 'Edot'=>'Edotaccent',
  324. 'edot'=>'edotaccent',
  325. 'Idot'=>'Idotaccent',
  326. 'Zdot'=>'Zdotaccent',
  327. 'zdot'=>'zdotaccent',
  328. 'Odblacute' => 'Ohungarumlaut',
  329. 'odblacute' => 'ohungarumlaut',
  330. 'Udblacute'=>'Uhungarumlaut',
  331. 'udblacute'=>'uhungarumlaut',
  332. 'Gcedilla'=>'Gcommaaccent'
  333. ,'gcedilla'=>'gcommaaccent',
  334. 'Kcedilla'=>'Kcommaaccent',
  335. 'kcedilla'=>'kcommaaccent',
  336. 'Lcedilla'=>'Lcommaaccent',
  337. 'lcedilla'=>'lcommaaccent',
  338. 'Ncedilla'=>'Ncommaaccent',
  339. 'ncedilla'=>'ncommaaccent',
  340. 'Rcedilla'=>'Rcommaaccent',
  341. 'rcedilla'=>'rcommaaccent',
  342. 'Scedilla'=>'Scommaaccent',
  343. 'scedilla'=>'scommaaccent',
  344. 'Tcedilla'=>'Tcommaaccent',
  345. 'tcedilla'=>'tcommaaccent',
  346. 'Dslash'=>'Dcroat',
  347. 'dslash'=>'dcroat',
  348. 'Dmacron'=>'Dcroat',
  349. 'dmacron'=>'dcroat',
  350. 'combininggraveaccent'=>'gravecomb',
  351. 'combininghookabove'=>'hookabovecomb',
  352. 'combiningtildeaccent'=>'tildecomb',
  353. 'combiningacuteaccent'=>'acutecomb',
  354. 'combiningdotbelow'=>'dotbelowcomb',
  355. 'dongsign'=>'dong'
  356. );
  357. foreach($a as $l) {
  358. $e = explode(' ', rtrim($l));
  359. if (count($e) < 2) {
  360. continue;
  361. }
  362. $code = $e[0];
  363. $param = $e[1];
  364. if ($code == 'C') {
  365. //Character metrics
  366. $cc = (int)$e[1];
  367. $w = $e[4];
  368. $gn = $e[7];
  369. if (substr($gn, -4) == '20AC') {
  370. $gn = 'Euro';
  371. }
  372. if (isset($fix[$gn])) {
  373. //Fix incorrect glyph name
  374. foreach ($map as $c => $n) {
  375. if ($n == $fix[$gn]) {
  376. $map[$c] = $gn;
  377. }
  378. }
  379. }
  380. if (empty($map)) {
  381. //Symbolic font: use built-in encoding
  382. $widths[$cc] = $w;
  383. } else {
  384. $widths[$gn] = $w;
  385. if($gn == 'X') {
  386. $fm['CapXHeight'] = $e[13];
  387. }
  388. }
  389. if($gn == '.notdef') {
  390. $fm['MissingWidth'] = $w;
  391. }
  392. } elseif($code == 'FontName') {
  393. $fm['FontName'] = $param;
  394. } elseif($code == 'Weight') {
  395. $fm['Weight'] = $param;
  396. } elseif($code == 'ItalicAngle') {
  397. $fm['ItalicAngle'] = (double)$param;
  398. } elseif($code == 'Ascender') {
  399. $fm['Ascender'] = (int)$param;
  400. } elseif($code == 'Descender') {
  401. $fm['Descender'] = (int)$param;
  402. } elseif($code == 'UnderlineThickness') {
  403. $fm['UnderlineThickness'] = (int)$param;
  404. } elseif($code == 'UnderlinePosition') {
  405. $fm['UnderlinePosition'] = (int)$param;
  406. } elseif($code == 'IsFixedPitch') {
  407. $fm['IsFixedPitch'] = ($param == 'true');
  408. } elseif($code == 'FontBBox') {
  409. $fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
  410. } elseif($code == 'CapHeight') {
  411. $fm['CapHeight'] = (int)$param;
  412. } elseif($code == 'StdVW') {
  413. $fm['StdVW'] = (int)$param;
  414. }
  415. }
  416. if (!isset($fm['FontName'])) {
  417. die('FontName not found');
  418. }
  419. if (!empty($map)) {
  420. if (!isset($widths['.notdef'])) {
  421. $widths['.notdef'] = 600;
  422. }
  423. if (!isset($widths['Delta']) AND isset($widths['increment'])) {
  424. $widths['Delta'] = $widths['increment'];
  425. }
  426. //Order widths according to map
  427. for ($i = 0; $i <= 255; $i++) {
  428. if (!isset($widths[$map[$i]])) {
  429. print "Warning: character ".$map[$i]." is missing\n";
  430. $widths[$i] = $widths['.notdef'];
  431. } else {
  432. $widths[$i] = $widths[$map[$i]];
  433. }
  434. }
  435. }
  436. $fm['Widths'] = $widths;
  437. return $fm;
  438. }
  439. function MakeFontDescriptor($fm, $symbolic=false) {
  440. //Ascent
  441. $asc = (isset($fm['Ascender']) ? $fm['Ascender'] : 1000);
  442. $fd = "array('Ascent'=>".$asc;
  443. //Descent
  444. $desc = (isset($fm['Descender']) ? $fm['Descender'] : -200);
  445. $fd .= ",'Descent'=>".$desc;
  446. //CapHeight
  447. if (isset($fm['CapHeight'])) {
  448. $ch = $fm['CapHeight'];
  449. } elseif (isset($fm['CapXHeight'])) {
  450. $ch = $fm['CapXHeight'];
  451. } else {
  452. $ch = $asc;
  453. }
  454. $fd .= ",'CapHeight'=>".$ch;
  455. //Flags
  456. $flags = 0;
  457. if (isset($fm['IsFixedPitch']) AND $fm['IsFixedPitch']) {
  458. $flags += 1<<0;
  459. }
  460. if ($symbolic) {
  461. $flags += 1<<2;
  462. } else {
  463. $flags += 1<<5;
  464. }
  465. if (isset($fm['ItalicAngle']) AND ($fm['ItalicAngle'] != 0)) {
  466. $flags += 1<<6;
  467. }
  468. $fd .= ",'Flags'=>".$flags;
  469. //FontBBox
  470. if (isset($fm['FontBBox'])) {
  471. $fbb = $fm['FontBBox'];
  472. } else {
  473. $fbb = array(0, ($desc - 100), 1000, ($asc + 100));
  474. }
  475. $fd .= ",'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'";
  476. //ItalicAngle
  477. $ia = (isset($fm['ItalicAngle']) ? $fm['ItalicAngle'] : 0);
  478. $fd .= ",'ItalicAngle'=>".$ia;
  479. //StemV
  480. if (isset($fm['StdVW'])) {
  481. $stemv = $fm['StdVW'];
  482. } elseif (isset($fm['Weight']) AND preg_match('/(bold|black)/i', $fm['Weight'])) {
  483. $stemv = 120;
  484. } else {
  485. $stemv = 70;
  486. }
  487. $fd .= ",'StemV'=>".$stemv;
  488. //MissingWidth
  489. if(isset($fm['MissingWidth'])) {
  490. $fd .= ",'MissingWidth'=>".$fm['MissingWidth'];
  491. }
  492. $fd .= ')';
  493. return $fd;
  494. }
  495. function MakeWidthArray($fm) {
  496. //Make character width array
  497. $s = 'array(';
  498. $cw = $fm['Widths'];
  499. $els = array();
  500. $c = 0;
  501. foreach ($cw as $i => $w) {
  502. if (is_numeric($i)) {
  503. $els[] = (((($c++)%10) == 0) ? "\n" : '').$i.'=>'.$w;
  504. }
  505. }
  506. $s .= implode(',', $els);
  507. $s .= ')';
  508. return $s;
  509. }
  510. function MakeFontEncoding($map) {
  511. //Build differences from reference encoding
  512. $ref = ReadMap('cp1252');
  513. $s = '';
  514. $last = 0;
  515. for ($i = 32; $i <= 255; $i++) {
  516. if ($map[$i] != $ref[$i]) {
  517. if ($i != $last+1) {
  518. $s .= $i.' ';
  519. }
  520. $last = $i;
  521. $s .= '/'.$map[$i].' ';
  522. }
  523. }
  524. return rtrim($s);
  525. }
  526. function SaveToFile($file, $s, $mode='t') {
  527. $f = fopen($file, 'w'.$mode);
  528. if(!$f) {
  529. die('Can\'t write to file '.$file);
  530. }
  531. fwrite($f, $s, strlen($s));
  532. fclose($f);
  533. }
  534. function ReadShort($f) {
  535. $a = unpack('n1n', fread($f, 2));
  536. return $a['n'];
  537. }
  538. function ReadLong($f) {
  539. $a = unpack('N1N', fread($f, 4));
  540. return $a['N'];
  541. }
  542. function CheckTTF($file) {
  543. //Check if font license allows embedding
  544. $f = fopen($file, 'rb');
  545. if (!$f) {
  546. die('Error: unable to open '.$file);
  547. }
  548. //Extract number of tables
  549. fseek($f, 4, SEEK_CUR);
  550. $nb = ReadShort($f);
  551. fseek($f, 6, SEEK_CUR);
  552. //Seek OS/2 table
  553. $found = false;
  554. for ($i = 0; $i < $nb; $i++) {
  555. if (fread($f, 4) == 'OS/2') {
  556. $found = true;
  557. break;
  558. }
  559. fseek($f, 12, SEEK_CUR);
  560. }
  561. if (!$found) {
  562. fclose($f);
  563. return;
  564. }
  565. fseek($f, 4, SEEK_CUR);
  566. $offset = ReadLong($f);
  567. fseek($f, $offset, SEEK_SET);
  568. //Extract fsType flags
  569. fseek($f, 8, SEEK_CUR);
  570. $fsType = ReadShort($f);
  571. $rl = ($fsType & 0x02) != 0;
  572. $pp = ($fsType & 0x04) != 0;
  573. $e = ($fsType & 0x08) != 0;
  574. fclose($f);
  575. if($rl AND (!$pp) AND (!$e)) {
  576. print 'Warning: font license does not allow embedding.'."\n";
  577. }
  578. }
  579. // -------------------------------------------------------------------
  580. $arg = $GLOBALS['argv'];
  581. if (count($arg) >= 3) {
  582. ob_start();
  583. array_shift($arg);
  584. if (sizeof($arg) == 3) {
  585. $arg[3] = $arg[2];
  586. $arg[2] = true;
  587. } else {
  588. if (!isset($arg[2])) {
  589. $arg[2] = true;
  590. }
  591. if (!isset($arg[3])) {
  592. $arg[3] = 'cp1252';
  593. }
  594. }
  595. if (!isset($arg[4])) {
  596. $arg[4] = array();
  597. }
  598. MakeFont($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]);
  599. $t = ob_get_clean();
  600. print preg_replace('!<BR( /)?>!i', "\n", $t);
  601. } else {
  602. print 'Usage: makefont.php <ttf/otf/pfb file> <afm/ufm file> <encoding> <patch>'."\n";
  603. }
  604. //============================================================+
  605. // END OF FILE
  606. //============================================================+