Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Zend_Pdf_Resource_Font_Type0 Class Reference
Inheritance diagram for Zend_Pdf_Resource_Font_Type0:
Zend_Pdf_Resource_Font Zend_Pdf_Resource

Public Member Functions

 __construct (Zend_Pdf_Resource_Font_CidFont $descendantFont)
 
 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 ()
 

Additional Inherited Members

- 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 63 of file Type0.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_Pdf_Resource_Font_CidFont  $descendantFont)

Object constructor

Definition at line 106 of file Type0.php.

107  {
108  parent::__construct();
109 
110  $this->_objectFactory->attach($descendantFont->getFactory());
111 
112  $this->_fontType = Zend_Pdf_Font::TYPE_TYPE_0;
113  $this->_descendantFont = $descendantFont;
114 
115 
116  $this->_fontNames = $descendantFont->getFontNames();
117 
118  $this->_isBold = $descendantFont->isBold();
119  $this->_isItalic = $descendantFont->isItalic();
120  $this->_isMonospaced = $descendantFont->isMonospace();
121 
122  $this->_underlinePosition = $descendantFont->getUnderlinePosition();
123  $this->_underlineThickness = $descendantFont->getUnderlineThickness();
124  $this->_strikePosition = $descendantFont->getStrikePosition();
125  $this->_strikeThickness = $descendantFont->getStrikeThickness();
126 
127  $this->_unitsPerEm = $descendantFont->getUnitsPerEm();
128 
129  $this->_ascent = $descendantFont->getAscent();
130  $this->_descent = $descendantFont->getDescent();
131  $this->_lineGap = $descendantFont->getLineGap();
132 
133 
134  $this->_resource->Subtype = new Zend_Pdf_Element_Name('Type0');
135  $this->_resource->BaseFont = new Zend_Pdf_Element_Name($descendantFont->getResource()->BaseFont->value);
136  $this->_resource->DescendantFonts = new Zend_Pdf_Element_Array(array( $descendantFont->getResource() ));
137  $this->_resource->Encoding = new Zend_Pdf_Element_Name('Identity-H');
138 
139  $toUnicode = $this->_objectFactory->newStreamObject(self::getToUnicodeCMapData());
140  $this->_resource->ToUnicode = $toUnicode;
141 
142  }
const TYPE_TYPE_0
Definition: Font.php:69

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 253 of file Type0.php.

254  {
255  return iconv('UTF-16BE', $charEncoding, $string);
256  }

◆ 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 239 of file Type0.php.

240  {
241  return iconv($charEncoding, 'UTF-16BE', $string);
242  }

◆ 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 192 of file Type0.php.

193  {
194  return $this->_descendantFont->getCoveredPercentage($string, $charEncoding);
195  }

◆ glyphNumberForCharacter()

glyphNumberForCharacter (   $characterCode)

Returns the glyph number corresponding to the Unicode character.

Zend_Pdf uses 'Identity-H' encoding for Type 0 fonts. So we don't need to perform any conversion

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

Definition at line 169 of file Type0.php.

170  {
171  return $characterCode;
172  }

◆ glyphNumbersForCharacters()

glyphNumbersForCharacters (   $characterCodes)

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

Zend_Pdf uses 'Identity-H' encoding for Type 0 fonts. So we don't need to perform any conversion

See also glyphNumberForCharacter().

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

Definition at line 155 of file Type0.php.

156  {
157  return $characterCodes;
158  }

◆ 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 225 of file Type0.php.

226  {
227  return $this->_descendantFont->widthForChar($glyphNumber);
228  }

◆ 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().

Throws an exception if the glyph number is out of range.

See also widthForGlyph().

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

Definition at line 211 of file Type0.php.

212  {
213  return $this->_descendantFont->widthsForChars($glyphNumbers);
214  }

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