Parsed.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @package Zend_Pdf
  16. * @subpackage Fonts
  17. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /** Zend_Pdf_Resource_Font_Simple */
  21. require_once 'Zend/Pdf/Resource/Font/Simple.php';
  22. /** Zend_Pdf_FileParser_Font_OpenType */
  23. require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
  24. /**
  25. * Parsed and (optionaly) embedded fonts implementation
  26. *
  27. * OpenType fonts can contain either TrueType or PostScript Type 1 outlines.
  28. *
  29. * @package Zend_Pdf
  30. * @subpackage Fonts
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class Zend_Pdf_Resource_Font_Simple_Parsed extends Zend_Pdf_Resource_Font_Simple
  35. {
  36. /**
  37. * Object constructor
  38. *
  39. * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file.
  40. * @throws Zend_Pdf_Exception
  41. */
  42. public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser)
  43. {
  44. parent::__construct();
  45. $fontParser->parse();
  46. /* Object properties */
  47. $this->_fontNames = $fontParser->names;
  48. $this->_isBold = $fontParser->isBold;
  49. $this->_isItalic = $fontParser->isItalic;
  50. $this->_isMonospaced = $fontParser->isMonospaced;
  51. $this->_underlinePosition = $fontParser->underlinePosition;
  52. $this->_underlineThickness = $fontParser->underlineThickness;
  53. $this->_strikePosition = $fontParser->strikePosition;
  54. $this->_strikeThickness = $fontParser->strikeThickness;
  55. $this->_unitsPerEm = $fontParser->unitsPerEm;
  56. $this->_ascent = $fontParser->ascent;
  57. $this->_descent = $fontParser->descent;
  58. $this->_lineGap = $fontParser->lineGap;
  59. $this->_glyphWidths = $fontParser->glyphWidths;
  60. $this->_missingGlyphWidth = $this->_glyphWidths[0];
  61. $this->_cmap = $fontParser->cmap;
  62. /* Resource dictionary */
  63. $baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
  64. $this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont);
  65. $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0);
  66. $this->_resource->LastChar = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1);
  67. /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects.
  68. */
  69. $pdfWidths = array();
  70. foreach ($this->_glyphWidths as $width) {
  71. $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width));
  72. }
  73. /* Create the Zend_Pdf_Element_Array object and add it to the font's
  74. * object factory and resource dictionary.
  75. */
  76. $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths);
  77. $widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
  78. $this->_resource->Widths = $widthsObject;
  79. }
  80. }