Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Zend_Pdf_Resource_Font_Extracted Class Reference
Inheritance diagram for Zend_Pdf_Resource_Font_Extracted:
Zend_Pdf_Resource_Font Zend_Pdf_Resource

Public Member Functions

 __construct ($fontDictionary)
 
 glyphNumbersForCharacters ($characterCodes)
 
 glyphNumberForCharacter ($characterCode)
 
 getCoveredPercentage ($string, $charEncoding='')
 
 widthsForGlyphs ($glyphNumbers)
 
 widthForGlyph ($glyphNumber)
 
 encodeString ($string, $charEncoding)
 
 decodeString ($string, $charEncoding)
 
- Public Member Functions inherited from Zend_Pdf_Resource_Font
 __construct ()
 
 __toString ()
 
 getFontType ()
 
 getFontName ($nameType, $language, $characterSet=null)
 
 getFontNames ()
 
 isBold ()
 
 isItalic ()
 
 isMonospace ()
 
 getUnderlinePosition ()
 
 getUnderlineThickness ()
 
 getStrikePosition ()
 
 getStrikeThickness ()
 
 getUnitsPerEm ()
 
 getAscent ()
 
 getDescent ()
 
 getLineGap ()
 
 getLineHeight ()
 
 glyphNumbersForCharacters ($characterCodes)
 
 glyphNumberForCharacter ($characterCode)
 
 getCoveredPercentage ($string, $charEncoding='')
 
 widthsForGlyphs ($glyphNumbers)
 
 widthForGlyph ($glyphNumber)
 
 encodeString ($string, $charEncoding)
 
 decodeString ($string, $charEncoding)
 
 toEmSpace ($value)
 
- Public Member Functions inherited from Zend_Pdf_Resource
 __construct ($resource)
 
 __clone ()
 
 cloneResource ($factory, &$processed)
 
 getResource ()
 
 getFactory ()
 

Data Fields

const TYPE_NOT_SUPPORTED = 'Unsupported font type.'
 
const ENCODING_NOT_SUPPORTED = 'Font encoding is not supported'
 
const OPERATION_NOT_SUPPORTED = 'Operation is not supported for extracted fonts'
 

Protected Attributes

 $_encoding = null
 
- Protected Attributes inherited from Zend_Pdf_Resource_Font
 $_fontType = Zend_Pdf_Font::TYPE_UNKNOWN
 
 $_fontNames = array()
 
 $_isBold = false
 
 $_isItalic = false
 
 $_isMonospace = false
 
 $_underlinePosition = 0
 
 $_underlineThickness = 0
 
 $_strikePosition = 0
 
 $_strikeThickness = 0
 
 $_unitsPerEm = 0
 
 $_ascent = 0
 
 $_descent = 0
 
 $_lineGap = 0
 
- Protected Attributes inherited from Zend_Pdf_Resource
 $_objectFactory
 
 $_resource
 

Detailed Description

Definition at line 38 of file Extracted.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $fontDictionary)

Object constructor

$fontDictionary is a Zend_Pdf_Element_Reference or Zend_Pdf_Element_Object object

Parameters
mixed$fontDictionary
Exceptions
Zend_Pdf_Exception

Definition at line 64 of file Extracted.php.

65  {
66  // Extract object factory and resource object from font dirctionary object
67  $this->_objectFactory = $fontDictionary->getFactory();
68  $this->_resource = $fontDictionary;
69 
70  if ($fontDictionary->Encoding !== null) {
71  $this->_encoding = $fontDictionary->Encoding->value;
72  }
73 
74  switch ($fontDictionary->Subtype->value) {
75  case 'Type0':
76  // Composite type 0 font
77  if (count($fontDictionary->DescendantFonts->items) != 1) {
78  // Multiple descendant fonts are not supported
79  #require_once 'Zend/Pdf/Exception.php';
80  throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
81  }
82 
83  $fontDictionaryIterator = $fontDictionary->DescendantFonts->items->getIterator();
84  $fontDictionaryIterator->rewind();
85  $descendantFont = $fontDictionaryIterator->current();
86  $fontDescriptor = $descendantFont->FontDescriptor;
87  break;
88 
89  case 'Type1':
90  if ($fontDictionary->FontDescriptor === null) {
91  // That's one of the standard fonts
92  $standardFont = Zend_Pdf_Font::fontWithName($fontDictionary->BaseFont->value);
93 
94  $this->_fontNames = $standardFont->getFontNames();
95  $this->_isBold = $standardFont->isBold();
96  $this->_isItalic = $standardFont->isItalic();
97  $this->_isMonospace = $standardFont->isMonospace();
98  $this->_underlinePosition = $standardFont->getUnderlinePosition();
99  $this->_underlineThickness = $standardFont->getUnderlineThickness();
100  $this->_strikePosition = $standardFont->getStrikePosition();
101  $this->_strikeThickness = $standardFont->getStrikeThickness();
102  $this->_unitsPerEm = $standardFont->getUnitsPerEm();
103  $this->_ascent = $standardFont->getAscent();
104  $this->_descent = $standardFont->getDescent();
105  $this->_lineGap = $standardFont->getLineGap();
106 
107  return;
108  }
109 
110  $fontDescriptor = $fontDictionary->FontDescriptor;
111  break;
112 
113  case 'TrueType':
114  $fontDescriptor = $fontDictionary->FontDescriptor;
115  break;
116 
117  default:
118  #require_once 'Zend/Pdf/Exception.php';
119  throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
120  }
121 
122  $this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] = iconv('UTF-8', 'UTF-16BE', $fontDictionary->BaseFont->value);
123 
124  $this->_isBold = false; // this property is actually not used anywhere
125  $this->_isItalic = ( ($fontDescriptor->Flags->value & (1 << 6)) != 0 ); // Bit-7 is set
126  $this->_isMonospace = ( ($fontDescriptor->Flags->value & (1 << 0)) != 0 ); // Bit-1 is set
127  $this->_underlinePosition = null; // Can't be extracted
128  $this->_underlineThickness = null; // Can't be extracted
129  $this->_strikePosition = null; // Can't be extracted
130  $this->_strikeThickness = null; // Can't be extracted
131  $this->_unitsPerEm = null; // Can't be extracted
132  $this->_ascent = $fontDescriptor->Ascent->value;
133  $this->_descent = $fontDescriptor->Descent->value;
134  $this->_lineGap = null; // Can't be extracted
135  }
const NAME_POSTSCRIPT
Definition: Font.php:224
static fontWithName($name, $embeddingOptions=0)
Definition: Font.php:463

Member Function Documentation

◆ decodeString()

decodeString (   $string,
  $charEncoding 
)

Convert string from the font encoding.

The method is used to convert strings retrieved from existing content streams

Parameters
string$string
string$charEncodingCharacter encoding of resulting text.
Returns
string

Definition at line 261 of file Extracted.php.

262  {
263  if ($this->_encoding == 'Identity-H') {
264  return iconv('UTF-16BE', $charEncoding, $string);
265  }
266 
267  if ($this->_encoding == 'WinAnsiEncoding') {
268  return iconv('CP1252', $charEncoding, $string);
269  }
270 
271  #require_once 'Zend/Pdf/Exception.php';
272  throw new Zend_Pdf_Exception(self::ENCODING_NOT_SUPPORTED);
273  }

◆ encodeString()

encodeString (   $string,
  $charEncoding 
)

Convert string to the font encoding.

The method is used to prepare string for text drawing operators

Parameters
string$string
string$charEncodingCharacter encoding of source text.
Returns
string

Definition at line 238 of file Extracted.php.

239  {
240  if ($this->_encoding == 'Identity-H') {
241  return iconv($charEncoding, 'UTF-16BE', $string);
242  }
243 
244  if ($this->_encoding == 'WinAnsiEncoding') {
245  return iconv($charEncoding, 'CP1252//IGNORE', $string);
246  }
247 
248  #require_once 'Zend/Pdf/Exception.php';
249  throw new Zend_Pdf_Exception(self::ENCODING_NOT_SUPPORTED);
250  }

◆ getCoveredPercentage()

getCoveredPercentage (   $string,
  $charEncoding = '' 
)

Returns a number between 0 and 1 inclusive that indicates the percentage of characters in the string which are covered by glyphs in this font.

Since no one font will contain glyphs for the entire Unicode character range, this method can be used to help locate a suitable font when the actual contents of the string are not known.

Note that some fonts lie about the characters they support. Additionally, fonts don't usually contain glyphs for control characters such as tabs and line breaks, so it is rare that you will get back a full 1.0 score. The resulting value should be considered informational only.

Parameters
string$string
string$charEncoding(optional) Character encoding of source text. If omitted, uses 'current locale'.
Returns
float

Definition at line 190 of file Extracted.php.

191  {
192  #require_once 'Zend/Pdf/Exception.php';
193  throw new Zend_Pdf_Exception(self::OPERATION_NOT_SUPPORTED);
194  }

◆ glyphNumberForCharacter()

glyphNumberForCharacter (   $characterCode)

Returns the glyph number corresponding to the Unicode character.

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also glyphNumbersForCharacters() which is optimized for bulk operations.

Parameters
integer$characterCodeUnicode character code (code point).
Returns
integer Glyph number.

Definition at line 166 of file Extracted.php.

167  {
168  #require_once 'Zend/Pdf/Exception.php';
169  throw new Zend_Pdf_Exception(self::OPERATION_NOT_SUPPORTED);
170  }

◆ glyphNumbersForCharacters()

glyphNumbersForCharacters (   $characterCodes)

Returns an array of glyph numbers corresponding to the Unicode characters.

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also glyphNumberForCharacter().

Parameters
array$characterCodesArray of Unicode character codes (code points).
Returns
array Array of glyph numbers.

Definition at line 148 of file Extracted.php.

149  {
150  #require_once 'Zend/Pdf/Exception.php';
151  throw new Zend_Pdf_Exception(self::OPERATION_NOT_SUPPORTED);
152  }

◆ widthForGlyph()

widthForGlyph (   $glyphNumber)

Returns the width of the glyph.

Like widthsForGlyphs() but used for one glyph at a time.

Parameters
integer$glyphNumber
Returns
integer
Exceptions
Zend_Pdf_Exception

Definition at line 223 of file Extracted.php.

224  {
225  #require_once 'Zend/Pdf/Exception.php';
226  throw new Zend_Pdf_Exception(self::OPERATION_NOT_SUPPORTED);
227  }

◆ widthsForGlyphs()

widthsForGlyphs (   $glyphNumbers)

Returns the widths of the glyphs.

The widths are expressed in the font's glyph space. You are responsible for converting to user space as necessary. See unitsPerEm().

See also widthForGlyph().

Parameters
array$glyphNumbersArray of glyph numbers.
Returns
array Array of glyph widths (integers).
Exceptions
Zend_Pdf_Exception

Definition at line 208 of file Extracted.php.

209  {
210  #require_once 'Zend/Pdf/Exception.php';
211  throw new Zend_Pdf_Exception(self::OPERATION_NOT_SUPPORTED);
212  }

Field Documentation

◆ $_encoding

$_encoding = null
protected

Definition at line 54 of file Extracted.php.

◆ ENCODING_NOT_SUPPORTED

const ENCODING_NOT_SUPPORTED = 'Font encoding is not supported'

Definition at line 44 of file Extracted.php.

◆ OPERATION_NOT_SUPPORTED

const OPERATION_NOT_SUPPORTED = 'Operation is not supported for extracted fonts'

Definition at line 45 of file Extracted.php.

◆ TYPE_NOT_SUPPORTED

const TYPE_NOT_SUPPORTED = 'Unsupported font type.'

Messages

Definition at line 43 of file Extracted.php.


The documentation for this class was generated from the following file: