Skip to content

Commit

Permalink
PDFLib: Avoid throwing with 0 font size
Browse files Browse the repository at this point in the history
  • Loading branch information
Mellthas committed Jun 15, 2022
1 parent 0739f2f commit 77c4207
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Adapter/PDFLib.php
Expand Up @@ -1076,6 +1076,10 @@ public function image($img, $x, $y, $w, $h, $resolution = "normal")

public function text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_spacing = 0, $char_spacing = 0, $angle = 0)
{
if ($size == 0) {
return;
}

$fh = $this->_load_font($font);

$this->_pdf->setfont($fh, $size);
Expand Down Expand Up @@ -1126,6 +1130,10 @@ public function add_link($url, $x, $y, $width, $height)

public function get_text_width($text, $font, $size, $word_spacing = 0.0, $letter_spacing = 0.0)
{
if ($size == 0) {
return 0.0;
}

$fh = $this->_load_font($font);

// Determine the additional width due to extra spacing
Expand All @@ -1142,6 +1150,10 @@ public function get_text_width($text, $font, $size, $word_spacing = 0.0, $letter

public function get_font_height($font, $size)
{
if ($size == 0) {
return 0.0;
}

$fh = $this->_load_font($font);

$this->_pdf->setfont($fh, $size);
Expand Down

0 comments on commit 77c4207

Please sign in to comment.