Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if font-size not set explicitly #195

Closed
meyfa opened this issue Jan 22, 2023 · 0 comments · Fixed by #198
Closed

Error if font-size not set explicitly #195

meyfa opened this issue Jan 22, 2023 · 0 comments · Fixed by #198
Labels
bug Something isn't working
Milestone

Comments

@meyfa
Copy link
Owner

meyfa commented Jan 22, 2023

The following code leads to an error:

SVG::addFont(__DIR__ . '/font/Roboto-Bold.ttf');
$svg = new SVG(100, 100);

$text = new SVGText('foo', 50, 50);
$svg->getDocument()->addChild($text);

header('Content-Type: image/png');
imagepng($larvatar->toRasterImage(100, 100));

Error:

Fatal error:
Uncaught TypeError:
Argument 1 passed to SVG\Rasterization\Transform\Transform::resize() must be of the type float, null given,
called in php-svg\src\Rasterization\Renderers\TextRenderer.php on line 31
and defined in php-svg\src\Rasterization\Transform\Transform.php on line 94

Setting the font size explicitly fixes the problem:

$text->setStyle('font-size', '12pt');

There should be a default font size used, in case none is explicitly defined, to avoid this error.

@meyfa meyfa added the bug Something isn't working label Jan 22, 2023
@meyfa meyfa added this to the v0.14.1 milestone Jan 22, 2023
meyfa added a commit that referenced this issue Jan 22, 2023
meyfa added a commit that referenced this issue Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant