@@ -49,11 +49,12 @@ public static function pixelsToCellDimension(int $pixelValue, \PhpOffice\PhpSpre
4949 // Font name and size
5050 $ name = $ defaultFont ->getName ();
5151 $ size = $ defaultFont ->getSize ();
52+ $ sizex = ($ size !== null && $ size == (int ) $ size ) ? ((int ) $ size ) : "$ size " ;
5253
53- if (isset (Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ])) {
54+ if (isset (Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ])) {
5455 // Exact width can be determined
55- return $ pixelValue * Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ]['width ' ]
56- / Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ]['px ' ];
56+ return $ pixelValue * Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ]['width ' ]
57+ / Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ]['px ' ];
5758 }
5859
5960 // We don't have data for this particular font and size, use approximation by
@@ -75,11 +76,12 @@ public static function cellDimensionToPixels(float $cellWidth, \PhpOffice\PhpSpr
7576 // Font name and size
7677 $ name = $ defaultFont ->getName ();
7778 $ size = $ defaultFont ->getSize ();
79+ $ sizex = ($ size !== null && $ size == (int ) $ size ) ? ((int ) $ size ) : "$ size " ;
7880
79- if (isset (Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ])) {
81+ if (isset (Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ])) {
8082 // Exact width can be determined
81- $ colWidth = $ cellWidth * Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ]['px ' ]
82- / Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ size ]['width ' ];
83+ $ colWidth = $ cellWidth * Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ]['px ' ]
84+ / Font::DEFAULT_COLUMN_WIDTHS [$ name ][$ sizex ]['width ' ];
8385 } else {
8486 // We don't have data for this particular font and size, use approximation by
8587 // extrapolating from Calibri 11
@@ -114,11 +116,7 @@ public static function pixelsToPoints(int $pixelValue): float
114116 */
115117 public static function pointsToPixels ($ pointValue ): int
116118 {
117- if ($ pointValue != 0 ) {
118- return (int ) ceil ($ pointValue / 0.75 );
119- }
120-
121- return 0 ;
119+ return (int ) ceil ($ pointValue / 0.75 );
122120 }
123121
124122 /**
0 commit comments