test.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="css/style.css" />
  5. <link rel="stylesheet" href="css/blitzer/jquery-ui-1.8.14.custom.css" />
  6. </head>
  7. <body>
  8. <pre>
  9. <?php
  10. require_once "../classes/font_binary_stream.cls.php";
  11. require_once "../classes/font.cls.php";
  12. $t = microtime(true);
  13. // RW methods
  14. $values = array(
  15. array(Font_Binary_Stream::uint8, 9),
  16. array(Font_Binary_Stream::int8, 9),
  17. array(Font_Binary_Stream::uint16, 5040),
  18. array(Font_Binary_Stream::int16, -5040),
  19. array(Font_Binary_Stream::uint32, 8400245),
  20. array(Font_Binary_Stream::int32, 8400245),
  21. array(Font_Binary_Stream::shortFrac, 1.0),
  22. array(Font_Binary_Stream::Fixed, -155.54),
  23. array(Font_Binary_Stream::FWord, -5040),
  24. array(Font_Binary_Stream::uFWord, 5040),
  25. array(Font_Binary_Stream::F2Dot14, -56.54),
  26. array(Font_Binary_Stream::longDateTime, "2011-07-21 21:37:00"),
  27. array(Font_Binary_Stream::char, "A"),
  28. );
  29. /*
  30. $stream = new Font_Binary_Stream();
  31. foreach($values as $value) {
  32. list($type, $data) = $value;
  33. $stream = new Font_Binary_Stream();
  34. $stream->setFile(Font_Binary_Stream::getTempFile());
  35. $stream->w($type, $data);
  36. $stream->seek(0);
  37. $new_data = $stream->r($type);
  38. if ($new_data !== $data) {
  39. echo "NOT OK \t $data \t => $new_data<br />";
  40. }
  41. else {
  42. echo "OK $type<br />";
  43. }
  44. }*/
  45. // font RW
  46. $filename = "../fonts/DejaVuSans.ttf";
  47. $filename_out = "$filename.2.ttf";
  48. Font::$debug = true;
  49. $font = Font::load($filename);
  50. $font->parse();
  51. $font->setSubset(utf8_encode("I am a test string with unicode chars éèàçîïö` and number 12496"));
  52. $font->reduce();
  53. $font->open($filename_out, Font_Binary_Stream::modeWrite);
  54. $font->encode(array("OS/2"));
  55. ?>
  56. File size: <?php echo number_format(filesize($filename_out), 0, ".", " "); ?> bytes
  57. Memory: <?php echo (memory_get_peak_usage(true) / 1024); ?>KB
  58. Time: <?php echo round(microtime(true) - $t, 4); ?>s
  59. </pre>
  60. </body>
  61. </html>