FontTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace FontLib\Tests;
  3. use FontLib\Font;
  4. class FontTest extends \PHPUnit_Framework_TestCase
  5. {
  6. /**
  7. * @expectedException \Fontlib\Exception\FontNotFoundException
  8. */
  9. public function testLoadFileNotFound()
  10. {
  11. Font::load('non-existing/font.ttf');
  12. }
  13. public function testLoadTTFFontSuccessfully()
  14. {
  15. $trueTypeFont = Font::load('sample-fonts/IntelClear-Light.ttf');
  16. $this->assertInstanceOf('FontLib\TrueType\File', $trueTypeFont);
  17. }
  18. public function test12CmapFormat()
  19. {
  20. $trueTypeFont = Font::load('sample-fonts/NotoSansShavian-Regular.ttf');
  21. $trueTypeFont->parse();
  22. $cmapTable = $trueTypeFont->getData("cmap", "subtables");
  23. $cmapFormat4Table = $cmapTable[0];
  24. $this->assertEquals(4, $cmapFormat4Table['format']);
  25. $this->assertEquals(6, $cmapFormat4Table['segCount']);
  26. $this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['startCode']));
  27. $this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['endCode']));
  28. $cmapFormat12Table = $cmapTable[1];
  29. $this->assertEquals(12, $cmapFormat12Table['format']);
  30. $this->assertEquals(6, $cmapFormat12Table['ngroups']);
  31. $this->assertEquals(6, count($cmapFormat12Table['startCode']));
  32. $this->assertEquals(6, count($cmapFormat12Table['endCode']));
  33. $this->assertEquals(53, count($cmapFormat12Table['glyphIndexArray']));
  34. }
  35. }