From 616ccb9adcae47801c0d8f9c262d267d7c7f76ab Mon Sep 17 00:00:00 2001 From: Maximilian Kresse <545671+MaximilianKresse@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:11:13 +0200 Subject: [PATCH] Fixed #29 Invalid doc block type hint for SetFont $size --- src/Modules/Font.php | 9 +++++++-- src/SetaFpdf.php | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Modules/Font.php b/src/Modules/Font.php index dc9c4d5..1d9f898 100644 --- a/src/Modules/Font.php +++ b/src/Modules/Font.php @@ -100,7 +100,7 @@ public function __construct(Manager $manager) * * @param string $family * @param string $style - * @param string $size + * @param string|int|float $size * @throws \InvalidArgumentException */ public function set($family, $style, $size) @@ -138,7 +138,12 @@ public function set($family, $style, $size) } $this->fontState->font = $this->fonts[$fontKey]; - if ($size !== '') { + if ($size !== 0) { + if (is_string($size) && \ctype_digit($size)) { + $size = (int) $size; + } elseif (!\is_int($size)) { + $size = (float) $size; + } $this->fontState->fontSize = $size; } } diff --git a/src/SetaFpdf.php b/src/SetaFpdf.php index c9f282c..209b0c0 100644 --- a/src/SetaFpdf.php +++ b/src/SetaFpdf.php @@ -624,24 +624,24 @@ public function SetFillColor(...$components) * font size, it is simpler to call SetFontSize(). * * @param string $family Family font. It can be either a name defined by AddFont() or one of the - * standard families (case insensitive): + * standard families (case-insensitive): * Courier: (fixed with) * Helvetica or Arial: (synonymous; sans serif) * Times: (serif) * Symbol: (symbolic) * ZapfDingbats: (symbolic) * It is also possible to pass an empty string. In that case, the current family is kept. - * @param string $style Font style. Possible values are (case insensitive): + * @param string $style Font style. Possible values are (case-insensitive): * empty string: regular * B: bold * I: italic * U: underline * or any combination. The default value is regular. Bold and italic styles do not apply to * Symbol and ZapfDingbats. - * @param string $size Font size in points. The default value is the current size. If no size has been specified - * since the beginning of the document, the value taken is 12. + * @param string|int|float $size Font size in points. The default value is the current size. If no size has been + * specified since the beginning of the document, the value taken is 12. */ - public function SetFont($family, $style = '', $size = '') + public function SetFont($family, $style = '', $size = 0) { $this->manager->getFont()->set($family, $style, $size); }