当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Shared_Font::fontSizeToPixels方法代码示例

本文整理汇总了PHP中PHPExcel_Shared_Font::fontSizeToPixels方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_Font::fontSizeToPixels方法的具体用法?PHP PHPExcel_Shared_Font::fontSizeToPixels怎么用?PHP PHPExcel_Shared_Font::fontSizeToPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Shared_Font的用法示例。


在下文中一共展示了PHPExcel_Shared_Font::fontSizeToPixels方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @param 	int		$rotation			Rotation angle
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0)
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     $columnWidth = (strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256;
     // Calculate approximate rotated column width
     if ($rotation !== 0) {
         if ($rotation == -165) {
             // stacked text
             $columnWidth = 4;
             // approximation
         } else {
             // rotated text
             $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5;
             // approximation
         }
     }
     // Return
     return round($columnWidth, 6);
 }
开发者ID:nagiro,项目名称:hospici_cultural,代码行数:43,代码来源:Font.php

示例2: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '')
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Calculate column width
     return round((strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256, 6);
 }
开发者ID:laiello,项目名称:myopensources,代码行数:21,代码来源:Font.php

示例3: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '')
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     return round((strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256, 6);
 }
开发者ID:eficklin,项目名称:Spreadsheet,代码行数:28,代码来源:Font.php

示例4: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @param 	int		$rotation			Rotation angle
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0)
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     // values 1.025 and 0.584 found via interpolation by inspecting real Excel files with
     // Calibri font. May need further adjustment
     $columnWidth = 1.025 * strlen($columnText) + 0.584;
     // Excel adds some padding
     // Calculate approximate rotated column width
     if ($rotation !== 0) {
         if ($rotation == -165) {
             // stacked text
             $columnWidth = 4;
             // approximation
         } else {
             // rotated text
             $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5;
             // approximation
         }
     }
     // Return
     return round($columnWidth, 6);
 }
开发者ID:linhanwei,项目名称:TP,代码行数:46,代码来源:Font.php

示例5: toCSSArray

	private static function toCSSArray($style) {
		$style = str_replace("\r", "", $style);
		$style = str_replace("\n", "", $style);

		$temp = explode(';', $style);

		$style = array();
		foreach ($temp as $item) {
			$item = explode(':', $item);

			if (strpos($item[1], 'px') !== false) {
				$item[1] = str_replace('px', '', $item[1]);
			}
			if (strpos($item[1], 'pt') !== false) {
				$item[1] = str_replace('pt', '', $item[1]);
				$item[1] = PHPExcel_Shared_Font::fontSizeToPixels($item[1]);
			}
			if (strpos($item[1], 'in') !== false) {
				$item[1] = str_replace('in', '', $item[1]);
				$item[1] = PHPExcel_Shared_Font::inchSizeToPixels($item[1]);
			}
			if (strpos($item[1], 'cm') !== false) {
				$item[1] = str_replace('cm', '', $item[1]);
				$item[1] = PHPExcel_Shared_Font::centimeterSizeToPixels($item[1]);
			}

			$style[$item[0]] = $item[1];
		}

		return $style;
	}
开发者ID:Opmantek,项目名称:open-audit,代码行数:31,代码来源:Excel2007.php

示例6: sizeRow

 /**
  * Convert the height of a cell from user's units to pixels. By interpolation
  * the relationship is: y = 4/3x. If the height hasn't been set by the user we
  * use the default value. If the row is hidden we use a value of zero.
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param integer $row The row index (1-based)
  * @return integer The width in pixels
  */
 public static function sizeRow($sheet, $row = 1)
 {
     // default font of the workbook
     $font = $sheet->getParent()->getDefaultStyle()->getFont();
     $rowDimensions = $sheet->getRowDimensions();
     // first find the true row height in pixels (uncollapsed and unhidden)
     if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
         // then we have a row dimension
         $rowDimension = $rowDimensions[$row];
         $rowHeight = $rowDimension->getRowHeight();
         $pixelRowHeight = (int) ceil(4 * $rowHeight / 3);
         // here we assume Arial 10
     } else {
         if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
             // then we have a default row dimension with explicit height
             $defaultRowDimension = $sheet->getDefaultRowDimension();
             $rowHeight = $defaultRowDimension->getRowHeight();
             $pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
         } else {
             // we don't even have any default row dimension. Height depends on default font
             $pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
             $pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
         }
     }
     // now find the effective row height in pixels
     if (isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible()) {
         $effectivePixelRowHeight = 0;
     } else {
         $effectivePixelRowHeight = $pixelRowHeight;
     }
     return $effectivePixelRowHeight;
 }
开发者ID:mehulsbhatt,项目名称:sale_purchase_tracking,代码行数:41,代码来源:Excel5.php


注:本文中的PHPExcel_Shared_Font::fontSizeToPixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。