本文整理汇总了PHP中Zend_Pdf_Resource_Font::getUnitsPerEm方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Resource_Font::getUnitsPerEm方法的具体用法?PHP Zend_Pdf_Resource_Font::getUnitsPerEm怎么用?PHP Zend_Pdf_Resource_Font::getUnitsPerEm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_Resource_Font
的用法示例。
在下文中一共展示了Zend_Pdf_Resource_Font::getUnitsPerEm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLineHeight
private function setLineHeight($numLines = 1)
{
if (empty($numLines)) {
$numLines = 1;
}
$lineLeading = intval($this->_font->getLineHeight() / $this->_font->getUnitsPerEm());
$this->_currentHeight = $this->getHeight() * $numLines + $lineLeading;
return $this;
}
示例2: widthForStringUsingFontSize
/**
* Returns the total width in points of the string using the specified font and
* size.
*
* This is not the most efficient way to perform this calculation. I'm
* concentrating optimization efforts on the upcoming layout manager class.
* Similar calculations exist inside the layout manager class, but widths are
* generally calculated only after determining line fragments.
*
* @param string $string
* @param Zend_Pdf_Resource_Font $font
* @param float $fontSize Font size in points
* @return float
*/
public function widthForStringUsingFontSize($string, $font, $fontSize)
{
$drawingString = '"libiconv"' == ICONV_IMPL ? iconv('UTF-8', 'UTF-16BE//IGNORE', $string) : @iconv('UTF-8', 'UTF-16BE', $string);
$characters = array();
for ($i = 0; $i < strlen($drawingString); $i++) {
$characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
}
$glyphs = $font->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
$stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
return $stringWidth;
}
示例3: getTextWidth
/**
* Calculate the width of given text in points taking into account current font and font-size
*
* @param string $text
* @param Zend_Pdf_Resource_Font $font
* @param float $font_size
* @return float
*/
public function getTextWidth($text, Zend_Pdf_Resource_Font $font, $font_size)
{
$drawing_text = iconv('', 'UTF-16BE', $text);
$characters = array();
for ($i = 0; $i < strlen($drawing_text); $i++) {
$characters[] = ord($drawing_text[$i++]) << 8 | ord($drawing_text[$i]);
}
$glyphs = $font->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
$text_width = array_sum($widths) / $font->getUnitsPerEm() * $font_size;
return $text_width;
}
示例4: width_to_points
/**
* Returns the total width in points of the string using the specified font and
* size.
*
* This is not the most efficient way to perform this calculation. I'm
* concentrating optimization efforts on the upcoming layout manager class.
* Similar calculations exist inside the layout manager class, but widths are
* generally calculated only after determining line fragments.
*
* @link http://devzone.zend.com/article/2525-Zend_Pdf-tutorial#comments-2535
* @param string $string
* @param Zend_Pdf_Resource_Font $font
* @param float $fontSize Font size in points
* @return float
*/
protected function width_to_points($string, $font, $fontSize)
{
try {
$drawingString = iconv('UTF-8', 'UTF-16BE//IGNORE', $string);
$characters = array();
for ($i = 0; $i < strlen($drawingString); $i++) {
$characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
}
$glyphs = $font->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
$stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
} catch (Exception $e) {
die($e->getMessage);
}
return $stringWidth;
}