Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Pdf_Resource_Font Class Reference
Inheritance diagram for Zend_Pdf_Resource_Font:
Zend_Pdf_Resource Zend_Pdf_Resource_Font_CidFont Zend_Pdf_Resource_Font_Extracted Zend_Pdf_Resource_Font_Simple Zend_Pdf_Resource_Font_Type0 Zend_Pdf_Resource_Font_CidFont_TrueType Zend_Pdf_Resource_Font_Simple_Parsed Zend_Pdf_Resource_Font_Simple_Standard Zend_Pdf_Resource_Font_Simple_Parsed_TrueType Zend_Pdf_Resource_Font_Simple_Standard_Courier Zend_Pdf_Resource_Font_Simple_Standard_CourierBold Zend_Pdf_Resource_Font_Simple_Standard_CourierBoldOblique Zend_Pdf_Resource_Font_Simple_Standard_CourierOblique Zend_Pdf_Resource_Font_Simple_Standard_Helvetica Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBold Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBoldOblique Zend_Pdf_Resource_Font_Simple_Standard_HelveticaOblique Zend_Pdf_Resource_Font_Simple_Standard_Symbol Zend_Pdf_Resource_Font_Simple_Standard_TimesBold Zend_Pdf_Resource_Font_Simple_Standard_TimesBoldItalic Zend_Pdf_Resource_Font_Simple_Standard_TimesItalic Zend_Pdf_Resource_Font_Simple_Standard_TimesRoman Zend_Pdf_Resource_Font_Simple_Standard_ZapfDingbats

Public Member Functions

 __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 ()
 

Protected Attributes

 $_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 50 of file Font.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Object constructor.

Definition at line 144 of file Font.php.

145  {
146  parent::__construct(new Zend_Pdf_Element_Dictionary());
147  $this->_resource->Type = new Zend_Pdf_Element_Name('Font');
148  }

Member Function Documentation

◆ __toString()

__toString ( )

Returns the full name of the font in the encoding method of the current locale. Transliterates any characters that cannot be naturally represented in that character set.

Returns
string

Definition at line 160 of file Font.php.

161  {
162  return $this->getFontName(Zend_Pdf_Font::NAME_FULL, '', '//TRANSLIT');
163  }
const NAME_FULL
Definition: Font.php:213
getFontName($nameType, $language, $characterSet=null)
Definition: Font.php:224

◆ decodeString()

decodeString (   $string,
  $charEncoding 
)
abstract

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

◆ encodeString()

encodeString (   $string,
  $charEncoding 
)
abstract

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

◆ getAscent()

getAscent ( )

Returns the typographic ascent in font glyph units.

The typographic ascent is the distance from the font's baseline to the top of the text frame. It is frequently used to locate the initial baseline for a paragraph of text inside a given rectangle.

Returns
integer

Definition at line 362 of file Font.php.

363  {
364  return $this->_ascent;
365  }

◆ getCoveredPercentage()

getCoveredPercentage (   $string,
  $charEncoding = '' 
)
abstract

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

◆ getDescent()

getDescent ( )

Returns the typographic descent in font glyph units.

The typographic descent is the distance below the font's baseline to the bottom of the text frame. It is always negative.

Returns
integer

Definition at line 375 of file Font.php.

376  {
377  return $this->_descent;
378  }

◆ getFontName()

getFontName (   $nameType,
  $language,
  $characterSet = null 
)

Returns the specified descriptive name for the font.

The font name type is usually one of the following:

Note that not all names are available for all fonts. In addition, some fonts may contain additional names, whose indicies are in the range 256 to 32767 inclusive, which are used for certain font layout features.

If the preferred language translation is not available, uses the first available translation for the name, which is usually English.

If the requested name does not exist, returns null.

All names are stored internally as Unicode strings, using UTF-16BE encoding. You may optionally supply a different resulting character set.

Parameters
integer$nameTypeType of name requested.
mixed$languagePreferred language (string) or array of languages in preferred order. Use the ISO 639 standard 2-letter language codes.
string$characterSet(optional) Desired resulting character set. You may use any character set supported by iconv();
Returns
string

Definition at line 224 of file Font.php.

225  {
226  if (! isset($this->_fontNames[$nameType])) {
227  return null;
228  }
229  $name = null;
230  if (is_array($language)) {
231  foreach ($language as $code) {
232  if (isset($this->_fontNames[$nameType][$code])) {
233  $name = $this->_fontNames[$nameType][$code];
234  break;
235  }
236  }
237  } else {
238  if (isset($this->_fontNames[$nameType][$language])) {
239  $name = $this->_fontNames[$nameType][$language];
240  }
241  }
242  /* If the preferred language could not be found, use whatever is first.
243  */
244  if ($name === null) {
245  $names = $this->_fontNames[$nameType];
246  $name = reset($names);
247  }
248  /* Convert the character set if requested.
249  */
250  if (($characterSet !== null) && ($characterSet != 'UTF-16BE') && PHP_OS != 'AIX') { // AIX knows not this charset
251  $name = iconv('UTF-16BE', $characterSet, $name);
252  }
253  return $name;
254  }
$code
Definition: info.phtml:12
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getFontNames()

getFontNames ( )

Returns whole set of font names.

Returns
array

Definition at line 261 of file Font.php.

262  {
263  return $this->_fontNames;
264  }

◆ getFontType()

getFontType ( )

Returns the type of font.

Returns
integer One of the TYPE_ constants defined in Zend_Pdf_Font.

Definition at line 174 of file Font.php.

175  {
176  return $this->_fontType;
177  }

◆ getLineGap()

getLineGap ( )

Returns the typographic line gap in font glyph units.

The typographic line gap is the distance between the bottom of the text frame of one line to the top of the text frame of the next. It is typically combined with the typographical ascent and descent to determine the font's total line height (or leading).

Returns
integer

Definition at line 390 of file Font.php.

391  {
392  return $this->_lineGap;
393  }

◆ getLineHeight()

getLineHeight ( )

Returns the suggested line height (or leading) in font glyph units.

This value is determined by adding together the values of the typographic ascent, descent, and line gap. This value yields the suggested line spacing as determined by the font developer.

It should be noted that this is only a guideline; layout engines will frequently modify this value to achieve special effects such as double- spacing.

Returns
integer

Definition at line 408 of file Font.php.

409  {
410  return $this->_ascent - $this->_descent + $this->_lineGap;
411  }

◆ getStrikePosition()

getStrikePosition ( )

Returns the suggested position above the text baseline of the strikethrough in glyph units.

Returns
integer

Definition at line 325 of file Font.php.

326  {
327  return $this->_strikePosition;
328  }

◆ getStrikeThickness()

getStrikeThickness ( )

Returns the suggested line thickness of the strikethrough in glyph units.

Returns
integer

Definition at line 335 of file Font.php.

336  {
338  }

◆ getUnderlinePosition()

getUnderlinePosition ( )

Returns the suggested position below the text baseline of the underline in glyph units.

This value is usually negative.

Returns
integer

Definition at line 304 of file Font.php.

305  {
307  }

◆ getUnderlineThickness()

getUnderlineThickness ( )

Returns the suggested line thickness of the underline in glyph units.

Returns
integer

Definition at line 314 of file Font.php.

315  {
317  }

◆ getUnitsPerEm()

getUnitsPerEm ( )

Returns the number of glyph units per em.

Used to convert glyph space to user space. Frequently used in conjunction with widthsForGlyphs() to calculate the with of a run of text.

Returns
integer

Definition at line 348 of file Font.php.

349  {
350  return $this->_unitsPerEm;
351  }

◆ glyphNumberForCharacter()

glyphNumberForCharacter (   $characterCode)
abstract

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.

◆ glyphNumbersForCharacters()

glyphNumbersForCharacters (   $characterCodes)
abstract

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.

◆ isBold()

isBold ( )

Returns true if font is bold.

Returns
boolean

Definition at line 271 of file Font.php.

272  {
273  return $this->_isBold;
274  }

◆ isItalic()

isItalic ( )

Returns true if font is italic.

Returns
boolean

Definition at line 281 of file Font.php.

282  {
283  return $this->_isItalic;
284  }

◆ isMonospace()

isMonospace ( )

Returns true if font is monospace.

Returns
boolean

Definition at line 291 of file Font.php.

292  {
293  return $this->_isMonospace;
294  }

◆ toEmSpace()

toEmSpace (   $value)

If the font's glyph space is not 1000 units per em, converts the value.

Definition at line 522 of file Font.php.

523  {
524  if ($this->_unitsPerEm == 1000) {
525  return $value;
526  }
527  return ceil(($value / $this->_unitsPerEm) * 1000); // always round up
528  }
$value
Definition: gender.phtml:16

◆ widthForGlyph()

widthForGlyph (   $glyphNumber)
abstract

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

◆ widthsForGlyphs()

widthsForGlyphs (   $glyphNumbers)
abstract

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

Field Documentation

◆ $_ascent

$_ascent = 0
protected

Definition at line 119 of file Font.php.

◆ $_descent

$_descent = 0
protected

Definition at line 125 of file Font.php.

◆ $_fontNames

$_fontNames = array()
protected

Definition at line 65 of file Font.php.

◆ $_fontType

$_fontType = Zend_Pdf_Font::TYPE_UNKNOWN
protected

Definition at line 59 of file Font.php.

◆ $_isBold

$_isBold = false
protected

Definition at line 71 of file Font.php.

◆ $_isItalic

$_isItalic = false
protected

Definition at line 77 of file Font.php.

◆ $_isMonospace

$_isMonospace = false
protected

Definition at line 83 of file Font.php.

◆ $_lineGap

$_lineGap = 0
protected

Definition at line 131 of file Font.php.

◆ $_strikePosition

$_strikePosition = 0
protected

Definition at line 101 of file Font.php.

◆ $_strikeThickness

$_strikeThickness = 0
protected

Definition at line 107 of file Font.php.

◆ $_underlinePosition

$_underlinePosition = 0
protected

Definition at line 89 of file Font.php.

◆ $_underlineThickness

$_underlineThickness = 0
protected

Definition at line 95 of file Font.php.

◆ $_unitsPerEm

$_unitsPerEm = 0
protected

Definition at line 113 of file Font.php.


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