You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.6 KiB

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