No Description

Font.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Shared;
  18. /**
  19. * DEPRECATED: Common font functions; Use 'Converter'
  20. *
  21. * @deprecated 0.12.0
  22. * @codeCoverageIgnore
  23. */
  24. class Font
  25. {
  26. /**
  27. * Calculate an (approximate) pixel size, based on a font points size
  28. *
  29. * @param int $fontSizeInPoints Font size (in points)
  30. * @return int Font size (in pixels)
  31. */
  32. public static function fontSizeToPixels($fontSizeInPoints = 12)
  33. {
  34. return Converter::pointToPixel($fontSizeInPoints);
  35. }
  36. /**
  37. * Calculate an (approximate) pixel size, based on inch size
  38. *
  39. * @param int $sizeInInch Font size (in inch)
  40. * @return int Size (in pixels)
  41. */
  42. public static function inchSizeToPixels($sizeInInch = 1)
  43. {
  44. return Converter::inchToPixel($sizeInInch);
  45. }
  46. /**
  47. * Calculate an (approximate) pixel size, based on centimeter size
  48. *
  49. * @param int $sizeInCm Font size (in centimeters)
  50. * @return double Size (in pixels)
  51. */
  52. public static function centimeterSizeToPixels($sizeInCm = 1)
  53. {
  54. return Converter::cmToPixel($sizeInCm);
  55. }
  56. /**
  57. * Convert centimeter to twip
  58. *
  59. * @param int $sizeInCm
  60. * @return double
  61. */
  62. public static function centimeterSizeToTwips($sizeInCm = 1)
  63. {
  64. return Converter::cmToTwip($sizeInCm);
  65. }
  66. /**
  67. * Convert inch to twip
  68. *
  69. * @param int $sizeInInch
  70. * @return double
  71. */
  72. public static function inchSizeToTwips($sizeInInch = 1)
  73. {
  74. return Converter::inchToTwip($sizeInInch);
  75. }
  76. /**
  77. * Convert pixel to twip
  78. *
  79. * @param int $sizeInPixel
  80. * @return double
  81. */
  82. public static function pixelSizeToTwips($sizeInPixel = 1)
  83. {
  84. return Converter::pixelToTwip($sizeInPixel);
  85. }
  86. /**
  87. * Calculate twip based on point size, used mainly for paragraph spacing
  88. *
  89. * @param integer $sizeInPoint Size in point
  90. * @return integer Size (in twips)
  91. */
  92. public static function pointSizeToTwips($sizeInPoint = 1)
  93. {
  94. return Converter::pointToTwip($sizeInPoint);
  95. }
  96. }