Skip to content

Commit 08dfb4a

Browse files
Merge pull request #36 from Setasign/development
Fixed #29 Invalid doc block type hint for SetFont $size
2 parents 9d75d1d + a18e6e5 commit 08dfb4a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/Modules/Font.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __construct(Manager $manager)
100100
*
101101
* @param string $family
102102
* @param string $style
103-
* @param string $size
103+
* @param string|int|float $size
104104
* @throws \InvalidArgumentException
105105
*/
106106
public function set($family, $style, $size)
@@ -138,7 +138,12 @@ public function set($family, $style, $size)
138138
}
139139

140140
$this->fontState->font = $this->fonts[$fontKey];
141-
if ($size !== '') {
141+
if ($size !== 0) {
142+
if (is_string($size) && \ctype_digit($size)) {
143+
$size = (int) $size;
144+
} elseif (!\is_int($size)) {
145+
$size = (float) $size;
146+
}
142147
$this->fontState->fontSize = $size;
143148
}
144149
}

src/SetaFpdf.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,24 +624,24 @@ public function SetFillColor(...$components)
624624
* font size, it is simpler to call SetFontSize().
625625
*
626626
* @param string $family Family font. It can be either a name defined by AddFont() or one of the
627-
* standard families (case insensitive):
627+
* standard families (case-insensitive):
628628
* Courier: (fixed with)
629629
* Helvetica or Arial: (synonymous; sans serif)
630630
* Times: (serif)
631631
* Symbol: (symbolic)
632632
* ZapfDingbats: (symbolic)
633633
* It is also possible to pass an empty string. In that case, the current family is kept.
634-
* @param string $style Font style. Possible values are (case insensitive):
634+
* @param string $style Font style. Possible values are (case-insensitive):
635635
* empty string: regular
636636
* B: bold
637637
* I: italic
638638
* U: underline
639639
* or any combination. The default value is regular. Bold and italic styles do not apply to
640640
* Symbol and ZapfDingbats.
641-
* @param string $size Font size in points. The default value is the current size. If no size has been specified
642-
* since the beginning of the document, the value taken is 12.
641+
* @param string|int|float $size Font size in points. The default value is the current size. If no size has been
642+
* specified since the beginning of the document, the value taken is 12.
643643
*/
644-
public function SetFont($family, $style = '', $size = '')
644+
public function SetFont($family, $style = '', $size = 0)
645645
{
646646
$this->manager->getFont()->set($family, $style, $size);
647647
}

0 commit comments

Comments
 (0)