Parsed.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. * @category Zend
  16. * @package Zend_Pdf
  17. * @subpackage Fonts
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Zend_Pdf_Resource_Font_Simple */
  23. require_once 'Zend/Pdf/Resource/Font/Simple.php';
  24. /** Zend_Pdf_FileParser_Font_OpenType */
  25. require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
  26. /**
  27. * Parsed and (optionaly) embedded fonts implementation
  28. *
  29. * OpenType fonts can contain either TrueType or PostScript Type 1 outlines.
  30. *
  31. * @package Zend_Pdf
  32. * @subpackage Fonts
  33. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. abstract class Zend_Pdf_Resource_Font_Simple_Parsed extends Zend_Pdf_Resource_Font_Simple
  37. {
  38. /**
  39. * Object constructor
  40. *
  41. * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file.
  42. * @throws Zend_Pdf_Exception
  43. */
  44. public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser)
  45. {
  46. parent::__construct();
  47. $fontParser->parse();
  48. /* Object properties */
  49. $this->_fontNames = $fontParser->names;
  50. $this->_isBold = $fontParser->isBold;
  51. $this->_isItalic = $fontParser->isItalic;
  52. $this->_isMonospaced = $fontParser->isMonospaced;
  53. $this->_underlinePosition = $fontParser->underlinePosition;
  54. $this->_underlineThickness = $fontParser->underlineThickness;
  55. $this->_strikePosition = $fontParser->strikePosition;
  56. $this->_strikeThickness = $fontParser->strikeThickness;
  57. $this->_unitsPerEm = $fontParser->unitsPerEm;
  58. $this->_ascent = $fontParser->ascent;
  59. $this->_descent = $fontParser->descent;
  60. $this->_lineGap = $fontParser->lineGap;
  61. $this->_glyphWidths = $fontParser->glyphWidths;
  62. $this->_missingGlyphWidth = $this->_glyphWidths[0];
  63. $this->_cmap = $fontParser->cmap;
  64. /* Resource dictionary */
  65. $baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
  66. $this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont);
  67. $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0);
  68. $this->_resource->LastChar = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1);
  69. /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects.
  70. */
  71. $pdfWidths = array();
  72. foreach ($this->_glyphWidths as $width) {
  73. $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width));
  74. }
  75. /* Create the Zend_Pdf_Element_Array object and add it to the font's
  76. * object factory and resource dictionary.
  77. */
  78. $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths);
  79. $widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
  80. $this->_resource->Widths = $widthsObject;
  81. }
  82. }