Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Font.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Resource.php';
25 
32 #require_once 'Zend/Pdf/Font.php';
33 
51 {
52  /**** Instance Variables ****/
53 
54 
60 
65  protected $_fontNames = array();
66 
71  protected $_isBold = false;
72 
77  protected $_isItalic = false;
78 
83  protected $_isMonospace = false;
84 
89  protected $_underlinePosition = 0;
90 
95  protected $_underlineThickness = 0;
96 
101  protected $_strikePosition = 0;
102 
107  protected $_strikeThickness = 0;
108 
113  protected $_unitsPerEm = 0;
114 
119  protected $_ascent = 0;
120 
125  protected $_descent = 0;
126 
131  protected $_lineGap = 0;
132 
133 
134 
135  /**** Public Interface ****/
136 
137 
138  /* Object Lifecycle */
139 
144  public function __construct()
145  {
146  parent::__construct(new Zend_Pdf_Element_Dictionary());
147  $this->_resource->Type = new Zend_Pdf_Element_Name('Font');
148  }
149 
150 
151  /* Object Magic Methods */
152 
160  public function __toString()
161  {
162  return $this->getFontName(Zend_Pdf_Font::NAME_FULL, '', '//TRANSLIT');
163  }
164 
165 
166  /* Accessors */
167 
174  public function getFontType()
175  {
176  return $this->_fontType;
177  }
178 
224  public function getFontName($nameType, $language, $characterSet = null)
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  }
255 
261  public function getFontNames()
262  {
263  return $this->_fontNames;
264  }
265 
271  public function isBold()
272  {
273  return $this->_isBold;
274  }
275 
281  public function isItalic()
282  {
283  return $this->_isItalic;
284  }
285 
291  public function isMonospace()
292  {
293  return $this->_isMonospace;
294  }
295 
304  public function getUnderlinePosition()
305  {
307  }
308 
314  public function getUnderlineThickness()
315  {
317  }
318 
325  public function getStrikePosition()
326  {
327  return $this->_strikePosition;
328  }
329 
335  public function getStrikeThickness()
336  {
338  }
339 
348  public function getUnitsPerEm()
349  {
350  return $this->_unitsPerEm;
351  }
352 
362  public function getAscent()
363  {
364  return $this->_ascent;
365  }
366 
375  public function getDescent()
376  {
377  return $this->_descent;
378  }
379 
390  public function getLineGap()
391  {
392  return $this->_lineGap;
393  }
394 
408  public function getLineHeight()
409  {
410  return $this->_ascent - $this->_descent + $this->_lineGap;
411  }
412 
413 
414  /* Information and Conversion Methods */
415 
427  abstract public function glyphNumbersForCharacters($characterCodes);
428 
441  abstract public function glyphNumberForCharacter($characterCode);
442 
461  abstract public function getCoveredPercentage($string, $charEncoding = '');
462 
475  abstract public function widthsForGlyphs($glyphNumbers);
476 
486  abstract public function widthForGlyph($glyphNumber);
487 
497  abstract public function encodeString($string, $charEncoding);
498 
508  abstract public function decodeString($string, $charEncoding);
509 
510 
511 
512  /**** Internal Methods ****/
513 
514 
522  public function toEmSpace($value)
523  {
524  if ($this->_unitsPerEm == 1000) {
525  return $value;
526  }
527  return ceil(($value / $this->_unitsPerEm) * 1000); // always round up
528  }
529 }
530 
const TYPE_UNKNOWN
Definition: Font.php:49
const NAME_FULL
Definition: Font.php:213
glyphNumbersForCharacters($characterCodes)
glyphNumberForCharacter($characterCode)
getFontName($nameType, $language, $characterSet=null)
Definition: Font.php:224
$value
Definition: gender.phtml:16
encodeString($string, $charEncoding)
getCoveredPercentage($string, $charEncoding='')
decodeString($string, $charEncoding)
widthForGlyph($glyphNumber)
widthsForGlyphs($glyphNumbers)
$code
Definition: info.phtml:12
if(!isset($_GET['name'])) $name
Definition: log.php:14